Reimplement adjacent tile region and height check - #227
Open
Krarilotus wants to merge 1 commit into
Open
Conversation
TheRedDaemon
requested changes
Sep 11, 2026
TheRedDaemon
left a comment
Contributor
There was a problem hiding this comment.
This is missing the matching status file update.
Comment on lines
+9
to
+12
| int direction = 0; | ||
| int* neighborOffset = this->directionTranslationMatrix[row]; | ||
| for (; direction < 8; ++direction, ++neighborOffset) { | ||
| int neighborTile = tile + *neighborOffset; |
Contributor
There was a problem hiding this comment.
Can you check if this loop would also work by index access and iterating over the directions?
Basically a normal for-loop and then using this->directionTranslationMatrix[row][direction]?
If not might neighborOffset[direction] possible, avoiding the pointer?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR: Reimplements the game's check for a neighboring tile in a requested path region, as used during moat selection. The C++ makes the height rule explicit while preserving the original behavior.
Implements
TileMapState::findTileInSameAreaAndNoTooHeightDifferenceat0x00500370. It examines eight offsets from the caller's row, accepts a neighbor no more than 16 height units above the source tile, and compares its signed 16-bit region ID with the requested area. This is an existence check: route selection, terrain suitability, and caller input validation remain outside this helper.Validation: built the linked
OpenSHC.dllwith MSVC 2005 SP1 in RelWithDebInfo and compared it against Crusader 1.41 with reccmp. Result: 100% effective match. The sole difference is the ordering of two independent setup instructions (add edx, ecxandlea ebx, [eax + 0x10]); the loop, comparisons, and returns match. This is not claimed as a byte-for-byte match or a gameplay fix.No generated headers, runtime infrastructure, or emulator tooling are changed.