From 71679934a186c2d9cec55fc07288fb1dbba3d9ad Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 30 Dec 2018 09:39:46 +0200 Subject: [PATCH] [Client] Send PlayerInventory packets when repairing items --- apps/openmw/mwmechanics/repair.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/apps/openmw/mwmechanics/repair.cpp b/apps/openmw/mwmechanics/repair.cpp index 5c6123e82..43fa35d8e 100644 --- a/apps/openmw/mwmechanics/repair.cpp +++ b/apps/openmw/mwmechanics/repair.cpp @@ -4,6 +4,18 @@ #include +/* + Start of tes3mp addition + + Include additional headers for multiplayer purposes +*/ +#include "../mwmp/Main.hpp" +#include "../mwmp/Networking.hpp" +#include "../mwmp/LocalPlayer.hpp" +/* + End of tes3mp addition +*/ + #include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/mechanicsmanager.hpp" @@ -57,8 +69,22 @@ void Repair::repair(const MWWorld::Ptr &itemToRepair) // repair by 'y' points int charge = itemToRepair.getClass().getItemHealth(itemToRepair); charge = std::min(charge + y, itemToRepair.getClass().getItemMaxHealth(itemToRepair)); + + /* + Start of tes3mp change (minor) + + Send PlayerInventory packets that replace the original item with the new one + */ + mwmp::LocalPlayer *localPlayer = mwmp::Main::get().getLocalPlayer(); + localPlayer->sendItemChange(itemToRepair, 1, mwmp::InventoryChanges::REMOVE); + itemToRepair.getCellRef().setCharge(charge); + localPlayer->sendItemChange(itemToRepair, 1, mwmp::InventoryChanges::ADD); + /* + End of tes3mp change (minor) + */ + // attempt to re-stack item, in case it was fully repaired MWWorld::ContainerStoreIterator stacked = player.getClass().getContainerStore(player).restack(itemToRepair);