Leaving ZKR starting fort through the south gate (by abnormal means) and traveling a few steps south leads to a crash #240
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The issue was identifies as trying to check if the tile has a road in a next sector to the south.
Save attached - move 1 tile south.
zkr_road_check_crash.exg.zip
Backtrace:
More precisely, it's trying to access the next sector to the south, which doesn't exist. We either need to enable "dummy" values if the view scrolls off the edge of the map, or have some special case so that it doesn't scroll at all when you're at the edge.
You could also use a system like what Realmz does here: setting invalid map sectors to ID -1, and checking for that ID before attempting to load an adjacent section. If there’s no sector there, don’t scroll the map past what would be the transition point.
I think that's basically the sort of idea I meant here:
The other method is probably easier, but then you'd see blackness or something beyond the edge. On the other hand, that might be okay - scenarios are supposed to be structured so you can't get that close, anyway. As long as it doesn't crash…
Loading this save file and moving south in the current build, I don't get a crash.
Responding to what you said on IRC…
The original game loads 4 outdoor sections into a 96x96 combined grid, shifting them as you move around the outdoors. I don't think I remember altering that aspect.
I'm working on a replay test case in a custom scenario that takes the party to all 4 world boundaries of the outdoors, and also in all 3 town sizes.
In an outdoors with only one tile, none of the 4 boundaries cause a crash when you get too close (on Mac). Weirdly, however, the cave tiles repeat themselves at the southern and eastern borders, but you get blackness at the north and west.
In a 3x3 outdoors, the behavior is the same (on Mac).
All 3 town sizes work at the boundaries as well.
This is really weird, because on Windows or Linux (don't remember which) I was definitely getting crashes at the boundaries while investigating this issue a few weeks ago. Maybe it's implementation-dependent on out-of-bounds access behavior?
That was correct -- the replay does crash on Windows.
There's supposed to be a special message when you try to travel out-of-bounds – instead of moving the party, the game writes something to the message buffer. I don't recall what the exact message was, but I definitely remember seeing it in one of my own custom scenarios running on vanilla BoE. The message is probably still in the source code somewhere.
That message is what happens on Mac 👍
Okay, so there's some issue that prevents the message from triggering on Windows for some reason?
I think on Windows, before the party gets to try to move out of bounds, draw_terrain() is trying to check tiles that are out of bounds. On Mac, this out-of-bounds access is for some reason returning safe values that the program then runs with, but on windows, it's throwing an error (as it should) (this is a case of undefined C++ stdlib behavior)
The fix will be to detect the out-of-bounds access before it happens, and supply the safe value on purpose
I wonder if this is related to the same issue.