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

TFS 1.X+ Depot Chest not saving

Dries390

Active Member
Joined
Sep 8, 2007
Messages
60
Solutions
4
Reaction score
41
Hello everyone, I've run into some trouble concerning storing items in the depot. Any item stored INSIDE the depot chest will cause the error in the picture. It seems like the items inside are being saved into player_depotlockeritems with identical sid's to the ones outside the box. Normally I'd think the sid's of the saved items should be < 100 or that they be saved in player_depotitems. If anyone could explain how sid's are assigned or could propose a solution for this 1.3 TFS (downgraded to 8.6) problem I'd appreciate it very much.


iologindata.cpp
bool IOLoginData::savePlayer(Player* player)
C++:
    if (player->lastDepotId != -1) {
        //save depot lockers
        query.str(std::string());
        query << "DELETE FROM `player_depotlockeritems` WHERE `player_id` = " << player->getGUID();

        if (!db.executeQuery(query.str())) {
            return false;
        }

        DBInsert depotQuery("INSERT INTO `player_depotlockeritems` (`player_id`, `pid`, `sid`, `itemtype`, `count`, `attributes`, `abilities`) VALUES ");
        itemList.clear();

        for (const auto& it : player->depotLockerMap) {
            DepotLocker* depotLocker = it.second;
            for (Item* item : depotLocker->getItemList()) {
                if (item->getID() == ITEM_DEPOT) {
                    continue;
                }
                itemList.emplace_back(it.first, item);
            }
        }

        if (!saveItems(player, itemList, depotQuery, propWriteStream)) {
            return false;
        }

        //save depot items
        query.str(std::string());
        query << "DELETE FROM `player_depotitems` WHERE `player_id` = " << player->getGUID();

        if (!db.executeQuery(query.str())) {
            return false;
        }

        DBInsert inboxQuery("INSERT INTO `player_depotitems` (`player_id`, `pid`, `sid`, `itemtype`, `count`, `attributes`, `abilities`) VALUES ");
        itemList.clear();

        for (const auto& it : player->depotChests) {
            DepotChest* depotChest = it.second;
            for (Item* item : depotChest->getItemList()) {
                itemList.emplace_back(it.first, item);
            }
        }

        if (!saveItems(player, itemList, depotQuery, propWriteStream)) {
            return false;
        }
    }

    query.str(std::string());
    query << "DELETE FROM `player_storage` WHERE `player_id` = " << player->getGUID();
    if (!db.executeQuery(query.str())) {
        return false;
    }

    query.str(std::string());

    DBInsert storageQuery("INSERT INTO `player_storage` (`player_id`, `key`, `value`) VALUES ");
    player->genReservedStorageRange();

    for (const auto& it : player->storageMap) {
        query << player->getGUID() << ',' << it.first << ',' << it.second;
        if (!storageQuery.addRow(query)) {
            return false;
        }
    }

    if (!storageQuery.execute()) {
        return false;
    }

    //End the transaction
    return transaction.commit();
}
 

Attachments

OP
OP
Dries390

Dries390

Active Member
Joined
Sep 8, 2007
Messages
60
Solutions
4
Reaction score
41
I was able to fix it with the following C++ modifications:

iologindata.cpp
bool IOLoginData::savePlayer(Player* player) l. 797 - l. 869
C++:
    if (player->lastDepotId != -1) {
        //save depot lockers
        query.str(std::string());
        query << "DELETE FROM `player_depotlockeritems` WHERE `player_id` = " << player->getGUID();

        if (!db.executeQuery(query.str())) {
            return false;
        }

        DBInsert lockerQuery("INSERT INTO `player_depotlockeritems` (`player_id`, `pid`, `sid`, `itemtype`, `count`, `attributes`, `abilities`) VALUES ");
        itemList.clear();

        for (const auto& it : player->depotLockerMap) {
            DepotLocker* depotLocker = it.second;
            for (Item* item : depotLocker->getItemList()) {
                if (item->getID() == ITEM_DEPOT) {
                    continue;
                }
                itemList.emplace_back(it.first, item);
            }
        }

        if (!saveItems(player, itemList, lockerQuery, propWriteStream)) {
            return false;
        }

        //save depot items
        query.str(std::string());
        query << "DELETE FROM `player_depotitems` WHERE `player_id` = " << player->getGUID();

        if (!db.executeQuery(query.str())) {
            return false;
        }

        DBInsert depotQuery("INSERT INTO `player_depotitems` (`player_id`, `pid`, `sid`, `itemtype`, `count`, `attributes`, `abilities`) VALUES ");
        itemList.clear();

        for (const auto& it : player->depotChests) {
            DepotChest* depotChest = it.second;
            for (Item* item : depotChest->getItemList()) {
                itemList.emplace_back(it.first, item);
            }
        }

        if (!saveItems(player, itemList, depotQuery, propWriteStream)) {
            return false;
        }
    }

    query.str(std::string());
    query << "DELETE FROM `player_storage` WHERE `player_id` = " << player->getGUID();
    if (!db.executeQuery(query.str())) {
        return false;
    }

    query.str(std::string());

    DBInsert storageQuery("INSERT INTO `player_storage` (`player_id`, `key`, `value`) VALUES ");
    player->genReservedStorageRange();

    for (const auto& it : player->storageMap) {
        query << player->getGUID() << ',' << it.first << ',' << it.second;
        if (!storageQuery.addRow(query)) {
            return false;
        }
    }

    if (!storageQuery.execute()) {
        return false;
    }

    //End the transaction
    return transaction.commit();
 
Top