Page 1 of 1

Possibly unit limit bug?

Posted: 21 Jul 2007, 17:37
by Orakio
Yesterday I hosted a 5v5 game on green fields with a unit limit of around 2600.

At some point I had to take and got a spare tech 1 air field so I decided to build 100 scouts for an amusing scouring mission to end all scouting mission.

Anyway at some point after around 80 were made I could no longer build anything at all. I did CTRL+A to select all units and I only had 450. I also double checked script .txt and the max unit limit (MaxUnits) was indeed set to 2600 or so. To confirm it was definitely the unit limit I sent my 80 scout planes in to get shot to pieces and after that I could build again.

So basically there's a horrible unit limit bug.

I'm not entirely sure but I think this is the code responsible:

if(gameSetup)
maxUnits=gameSetup->maxUnits;
if(maxUnits>MAX_UNITS/gs->activeTeams-5)
maxUnits=MAX_UNITS/gs->activeTeams-5;

There were a couple of specs I think. And 5000/11 then -5 is 450 although I'm not entirely sure what activeTeams consists of. Basically what I would have thought this code should look like is this:

if(maxUnits>MAX_UNITS)
maxUnits=MAX_UNITS;

Because otherwise the maxunits value is being applied not per team but for all the teams combined.

That code is from UnitHandler.cpp so if it is indeed wrong a fix would be great, because otherwise 8v8 games are limited to 300 or less units per player regardless of what the unit limit was set to.

Posted: 21 Jul 2007, 18:22
by Kloot
No, that's not a bug. MAX_UNITS is the engine unit limit (5000), maxUnits in CUnitHandler is the per-team unit limit (which is the value set in script.txt, divided by the number of active teams to ensure that it doesn't exceed 4995 if there's only one activeTeam). Thus if there are 16 players and all are in their own team, everyone gets to build a maximum of (n / 16) - 5 units, where n can be at most 5000.

Posted: 21 Jul 2007, 20:06
by Spawn_Retard
i thought it was 5000 per person not shared equally with every player in the host

Posted: 21 Jul 2007, 22:26
by KDR_11k
The total limit is 4998, if more than that are in play Spring crashes. Therefore the limit is set so that if all players hit their limit they still don't reach 4998.