From c0ef625972620a3ff1490a98458d16160b4ef8a1 Mon Sep 17 00:00:00 2001 From: iProgramInCpp Date: Tue, 8 Aug 2023 10:52:45 +0300 Subject: [PATCH] * Revert to the old system, don't remove clashing ID entities, prioritize players over other entities. --- source/world/level/Level.cpp | 17 ++++++++++++++++- source/world/tile/SandTile.cpp | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/source/world/level/Level.cpp b/source/world/level/Level.cpp index c81c5ab..00f4b1b 100644 --- a/source/world/level/Level.cpp +++ b/source/world/level/Level.cpp @@ -279,6 +279,13 @@ Material* Level::getMaterial(int x, int y, int z) Entity* Level::getEntity(int id) { + // prioritize players first. + for (auto it = m_players.begin(); it != m_players.end(); it++) + { + Player* pEnt = *it; + if (pEnt->m_EntityID == id) + return pEnt; + } for (auto it = m_entities.begin(); it != m_entities.end(); it++) { Entity* pEnt = *it; @@ -1062,7 +1069,15 @@ bool Level::addEntity(Entity* pEnt) { Entity* pOldEnt = getEntity(pEnt->hashCode()); if (pOldEnt) - removeEntity(pOldEnt); + { + LogMsg("Warning: entity %d already exists.", pEnt->hashCode()); + //removeEntity(pOldEnt); + } + + if (!pEnt->isPlayer() && field_11) + { + LogMsg("Hey, why are you trying to add an non-player entity in a multiplayer world?"); + } //@NOTE: useless Mth::floor() calls Mth::floor(pEnt->m_pos.x / 16); diff --git a/source/world/tile/SandTile.cpp b/source/world/tile/SandTile.cpp index ddd9ab3..356d4bd 100644 --- a/source/world/tile/SandTile.cpp +++ b/source/world/tile/SandTile.cpp @@ -81,6 +81,9 @@ bool SandTile::isFree(Level* level, int x, int y, int z) void SandTile::tick(Level* level, int x, int y, int z, Random* random) { + if (level->field_11) + return; + checkSlide(level, x, y, z); }