[Server] Add previous state argument to ON_PLAYER_ATTRIBUTE event

That is array of struct with next content: {base, current, mod, damage}
sol2-server-rewrite
Koncord 7 years ago
parent afbafdf806
commit 017956366f

@ -12,9 +12,26 @@ namespace mwmp
class ProcessorPlayerAttribute final: public PlayerProcessor
{
public:
using OldAState = ESM::StatState<int>;
ProcessorPlayerAttribute()
{
BPP_INIT(ID_PLAYER_ATTRIBUTE)
Networking::get().getState().getState()->new_usertype<OldAState>("OldAState",
"base", &OldAState::mBase,
"current", &OldAState::mCurrent,
"mod", &OldAState::mMod,
"damage", &OldAState::mDamage);
}
void PreReading(PlayerPacket &packet, const std::shared_ptr<Player> &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> &player) override
@ -22,12 +39,13 @@ namespace mwmp
if (!player->creatureStats.mDead)
{
//myPacket->Send(player, true);
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_PLAYER_ATTRIBUTE, true>(&oldValues, player.get());
player->sendToLoaded(packet);
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_PLAYER_ATTRIBUTE>(player.get());
}
}
private:
std::array<OldAState, ESM::Attribute::Length> oldValues;
};
}

Loading…
Cancel
Save