• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Swap items slot position when container

Pawcio6

Member
Joined
Sep 26, 2009
Messages
143
Solutions
4
Reaction score
15
Hi
I wanna to make containers swap like normal items when they have special attribute(that part is done) but i dont know where add swap checking thing. Can someone say where should i look for it? I mean when now is like this :

if !isContainer
doswapitems

then add to it

if !isContainer || isSwap(firstitem) && isSwap(seconditem)
doswapitems

My source 0.3.6
 
Hi
I wanna to make containers swap like normal items when they have special attribute(that part is done) but i dont know where add swap checking thing. Can someone say where should i look for it? I mean when now is like this :

if !isContainer
doswapitems

then add to it

if !isContainer || isSwap(firstitem) && isSwap(seconditem)
doswapitems

My source 0.3.6
Post the code
 
okey i found something like that
Code:
void Container::__replaceThing(uint32_t index, Thing* thing)
{
    Item* item = thing->getItem();
    if(item == NULL)
    {
#ifdef __DEBUG_MOVESYS__
        std::cout << "Failure: [Container::__replaceThing] item == NULL" << std::endl;
        DEBUG_REPORT
#endif
        return /*RET_NOTPOSSIBLE*/;
    }

    uint32_t count = 0;
    ItemList::iterator cit = itemlist.end();
    for(cit = itemlist.begin(); cit != itemlist.end(); ++cit)
    {
        if(count == index)
            break;
        else
            ++count;
    }

    if(cit == itemlist.end())
    {
#ifdef __DEBUG_MOVESYS__
        std::cout << "Failure: [Container::__updateThing] item not found" << std::endl;
        DEBUG_REPORT
#endif
        return /*RET_NOTPOSSIBLE*/;
    }

    totalWeight -= (*cit)->getWeight();
    totalWeight += item->getWeight();
    if(Container* parentContainer = getParentContainer())
        parentContainer->updateItemWeight(-(*cit)->getWeight() + item->getWeight());

    itemlist.insert(cit, item);
    item->setParent(this);
    //send change to client
    if(getParent())
    {
        const ItemType& oldType = Item::items[(*cit)->getID()];
        const ItemType& newType = Item::items[item->getID()];
        onUpdateContainerItem(index, *cit, oldType, item, newType);
    }

    (*cit)->setParent(NULL);
    itemlist.erase(cit);
}
any ideas how to change?
 
Back
Top