1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 15:49:55 +00:00
openmw-tes3mp/apps/openmw/mwmp/processors/player/ProcessorPlayerStatsDynamic.hpp
2017-06-07 00:06:10 +08:00

47 lines
1.3 KiB
C++

//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORPLAYERSTATSDYNAMIC_HPP
#define OPENMW_PROCESSORPLAYERSTATSDYNAMIC_HPP
#include "../PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorPlayerStatsDynamic : public PlayerProcessor
{
public:
ProcessorPlayerStatsDynamic()
{
BPP_INIT(ID_PLAYER_STATS_DYNAMIC)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (isLocal())
{
if (isRequest())
static_cast<LocalPlayer *>(player)->updateStatsDynamic(true);
else
static_cast<LocalPlayer *>(player)->setDynamicStats();
}
else if (player != 0)
{
MWWorld::Ptr ptrPlayer = static_cast<DedicatedPlayer*>(player)->getPtr();
MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer);
MWMechanics::DynamicStat<float> value;
for (int i = 0; i < 3; ++i)
{
value.readState(player->creatureStats.mDynamic[i]);
ptrCreatureStats->setDynamic(i, value);
}
}
}
};
}
#endif //OPENMW_PROCESSORPLAYERSTATSDYNAMIC_HPP