[Freeciv-Dev] (PR#39948) divorce client_states from server_states

2007-12-06 Thread William Allen Simpson

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39948 

The current game state is very fragile.  It depends on client and server
packets arriving in the correct order, and scattered checks for correct
state.  Rather than a formal finite state machine, the game has an ad hoc
dichotomy between the client and server.

The client state values were sent across the network (and actually are
the server state).  The server state values are saved in savegames,
although the values are usually replaced and/or ignored upon loading

This patch stops sending game state as a packet.  Each client derives its
own current state from the packet events independently.

(Amazingly, now that old unused state values can be discarded, the
client_states and server_states have the same values in parallel)

Also, send_game_state() had special processing to clear the delta values
sent across the network.  (PR#7085  7216)  This patch clears the delta
values with send_ruleset_control() instead, because that better matches
client/packhand.c clearing the rulesets for each game!

Because the client_states are no longer in game.h, and game.h is not
needed in civclient.h, fix a significant number of missing game.h and
specialist.h #includes.  They always should have been there!

Index: version.in
===
--- version.in  (revision 14141)
+++ version.in  (working copy)
@@ -23,4 +23,4 @@
 #   - Avoid adding a new mandatory capbility to the development branch for
 # as long as possible.  We want to maintain network compatibility with
 # the stable branch for as long as possible.
-NETWORK_CAPSTRING=+Freeciv.Devel.2007.Nov.01
+NETWORK_CAPSTRING=+Freeciv.Devel.2007.Dec.07
Index: server/cityhand.c
===
--- server/cityhand.c   (revision 14141)
+++ server/cityhand.c   (working copy)
@@ -29,6 +29,7 @@
 #include map.h
 #include player.h
 #include rand.h
+#include specialist.h
 #include support.h
 #include unit.h
 #include worklist.h
Index: server/score.c
===
--- server/score.c  (revision 14141)
+++ server/score.c  (working copy)
@@ -26,6 +26,7 @@
 #include improvement.h
 #include map.h
 #include player.h
+#include specialist.h
 #include unit.h
 #include unitlist.h
 
Index: server/srv_main.c
===
--- server/srv_main.c   (revision 14141)
+++ server/srv_main.c   (working copy)
@@ -640,7 +640,7 @@
   } phase_players_iterate_end;
   send_player_info(NULL, NULL);
 
-  send_start_phase_to_clients();
+  dlsend_packet_start_phase(game.est_connections, game.info.phase);
 
   if (is_new_phase) {
 /* Unit end of turn activities - of course these actually go at
@@ -1921,7 +1921,6 @@
 calc_civ_score(pplayer);
   } players_iterate_end;
 
-  send_game_state(game.est_connections, C_S_OVER);
   report_final_scores();
   show_map_to_all();
   notify_player(NULL, NULL, E_GAME_END, _(The game is over...));
@@ -2079,8 +2078,6 @@
   if (game.info.is_new_game) {
 init_new_game();
   }
-
-  send_game_state(game.est_connections, C_S_RUNNING);
 }
 
 /**
Index: server/connecthand.c
===
--- server/connecthand.c(revision 14141)
+++ server/connecthand.c(working copy)
@@ -117,7 +117,6 @@
* See the comment in lost_connection_to_client(). */
   send_packet_freeze_hint(pconn);
   send_all_info(dest);
-  send_game_state(dest, C_S_RUNNING);
   send_player_info(NULL,NULL);
   send_diplomatic_meetings(pconn);
   send_packet_thaw_hint(pconn);
Index: server/citytools.c
===
--- server/citytools.c  (revision 14141)
+++ server/citytools.c  (working copy)
@@ -37,6 +37,7 @@
 #include movement.h
 #include player.h
 #include requirements.h
+#include specialist.h
 #include tech.h
 #include unit.h
 #include unitlist.h
Index: server/report.c
===
--- server/report.c (revision 14141)
+++ server/report.c (working copy)
@@ -31,8 +31,9 @@
 #include government.h
 #include packets.h
 #include player.h
+#include specialist.h
+#include unitlist.h
 #include version.h
-#include unitlist.h
 
 #include citytools.h
 #include report.h
@@ -1074,6 +1075,7 @@
 
 /**
   Inform clients about player scores and statistics when the game ends.
+  Called only from server/srv_main.c srv_scores()
 **/
 void report_final_scores(void)
 {
Index: server/cityturn.c
===
--- server/cityturn.c   (revision 14141)
+++ server/cityturn.c 

Re: [Freeciv-Dev] (PR#39850) missing control re-initialization for second game

2007-12-06 Thread William Allen Simpson

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39850 

William Allen Simpson wrote:
 Obviously not a code path that was well tested  Committing immediately,
 and I'd appreciate independent testing, please.
 
Found another recent report and merged them.  Is it now fixed for everybody?



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev