[Server] Pass shared_ptr<Player> by reference

sol2-server-rewrite
Koncord 7 years ago
parent 85a9181c12
commit c55f0f73b8

@ -6,7 +6,7 @@ using namespace mwmp;
template<class T>
typename BasePacketProcessor<T>::processors_t BasePacketProcessor<T>::processors;
void ActorProcessor::Do(ActorPacket &packet, std::shared_ptr<Player> player, BaseActorList &actorList)
void ActorProcessor::Do(ActorPacket &packet, const std::shared_ptr<Player> &player, BaseActorList &actorList)
{
packet.Send(true);
}

@ -14,7 +14,7 @@ namespace mwmp
{
public:
virtual void Do(ActorPacket &packet, std::shared_ptr<Player> player, BaseActorList &actorList);
virtual void Do(ActorPacket &packet, const std::shared_ptr<Player> &player, BaseActorList &actorList);
static bool Process(RakNet::Packet &packet, BaseActorList &actorList) noexcept;
};

@ -18,7 +18,7 @@ namespace mwmp
{
public:
virtual void Do(PlayerPacket &packet, std::shared_ptr<Player> player) = 0;
virtual void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) = 0;
static bool Process(RakNet::Packet &packet) noexcept;
};

@ -10,7 +10,7 @@ using namespace mwmp;
template<class T>
typename BasePacketProcessor<T>::processors_t BasePacketProcessor<T>::processors;
void WorldProcessor::Do(WorldPacket &packet, std::shared_ptr<Player> player, BaseEvent &event)
void WorldProcessor::Do(WorldPacket &packet, const std::shared_ptr<Player> &player, BaseEvent &event)
{
packet.Send(true);
}

@ -18,7 +18,7 @@ namespace mwmp
{
public:
virtual void Do(WorldPacket &packet, std::shared_ptr<Player> player, BaseEvent &event);
virtual void Do(WorldPacket &packet, const std::shared_ptr<Player> &player, BaseEvent &event);
static bool Process(RakNet::Packet &packet, BaseEvent &event) noexcept;
};

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_ACTOR_AI)
}
void Do(ActorPacket &packet, std::shared_ptr<Player> player, BaseActorList &actorList) override
void Do(ActorPacket &packet, const std::shared_ptr<Player> &player, BaseActorList &actorList) override
{
// Send only to players who have the cell loaded
Cell *serverCell = CellController::get()->getCell(&actorList.cell);

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_ACTOR_ANIM_FLAGS)
}
void Do(ActorPacket &packet, std::shared_ptr<Player> player, BaseActorList &actorList) override
void Do(ActorPacket &packet, const std::shared_ptr<Player> &player, BaseActorList &actorList) override
{
// Send only to players who have the cell loaded
Cell *serverCell = CellController::get()->getCell(&actorList.cell);

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_ACTOR_ANIM_PLAY)
}
void Do(ActorPacket &packet, std::shared_ptr<Player> player, BaseActorList &actorList) override
void Do(ActorPacket &packet, const std::shared_ptr<Player> &player, BaseActorList &actorList) override
{
// Send only to players who have the cell loaded
Cell *serverCell = CellController::get()->getCell(&actorList.cell);

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_ACTOR_ATTACK)
}
void Do(ActorPacket &packet, std::shared_ptr<Player> player, BaseActorList &actorList) override
void Do(ActorPacket &packet, const std::shared_ptr<Player> &player, BaseActorList &actorList) override
{
// Send only to players who have the cell loaded
Cell *serverCell = CellController::get()->getCell(&actorList.cell);

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_ACTOR_CELL_CHANGE)
}
void Do(ActorPacket &packet, std::shared_ptr<Player> player, BaseActorList &actorList) override
void Do(ActorPacket &packet, const std::shared_ptr<Player> &player, BaseActorList &actorList) override
{
Cell *serverCell = CellController::get()->getCell(&actorList.cell);

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_ACTOR_DEATH)
}
void Do(ActorPacket &packet, std::shared_ptr<Player> player, BaseActorList &actorList) override
void Do(ActorPacket &packet, const std::shared_ptr<Player> &player, BaseActorList &actorList) override
{
// Send only to players who have the cell loaded
Cell *serverCell = CellController::get()->getCell(&actorList.cell);

@ -14,7 +14,7 @@ namespace mwmp
BPP_INIT(ID_ACTOR_EQUIPMENT)
}
void Do(ActorPacket &packet, std::shared_ptr<Player> player, BaseActorList &actorList) override
void Do(ActorPacket &packet, const std::shared_ptr<Player> &player, BaseActorList &actorList) override
{
std::vector<std::shared_ptr<Actor>> actors;

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_ACTOR_LIST)
}
void Do(ActorPacket &packet, std::shared_ptr<Player> player, BaseActorList &actorList) override
void Do(ActorPacket &packet, const std::shared_ptr<Player> &player, BaseActorList &actorList) override
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player->npc.mName.c_str());

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_ACTOR_POSITION)
}
void Do(ActorPacket &packet, std::shared_ptr<Player> player, BaseActorList &actorList) override
void Do(ActorPacket &packet, const std::shared_ptr<Player> &player, BaseActorList &actorList) override
{
// Send only to players who have the cell loaded
Cell *serverCell = CellController::get()->getCell(&actorList.cell);

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_ACTOR_SPEECH)
}
void Do(ActorPacket &packet, std::shared_ptr<Player> player, BaseActorList &actorList) override
void Do(ActorPacket &packet, const std::shared_ptr<Player> &player, BaseActorList &actorList) override
{
// Send only to players who have the cell loaded
Cell *serverCell = CellController::get()->getCell(&actorList.cell);

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_ACTOR_STATS_DYNAMIC)
}
void Do(ActorPacket &packet, std::shared_ptr<Player> player, BaseActorList &actorList) override
void Do(ActorPacket &packet, const std::shared_ptr<Player> &player, BaseActorList &actorList) override
{
// Send only to players who have the cell loaded
Cell *serverCell = CellController::get()->getCell(&actorList.cell);

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_ACTOR_TEST)
}
void Do(ActorPacket &packet, std::shared_ptr<Player> player, BaseActorList &actorList) override
void Do(ActorPacket &packet, const std::shared_ptr<Player> &player, BaseActorList &actorList) override
{
std::vector<std::shared_ptr<Actor>> actors;

@ -17,7 +17,7 @@ namespace mwmp
BPP_INIT(ID_CHAT_MESSAGE)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());

@ -17,7 +17,7 @@ namespace mwmp
BPP_INIT(ID_GUI_MESSAGEBOX)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());

@ -17,7 +17,7 @@ namespace mwmp
BPP_INIT(ID_GUI_WINDOW)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());

@ -13,9 +13,11 @@ namespace mwmp
BPP_INIT(ID_GAME_WEATHER)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) final
{
// Placeholder to be filled in later
DEBUG_PRINTF(strPacketID);
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_PLAYER_WEATHER>(player);
}
};
}

@ -17,7 +17,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_ANIM_FLAGS)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_ANIM_PLAY)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());

@ -19,7 +19,7 @@ namespace mwmp
playerController = Networking::get().getPlayerPacketController();
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());

@ -17,7 +17,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_ATTRIBUTE)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
if (!player->creatureStats.mDead)
{

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_BOOK)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_BOUNTY)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_PLAYER_BOUNTY>(player);
}

@ -21,7 +21,7 @@ namespace mwmp
playerController = Networking::get().getPlayerPacketController();
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player->npc.mName.c_str());

@ -17,7 +17,7 @@ namespace mwmp
playerController = Networking::get().getPlayerPacketController();
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player->npc.mName.c_str());

@ -17,7 +17,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_CHARCLASS)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());
}

@ -17,7 +17,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_CHARGEN)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());

@ -18,7 +18,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_DEATH)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player->npc.mName.c_str());

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_DISPOSITION)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());

@ -17,7 +17,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_EQUIPMENT)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_FACTION)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());

@ -17,7 +17,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_INVENTORY)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_JOURNAL)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_KILL_COUNT)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_LEVEL)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
if (!player->creatureStats.mDead)
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_PLAYER_LEVEL>(player);

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_MAP)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());

@ -17,7 +17,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_POSITION)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
//DEBUG_PRINTF(strPacketID);
if (!player->creatureStats.mDead)

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_REST)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());

@ -17,7 +17,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_RESURRECT)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received %s from %s", strPacketID.c_str(), player->npc.mName.c_str());

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_SHAPESHIFT)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player->npc.mName.c_str());

@ -17,7 +17,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_SKILL)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
if (!player->creatureStats.mDead)
{

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_SPEECH)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());

@ -17,7 +17,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_SPELLBOOK)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());

@ -17,7 +17,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_STATS_DYNAMIC)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_PLAYER_TOPIC)
}
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
{
DEBUG_PRINTF(strPacketID.c_str());

@ -15,7 +15,7 @@ namespace mwmp
BPP_INIT(ID_CONTAINER)
}
void Do(WorldPacket &packet, std::shared_ptr<Player> player, BaseEvent &event) override
void Do(WorldPacket &packet, const std::shared_ptr<Player> &player, BaseEvent &event) override
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player->npc.mName.c_str());
LOG_APPEND(Log::LOG_INFO, "- action: %i", event.action);

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_DOOR_STATE)
}
void Do(WorldPacket &packet, std::shared_ptr<Player> player, BaseEvent &event) override
void Do(WorldPacket &packet, const std::shared_ptr<Player> &player, BaseEvent &event) override
{
packet.Send(true);

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_OBJECT_DELETE)
}
void Do(WorldPacket &packet, std::shared_ptr<Player> player, BaseEvent &event) override
void Do(WorldPacket &packet, const std::shared_ptr<Player> &player, BaseEvent &event) override
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player->npc.mName.c_str());

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_OBJECT_LOCK)
}
void Do(WorldPacket &packet, std::shared_ptr<Player> player, BaseEvent &event) override
void Do(WorldPacket &packet, const std::shared_ptr<Player> &player, BaseEvent &event) override
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player->npc.mName.c_str());

@ -14,7 +14,7 @@ namespace mwmp
BPP_INIT(ID_OBJECT_PLACE)
}
void Do(WorldPacket &packet, std::shared_ptr<Player> player, BaseEvent &event) override
void Do(WorldPacket &packet, const std::shared_ptr<Player> &player, BaseEvent &event) override
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player->npc.mName.c_str());

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_OBJECT_SCALE)
}
void Do(WorldPacket &packet, std::shared_ptr<Player> player, BaseEvent &event) override
void Do(WorldPacket &packet, const std::shared_ptr<Player> &player, BaseEvent &event) override
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player->npc.mName.c_str());

@ -14,7 +14,7 @@ namespace mwmp
BPP_INIT(ID_OBJECT_SPAWN)
}
void Do(WorldPacket &packet, std::shared_ptr<Player> player, BaseEvent &event) override
void Do(WorldPacket &packet, const std::shared_ptr<Player> &player, BaseEvent &event) override
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player->npc.mName.c_str());

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_OBJECT_STATE)
}
void Do(WorldPacket &packet, std::shared_ptr<Player> player, BaseEvent &event) override
void Do(WorldPacket &packet, const std::shared_ptr<Player> &player, BaseEvent &event) override
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player->npc.mName.c_str());

@ -13,7 +13,7 @@ namespace mwmp
BPP_INIT(ID_OBJECT_TRAP)
}
void Do(WorldPacket &packet, std::shared_ptr<Player> player, BaseEvent &event) override
void Do(WorldPacket &packet, const std::shared_ptr<Player> &player, BaseEvent &event) override
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player->npc.mName.c_str());

Loading…
Cancel
Save