[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.
0.6.1
David Cernat 8 years ago
parent a353a21280
commit 34a452d775

@ -210,32 +210,32 @@ void DedicatedPlayer::setCell()
return; return;
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::CellStore *cellStore;
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Server says DedicatedPlayer %s moved to %s", 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 (cell.isExterior()) if (!cellStore)
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"); LOG_APPEND(Log::LOG_INFO, "%s", "- Cell doesn't exist on this client");
world->disable(getPtr());
return;
} }
else
if (!cellStore) return; world->enable(getPtr());
// Allow this player's reference to move across a cell now that a manual cell // Allow this player's reference to move across a cell now that a manual cell
// update has been called // update has been called
setPtr(world->moveObject(ptr, cellStore, position.pos[0], position.pos[1], position.pos[2])); 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 // 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 // NPC data in that cell
if (Main::get().getCellController()->hasLocalAuthority(cell)) if (Main::get().getCellController()->hasLocalAuthority(cell))

@ -145,6 +145,10 @@ void PlayerList::createPlayer(RakNet::RakNetGUID guid)
dedicPlayer->cell = *dedicPlayer->ptr.getCell()->getCell(); dedicPlayer->cell = *dedicPlayer->ptr.getCell()->getCell();
dedicPlayer->position = dedicPlayer->ptr.getRefData().getPosition(); dedicPlayer->position = dedicPlayer->ptr.getRefData().getPosition();
} }
ESM::CustomMarker mEditingMarker = Main::get().getGUIController()->createMarker(guid);
dedicPlayer->marker = mEditingMarker;
dedicPlayer->setMarkerState(true);
} }
else 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->setPtr(world->moveObject(dedicPlayer->ptr, cellStore, spawnPos.pos[0], spawnPos.pos[1], spawnPos.pos[2]));
dedicPlayer->setCell(); dedicPlayer->setCell();
ESM::CustomMarker mEditingMarker = Main::get().getGUIController()->CreateMarker(guid);
dedicPlayer->marker = mEditingMarker;
dedicPlayer->setMarkerState(true);
} }
dedicPlayer->guid = guid; dedicPlayer->guid = guid;

Loading…
Cancel
Save