game crash if modding speed

Joined
Feb 6, 2006
Messages
796
I think it's a bug (well, in a certain way), and it has always been there since Civ Vanilla.

It only happens if you mod the game speed settings to have each turn with a month increment during BC years. The easiest way to reproduce it is to set the first turns of a game to be a 1 month increment.

This is what happens:
in the second turn, the main screen shows a wrong date (in the upper right panel);
as soon as you end the second turn, the game crashes.

I've investigated the SDK, and found the cause.
The problem is in the function that calculate the text format of the current date (for example, the text "3999BC, January"). The function name is something like "getDateString" or "getDateText".
It computes the absolute month number. It should be -47999 (the first month after year -4000).
It computes the result mod 12, to have the number of the month in the year. It is -11.
Then, it tries to get the month information for the month -11. Obviously there's NO month -11; months are from 0 (january) to 11 (december), and cannot be negative, so the game crashes.

I've resolved it in my mod, by adding the "-11" value to the number of month infos (12). So a -11 becomes 1 (january), and a -10 becomes 2 (february), and so on. Positive values work fine, it has only to be applied to negative values.
 
Back
Top Bottom