[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]
> >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
|
|