openmw-tes3coop/apps/openmw-mp/processors/actor/ProcessorActorCellChange.hpp
Koncord 4ca5da5666 [Server] Rework Plugin API, move Lua system to external library
Use LibFFI for Public & Timer APIs
Use "PlayerId" type instead "unsigned short"
Add GetPluginDir() function
2019-02-12 05:29:57 +08:00

50 lines
1.5 KiB
C++

#ifndef OPENMW_PROCESSORACTORCELLCHANGE_HPP
#define OPENMW_PROCESSORACTORCELLCHANGE_HPP
#include "../ActorProcessor.hpp"
namespace mwmp
{
class ProcessorActorCellChange : public ActorProcessor
{
public:
ProcessorActorCellChange()
{
BPP_INIT(ID_ACTOR_CELL_CHANGE)
}
void Do(ActorPacket &packet, Player &player, BaseActorList &actorList) override
{
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
if (serverCell != nullptr)
{
bool isFollowerCellChange = false;
// TODO: Move this check on the Lua side
for (unsigned int i = 0; i < actorList.count; i++)
{
if (actorList.baseActors.at(i).isFollowerCellChange)
{
isFollowerCellChange = true;
break;
}
}
// Only accept regular cell changes from a cell's authority, but accept follower
// cell changes from other players
if (*serverCell->getAuthority() == actorList.guid || isFollowerCellChange)
{
serverCell->removeActors(&actorList);
Plugin::Call<CallbackIndex("OnActorCellChange")>(player.getId(), actorList.cell.getDescription().c_str());
// Send this to everyone
packet.Send(true);
}
}
}
};
}
#endif //OPENMW_PROCESSORACTORCELLCHANGE_HPP