From b8554f6648ec24aadc270db8670dbfbe49852bfc Mon Sep 17 00:00:00 2001 From: Krarilotus <51748815+Krarilotus@users.noreply.github.com> Date: Thu, 10 Sep 2026 13:39:46 +0200 Subject: [PATCH] Reimplement adjacent region and height check for moat access --- ...TileInSameAreaAndNoTooHeightDifference.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/OpenSHC/Map/TileMapState/findTileInSameAreaAndNoTooHeightDifference.cpp diff --git a/src/OpenSHC/Map/TileMapState/findTileInSameAreaAndNoTooHeightDifference.cpp b/src/OpenSHC/Map/TileMapState/findTileInSameAreaAndNoTooHeightDifference.cpp new file mode 100644 index 00000000..4afff15c --- /dev/null +++ b/src/OpenSHC/Map/TileMapState/findTileInSameAreaAndNoTooHeightDifference.cpp @@ -0,0 +1,24 @@ +#include "../TileMapState.func.hpp" + +namespace OpenSHC { +namespace Map { + + // FUNCTION: STRONGHOLDCRUSADER 0x00500370 + BOOLEnum TileMapState::findTileInSameAreaAndNoTooHeightDifference(int area, int tile, int row) + { + int direction = 0; + int* neighborOffset = this->directionTranslationMatrix[row]; + for (; direction < 8; ++direction, ++neighborOffset) { + int neighborTile = tile + *neighborOffset; + // This is an existence check, not a route search. Lower neighbors have + // no height restriction; a neighbor may be at most 16 units higher. + if (this->HeightLayer[neighborTile] <= this->HeightLayer[tile] + 16 && + static_cast(this->PathConnectionLayer[neighborTile]) == area) { + return TRUE; + } + } + return FALSE; + } + +} // namespace Map +} // namespace OpenSHC