Is the number of units limited?

gomezfett

Chieftain
Joined
Aug 26, 2017
Messages
31
Location
Valencia, Spain
First of all, I wanna apologize for my poor English. I'm from Spain and I don't speak English very well; besides, I can't understand many posts when they talk about IT or technical stuff, including abreviations people use.

Well. that's my problem. I don't know if this is a bug, but I can't build any kind of units anymore. When I try to do it, the game crash to desktop. So I must wipe out some of my units if I wanna build other. That includes all kind of units: ships, tamed animals, settlers, and so on.

So I wonder if there is a limit of units you can own in the game, or if it is related to how many cities you have, I mean, if you conquer or settle more cities, can you build more units?

I've been playing the same game since January, so I'd feel very dissapointed and frustrasted if I could't continue playing the same game.

I use the last SVN update, and the multilanguage version from CIV4 Complete Edition.

I really appreciate your answers. If you need more information or files, I can provide them.
 
Last edited:
There is a limit to the number of units a player can have. Can't recall exactly what that limit is but if you're on a really really big map you could start hitting that limit if you train and maintain a lot of them.
 
Ok, thundirbird. I use a giant map, but I have a really big number of units because I built (and still have) national units of almost all cultures (I like have remains of all cultures), most of them obsolete. So I'll wipe old units and I'll build stronger or usefull ones.

Thanks very much for your answer.
 
If the limit is known then it should be possible to put a test in the "canTrain"/"cannotTrain" areas of the code to check for that number and if the player gets anywhere near it then turn off the training of all units, ie grey them out possibly with a hover message to the effect "You have as many units as the game can support.".

Not sure how difficult that would be to do. I have been toying with the idea of such a unit limit based on your leader skill, technology level and number of cities in my mod. The limit would therefore be dynamic and would probably be split by major groupings eg foot solders (army), navy, air force, workers, other civilians.

Note that with Size Matters you should be able to merge units but splitting them when you approach the limit would also need to be turned off.
 
The limit is VERY high and should only be something you could break if you were really trying to hoard a LOT of units.

I'd have to break out the binary math here to really figure it out what the actual limit is. Spirictum might be able to help me with that.
 
Well lets just put a limit of 10,000 or so units per nation then.;) I know that there used to be a problem when the barbarians wanted to upgrade all 2000 units to archers at one stage
 
Easier said than done of course but yeah it's probably the safest way to go eventually. It affects unit trades as well as splits and possibly yet more, like free units you get with events. And the count is maintained in a VERY touchy part of the code that can cause huge problems if it gets off in the slightest so we might need to maintain the count in a whole new integer. That's fun too. (But might help to make some things easier than trying to get the count from the binary math system.)
 
If the limit set is not too close to the actual limit trades could probably be ignored. Putting a limit on building more units is possibly 3 lines of code in Python but that would be a single limit ie if have > X units in total then can't build any more of any type. It may be possible to do limits by type in Python but I have not looked at it in detail. If so it would probably not be much slower than the single maximum.
 
If this can help you, I've counted all units at the moment that I reach the limit and game crashes to desktop, I have 8,200 units, a giant map and 88 cities.

Hope this can be useful.:thumbsup:
 
If this can help you, I've counted all units at the moment that I reach the limit and game crashes to desktop, I have 8,200 units, a giant map and 88 cities.

Hope this can be useful.:thumbsup:
Curious, what Era are you in?
 
>8k units in Nanotech... quite an achievement without reaching other severe problem spots. You'll be able to extend your game by reducing units but the fact that you're even there without MAF (Memory Allocation Failure) crashes and integer overflows (numbers, like gold count, getting too large and going haywire as a result) is quite impressive. We know of numerous things we need to do to make this end of the game more valid past the point you're at. I would start emotionally bracing yourself for soon hitting a wall you won't be able to get past at this point.
 
>8k units in Nanotech... quite an achievement without reaching other severe problem spots. You'll be able to extend your game by reducing units but the fact that you're even there without MAF (Memory Allocation Failure) crashes and integer overflows (numbers, like gold count, getting too large and going haywire as a result) is quite impressive. We know of numerous things we need to do to make this end of the game more valid past the point you're at. I would start emotionally bracing yourself for soon hitting a wall you won't be able to get past at this point.

Hahaha. Well, my old laptop started to have lots of MAF when I used v36, so last year I bought a new better laptop only because I LOVE this mod and I wanted to keep enjoying it. But to be honest, I must admit that your work in the v37 has reduced MAF strongly, and makes the game very playable. But since industrial era I had to reduce graphics level from medium to basic, and this way allows me to reduce MAF quite a lot. Fighting against integer overflows is more complicated, but only when I updated dll's, so I only updated SVN when changes were significant.

Despite that, the only way I've been able to face huge integer overflows is modifying values through the Worldbuilder, city by city, only when I could't keep playing with those values.

But I thank VERY MUCH to the C2C Team for your work and the time you spend on it.:smoke:
 
Ah... you've been tricky about it I see. :P Good job! Hopefully within the next few months I'll be able to have the majority of the overflows resolved.
 
Set autosave to save like every turn and keep 20 autosaves.
Also recalculate variables once a while, thats what I did on my space playtrough, and I managed to finish tech tree.
 
Set autosave to save like every turn and keep 20 autosaves.
Also recalculate variables once a while, thats what I did on my space playtrough, and I managed to finish tech tree.
You also had no AI opponents
 
Yep, I guess that would be major reason for being seemingly overflow crapstorm proof.


mmk, how many ai's are in your current game?

I'm not sure, but there would be about 12 other civs..But all of them are very weak and underdeveloped (bigger and stronger empires were conquered by mine).
 
I don't know where I read it, but I seem to remember there being a hard limit on unit number equal to 2^13, or 8192, just about the ~8k you mentioned. I don't remember what the effect was once it was reached, presumably the original Civ4 designers never intended anyone to reach such numbers, which is fair considering vanilla. That many units would be extremely difficult to reach in the regular game, especially without Multiple Production.

Did anyone else ever play the first game, Civilization 1? In that game the unit limit was 2^7, a mere 128 units!!! Because it was known this limit would be reached in late game, an event was added when you tried to build past the limit, where an adviser would inform you that your civilisation was unable to maintain all your units. It was infuriating until I discovered the cause!

I was wondering about this ~8k limit myself actually. I often adjust difficulty up to deity once I get ahead (plus Nightmare mode), which requires up to 20-25 town guards per large city to control crime, plus a doggy, and some entertainers for education. Add to this some periodic garrisons of normal troops, several separate contained standing armies of about 40 units each, border guards to physically block AI strike teams, some workers, and a vast navy, and I can envision getting near to the limit.
 
Back
Top Bottom