From 2ac01dc02a4f85d63b89859c999b3b1ce028c8c9 Mon Sep 17 00:00:00 2001 From: Koncord Date: Mon, 5 Mar 2018 15:40:23 +0800 Subject: [PATCH] [Server] Add previous state to ON_RECORD_DYNAMIC --- .../player/ProcessorRecordDynamic.hpp | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/apps/openmw-mp/processors/player/ProcessorRecordDynamic.hpp b/apps/openmw-mp/processors/player/ProcessorRecordDynamic.hpp index 14838fe06..b36270840 100644 --- a/apps/openmw-mp/processors/player/ProcessorRecordDynamic.hpp +++ b/apps/openmw-mp/processors/player/ProcessorRecordDynamic.hpp @@ -8,17 +8,36 @@ namespace mwmp class ProcessorRecordDynamic final : public PlayerProcessor { public: + using OldDState = ESM::StatState; ProcessorRecordDynamic() { BPP_INIT(ID_RECORD_DYNAMIC) + + Networking::get().getState().getState()->new_usertype("OldDState", + "base", &OldDState::mBase, + "current", &OldDState::mCurrent, + "mod", &OldDState::mMod, + "damage", &OldDState::mDamage, + "progress", &OldDState::mProgress); + } + + void PreReading(PlayerPacket &packet, const std::shared_ptr &player) override + { + std::copy(std::begin(player->creatureStats.mDynamic), + std::end(player->creatureStats.mDynamic), + oldValues.begin() + ); + } void Do(PlayerPacket &packet, const std::shared_ptr &player) override { DEBUG_PRINTF(strPacketID.c_str()); - Networking::get().getState().getEventCtrl().Call(player); + Networking::get().getState().getEventCtrl().Call(&oldValues, player); } + private: + std::array oldValues; }; }