Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2005:
[Freeciv-Dev] Re: (PR#14822) fix spacerace endgame
Home

[Freeciv-Dev] Re: (PR#14822) fix spacerace endgame

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] Re: (PR#14822) fix spacerace endgame
From: "Mike Kaufman" <kaufman@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 10 Dec 2005 16:10:06 -0800
Reply-to: bugs@xxxxxxxxxxx

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

updated patch.

-mike

Index: server/srv_main.c
===================================================================
--- server/srv_main.c   (revision 11336)
+++ server/srv_main.c   (working copy)
@@ -205,7 +205,7 @@
 bool is_game_over(void)
 {
   int barbs = 0, alive = 0;
-  struct player *victor = NULL;
+  struct player *victor = NULL, *spacer = NULL;
 
   /* quit if we are past the year limit */
   if (game.info.year > game.info.end_year) {
@@ -239,6 +239,36 @@
     return FALSE;
   }
 
+  /* check for a spacerace win */
+  if ((spacer = check_spaceship_arrival())) {
+    bool loner = TRUE;
+    victor = spacer;
+ 
+    notify_player(NULL, NULL, E_SPACESHIP,
+                  _("The %s spaceship has arrived at Alpha Centauri."),
+                  get_nation_name(victor->nation));
+
+    /* this guy has won, now check if anybody else wins with him */
+    players_iterate(pplayer) {
+      if (pplayer->team == victor->team && pplayer != victor) {
+        loner = FALSE;
+        break;
+      }
+    } players_iterate_end;
+
+    if (!loner) {
+      notify_conn(NULL, NULL, E_GAME_END,
+                  _("Team victory to %s"), team_get_name_orig(victor->team));
+      gamelog(GAMELOG_JUDGE, GL_TEAMWIN, victor->team);
+    } else {
+      notify_conn(NULL, NULL, E_GAME_END,
+                  _("Game ended in victory for %s"), victor->name);
+      gamelog(GAMELOG_JUDGE, GL_LONEWIN, victor);
+    }
+
+    return TRUE;
+  }
+
   /* quit if we have team victory */
   team_iterate(pteam) {
     bool win = TRUE; /* optimistic */
@@ -697,8 +727,6 @@
   freelog(LOG_DEBUG, "Updatetimeout");
   update_timeout();
 
-  check_spaceship_arrivals();
-
   freelog(LOG_DEBUG, "Sendplayerinfo");
   send_player_info(NULL, NULL);
 
Index: server/spacerace.c
===================================================================
--- server/spacerace.c  (revision 11336)
+++ server/spacerace.c  (working copy)
@@ -359,7 +359,7 @@
 /**************************************************************************
 Use shuffled order to randomly resolve ties.
 **************************************************************************/
-void check_spaceship_arrivals(void)
+struct player *check_spaceship_arrival(void)
 {
   double arrival, best_arrival = 0.0;
   struct player *best_pplayer = NULL;
@@ -376,13 +376,10 @@
       }
     }
   } shuffled_players_iterate_end;
+
   if (best_pplayer) {
     best_pplayer->spaceship.state = SSHIP_ARRIVED;
-    server_state = GAME_OVER_STATE;
-    notify_player(NULL, NULL, E_SPACESHIP,
-                    _("The %s spaceship has arrived "
-                      "at Alpha Centauri."),
-                    get_nation_name(best_pplayer->nation));
-    gamelog(GAMELOG_JUDGE, GL_LONEWIN, best_pplayer);
   }
+
+  return best_pplayer;
 }
Index: server/spacerace.h
===================================================================
--- server/spacerace.h  (revision 11336)
+++ server/spacerace.h  (working copy)
@@ -22,7 +22,7 @@
 void spaceship_calc_derived(struct player_spaceship *ship);
 void send_spaceship_info(struct player *src, struct conn_list *dest);
 void spaceship_lost(struct player *pplayer);
-void check_spaceship_arrivals(void);
+struct player *check_spaceship_arrival(void);
 
 void handle_spaceship_launch(struct player *pplayer);
 void handle_spaceship_place(struct player *pplayer,

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: (PR#14822) fix spacerace endgame, Mike Kaufman <=