To reproduce, load up Tarraco from campaign (attached), and add a conditional breakpoint here:
After a short wait this should get hit, and will result in an out of bounds memory check on the next line. What's happening here is:
In formation.c, the sheep formation gets initialized with a destination x/y of 0,0. For campaign it's loaded from a saved game but the same thing happens from CCK.
The sheep are unable to find a location to move to, so the formation destination x/y stays at 0.
In animal.c, the sheep figure gets its destination_x/y set based on the formation destination_x/y plus the formation offset.
Since some formation offset values can be negative and the sheep figure's destination_x/y are unsigned chars, this results in the destination_x/y values rolling over into the 250s (i.e., 0 + -1 = 255), which is out of the bounds of the map.
The sheep then attempt to find an out of bounds destination, resulting in a bad lookup.
I've gone ahead and fixed the issue for all the animal herds. It wasn't clear to me if this was an issue for soldier and enemy formations as well, but we should probably check that.
This is falling the earthquake tests for some reason. We'll need to check if there's a legitimate reason for that or if we should add an exception to the test.
To reproduce, load up Tarraco from campaign (attached), and add a conditional breakpoint here:
After a short wait this should get hit, and will result in an out of bounds memory check on the next line. What's happening here is:
formation.c
, the sheep formation gets initialized with a destination x/y of 0,0. For campaign it's loaded from a saved game but the same thing happens from CCK.animal.c
, the sheep figure gets its destination_x/y set based on the formation destination_x/y plus the formation offset.I've gone ahead and fixed the issue for all the animal herds. It wasn't clear to me if this was an issue for soldier and enemy formations as well, but we should probably check that.
Architect1.zip