[Freeciv-Dev] (PR#2275) compiler warning
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients:; |
Subject: |
[Freeciv-Dev] (PR#2275) compiler warning |
From: |
"Jason Short via RT" <rt@xxxxxxxxxxxxxx> |
Date: |
Thu, 7 Nov 2002 12:26:38 -0800 |
Reply-to: |
rt@xxxxxxxxxxxxxx |
cc1: warnings being treated as errors
srv_main.c: In function `is_game_over':
srv_main.c:196: warning: `victor' might be used uninitialized in this
function
At first I thought this was harmless, but it doesn't appear to be.
Isn't it possible for all players to be killed simultaneously? The game
only checks once per turn. If this happens, Bad Things would result.
In fact, I'm sure it's possible. I once played a quick game *by myself*
to test something out, and ended up being killed by barbarians.
Attached is one possible fix for this. It detects the case of no
winners. I'm not sure if the reaction is appropriate in this case. It
also initializes 'victor' to NULL to avoid the spurious warning. It
might be cleaner to have an if(victor) check down below rather than
relying on the number of players alive.
jason
Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.102
diff -u -r1.102 srv_main.c
--- server/srv_main.c 7 Nov 2002 18:55:26 -0000 1.102
+++ server/srv_main.c 7 Nov 2002 20:22:02 -0000
@@ -193,7 +193,7 @@
{
int barbs = 0, alive = 0;
bool all_allied;
- struct player *victor;
+ struct player *victor = NULL;
/* quit if we are past the year limit */
if (game.year > game.end_year) {
@@ -241,6 +241,11 @@
gamelog(GAMELOG_NORMAL, _("Game ended in victory for %s"),
victor->name);
gamelog(GAMELOG_TEAM, "SINGLEWINNER %s", victor->name);
+ return TRUE;
+ } else if (alive == 0) {
+ notify_conn(&game.est_connections, "Game ended in a draw");
+ gamelog(GAMELOG_NORMAL, _("Game ended in a draw"));
+ gamelog(GAMELOG_TEAM, "NOWINNER");
return TRUE;
}
- [Freeciv-Dev] (PR#2275) compiler warning,
Jason Short via RT <=
|
|