diff --git a/apps/openmw-mp/Script/Functions/Items.cpp b/apps/openmw-mp/Script/Functions/Items.cpp index 0812e35ba..b391f8ccf 100644 --- a/apps/openmw-mp/Script/Functions/Items.cpp +++ b/apps/openmw-mp/Script/Functions/Items.cpp @@ -24,14 +24,14 @@ unsigned int ItemFunctions::GetInventoryChangesSize(unsigned short pid) noexcept return player->inventoryChanges.count; } -void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const char *itemId, unsigned int count, int health) noexcept +void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const char *itemId, unsigned int count, int charge) noexcept { Player *player; GET_PLAYER(pid, player,); player->equipedItems[slot].refId = itemId; player->equipedItems[slot].count = count; - player->equipedItems[slot].health = health; + player->equipedItems[slot].charge = charge; } void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcept @@ -42,7 +42,7 @@ void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcep ItemFunctions::EquipItem(pid, slot, "", 0, -1); } -void ItemFunctions::AddItem(unsigned short pid, const char* itemId, unsigned int count, int health) noexcept +void ItemFunctions::AddItem(unsigned short pid, const char* itemId, unsigned int count, int charge) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -50,7 +50,7 @@ void ItemFunctions::AddItem(unsigned short pid, const char* itemId, unsigned int Item item; item.refId = itemId; item.count = count; - item.health = health; + item.charge = charge; player->inventoryChangesBuffer.items.push_back(item); player->inventoryChangesBuffer.action = InventoryChanges::ADD; @@ -105,12 +105,12 @@ int ItemFunctions::GetEquipmentItemCount(unsigned short pid, unsigned short slot return player->equipedItems[slot].count; } -int ItemFunctions::GetEquipmentItemHealth(unsigned short pid, unsigned short slot) noexcept +int ItemFunctions::GetEquipmentItemCharge(unsigned short pid, unsigned short slot) noexcept { Player *player; GET_PLAYER(pid, player, 0); - return player->equipedItems[slot].health; + return player->equipedItems[slot].charge; } const char *ItemFunctions::GetInventoryItemId(unsigned short pid, unsigned int i) noexcept @@ -132,12 +132,12 @@ int ItemFunctions::GetInventoryItemCount(unsigned short pid, unsigned int i) noe return player->inventoryChanges.items.at(i).count; } -int ItemFunctions::GetInventoryItemHealth(unsigned short pid, unsigned int i) noexcept +int ItemFunctions::GetInventoryItemCharge(unsigned short pid, unsigned int i) noexcept { Player *player; GET_PLAYER(pid, player, 0); - return player->inventoryChanges.items.at(i).health; + return player->inventoryChanges.items.at(i).charge; } void ItemFunctions::SendEquipment(unsigned short pid) noexcept diff --git a/apps/openmw-mp/Script/Functions/Items.hpp b/apps/openmw-mp/Script/Functions/Items.hpp index 50f9191b8..6806cd7c1 100644 --- a/apps/openmw-mp/Script/Functions/Items.hpp +++ b/apps/openmw-mp/Script/Functions/Items.hpp @@ -20,11 +20,11 @@ \ {"GetEquipmentItemId", ItemFunctions::GetEquipmentItemId},\ {"GetEquipmentItemCount", ItemFunctions::GetEquipmentItemCount},\ - {"GetEquipmentItemHealth", ItemFunctions::GetEquipmentItemHealth},\ + {"GetEquipmentItemCharge", ItemFunctions::GetEquipmentItemCharge},\ \ {"GetInventoryItemId", ItemFunctions::GetInventoryItemId},\ {"GetInventoryItemCount", ItemFunctions::GetInventoryItemCount},\ - {"GetInventoryItemHealth", ItemFunctions::GetInventoryItemHealth},\ + {"GetInventoryItemCharge", ItemFunctions::GetInventoryItemCharge},\ \ {"SendEquipment", ItemFunctions::SendEquipment},\ {"SendInventoryChanges", ItemFunctions::SendInventoryChanges} @@ -36,10 +36,10 @@ public: static int GetEquipmentSize() noexcept; static unsigned int GetInventoryChangesSize(unsigned short pid) noexcept; - static void EquipItem(unsigned short pid, unsigned short slot, const char* itemId, unsigned int count, int health) noexcept; + static void EquipItem(unsigned short pid, unsigned short slot, const char* itemId, unsigned int count, int charge) noexcept; static void UnequipItem(unsigned short pid, unsigned short slot) noexcept; - static void AddItem(unsigned short pid, const char* itemId, unsigned int count, int health) noexcept; + static void AddItem(unsigned short pid, const char* itemId, unsigned int count, int charge) noexcept; static void RemoveItem(unsigned short pid, const char* itemId, unsigned short count) noexcept; static void ClearInventory(unsigned short pid) noexcept; @@ -47,11 +47,11 @@ public: static const char *GetEquipmentItemId(unsigned short pid, unsigned short slot) noexcept; static int GetEquipmentItemCount(unsigned short pid, unsigned short slot) noexcept; - static int GetEquipmentItemHealth(unsigned short pid, unsigned short slot) noexcept; + static int GetEquipmentItemCharge(unsigned short pid, unsigned short slot) noexcept; static const char *GetInventoryItemId(unsigned short pid, unsigned int i) noexcept; static int GetInventoryItemCount(unsigned short pid, unsigned int i) noexcept; - static int GetInventoryItemHealth(unsigned short pid, unsigned int i) noexcept; + static int GetInventoryItemCharge(unsigned short pid, unsigned int i) noexcept; static void SendEquipment(unsigned short pid) noexcept; static void SendInventoryChanges(unsigned short pid) noexcept; diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index a520d967a..5f91884af 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -400,7 +400,7 @@ void LocalPlayer::updateEquipment(bool forceUpdate) equipChanged = true; equipedItems[slot].refId = it->getCellRef().getRefId(); - equipedItems[slot].health = it->getCellRef().getCharge(); + equipedItems[slot].charge = it->getCellRef().getCharge(); if (slot == MWWorld::InventoryStore::Slot_CarriedRight) { MWMechanics::WeaponType weaptype; @@ -416,7 +416,7 @@ void LocalPlayer::updateEquipment(bool forceUpdate) equipChanged = true; equipedItems[slot].refId = ""; equipedItems[slot].count = 0; - equipedItems[slot].health = 0; + equipedItems[slot].charge = 0; } } @@ -453,7 +453,7 @@ void LocalPlayer::updateInventory(bool forceUpdate) continue; item.count = result->getRefData().getCount(); - item.health = result->getCellRef().getCharge(); + item.charge = result->getCellRef().getCharge(); if (item == (*iter)) break; @@ -475,7 +475,7 @@ void LocalPlayer::updateInventory(bool forceUpdate) continue; item.count = iter->getRefData().getCount(); - item.health = iter->getCellRef().getCharge(); + item.charge = iter->getCellRef().getCharge(); vector::iterator result = inventoryChanges.items.begin(); @@ -638,8 +638,8 @@ void LocalPlayer::addItems() { mwmp::Item item = inventoryChanges.items[i]; MWWorld::Ptr itemPtr = *ptrStore.add(item.refId, item.count, ptrPlayer); - if (item.health != -1) - itemPtr.getCellRef().setCharge(item.health); + if (item.charge != -1) + itemPtr.getCellRef().setCharge(item.charge); } } @@ -970,7 +970,7 @@ void LocalPlayer::sendInventory() continue; item.count = iter->getRefData().getCount(); - item.health = iter->getCellRef().getCharge(); + item.charge = iter->getCellRef().getCharge(); inventoryChanges.items.push_back(item); } diff --git a/components/openmw-mp/Base/BasePlayer.hpp b/components/openmw-mp/Base/BasePlayer.hpp index e47b1bf08..5739de103 100644 --- a/components/openmw-mp/Base/BasePlayer.hpp +++ b/components/openmw-mp/Base/BasePlayer.hpp @@ -39,10 +39,11 @@ namespace mwmp { std::string refId; int count; - int health; + int charge; + inline bool operator==(const Item& rhs) { - return refId == rhs.refId && count == rhs.count && health == rhs.health; + return refId == rhs.refId && count == rhs.count && charge == rhs.charge; } }; diff --git a/components/openmw-mp/Packets/Player/PacketPlayerEquipment.cpp b/components/openmw-mp/Packets/Player/PacketPlayerEquipment.cpp index cf4e7146c..fb28a9800 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerEquipment.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerEquipment.cpp @@ -20,6 +20,6 @@ void PacketPlayerEquipment::Packet(RakNet::BitStream *bs, BasePlayer *player, bo { RW(player->equipedItems[i].refId, send); RW(player->equipedItems[i].count, send); - RW(player->equipedItems[i].health, send); + RW(player->equipedItems[i].charge, send); } } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerInventory.cpp b/components/openmw-mp/Packets/Player/PacketPlayerInventory.cpp index f6761c78c..a3c0f8f2c 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerInventory.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerInventory.cpp @@ -33,15 +33,14 @@ void PacketPlayerInventory::Packet(RakNet::BitStream *bs, BasePlayer *player, bo if (send) { item = player->inventoryChanges.items[i]; - RW(item.refId, send); - RW(item.count, send); - RW(item.health, send); } - else + + RW(item.refId, send); + RW(item.count, send); + RW(item.charge, send); + + if (!send) { - RW(item.refId, send); - RW(item.count, send); - RW(item.health, send); player->inventoryChanges.items.push_back(item); } } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.cpp b/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.cpp index 65c0db41d..c7efdc01a 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.cpp @@ -29,11 +29,12 @@ void PacketPlayerSpellbook::Packet(RakNet::BitStream *bs, BasePlayer *player, bo if (send) { spell = player->spellbookChanges.spells[i]; - RW(spell.mId, send); } - else + + RW(spell.mId, send); + + if (!send) { - RW(spell.mId, send); player->spellbookChanges.spells.push_back(spell); } }