You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After adding ASSERT checks to Diplo AI memory, I was confronted with a very hard to catch bug where approaches towards player 0 would be randomly replaced with huge negative or positive numbers. Even player 0's approach scores towards themselves, which shouldn't ever be updated.
Turns out SetCivApproach() was setting -1 for m_aeCachedSurfaceApproach[MAX_MAJOR_CIVS] (the array right before the approach scores) for every City-State. Because this went beyond the bounds of the array, it would randomly overwrite approach scores towards human players with garbage data, resulting in the AI being extremely passive or aggressive for no reason.
This was a silent failure for probably several versions now. I was unaware there's no out-of-bounds exception in C++, and there may be other instances of this in the code somewhere. We need assert checks for all arrays to make sure the index is in bounds!
The text was updated successfully, but these errors were encountered:
edit: Difference that I can see between CvAsserts, focused on Civ 5 game debugging and FAsserts, more generalized asserts.
Past comment on the FAssert work: #9155 - CvAssert vs FAssert in reference to "Invariants" noting we have working CvAssert dialog now. Project should move eventually towards standardisation of asserts.
After adding ASSERT checks to Diplo AI memory, I was confronted with a very hard to catch bug where approaches towards player 0 would be randomly replaced with huge negative or positive numbers. Even player 0's approach scores towards themselves, which shouldn't ever be updated.
Turns out SetCivApproach() was setting -1 for
m_aeCachedSurfaceApproach[MAX_MAJOR_CIVS]
(the array right before the approach scores) for every City-State. Because this went beyond the bounds of the array, it would randomly overwrite approach scores towards human players with garbage data, resulting in the AI being extremely passive or aggressive for no reason.This was a silent failure for probably several versions now. I was unaware there's no out-of-bounds exception in C++, and there may be other instances of this in the code somewhere. We need assert checks for all arrays to make sure the index is in bounds!
The text was updated successfully, but these errors were encountered: