Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2004:
[Freeciv-Dev] (PR#8859) new function begin_phase
Home

[Freeciv-Dev] (PR#8859) new function begin_phase

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8859) new function begin_phase
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 28 May 2004 01:54:43 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=8859 >

This patch creates a new srv_main function begin_phase.

Some code from begin_turn is moved into begin_phase.  And some code from 
  main_loop is moved into one or the other of these functions.  However 
a little bit of code remains in the main_loop function (like 
auto-saving, which requires a variable there).

Autogames are changed by this patch.  This is expected, because 
shuffle_players is (correctly) moved up to near the beginning of the 
turn start actions.  Other than this the only action that is moved is 
the setting of force_end_of_sniff (which makes no difference).

See also PR#725, PR#576, and maybe PR#436.

jason

? ferries
? flags
? data/flags
Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.163
diff -u -r1.163 srv_main.c
--- server/srv_main.c   28 May 2004 06:52:30 -0000      1.163
+++ server/srv_main.c   28 May 2004 08:33:54 -0000
@@ -445,6 +445,8 @@
 **************************************************************************/
 static void begin_turn(void)
 {
+  freelog(LOG_DEBUG, "Begin turn");
+
   /* See if the value of fog of war has changed */
   if (game.fogofwar != game.fogofwar_old) {
     if (game.fogofwar) {
@@ -456,6 +458,20 @@
     }
   }
 
+  freelog(LOG_DEBUG, "Shuffleplayers");
+  shuffle_players();
+
+  sanity_check();
+}
+
+/**************************************************************************
+  Begin a phase of movement.  This handles all beginning-of-phase actions
+  for one or more players.
+**************************************************************************/
+static void begin_phase(void)
+{
+  freelog(LOG_DEBUG, "Begin phase");
+
   conn_list_do_buffer(&game.game_connections);
 
   players_iterate(pplayer) {
@@ -478,6 +494,12 @@
       ai_diplomacy_actions(pplayer);
     }
   } players_iterate_end;
+
+  freelog(LOG_DEBUG, "Aistartturn");
+  ai_start_turn();
+  send_start_turn_to_clients();
+
+  sanity_check();
 }
 
 /**************************************************************************
@@ -1337,19 +1359,11 @@
 
   while(server_state==RUN_GAME_STATE) {
     /* absolute beginning of a turn */
-    freelog(LOG_DEBUG, "Begin turn");
     begin_turn();
-
-    sanity_check();
+    begin_phase();
 
     force_end_of_sniff = FALSE;
 
-    freelog(LOG_DEBUG, "Shuffleplayers");
-    shuffle_players();
-    freelog(LOG_DEBUG, "Aistartturn");
-    ai_start_turn();
-    send_start_turn_to_clients();
-
     /* 
      * This will thaw the reports and agents at the client.
      */

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#8859) new function begin_phase, Jason Short <=