• 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!

Market item duplicated

xixigisi

New Member
Joined
May 11, 2023
Messages
16
Reaction score
2
I have a problem with Market Item used to access market when player use depot. It is been creating duplicated.

The function that add that item is getDepotLocker. Is it in correct place? What can be happen to duplicate market item?

I'm using TFS 1.5 Nekiro downgrade to 7.72.


C++:
DepotLocker* Player::getDepotLocker(uint32_t depotId)
{
    auto it = depotLockerMap.find(depotId);
    if (it != depotLockerMap.end()) {
        return it->second.get();
    }

    it = depotLockerMap.emplace(depotId, new DepotLocker(ITEM_LOCKER1)).first;
    it->second->setDepotId(depotId);

    Item* marketItem = Item::CreateItem(ITEM_MARKET);
    if(marketItem){
        it->second->internalAddThing(marketItem);
    }
    it->second->internalAddThing(getDepotChest(depotId, true));
    return it->second.get();
}
 
I would like to know how you enabled this market system in TFS 1.5. I am interested.
I'm thinking how to help you because I didn't find my commit about it.
But basically I got commented functions from nekiro and fix some points of error.
I can't load item list from server then fixed it on client.
The rest of it works as other versions.
 
I have a problem with Market Item used to access market when player use depot. It is been creating duplicated.

The function that add that item is getDepotLocker. Is it in correct place? What can be happen to duplicate market item?

I'm using TFS 1.5 Nekiro downgrade to 7.72.


C++:
DepotLocker* Player::getDepotLocker(uint32_t depotId)
{
    auto it = depotLockerMap.find(depotId);
    if (it != depotLockerMap.end()) {
        return it->second.get();
    }

    it = depotLockerMap.emplace(depotId, new DepotLocker(ITEM_LOCKER1)).first;
    it->second->setDepotId(depotId);

    Item* marketItem = Item::CreateItem(ITEM_MARKET);
    if(marketItem){
        it->second->internalAddThing(marketItem);
    }
    it->second->internalAddThing(getDepotChest(depotId, true));
    return it->second.get();
}
i've solved this way:
always create new items, and doesnt load them on loadPlayer...
(if u are not going to use inbox, just remove it.. also, if u wanna use, search for inbox in this files, there's some functions to uncomment)
i suggest that u try without inbox at first time, if it works for market item, then u start to look around for inbox, if u want.

C++:
// PLAYER.CPP
DepotChest* Player::getDepotChest(uint32_t depotId, bool autoCreate)
{
    auto it = depotChests.find(depotId);
    if (it != depotChests.end()) {
        return it->second;
    }

    if (!autoCreate) {
        return nullptr;
    }

    it = depotChests.emplace(depotId, new DepotChest(ITEM_DEPOT)).first;
    it->second->setMaxDepotItems(getMaxDepotItems());
    return it->second;
}

DepotLocker* Player::getDepotLocker(uint32_t depotId)
{
    auto it = depotLockerMap.find(depotId);
    if (it != depotLockerMap.end()) {
        inbox->setParent(it->second.get());
        return it->second.get();
    }

    it = depotLockerMap.emplace(depotId, new DepotLocker(ITEM_LOCKER1)).first;
    it->second->setDepotId(depotId);
    it->second->internalAddThing(Item::CreateItem(ITEM_MARKET));
      it->second->internalAddThing(inbox);
    it->second->internalAddThing(getDepotChest(depotId, true));
      inbox->setParent(it->second.get());
    return it->second.get();
}

//IOLOGINDATA.CPP
//load depot locker items
itemMap.clear();

if ((result = db.storeQuery(fmt::format("SELECT `pid`, `sid`, `itemtype`, `count`, `attributes` FROM `player_depotlockeritems` WHERE `player_id` = {:d} ORDER BY `sid` DESC", player->getGUID())))) {
    loadItems(itemMap, result);

    for (ItemMap::const_reverse_iterator it = itemMap.rbegin(), end = itemMap.rend(); it != end; ++it) {
        const std::pair<Item*, int32_t>& pair = it->second;
        Item* item = pair.first;
        if (item->getID() != ITEM_MARKET && item->getID() != ITEM_INBOX ) {           

            int32_t pid = pair.second;
            if (pid >= 0 && pid < 100) {
                DepotLocker* depotLocker = player->getDepotLocker(pid);
                if (depotLocker) {
                    depotLocker->internalAddThing(item);
                }
            } else {
                ItemMap::const_iterator it2 = itemMap.find(pid);
                if (it2 == itemMap.end()) {
                    continue;
                }

                Container* container = it2->second.first->getContainer();
                if (container) {
                    container->internalAddThing(item);
                }
            }
        }
    }
}
 
I have a problem with Market Item used to access market when player use depot. It is been creating duplicated.

The function that add that item is getDepotLocker. Is it in correct place? What can be happen to duplicate market item?

I'm using TFS 1.5 Nekiro downgrade to 7.72.


C++:
DepotLocker* Player::getDepotLocker(uint32_t depotId)
{
    auto it = depotLockerMap.find(depotId);
    if (it != depotLockerMap.end()) {
        return it->second.get();
    }

    it = depotLockerMap.emplace(depotId, new DepotLocker(ITEM_LOCKER1)).first;
    it->second->setDepotId(depotId);

    Item* marketItem = Item::CreateItem(ITEM_MARKET);
    if(marketItem){
        it->second->internalAddThing(marketItem);
    }
    it->second->internalAddThing(getDepotChest(depotId, true));
    return it->second.get();
}
can you share commits ? would like to enable market system too
 
can somebody share commits ? im trying to add this thing, uncommented commented lines, also compared files with main tfs repository but when i try to use depot i get crash
i added this at itemss.xml
<item id="14405" article="the" name="market" />
in actions.xml
<!-- Market -->
<action itemid="14405" function="market" />
im using tfs 1.5 - 8.6
also in otcv8 features.lua

if(version >= 860) then
g_game.enableFeature(GamePlayerMarket)
 
Back
Top