diff --git a/Source/control.cpp b/Source/control.cpp index 955e7f13c..9d8576f42 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -378,10 +378,12 @@ void RemoveGold(Player &player, int goldIndex) { int gi = goldIndex - INVITEM_INV_FIRST; player.InvList[gi]._ivalue -= dropGoldValue; - if (player.InvList[gi]._ivalue > 0) + if (player.InvList[gi]._ivalue > 0) { SetPlrHandGoldCurs(player.InvList[gi]); - else + NetSyncInvItem(player, gi); + } else { player.RemoveInvItem(gi); + } MakeGoldStack(player.HoldItem, dropGoldValue); NewCursor(player.HoldItem); diff --git a/Source/inv.cpp b/Source/inv.cpp index 1344455bf..365d542d0 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -523,6 +523,9 @@ void CheckInvPaste(Player &player, Point cursorPosition) player._pNumInv++; player.InvGrid[ii] = player._pNumInv; } + if (&player == MyPlayer) { + NetSendCmdChInvItem(false, ii); + } } else { if (it == 0) { player.InvList[player._pNumInv] = player.HoldItem.pop(); @@ -1020,6 +1023,9 @@ int CreateGoldItemInInventorySlot(Player &player, int slotIndex, int value) MakeGoldStack(goldItem, std::min(value, MaxGold)); player._pNumInv++; player.InvGrid[slotIndex] = player._pNumInv; + if (&player == MyPlayer) { + NetSendCmdChInvItem(false, slotIndex); + } value -= goldItem._ivalue; @@ -1424,6 +1430,7 @@ int AddGoldToInventory(Player &player, int value) value = 0; } + NetSyncInvItem(player, i); SetPlrHandGoldCurs(goldItem); } diff --git a/Source/msg.cpp b/Source/msg.cpp index aa9483ecb..f546a832b 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -3118,6 +3118,19 @@ void NetSendCmdDelItem(bool bHiPri, uint8_t bLoc) NetSendLoPri(MyPlayerId, (byte *)&cmd, sizeof(cmd)); } +void NetSyncInvItem(const Player &player, int invListIndex) +{ + if (&player != MyPlayer) + return; + + for (int j = 0; j < InventoryGridCells; j++) { + if (player.InvGrid[j] == invListIndex + 1) { + NetSendCmdChInvItem(false, j); + break; + } + } +} + void NetSendCmdChInvItem(bool bHiPri, int invGridIndex) { TCmdChItem cmd {}; diff --git a/Source/msg.h b/Source/msg.h index 16ff11536..f2f86547d 100644 --- a/Source/msg.h +++ b/Source/msg.h @@ -768,6 +768,7 @@ void NetSendCmdParam4(bool bHiPri, _cmd_id bCmd, uint16_t wParam1, uint16_t wPar void NetSendCmdQuest(bool bHiPri, const Quest &quest); void NetSendCmdGItem(bool bHiPri, _cmd_id bCmd, uint8_t pnum, uint8_t ii); void NetSendCmdPItem(bool bHiPri, _cmd_id bCmd, Point position, const Item &item); +void NetSyncInvItem(const Player &player, int invListIndex); void NetSendCmdChItem(bool bHiPri, uint8_t bLoc); void NetSendCmdDelItem(bool bHiPri, uint8_t bLoc); void NetSendCmdChInvItem(bool bHiPri, int invGridIndex);