The gold amount overflows when it is over INT_MAX. This is often the case when you have a lot of Rampart towns, each has Treasury built, and then your gold amount multiplies on the first day of each week, After you have played long enough, it will eventually hit the limit and fall back to 0. (12 weeks is enough if you have 12 Ramparts and you don’t consume it. When I was playing a modified version of the map Pandora’s Box, I captured 9 Ramparts, and it just took me about 15 weeks to hit that limit.)
It might be better to limit it to a specific value, like 1e10 or so, rather than letting it to overflow and fall back.
Btw, any approach for a mod to modify the map when playing?