From 34a452d77581a3bf4d346ed750fc8247cc4944cb Mon Sep 17 00:00:00 2001 From: David Cernat Date: Wed, 31 May 2017 10:54:19 +0300 Subject: [PATCH] [Client] Fix logic for initialization and updating of player markers Additionally, disable the Ptrs of players who move to cells that don't exist for us instead of placing them in ToddTest. --- apps/openmw/mwmp/DedicatedPlayer.cpp | 30 ++++++++++++++-------------- apps/openmw/mwmp/PlayerList.cpp | 8 ++++---- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/apps/openmw/mwmp/DedicatedPlayer.cpp b/apps/openmw/mwmp/DedicatedPlayer.cpp index 9f2c4c87f..5ba963965 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.cpp +++ b/apps/openmw/mwmp/DedicatedPlayer.cpp @@ -210,32 +210,32 @@ void DedicatedPlayer::setCell() return; MWBase::World *world = MWBase::Environment::get().getWorld(); - MWWorld::CellStore *cellStore; - LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Server says DedicatedPlayer %s moved to %s", - this->npc.mName.c_str(), cell.getDescription().c_str()); + npc.mName.c_str(), cell.getDescription().c_str()); - try - { - if (cell.isExterior()) - cellStore = world->getExterior(cell.mData.mX, cell.mData.mY); - else - cellStore = world->getInterior(cell.mName); - } - // If the intended cell doesn't exist on this client, use ToddTest as a replacement - catch (std::exception&) + MWWorld::CellStore *cellStore = Main::get().getCellController()->getCellStore(cell); + + if (!cellStore) { - cellStore = world->getInterior("ToddTest"); LOG_APPEND(Log::LOG_INFO, "%s", "- Cell doesn't exist on this client"); + world->disable(getPtr()); + return; } - - if (!cellStore) return; + else + world->enable(getPtr()); // Allow this player's reference to move across a cell now that a manual cell // update has been called setPtr(world->moveObject(ptr, cellStore, position.pos[0], position.pos[1], position.pos[2])); + // Remove the marker entirely if this player has moved to an interior that is inactive for us + if (!cell.isExterior() && !Main::get().getCellController()->isActiveWorldCell(cell)) + Main::get().getGUIController()->mPlayerMarkers.deleteMarker(marker); + // Otherwise, update their marker so the player shows up in the right cell on the world map + else + updateMarker(); + // If this player is now in a cell that we are the local authority over, we should send them all // NPC data in that cell if (Main::get().getCellController()->hasLocalAuthority(cell)) diff --git a/apps/openmw/mwmp/PlayerList.cpp b/apps/openmw/mwmp/PlayerList.cpp index 13848a2b0..448002046 100644 --- a/apps/openmw/mwmp/PlayerList.cpp +++ b/apps/openmw/mwmp/PlayerList.cpp @@ -145,6 +145,10 @@ void PlayerList::createPlayer(RakNet::RakNetGUID guid) dedicPlayer->cell = *dedicPlayer->ptr.getCell()->getCell(); dedicPlayer->position = dedicPlayer->ptr.getRefData().getPosition(); } + + ESM::CustomMarker mEditingMarker = Main::get().getGUIController()->createMarker(guid); + dedicPlayer->marker = mEditingMarker; + dedicPlayer->setMarkerState(true); } else { @@ -184,10 +188,6 @@ void PlayerList::createPlayer(RakNet::RakNetGUID guid) dedicPlayer->setPtr(world->moveObject(dedicPlayer->ptr, cellStore, spawnPos.pos[0], spawnPos.pos[1], spawnPos.pos[2])); dedicPlayer->setCell(); - - ESM::CustomMarker mEditingMarker = Main::get().getGUIController()->CreateMarker(guid); - dedicPlayer->marker = mEditingMarker; - dedicPlayer->setMarkerState(true); } dedicPlayer->guid = guid;