openmw-tes3coop/apps/openmw/mwmp/processors/player/ProcessorPlayerStatsDynamic.hpp

48 lines
1.3 KiB
C++
Raw Normal View History

2017-04-16 07:00:25 +00:00
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORPLAYERSTATSDYNAMIC_HPP
#define OPENMW_PROCESSORPLAYERSTATSDYNAMIC_HPP
2017-04-16 07:00:25 +00:00
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorPlayerStatsDynamic : public PlayerProcessor
2017-04-16 07:00:25 +00:00
{
public:
ProcessorPlayerStatsDynamic()
2017-04-16 07:00:25 +00:00
{
2017-04-18 04:17:58 +00:00
BPP_INIT(ID_PLAYER_STATS_DYNAMIC)
2017-04-16 07:00:25 +00:00
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (isLocal())
{
if (isRequest())
2017-04-18 04:17:58 +00:00
static_cast<LocalPlayer *>(player)->updateStatsDynamic(true);
2017-04-16 07:00:25 +00:00
else
static_cast<LocalPlayer *>(player)->setDynamicStats();
}
else if (player != 0)
2017-04-16 07:00:25 +00:00
{
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