mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-26 22:45:15 -04:00
[Client] Use DetourNavigator for local actors, working around c1ebd9474bdafb7c252428c83927802eac09b269
This commit is contained in:
parent
57734c172b
commit
63480a0012
@ -1,3 +1,4 @@
|
|||||||
|
#include <components/detournavigator/navigator.hpp>
|
||||||
#include <components/esm/cellid.hpp>
|
#include <components/esm/cellid.hpp>
|
||||||
#include <components/openmw-mp/TimedLog.hpp>
|
#include <components/openmw-mp/TimedLog.hpp>
|
||||||
#include <components/openmw-mp/Utils.hpp>
|
#include <components/openmw-mp/Utils.hpp>
|
||||||
@ -31,12 +32,14 @@ CellController::~CellController()
|
|||||||
|
|
||||||
void CellController::updateLocal(bool forceUpdate)
|
void CellController::updateLocal(bool forceUpdate)
|
||||||
{
|
{
|
||||||
|
MWBase::World* world = MWBase::Environment::get().getWorld();
|
||||||
|
|
||||||
// Loop through Cells, deleting inactive ones and updating LocalActors in active ones
|
// Loop through Cells, deleting inactive ones and updating LocalActors in active ones
|
||||||
for (auto it = cellsInitialized.begin(); it != cellsInitialized.end();)
|
for (auto it = cellsInitialized.begin(); it != cellsInitialized.end();)
|
||||||
{
|
{
|
||||||
mwmp::Cell *mpCell = it->second;
|
mwmp::Cell *mpCell = it->second;
|
||||||
|
|
||||||
if (!MWBase::Environment::get().getWorld()->isCellActive(*mpCell->getCellStore()->getCell()))
|
if (!world->isCellActive(*mpCell->getCellStore()->getCell()))
|
||||||
{
|
{
|
||||||
mpCell->uninitializeLocalActors();
|
mpCell->uninitializeLocalActors();
|
||||||
mpCell->uninitializeDedicatedActors();
|
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
|
// 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
|
// deleted from their previous one can make their records stay deleted
|
||||||
for (auto &cell : cellsInitialized)
|
if (cellsInitialized.size() > 0)
|
||||||
{
|
{
|
||||||
mwmp::Cell *mpCell = cell.second;
|
for (auto& cell : cellsInitialized)
|
||||||
if (mpCell->shouldInitializeActors == true)
|
|
||||||
{
|
{
|
||||||
mpCell->shouldInitializeActors = false;
|
mwmp::Cell* mpCell = cell.second;
|
||||||
mpCell->initializeLocalActors();
|
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)
|
void CellController::updateDedicated(float dt)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "../ActorProcessor.hpp"
|
#include "../ActorProcessor.hpp"
|
||||||
|
#include <components/detournavigator/navigator.hpp>
|
||||||
#include "apps/openmw/mwmp/Main.hpp"
|
#include "apps/openmw/mwmp/Main.hpp"
|
||||||
#include "apps/openmw/mwmp/CellController.hpp"
|
#include "apps/openmw/mwmp/CellController.hpp"
|
||||||
|
|
||||||
@ -34,6 +35,11 @@ namespace mwmp
|
|||||||
cell->uninitializeDedicatedActors();
|
cell->uninitializeDedicatedActors();
|
||||||
cell->initializeLocalActors();
|
cell->initializeLocalActors();
|
||||||
cell->updateLocal(true);
|
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
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user