From 8a99f215f6cb733d2425bf854315348c4c226746 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Fri, 11 Jan 2019 12:54:47 +0200 Subject: [PATCH] [Client] Add LocalPlayer::sendItemChange() variant with mwmp::Item arg --- apps/openmw/mwmp/LocalPlayer.cpp | 26 +++++++++----------------- apps/openmw/mwmp/LocalPlayer.hpp | 1 + 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 1d7c3899e..7eb31db2c 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -1403,33 +1403,25 @@ void LocalPlayer::sendInventory() getNetworking()->getPlayerPacket(ID_PLAYER_INVENTORY)->Send(); } - -void LocalPlayer::sendItemChange(const MWWorld::Ptr& itemPtr, int count, unsigned int action) +void LocalPlayer::sendItemChange(const mwmp::Item& item, unsigned int action) { LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending item change for %s with action %i, count %i", - itemPtr.getCellRef().getRefId().c_str(), action, count); + item.refId.c_str(), action, item.count); inventoryChanges.items.clear(); - - mwmp::Item item; - - if (itemPtr.getClass().isGold(itemPtr)) - item.refId = MWWorld::ContainerStore::sGoldId; - else - item.refId = itemPtr.getCellRef().getRefId(); - - item.count = count; - item.charge = itemPtr.getCellRef().getCharge(); - item.enchantmentCharge = itemPtr.getCellRef().getEnchantmentCharge(); - item.soul = itemPtr.getCellRef().getSoul(); - inventoryChanges.items.push_back(item); - inventoryChanges.action = action; + getNetworking()->getPlayerPacket(ID_PLAYER_INVENTORY)->setPlayer(this); getNetworking()->getPlayerPacket(ID_PLAYER_INVENTORY)->Send(); } +void LocalPlayer::sendItemChange(const MWWorld::Ptr& itemPtr, int count, unsigned int action) +{ + mwmp::Item item = MechanicsHelper::getItem(itemPtr, count); + sendItemChange(item, action); +} + void LocalPlayer::sendItemChange(const std::string& refId, int count, unsigned int action) { LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending item change for %s with action %i, count %i", diff --git a/apps/openmw/mwmp/LocalPlayer.hpp b/apps/openmw/mwmp/LocalPlayer.hpp index 5e8d242a4..377cf0977 100644 --- a/apps/openmw/mwmp/LocalPlayer.hpp +++ b/apps/openmw/mwmp/LocalPlayer.hpp @@ -77,6 +77,7 @@ namespace mwmp void sendClass(); void sendInventory(); + void sendItemChange(const mwmp::Item& item, unsigned int action); void sendItemChange(const MWWorld::Ptr& itemPtr, int count, unsigned int action); void sendItemChange(const std::string& refId, int count, unsigned int action); void sendSpellbook();