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:
and the part of iologindata.cpp:
Will appreciate any tips what might be wrong, cheers
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