1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-06 02:19:41 +00:00

[Client] Use DetourNavigator for local actors, working around c1ebd9474b

This commit is contained in:
David Cernat 2020-07-26 17:58:59 +02:00
parent 57734c172b
commit 63480a0012
2 changed files with 25 additions and 7 deletions

View file

@ -1,3 +1,4 @@
#include <components/detournavigator/navigator.hpp>
#include <components/esm/cellid.hpp>
#include <components/openmw-mp/TimedLog.hpp>
#include <components/openmw-mp/Utils.hpp>
@ -31,12 +32,14 @@ CellController::~CellController()
void CellController::updateLocal(bool forceUpdate)
{
MWBase::World* world = MWBase::Environment::get().getWorld();
// Loop through Cells, deleting inactive ones and updating LocalActors in active ones
for (auto it = cellsInitialized.begin(); it != cellsInitialized.end();)
{
mwmp::Cell *mpCell = it->second;
if (!MWBase::Environment::get().getWorld()->isCellActive(*mpCell->getCellStore()->getCell()))
if (!world->isCellActive(*mpCell->getCellStore()->getCell()))
{
mpCell->uninitializeLocalActors();
mpCell->uninitializeDedicatedActors();
@ -50,19 +53,28 @@ void CellController::updateLocal(bool forceUpdate)
}
}
// Loop through Cells and initialize new LocalActors for eligible ones
// If there are cellsInitialized remaining, loop through them and initialize new LocalActors for eligible ones
//
//
// Note: This cannot be combined with the above loop because initializing LocalActors in a Cell before they are
// deleted from their previous one can make their records stay deleted
for (auto &cell : cellsInitialized)
if (cellsInitialized.size() > 0)
{
mwmp::Cell *mpCell = cell.second;
if (mpCell->shouldInitializeActors == true)
for (auto& cell : cellsInitialized)
{
mpCell->shouldInitializeActors = false;
mpCell->initializeLocalActors();
mwmp::Cell* mpCell = cell.second;
if (mpCell->shouldInitializeActors == true)
{
mpCell->shouldInitializeActors = false;
mpCell->initializeLocalActors();
}
}
}
// Otherwise, disable the DetourNavigator for advanced pathfinding for the time being
else
{
world->getNavigator()->setUpdatesEnabled(false);
}
}
void CellController::updateDedicated(float dt)

View file

@ -3,6 +3,7 @@
#include "../ActorProcessor.hpp"
#include <components/detournavigator/navigator.hpp>
#include "apps/openmw/mwmp/Main.hpp"
#include "apps/openmw/mwmp/CellController.hpp"
@ -34,6 +35,11 @@ namespace mwmp
cell->uninitializeDedicatedActors();
cell->initializeLocalActors();
cell->updateLocal(true);
// Enable updates for DetourNavigator for advanced pathfinding
MWBase::World* world = MWBase::Environment::get().getWorld();
world->getNavigator()->setUpdatesEnabled(true);
world->getNavigator()->update(world->getPlayerPtr().getRefData().getPosition().asVec3());
}
else
{