Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2000:
[Freeciv-Dev] Re: barbarians can end a game (PR#230)
Home

[Freeciv-Dev] Re: barbarians can end a game (PR#230)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jjm@xxxxxxxxxxxx, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: barbarians can end a game (PR#230)
From: Reinier Post <rp@xxxxxxxxxx>
Date: Wed, 12 Jan 2000 17:55:01 +0100

> >An interesting thing happened when I was playing a single-player game to test
> >the new CVS features: a barbarian unit appeared, and when it was killed, the
> >game was over!

[...]

> How about this?

[part of patch copied here:]

-  if (game.nplayers == 1)
+
+  for (i=0;i<game.nplayers; i++) {
+    if (is_barbarian(&(game.players[i])))
+      barbs++;
+  }
+  if (game.nplayers == (barbs + 1))
     return 0;
+
   for (i=0;i<game.nplayers; i++) {
-    if (game.players[i].is_alive)
-      alive ++;
+    if (game.players[i].is_alive && !(is_barbarian(&(game.players[i]))))
+      alive++;
   }
   return (alive <= 1);
 }

(in the function http://www.freeciv.org/lxr/ident?i=is_game_over)

Yes, it seems odd to have two loops, but this makes the function
disregard barbarian races, which repairs more than just the problem
I mentioned.

-- 
Reinier

[Prev in Thread] Current Thread [Next in Thread]