diff --git a/apps/openmw-mp/Cell.cpp b/apps/openmw-mp/Cell.cpp index 6ffd67fc6..05ce084ac 100644 --- a/apps/openmw-mp/Cell.cpp +++ b/apps/openmw-mp/Cell.cpp @@ -183,7 +183,10 @@ void Cell::sendToLoaded(mwmp::ActorPacket *actorPacket, mwmp::BaseActorList *bas std::list plList; for (auto pl : players) - plList.push_back(pl); + { + if (pl != nullptr && !pl->npc.mName.empty()) + plList.push_back(pl); + } plList.sort(); plList.unique(); @@ -207,7 +210,10 @@ void Cell::sendToLoaded(mwmp::WorldPacket *worldPacket, mwmp::BaseEvent *baseEve std::list plList; for (auto pl : players) - plList.push_back(pl); + { + if (pl != nullptr && !pl->npc.mName.empty()) + plList.push_back(pl); + } plList.sort(); plList.unique(); diff --git a/apps/openmw-mp/Player.cpp b/apps/openmw-mp/Player.cpp index 03b17e216..d980c3282 100644 --- a/apps/openmw-mp/Player.cpp +++ b/apps/openmw-mp/Player.cpp @@ -142,8 +142,13 @@ void Player::forEachLoaded(std::function func) std::list plList; for (auto cell : cells) + { for (auto pl : *cell) - plList.push_back(pl); + { + if (pl != nullptr && !pl->npc.mName.empty()) + plList.push_back(pl); + } + } plList.sort(); plList.unique(); diff --git a/apps/openmw-mp/processors/player/ProcessorPlayerCellChange.hpp b/apps/openmw-mp/processors/player/ProcessorPlayerCellChange.hpp index 4ae16f0a9..d7f2228d1 100644 --- a/apps/openmw-mp/processors/player/ProcessorPlayerCellChange.hpp +++ b/apps/openmw-mp/processors/player/ProcessorPlayerCellChange.hpp @@ -32,43 +32,35 @@ namespace mwmp player.forEachLoaded([this](Player *pl, Player *other) { - if (other == nullptr) - { - LOG_APPEND(Log::LOG_INFO, "- Tried to exchange information with nullptr!"); - LOG_APPEND(Log::LOG_INFO, "- Please report this to a developer"); - } - else - { - LOG_APPEND(Log::LOG_INFO, "- Started information exchange with %s", other->npc.mName.c_str()); + LOG_APPEND(Log::LOG_INFO, "- Started information exchange with %s", other->npc.mName.c_str()); - playerController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->setPlayer(other); - playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->setPlayer(other); - playerController->GetPacket(ID_PLAYER_POSITION)->setPlayer(other); - playerController->GetPacket(ID_PLAYER_SKILL)->setPlayer(other); - playerController->GetPacket(ID_PLAYER_EQUIPMENT)->setPlayer(other); - playerController->GetPacket(ID_PLAYER_ANIM_FLAGS)->setPlayer(other); + playerController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->setPlayer(other); + playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->setPlayer(other); + playerController->GetPacket(ID_PLAYER_POSITION)->setPlayer(other); + playerController->GetPacket(ID_PLAYER_SKILL)->setPlayer(other); + playerController->GetPacket(ID_PLAYER_EQUIPMENT)->setPlayer(other); + playerController->GetPacket(ID_PLAYER_ANIM_FLAGS)->setPlayer(other); - playerController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->Send(pl->guid); - playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->Send(pl->guid); - playerController->GetPacket(ID_PLAYER_POSITION)->Send(pl->guid); - playerController->GetPacket(ID_PLAYER_SKILL)->Send(pl->guid); - playerController->GetPacket(ID_PLAYER_EQUIPMENT)->Send(pl->guid); - playerController->GetPacket(ID_PLAYER_ANIM_FLAGS)->Send(pl->guid); + playerController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->Send(pl->guid); + playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->Send(pl->guid); + playerController->GetPacket(ID_PLAYER_POSITION)->Send(pl->guid); + playerController->GetPacket(ID_PLAYER_SKILL)->Send(pl->guid); + playerController->GetPacket(ID_PLAYER_EQUIPMENT)->Send(pl->guid); + playerController->GetPacket(ID_PLAYER_ANIM_FLAGS)->Send(pl->guid); - playerController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->setPlayer(pl); - playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->setPlayer(pl); - playerController->GetPacket(ID_PLAYER_SKILL)->setPlayer(pl); - playerController->GetPacket(ID_PLAYER_EQUIPMENT)->setPlayer(pl); - playerController->GetPacket(ID_PLAYER_ANIM_FLAGS)->setPlayer(pl); + playerController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->setPlayer(pl); + playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->setPlayer(pl); + playerController->GetPacket(ID_PLAYER_SKILL)->setPlayer(pl); + playerController->GetPacket(ID_PLAYER_EQUIPMENT)->setPlayer(pl); + playerController->GetPacket(ID_PLAYER_ANIM_FLAGS)->setPlayer(pl); - playerController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->Send(other->guid); - playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->Send(other->guid); - playerController->GetPacket(ID_PLAYER_SKILL)->Send(other->guid); - playerController->GetPacket(ID_PLAYER_EQUIPMENT)->Send(other->guid); - playerController->GetPacket(ID_PLAYER_ANIM_FLAGS)->Send(other->guid); + playerController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->Send(other->guid); + playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->Send(other->guid); + playerController->GetPacket(ID_PLAYER_SKILL)->Send(other->guid); + playerController->GetPacket(ID_PLAYER_EQUIPMENT)->Send(other->guid); + playerController->GetPacket(ID_PLAYER_ANIM_FLAGS)->Send(other->guid); - LOG_APPEND(Log::LOG_INFO, "- Finished information exchange with %s", other->npc.mName.c_str()); - } + LOG_APPEND(Log::LOG_INFO, "- Finished information exchange with %s", other->npc.mName.c_str()); }); playerController->GetPacket(ID_PLAYER_POSITION)->setPlayer(&player);