From 4aff1f1833dc4fa2be763ce0574953a3bd862c8d Mon Sep 17 00:00:00 2001 From: Koncord Date: Mon, 5 Mar 2018 15:30:24 +0800 Subject: [PATCH] [Server] Add previous state to ON_PLAYER_SKILL That is array of struct with next content: {base, current, mod, damage, progress} --- .../player/ProcessorPlayerAttribute.hpp | 2 +- .../player/ProcessorPlayerSkill.hpp | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/apps/openmw-mp/processors/player/ProcessorPlayerAttribute.hpp b/apps/openmw-mp/processors/player/ProcessorPlayerAttribute.hpp index 2d93e7beb..8d0e2e3b2 100644 --- a/apps/openmw-mp/processors/player/ProcessorPlayerAttribute.hpp +++ b/apps/openmw-mp/processors/player/ProcessorPlayerAttribute.hpp @@ -24,7 +24,7 @@ namespace mwmp "damage", &OldAState::mDamage); } - void PreReading(PlayerPacket &packet, const std::shared_ptr &player) + void PreReading(PlayerPacket &packet, const std::shared_ptr &player) override { if (!player->creatureStats.mDead) std::copy(std::begin(player->creatureStats.mAttributes), diff --git a/apps/openmw-mp/processors/player/ProcessorPlayerSkill.hpp b/apps/openmw-mp/processors/player/ProcessorPlayerSkill.hpp index b262a8972..4d1832a4f 100644 --- a/apps/openmw-mp/processors/player/ProcessorPlayerSkill.hpp +++ b/apps/openmw-mp/processors/player/ProcessorPlayerSkill.hpp @@ -11,10 +11,26 @@ namespace mwmp { class ProcessorPlayerSkill final: public PlayerProcessor { + using OldSState = ESM::StatState; public: ProcessorPlayerSkill() { BPP_INIT(ID_PLAYER_SKILL) + Networking::get().getState().getState()->new_usertype("OldSState", + "base", &OldSState::mBase, + "current", &OldSState::mCurrent, + "mod", &OldSState::mMod, + "damage", &OldSState::mDamage, + "progress", &OldSState::mProgress); + } + + void PreReading(PlayerPacket &packet, const std::shared_ptr &player) override + { + if (!player->creatureStats.mDead) + std::copy(std::begin(player->npcStats.mSkills), + std::end(player->npcStats.mSkills), + oldValues.begin() + ); } void Do(PlayerPacket &packet, const std::shared_ptr &player) override @@ -22,11 +38,12 @@ 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; }; }