Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2002:
[Freeciv-Dev] Re: (PR#2275) compiler warning
Home

[Freeciv-Dev] Re: (PR#2275) compiler warning

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#2275) compiler warning
From: "Jason Short via RT" <rt@xxxxxxxxxxxxxx>
Date: Sun, 10 Nov 2002 22:26:09 -0800
Reply-to: rt@xxxxxxxxxxxxxx

Mike Kaufman via RT wrote:

> your code will never get used unless you change:
> 
>   /* quit if only one player is left alive */
>   if (alive <= 1) {
>     notify_conn(&game.est_connections,
> 
> to   
> 
> /* quit if only one player is left alive */
>   if (alive == 1) {
>     notify_conn(&game.est_connections,

Now how did I ever miss that?

New patch attached.

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   11 Nov 2002 06:23:55 -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) {
@@ -235,12 +235,17 @@
   } team_iterate_end;
 
   /* quit if only one player is left alive */
-  if (alive <= 1) {
+  if (alive == 1) {
     notify_conn(&game.est_connections, 
         "Game ended in victory for %s", victor->name);
     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;
   }
 

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