From 017956366f7eef48f98b0e407afae8d2a56d90ce Mon Sep 17 00:00:00 2001 From: Koncord Date: Mon, 5 Mar 2018 15:19:09 +0800 Subject: [PATCH] [Server] Add previous state argument to ON_PLAYER_ATTRIBUTE event That is array of struct with next content: {base, current, mod, damage} --- .../player/ProcessorPlayerAttribute.hpp | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/apps/openmw-mp/processors/player/ProcessorPlayerAttribute.hpp b/apps/openmw-mp/processors/player/ProcessorPlayerAttribute.hpp index 6c982e5af..2d93e7beb 100644 --- a/apps/openmw-mp/processors/player/ProcessorPlayerAttribute.hpp +++ b/apps/openmw-mp/processors/player/ProcessorPlayerAttribute.hpp @@ -12,9 +12,26 @@ namespace mwmp class ProcessorPlayerAttribute final: public PlayerProcessor { public: + using OldAState = ESM::StatState; ProcessorPlayerAttribute() { BPP_INIT(ID_PLAYER_ATTRIBUTE) + + Networking::get().getState().getState()->new_usertype("OldAState", + "base", &OldAState::mBase, + "current", &OldAState::mCurrent, + "mod", &OldAState::mMod, + "damage", &OldAState::mDamage); + } + + void PreReading(PlayerPacket &packet, const std::shared_ptr &player) + { + if (!player->creatureStats.mDead) + std::copy(std::begin(player->creatureStats.mAttributes), + std::end(player->creatureStats.mAttributes), + oldValues.begin() + ); + } void Do(PlayerPacket &packet, const std::shared_ptr &player) override @@ -22,12 +39,13 @@ namespace mwmp if (!player->creatureStats.mDead) { //myPacket->Send(player, true); + Networking::get().getState().getEventCtrl().Call(&oldValues, player.get()); player->sendToLoaded(packet); - - Networking::get().getState().getEventCtrl().Call(player.get()); } } + private: + std::array oldValues; }; }