Alpha Centauri 2

Sid Meier's Alpha Centauri & Alien Crossfire => Modding => Bug/Patch Discussion => Topic started by: Buster's Uncle on January 22, 2021, 03:36:52 AM

Title: Pop 128 bug
Post by: Buster's Uncle on January 22, 2021, 03:36:52 AM
I don't recall it being reported/patched.  Game-breaking bug when a base's population, at least player headquarters, reaches 128.  Pop goes to negative numbers and the game crashes within two or three before it builds back to zero, let alone one.

scient?  Anyone?
Title: Re: Pop 128 bug
Post by: scient on February 06, 2021, 04:09:44 AM
This is because the population variable (https://github.com/b-casey/OpenSMACX/blob/master/src/base.h#L322) inside the base struct is treated as signed. This alone isn't the problem. The problem is that it's a signed byte so max is 127 before it rolls over to signed. There are ~269 references to this variable across 55-60 functions. About ~150 of these references are signed. Once these references are decompiled then I can start to fix this. Initially, treating the value as unsigned. Eventually, once all the base references (as in all the Base related code since this will change struct size) are complete I think the best method will be increase this value to int.
Templates: 1: Printpage (default).
Sub templates: 4: init, print_above, main, print_below.
Language files: 4: index+Modifications.english (default), TopicRating/.english (default), PortaMx/PortaMx.english (default), OharaYTEmbed.english (default).
Style sheets: 0: .
Files included: 31 - 840KB. (show)
Queries used: 15.

[Show Queries]