[Client] Initialize Actors based on the guid of an ActorAuthority packet

This commit is contained in:
David Cernat 2017-05-03 04:47:04 +03:00
parent e01cadad23
commit 34e77c5dae

View file

@ -22,14 +22,31 @@ namespace mwmp
virtual void Do(ActorPacket &packet, ActorList &actorList) virtual void Do(ActorPacket &packet, ActorList &actorList)
{ {
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received %s about %s", strPacketID.c_str(), actorList.cell.getDescription().c_str()); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s about %s", strPacketID.c_str(), actorList.cell.getDescription().c_str());
// Never initialize LocalActors in a cell that is no longer loaded, if the server's packet arrived too late // Never initialize LocalActors in a cell that is no longer loaded, if the server's packet arrived too late
if (mwmp::Main::get().getCellController()->isActiveWorldCell(actorList.cell)) if (mwmp::Main::get().getCellController()->isActiveWorldCell(actorList.cell))
{ {
if (isLocal())
{
LOG_APPEND(Log::LOG_INFO, "- The new authority is me");
Main::get().getCellController()->initializeLocalActors(actorList.cell); Main::get().getCellController()->initializeLocalActors(actorList.cell);
Main::get().getCellController()->getCell(actorList.cell)->updateLocal(true); Main::get().getCellController()->getCell(actorList.cell)->updateLocal(true);
} }
else
{
BasePlayer *player = PlayerList::getPlayer(guid);
if (player != 0)
LOG_APPEND(Log::LOG_INFO, "- The new authority is %s", player->npc.mName.c_str());
Main::get().getCellController()->getCell(actorList.cell)->uninitializeLocalActors();
}
}
else
{
LOG_APPEND(Log::LOG_INFO, "- Ignoring it because that cell isn't loaded");
}
} }
}; };
} }