mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-30 06:36:44 +00:00
[Client] Fix crash caused by late-arriving ActorAuthority packets
This commit is contained in:
parent
14e1ff27cb
commit
a12694c6ef
4 changed files with 19 additions and 3 deletions
|
@ -289,6 +289,15 @@ bool CellController::isInitializedCell(const ESM::Cell& cell)
|
||||||
return (cellsInitialized.count(cell.getDescription()) > 0);
|
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)
|
Cell *CellController::getCell(const ESM::Cell& cell)
|
||||||
{
|
{
|
||||||
return cellsInitialized.at(cell.getDescription());
|
return cellsInitialized.at(cell.getDescription());
|
||||||
|
|
|
@ -51,6 +51,7 @@ namespace mwmp
|
||||||
std::string generateMapIndex(mwmp::BaseActor baseActor);
|
std::string generateMapIndex(mwmp::BaseActor baseActor);
|
||||||
|
|
||||||
bool isInitializedCell(const ESM::Cell& cell);
|
bool isInitializedCell(const ESM::Cell& cell);
|
||||||
|
bool isActiveWorldCell(const ESM::Cell& cell);
|
||||||
virtual Cell *getCell(const ESM::Cell& cell);
|
virtual Cell *getCell(const ESM::Cell& cell);
|
||||||
|
|
||||||
virtual MWWorld::CellStore *getCellStore(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
|
// If this player is now in a cell that is active for us, we should send them all
|
||||||
// NPC data in that cell
|
// NPC data in that cell
|
||||||
if (MWBase::Environment::get().getWorld()->isCellActive(cellStore))
|
if (Main::get().getCellController()->isActiveWorldCell(cell))
|
||||||
{
|
{
|
||||||
if (Main::get().getCellController()->isInitializedCell(cell))
|
if (Main::get().getCellController()->isInitializedCell(cell))
|
||||||
Main::get().getCellController()->getCell(cell)->updateLocal(true);
|
Main::get().getCellController()->getCell(cell)->updateLocal(true);
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#include "apps/openmw/mwmp/Main.hpp"
|
#include "apps/openmw/mwmp/Main.hpp"
|
||||||
#include "apps/openmw/mwmp/CellController.hpp"
|
#include "apps/openmw/mwmp/CellController.hpp"
|
||||||
|
|
||||||
|
#include "../mwworld/worldimp.hpp"
|
||||||
|
|
||||||
namespace mwmp
|
namespace mwmp
|
||||||
{
|
{
|
||||||
class ProcessorActorAuthority : public ActorProcessor
|
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());
|
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received %s about %s", strPacketID.c_str(), actorList.cell.getDescription().c_str());
|
||||||
|
|
||||||
Main::get().getCellController()->initializeLocalActors(actorList.cell);
|
// Never initialize LocalActors in a cell that is no longer loaded, if the server's packet arrived too late
|
||||||
Main::get().getCellController()->getCell(actorList.cell)->updateLocal(true);
|
if (mwmp::Main::get().getCellController()->isActiveWorldCell(actorList.cell))
|
||||||
|
{
|
||||||
|
Main::get().getCellController()->initializeLocalActors(actorList.cell);
|
||||||
|
Main::get().getCellController()->getCell(actorList.cell)->updateLocal(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue