Clean up around updatePos

This commit is contained in:
Lars Mueller 2024-09-04 19:41:03 +02:00
parent 2b99f66d44
commit 9126063caf
7 changed files with 9 additions and 17 deletions

View File

@ -117,8 +117,8 @@ void ActiveObjectMgr::invalidateActiveObjectObserverCaches()
}
}
void ActiveObjectMgr::updatePos(const v3f &pos, u16 id) {
// laziggy solution: only update if we already know the object
void ActiveObjectMgr::updatePos(u16 id, const v3f &pos) {
// HACK only update if we already know the object
if (m_active_objects.get(id) != nullptr)
m_spatial_index.update(pos.toArray(), id);
}

View File

@ -26,7 +26,7 @@ public:
void invalidateActiveObjectObserverCaches();
void updatePos(const v3f &pos, u16 id);
void updatePos(u16 id, const v3f &pos);
void getObjectsInsideRadius(const v3f &pos, float radius,
std::vector<ServerActiveObject *> &result,

View File

@ -6,6 +6,7 @@
#include "inventory.h"
#include "inventorymanager.h"
#include "constants.h" // BS
#include "serverenvironment.h"
ServerActiveObject::ServerActiveObject(ServerEnvironment *env, v3f pos):
ActiveObject(0),
@ -17,8 +18,8 @@ ServerActiveObject::ServerActiveObject(ServerEnvironment *env, v3f pos):
void ServerActiveObject::setBasePosition(v3f pos) {
bool changed = m_base_position != pos;
m_base_position = pos;
if (changed && m_env) // HACK this doesn't feel right; *when* is m_env null?
ServerEnvironment_updatePos(m_env, pos, getId());
if (changed && getEnv()) // HACK *when* is getEnv() null?
getEnv()->updatePos(getId(), pos);
}
float ServerActiveObject::getMinimumSavedMovement()

View File

@ -30,7 +30,6 @@ Some planning
*/
class ServerEnvironment;
void ServerEnvironment_updatePos(ServerEnvironment *senv, const v3f &pos, u16 id);
struct ItemStack;
struct ToolCapabilities;
struct ObjectProperties;

View File

@ -2566,8 +2566,3 @@ bool ServerEnvironment::migrateAuthDatabase(
}
return true;
}
// HACK
void ServerEnvironment_updatePos(ServerEnvironment *senv, const v3f &pos, u16 id) {
senv->updatePos(pos, id);
}

View File

@ -335,8 +335,8 @@ public:
// Find the daylight value at pos with a Depth First Search
u8 findSunlight(v3s16 pos) const;
void updatePos(const v3f &pos, u16 id) {
return m_ao_manager.updatePos(pos, id);
void updatePos(u16 id, const v3f &pos) {
return m_ao_manager.updatePos(id, pos);
}
// Find all active objects inside a radius around a point
@ -518,6 +518,3 @@ private:
std::unique_ptr<ServerActiveObject> createSAO(ActiveObjectType type, v3f pos,
const std::string &data);
};
// HACK
void ServerEnvironment_updatePos(ServerEnvironment *senv, const v3f &pos, u16 id);

View File

@ -44,7 +44,7 @@ public:
auto *obj = saomgr.getActiveObject(id);
REQUIRE(obj != nullptr);
obj->setPos(pos);
saomgr.updatePos(pos, id); // HACK work around m_env == nullptr
saomgr.updatePos(id, pos); // HACK work around m_env == nullptr
}
void clear() {