File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -138,6 +138,7 @@ abstract class AiBase {
138138 var skipedTicks = 0 ;
139139 var lastSkipedTicks = 100 ;
140140 var averageSleepTime : Float = 0 ;
141+ var currentMaxAIs = ServerSettings . MinNumberOfAis ;
141142
142143 while (true ) {
143144 if (ServerSettings . UseOneGlobalMutex ) Server . Acquire ();
@@ -149,7 +150,7 @@ abstract class AiBase {
149150
150151 var aiCount = Connection .getAis ().length ;
151152
152- if (AiBase .tick % 20 != 0 && aiCount < ServerSettings . NumberOfAis ) {
153+ if (AiBase .tick % 20 != 0 && aiCount < currentMaxAIs ) {
153154 if (lastSkipedTicks < ServerSettings . MaxAiSkipedTicksBeforeReducingAIs
154155 || aiCount < ServerSettings . MinNumberOfAis ) Macro .exception (var ai = ServerAi .createNewServerAiWithNewPlayer ());
155156 // ai.player.delete(); // delete, so that they wont all spawn at same time
@@ -168,6 +169,11 @@ abstract class AiBase {
168169 averageSleepTime = 0 ;
169170 lastSkipedTicks = skipedTicks ;
170171 skipedTicks = 0 ;
172+
173+ if (currentMaxAIs < ServerSettings . NumberOfAis
174+ && lastSkipedTicks < ServerSettings . MaxAiSkipedTicksBeforeReducingAIs ) currentMaxAIs + = 1 ;
175+ if (currentMaxAIs > ServerSettings . MinNumberOfAis
176+ && lastSkipedTicks > ServerSettings . MaxAiSkipedTicksBeforeReducingAIs ) currentMaxAIs - = 1 ;
171177 }
172178
173179 var timePassedInSeconds = CalculateTimeSinceTicksInSec (lastTick );
You can’t perform that action at this time.
0 commit comments