openmw-tes3coop/apps/openmw-mp/processors/actor/ProcessorActorCellChange.hpp
Koncord f35d35741e [General] Remove redundant code
Remove BaseEvent::worldObjectCount
Remove BaseActor::count
Use foreach loops in packets and processors
Remove redundant "&" in CellController::get().getCell() calls
2017-12-09 14:59:41 +08:00

44 lines
1.3 KiB
C++

#ifndef OPENMW_PROCESSORACTORCELLCHANGE_HPP
#define OPENMW_PROCESSORACTORCELLCHANGE_HPP
#include "../ActorProcessor.hpp"
namespace mwmp
{
class ProcessorActorCellChange final: public ActorProcessor
{
public:
ProcessorActorCellChange()
{
BPP_INIT(ID_ACTOR_CELL_CHANGE)
}
void Do(ActorPacket &packet, const std::shared_ptr<Player> &player, BaseActorList &actorList) override
{
Cell *serverCell = CellController::get().getCell(actorList.cell);
if (serverCell != nullptr && *serverCell->getAuthority() == actorList.guid)
{
serverCell->removeActors(actorList);
std::vector<std::shared_ptr<Actor>> actors;
for (auto &baseActor : actorList.baseActors)
{
Actor *actor = new Actor;
actor->actor = baseActor;
actors.emplace_back(actor);
}
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_ACTOR_CELL_CHANGE>(player, actors);
Networking::get().getState().getActorCtrl().sendActors(player, actors, actorList.cell, true);
// Send this to everyone
packet.Send(true);
}
}
};
}
#endif //OPENMW_PROCESSORACTORCELLCHANGE_HPP