[Client] Send PlayerInventory packets when repairing items

master
David Cernat 6 years ago
parent 5d9893ee92
commit 71679934a1

@ -4,6 +4,18 @@
#include <components/misc/rng.hpp> #include <components/misc/rng.hpp>
/*
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/world.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/mechanicsmanager.hpp"
@ -57,8 +69,22 @@ void Repair::repair(const MWWorld::Ptr &itemToRepair)
// repair by 'y' points // repair by 'y' points
int charge = itemToRepair.getClass().getItemHealth(itemToRepair); int charge = itemToRepair.getClass().getItemHealth(itemToRepair);
charge = std::min(charge + y, itemToRepair.getClass().getItemMaxHealth(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); 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 // attempt to re-stack item, in case it was fully repaired
MWWorld::ContainerStoreIterator stacked = player.getClass().getContainerStore(player).restack(itemToRepair); MWWorld::ContainerStoreIterator stacked = player.getClass().getContainerStore(player).restack(itemToRepair);

Loading…
Cancel
Save