Extra unit limits

frunobulax

High Sheriff of Catford
Joined
Jun 18, 2001
Messages
698
Location
London, England
Couldn't find a quick answer to this in the CivFanatics Forum, so thought I'd post it here...

What is the maximum number of extra units you can add using the Editor ?

thanks

Fruno
 
Not sure anyone ever really tested this, but i guess this will have something to do with how many units you can tell the game you have. This is determined by some bytes at the beginning of the PRTO (units) section of the .bic file.

If you never opened your .bic in an hex editor, this is what you find at the beginning of the PRTO section
Code:
[color=blue]50 52 54 4F 4D[/color] 00 00 00 [color=red]A4 00 00 00[/color] 00 00 00 00
Wich, if translated to ASCII gives
Code:
[color=blue]P  R  T  O  M[/color]  .  .  .  [color=red]§  .  .  .[/color]  .  .  .  .
The A4 is the hex form for 164, the umber of units in the game. According to Apolyton's bic file description, the number of units is coded by a LONG (four bytes, of wich only the first is used by the standart game), if you want to put all Fs (the last "number" in hex format in a long, this gives FFFFFFFF wich in decimal format is 4 294 967 295 :eek: , i guess this is the theoric maximum number of units. Now, if you want to add that much units you can tell us wether or not the game keeps stable :D

I hope i did not made a big mistake, i'm no software developper :o
 
Originally posted by Bob Morane
4 294 967 295 :eek:

:crazyeye:

I thought it might be 10-15 extra.... jeez, 4,294,967,295 is a lot of modding ! ;)

So, starting with the Middle Ages, that's one Trebuchet, one Trebuchet with extra relish, a Trebuchet with fries, a Trebuchet with cheese, a Trebuchet with bacon & cheese, Trebuchet 1/4 pounder, one Big (Mac) Trebuchet, one Barbecued Trebuchet, one Vegan Trebuchet with Lettuce, a Trebuchet Whopper with a family bucket of chicken.... etc
 
Originally posted by Bob Morane
if you want to put all Fs (the last "number" in hex format in a long, this gives FFFFFFFF wich in decimal format is 4 294 967 295 :eek: , i guess this is the theoric maximum number of units. Now, if you want to add that much units you can tell us wether or not the game keeps stable :D

I hope i did not made a big mistake, i'm no software developper :o

I'd be very surprised if you can add that many. The file format typically uses LONGs for all its values unless they've made special efforts to economise where there are lots of something - the tile records are an example of this. The value you have correctly identified only occurs once so they haven't bothered to limit its size. [ BTW A LONG value of 0xffffffff is actually -1 unless they've used unsigned integers. ]

My guess is that the programmed limit is something like 255, using a single byte of the LONG value. My reasoning is that the .sav game file contains a record for every unit instance. These records are likely to be optimised because there can be thousands of them (I seem to recall seeing a limit of 4000 units in a game somewhere), and each record will contain an index number to define which unit type it is. That index is quite likely to be a single byte value, and if so it can only count up to 255 unit types.
 
Originally posted by frunobulax
I thought it might be 10-15 extra.... jeez, 4,294,967,295 is a lot of modding !
See my other post. It's *only 2,147,483,647 :).

Seriously, I would imagine it's more than 10-15 as that would impose a severe limit on the modders and there would be lots of people complaining about it, so you'd have found it somewhere.

There are 65 units in Civ3 1.29 and probably a few more in PTW for the extra civ UUs. If my guess at one byte is correct you can safely add 40 or so even if the limit is 127 (a signed byte), or about 160 if it's 255 (an unsigned byte).

[Update] Note that the full GOTM add-on installer installs 32 extra units. They are probably not all used in any one game, but I think most appeared in GOTM21. So I'm sticking with my gut feel that it's a 255 total.

[BTW did you know you can use Google as a calculator now? Enter 2^31-1 and it gives you the above number. In Safari that means you can use the search field as a calculator]
 
Originally posted by AlanH
I'm sticking with my gut feel that it's a 255 total.

Wow.. that's great !
 
Originally posted by AlanH
So I'm sticking with my gut feel that it's a 255 total.
Hmm, i would think it's more, cause i know of a mod that claims having 500+ units.
I'll investigate a .sav file :)
 
Originally posted by Bob Morane

Hmm, i would think it's more, cause i know of a mod that claims having 500+ units.
I'll investigate a .sav file :)
OK, you win your bet. The start of the unit record in a sav file does appear to contain a sequence of longs, and one of those is probably the unit index, so thatblows my theory out of the window. I still doubt if the code can handle 2 billion unit types, but I don't have a way to guess at the actual limit now.
 
Top Bottom