How to change the unit limit?

kotekiipsotek

Chieftain
Joined
Mar 19, 2021
Messages
2
After some time, a message pops up:

Sire, our population can not
support so many military units.
We must eliminate some of our old
units before we build new once.

How do I change this limit?
 
It's possible to store some units in 2 "special fields" in city data, though. Only human player can do this. I cannot say right away what rules for the game to do that, exactly. Should look into the code. Theoretical limit for units then 128 cities max*2+127 = 383.
 
Last edited:
It's possible to store some units in 2 "special fields" in city data, though. Only human player can do this. I cannot say right away what rules for the game to do that, exactly. Should look into the code. Theoretical limit for units then 128 cities max*2+128 = 384.

Does this actually work in game ? I wonder... Anyhow, as soon as you activate or get one of the units out of the city, something will get lost somewhere.
 
Does this actually work in game ? I wonder... Anyhow, as soon as you activate or get one of the units out of the city, something will get lost somewhere.
Yes, it does work. But only for human player, for fortified units, starting from 2nd (first F unit skipped), and only if unit in its home city. Tested it just now. 3 militias in London. Fortified all of 3. 2 went to special fields.

Also "celebration cancelled" flag in JCivED actually is used as flag "unit was moved from special field" and this is its only purpose.

Game tries to move units FROM special fields to normal unit array when: 1) city screen of this city is shown or 2) some unit is activated or moves to a next square - then game checks if there are any cities in 8 squares around the unit, and if civ of city is not same as the civ of the unit, then game tries to move units from special fields of this city to a normal unit array. If game failed to do this, unit(s) still will disappear from special field(s) and "Sire, our population cannot..." message will appear. City flag 4 is set to 1 here. If it fails, only unit(s) from the special field(s) will disappear. Main unit array will be alright.

Game tries to move units TO the special fields when:
1) unit changes its status from "freshly fortified" to "fortified" and there's no any enemy units around (in 8 adjacent squares)
2) in city logic, after paying for maintenance of city improvements, if there's no any enemy units around (in 8 adj. squares). In this case, game also checks if city flag 4 is not 0, which means that this city already moved unit from special field to normal status before.
City flag 4 is set to 0 here.

Maybe should add pastebin with some C about put in/put out logic later.
 
Last edited:
Civ 1 is not open source and we don't have a full buildable disassembly or decompilation. When I say "gonna look into the code", I mean (partially) disassembled code. Only simple hacks (without changing number of bytes) are easy to do for now.

Limit of units is not a constant, but just a number (probably was #define 128), so change it everywhere should be very hard. Then also we should add memory for these units, so all addresses will change in result - so it's not feasible. Maybe if decrease max amount of civs - then additional memory will not be needed. Anyway, it would be incredible pain to trying to do this. If only CivOne project was more alive and finished.
 
Last edited:
Top Bottom