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

C++ [OTX3] Old parcel system.

MashJ

New Member
Joined
Jul 6, 2017
Messages
7
Reaction score
0
Hello guys,

For some days I am struggling with the parcel system. I want to make it work like in older versions, so parcels are sent to players locker instead of common inbox for all cities.
I did succeed, but only partialy - system works as far as player is online. If you are trying to send parcel to player who is offline - parcel is gone (player_inboxitems table remains empty).

Here's the part of mailbox.cpp:

C++:
Player* player = g_game.getPlayerByName(receiver);
   if (player) {
       DepotLocker* depotLocker = player->getDepotLocker(depotId);
       if (depotLocker) {
           if (g_game.internalMoveItem(item->getParent(), depotLocker, INDEX_WHEREEVER,
               item, item->getItemCount(), nullptr, FLAG_NOLIMIT) == RETURNVALUE_NOERROR) {
               g_game.transformItem(item, item->getID() + 1);
               player->onReceiveMail();
               return true;
           }
       }
   }
   else {
       Player tmpPlayer(nullptr);
       if (!IOLoginData::loadPlayerByName(&tmpPlayer, receiver)) {
           return false;
       }

       DepotLocker* depotLocker = tmpPlayer.getDepotLocker(depotId);
       if (depotLocker) {
           if (g_game.internalMoveItem(item->getParent(), depotLocker, INDEX_WHEREEVER,
               item, item->getItemCount(), nullptr, FLAG_NOLIMIT) == RETURNVALUE_NOERROR) {
               g_game.transformItem(item, item->getID() + 1);
               IOLoginData::savePlayer(&tmpPlayer);
               return true;
           }
       }
   }

and the part of iologindata.cpp:

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

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

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

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

Will appreciate any tips what might be wrong, cheers :)
 
Back
Top