Closed TsukiZero closed 1 year ago
Thanks for the report!
Easy to replicate
also interesting, when the mouse is towards the top left, it shows AGAIN... but when the mouse is bottom left, it rotates between a few different sprites. including the cross from the hill screen, and explosions
this is related to an original engine bug, which has caused issues in the past... a naive hack i put in place appears to work for almost every situation, except this one
the current sprite action & frame index are managed across multiple functions, in some cases the current state (even partial) is saved and restored after a function runs, if a particular condition is met.
Walk action has 3 frames Swim action has 2 frames
in this case, prior to updating the soldier to face the mouse cursor, the index is kept (which is 2) the direction is updated toward the mouse cursor, which also resets the index to 0 but the 'reached other soldier' flag is set, which resets the frame index to the kept index (2)
at this point the state is invalid, as its reading past the end of the swim[direction] array.
in the debug build of the exe, the bug doesnt cause any effect, it matches the original engine (which is reading from the next structure in memory) the release build however, compiler optimizations are shuffling the structs, so when it reads past the end of the array, its getting data from a completely different sprite set.
it should be noticeable in the original dos/amiga version, if you can have a troop land in the water, bump into another troop, and be facing up right at the same time, all in 1 engine cycle (it should switch to a death sprite)
these structs (20 bytes each) are all in order in the original exe, and in the debug build.. but you can see here they are all over the place
not really sure the best way to go about fixing this yet, an easy win might just be to restrict the index depending on action
Glad to know it was of help in spotting the cause of it, hope it can be fixed.
Fixed, will release 1.7.0 later today
I didn't record it, I might do eventually, but it happened when moving from the south coast to the pier as I marked in this map
If you stand in a certain spot it should be visible enough.
FTR, using GOG's version of Cannon Fodder 1