[Client] Fix crash caused by late-arriving ActorAuthority packets

0.6.1
David Cernat 8 years ago
parent 14e1ff27cb
commit a12694c6ef

@ -289,6 +289,15 @@ bool CellController::isInitializedCell(const ESM::Cell& cell)
return (cellsInitialized.count(cell.getDescription()) > 0);
}
bool CellController::isActiveWorldCell(const ESM::Cell& cell)
{
MWWorld::CellStore *cellStore = getCellStore(cell);
if (!cellStore) return false;
return MWBase::Environment::get().getWorld()->isCellActive(cellStore);
}
Cell *CellController::getCell(const ESM::Cell& cell)
{
return cellsInitialized.at(cell.getDescription());

@ -51,6 +51,7 @@ namespace mwmp
std::string generateMapIndex(mwmp::BaseActor baseActor);
bool isInitializedCell(const ESM::Cell& cell);
bool isActiveWorldCell(const ESM::Cell& cell);
virtual Cell *getCell(const ESM::Cell& cell);
virtual MWWorld::CellStore *getCellStore(const ESM::Cell& cell);

@ -375,7 +375,7 @@ void DedicatedPlayer::updateCell()
// If this player is now in a cell that is active for us, we should send them all
// NPC data in that cell
if (MWBase::Environment::get().getWorld()->isCellActive(cellStore))
if (Main::get().getCellController()->isActiveWorldCell(cell))
{
if (Main::get().getCellController()->isInitializedCell(cell))
Main::get().getCellController()->getCell(cell)->updateLocal(true);

@ -10,6 +10,8 @@
#include "apps/openmw/mwmp/Main.hpp"
#include "apps/openmw/mwmp/CellController.hpp"
#include "../mwworld/worldimp.hpp"
namespace mwmp
{
class ProcessorActorAuthority : public ActorProcessor
@ -24,8 +26,12 @@ namespace mwmp
{
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received %s about %s", strPacketID.c_str(), actorList.cell.getDescription().c_str());
Main::get().getCellController()->initializeLocalActors(actorList.cell);
Main::get().getCellController()->getCell(actorList.cell)->updateLocal(true);
// 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))
{
Main::get().getCellController()->initializeLocalActors(actorList.cell);
Main::get().getCellController()->getCell(actorList.cell)->updateLocal(true);
}
}
};
}

Loading…
Cancel
Save