Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2005:
[Freeciv-Dev] (PR#12975) reset pplayer->is_started when Stuff happens
Home

[Freeciv-Dev] (PR#12975) reset pplayer->is_started when Stuff happens

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12975) reset pplayer->is_started when Stuff happens
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 3 May 2005 17:35:53 -0700
Reply-to: bugs@xxxxxxxxxxx

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

This patch resets pplayer->is_started when something significant happens.

The infrastructure is pretty straightforward.  I wasn't quite sure
whether game.est_connections or game.game_connections should be used to
send the player info; I used game.est_connections (as is used
elsehwere).  A new function reset_all_start_commands is added.

Readiness for all players is reset if:

* A player joins or leaves.
* A take or detach is called.
* A server setting is changed (this includes if a setting is set but not
changed; which is an existing bug AFAICT).

Surely there are some more actions that should trigger resets.  Feel
free to point them out.

-jason

Index: server/connecthand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/connecthand.c,v
retrieving revision 1.44
diff -u -r1.44 connecthand.c
--- server/connecthand.c        1 May 2005 13:59:21 -0000       1.44
+++ server/connecthand.c        4 May 2005 00:30:45 -0000
@@ -184,6 +184,7 @@
   conn_list_append(game.est_connections, pconn);
   send_conn_info(game.est_connections, dest);
   send_player_info_c(NULL, dest);
+  reset_all_start_commands();
   (void) send_server_info_to_metaserver(META_INFO);
 }
 
@@ -594,6 +595,7 @@
 
     check_for_full_turn_done();
   }
+  reset_all_start_commands();
 
   delayed_disconnect--;
 }
Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.371
diff -u -r1.371 plrhand.c
--- server/plrhand.c    2 May 2005 08:45:23 -0000       1.371
+++ server/plrhand.c    4 May 2005 00:30:45 -0000
@@ -1967,6 +1967,22 @@
   return pplayer;
 }
 
+/****************************************************************************
+  Called when something is changed; this resets everyone's readiness.
+****************************************************************************/
+void reset_all_start_commands(void)
+{
+  if (server_state != PRE_GAME_STATE) {
+    return;
+  }
+  players_iterate(pplayer) {
+    if (pplayer->is_started) {
+      pplayer->is_started = FALSE;
+      send_player_info_c(pplayer, game.est_connections);
+    }
+  } players_iterate_end;
+}
+
 /**********************************************************************
 This function creates a new player and copies all of it's science
 research etc.  Players are both thrown into anarchy and gold is
Index: server/plrhand.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.h,v
retrieving revision 1.71
diff -u -r1.71 plrhand.h
--- server/plrhand.h    1 May 2005 04:57:45 -0000       1.71
+++ server/plrhand.h    4 May 2005 00:30:45 -0000
@@ -82,6 +82,7 @@
 void set_shuffled_players(int *shuffled_players);
 struct player *shuffled_player(int i);
 struct player *create_global_observer(void);
+void reset_all_start_commands(void);
 
 #define shuffled_players_iterate(pplayer)                                   \
 {                                                                           \
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.404
diff -u -r1.404 stdinhand.c
--- server/stdinhand.c  3 May 2005 20:08:25 -0000       1.404
+++ server/stdinhand.c  4 May 2005 00:30:47 -0000
@@ -927,6 +927,7 @@
 
   pplayer->ai.control = TRUE;
   set_ai_level_directer(pplayer, game.skill_level);
+  reset_all_start_commands();
   (void) send_server_info_to_metaserver(META_INFO);
   return TRUE;
 }
@@ -2534,6 +2535,7 @@
   }
 
   if (!check && do_update) {
+    reset_all_start_commands();
     send_server_info_to_metaserver(META_INFO);
     /* 
      * send any modified game parameters to the clients -- if sent
@@ -3057,6 +3059,7 @@
     game_remove_player(pplayer);
     game_renumber_players(pplayer->player_no);
     player_init(&game.players[game.nplayers]);
+    reset_all_start_commands();
   }
 
   if (!pplayer->is_connected) {

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12975) reset pplayer->is_started when Stuff happens, Jason Short <=