mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-24 20:23:51 +00:00
a74bf1baec
(cherry picked from commit 7748e582a8
)
42 lines
1.2 KiB
C++
42 lines
1.2 KiB
C++
#ifndef OPENMW_PROCESSORPLAYERSPELLBOOK_HPP
|
|
#define OPENMW_PROCESSORPLAYERSPELLBOOK_HPP
|
|
|
|
|
|
#include "../PlayerProcessor.hpp"
|
|
|
|
namespace mwmp
|
|
{
|
|
class ProcessorPlayerSpellbook final: public PlayerProcessor
|
|
{
|
|
public:
|
|
ProcessorPlayerSpellbook()
|
|
{
|
|
BPP_INIT(ID_PLAYER_SPELLBOOK)
|
|
}
|
|
|
|
virtual void Do(PlayerPacket &packet, BasePlayer *player)
|
|
{
|
|
if (!isLocal()) return;
|
|
|
|
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received ID_PLAYER_SPELLBOOK about LocalPlayer from server");
|
|
|
|
if (isRequest())
|
|
static_cast<LocalPlayer*>(player)->sendSpellbook();
|
|
else
|
|
{
|
|
LocalPlayer &localPlayer = static_cast<LocalPlayer&>(*player);
|
|
|
|
int spellbookAction = localPlayer.spellbookChanges.action;
|
|
|
|
if (spellbookAction == SpellbookChanges::ADD)
|
|
localPlayer.addSpells();
|
|
else if (spellbookAction == SpellbookChanges::REMOVE)
|
|
localPlayer.removeSpells();
|
|
else // SpellbookChanges::SET
|
|
localPlayer.setSpellbook();
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
#endif //OPENMW_PROCESSORPLAYERSPELLBOOK_HPP
|