[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.
This commit is contained in:
David Cernat 2017-05-31 10:54:19 +03:00
parent a353a21280
commit 34a452d775
2 changed files with 19 additions and 19 deletions

View file

@ -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
MWWorld::CellStore *cellStore = Main::get().getCellController()->getCellStore(cell);
if (!cellStore)
{
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&)
{
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))

View file

@ -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;