<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40481 >

Attached patch addresses two issues with the aifill

For some reason that is not apparent to me the aifill
function does nothing when the aifill amount is zero.
This is changed to allow setting aifill=0 and thus
removing all filled-in AIs.

When a new player joins in pregame the amount of AIs
due to aifill is correctly updated, but when a player
is removed due to a user disconnecting then the number
of AIs is not kept in step with the aifill setting.
A call to aifill is added to the end of the function
server_remove_player to address this.

(I am slightly uncomfortable with putting it there,
since it might lead to some recursive socket write
errors under exceptional network loads; the alternative
would be to call aifill every server tick in pregame,
i.e. after reads, writes and disconnects are handled
in the packet sniff loop.)

diff --git a/server/plrhand.c b/server/plrhand.c
index 49cae2c..92308c6 100644
--- a/server/plrhand.c
+++ b/server/plrhand.c
@@ -1115,6 +1115,8 @@ void server_remove_player(struct player *pplayer)
+  aifill(game.info.aifill);
diff --git a/server/srv_main.c b/server/srv_main.c
index 06342e5..35eccc5 100644
--- a/server/srv_main.c
+++ b/server/srv_main.c
@@ -1558,11 +1558,6 @@ void aifill(int amount)
-  if (amount == 0) {
-    /* Special case for value 0: do nothing. */
-    return;
-  }
   amount = MIN(amount, game.info.max_players);
   /* Limit to nations provided by ruleset */
Freeciv-dev mailing list

Reply via email to