Author: cazfi
Date: Sun Apr  5 02:20:41 2015
New Revision: 28710

URL: http://svn.gna.org/viewcvs/freeciv?rev=28710&view=rev
Log:
Added server setting 'persistentready'

See patch #5978

Modified:
    trunk/common/fc_types.h
    trunk/common/game.h
    trunk/common/packets.def
    trunk/fc_version
    trunk/server/connecthand.c
    trunk/server/plrhand.c
    trunk/server/plrhand.h
    trunk/server/settings.c
    trunk/server/stdinhand.c

Modified: trunk/common/fc_types.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/fc_types.h?rev=28710&r1=28709&r2=28710&view=diff
==============================================================================
--- trunk/common/fc_types.h     (original)
+++ trunk/common/fc_types.h     Sun Apr  5 02:20:41 2015
@@ -483,6 +483,14 @@
 #define SPECENUM_VALUE3 AIRLIFTING_UNLIMITED_DEST
 #include "specenum_gen.h"
 
+/* Used in the network protocol. */
+#define SPECENUM_NAME persistent_ready
+#define SPECENUM_VALUE0  PERSISTENTR_DISABLED
+#define SPECENUM_VALUE0NAME "Disabled"
+#define SPECENUM_VALUE1  PERSISTENTR_CONNECTED
+#define SPECENUM_VALUE1NAME "Connected"
+#include "specenum_gen.h"
+
 #define SPECENUM_NAME reveal_map
 #define SPECENUM_BITWISE
 /* Reveal only the area around the first units at the beginning. */

Modified: trunk/common/game.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/game.h?rev=28710&r1=28709&r2=28710&view=diff
==============================================================================
--- trunk/common/game.h (original)
+++ trunk/common/game.h Sun Apr  5 02:20:41 2015
@@ -617,6 +617,7 @@
 #define GAME_START_YEAR -4000
 
 #define GAME_DEFAULT_AIRLIFTINGSTYLE AIRLIFTING_CLASSICAL
+#define GAME_DEFAULT_PERSISTENTREADY PERSISTENTR_DISABLED
 
 #define GAME_MAX_READ_RECURSION 10 /* max recursion for the read command */
 

Modified: trunk/common/packets.def
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/packets.def?rev=28710&r1=28709&r2=28710&view=diff
==============================================================================
--- trunk/common/packets.def    (original)
+++ trunk/common/packets.def    Sun Apr  5 02:20:41 2015
@@ -204,6 +204,7 @@
 # typedefs for enums
 type ACTIVITY           = uint8(enum unit_activity)
 type AIRLIFTING_STYLE   = uint8(enum airlifting_style)
+type PERSISTENT_READY   = uint8(enum persistent_ready)
 type VICTORY_CONDITIONS = uint8(enum victory_condition_type)
 type TECH_UPKEEP_STYLE  = uint8(enum tech_upkeep_style)
 type AUTH_TYPE          = uint8(enum authentication_type)
@@ -425,6 +426,7 @@
 PACKET_GAME_INFO = 16; sc, is-info
   UINT8 add_to_size_limit;
   UINT8 aifill;
+  PERSISTENT_READY persistent_ready;
   AIRLIFTING_STYLE airlifting_style;
   UINT8 angrycitizen;
   SINT16 base_pollution;

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=28710&r1=28709&r2=28710&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Sun Apr  5 02:20:41 2015
@@ -54,7 +54,7 @@
 #   - Avoid adding a new mandatory capability 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_MANDATORY="+Freeciv.Devel-3.0-2015.Apr.02"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Apr.05"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/connecthand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/connecthand.c?rev=28710&r1=28709&r2=28710&view=diff
==============================================================================
--- trunk/server/connecthand.c  (original)
+++ trunk/server/connecthand.c  Sun Apr  5 02:20:41 2015
@@ -300,7 +300,7 @@
 
   if (NULL != pplayer) {
     /* Else, no need to do anything. */
-    reset_all_start_commands();
+    reset_all_start_commands(TRUE);
     (void) send_server_info_to_metaserver(META_INFO);
   }
   conn_compression_thaw(pconn);
@@ -765,7 +765,7 @@
         /* Actually do the removal. */
         server_remove_player(pplayer);
         aifill(game.info.aifill);
-        reset_all_start_commands();
+        reset_all_start_commands(TRUE);
       } else {
         /* Aitoggle the player if no longer connected. */
         if (game.server.auto_ai_toggle && !pplayer->ai_controlled) {
@@ -780,7 +780,7 @@
           log_verbose("connection_detach() calls send_player_info_c()");
           send_player_info_c(pplayer, NULL);
 
-          reset_all_start_commands();
+          reset_all_start_commands(TRUE);
         }
       }
     }

Modified: trunk/server/plrhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/plrhand.c?rev=28710&r1=28709&r2=28710&view=diff
==============================================================================
--- trunk/server/plrhand.c      (original)
+++ trunk/server/plrhand.c      Sun Apr  5 02:20:41 2015
@@ -2351,15 +2351,30 @@
 /****************************************************************************
   Called when something is changed; this resets everyone's readiness.
 ****************************************************************************/
-void reset_all_start_commands(void)
+void reset_all_start_commands(bool plrchange)
 {
   if (S_S_INITIAL != server_state()) {
     return;
   }
   players_iterate(pplayer) {
     if (pplayer->is_ready) {
-      pplayer->is_ready = FALSE;
-      send_player_info_c(pplayer, game.est_connections);
+      bool persistent = FALSE;
+
+      if (plrchange) {
+        switch (game.info.persistent_ready)
+          {
+          case PERSISTENTR_DISABLED:
+            persistent = FALSE;
+            break;
+          case PERSISTENTR_CONNECTED:
+            persistent = pplayer->is_connected;
+          }
+      }
+
+      if (!persistent) {
+        pplayer->is_ready = FALSE;
+        send_player_info_c(pplayer, game.est_connections);
+      }
     }
   } players_iterate_end;
 }

Modified: trunk/server/plrhand.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/plrhand.h?rev=28710&r1=28709&r2=28710&view=diff
==============================================================================
--- trunk/server/plrhand.h      (original)
+++ trunk/server/plrhand.h      Sun Apr  5 02:20:41 2015
@@ -84,7 +84,7 @@
 void shuffle_players(void);
 void set_shuffled_players(int *shuffled_players);
 struct player *shuffled_player(int i);
-void reset_all_start_commands(void);
+void reset_all_start_commands(bool plrchange);
 
 #define shuffled_players_iterate(NAME_pplayer)\
 do {\

Modified: trunk/server/settings.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/settings.c?rev=28710&r1=28709&r2=28710&view=diff
==============================================================================
--- trunk/server/settings.c     (original)
+++ trunk/server/settings.c     Sun Apr  5 02:20:41 2015
@@ -287,6 +287,21 @@
 }
 
 /****************************************************************************
+  Persistentready setting names accessor.
+****************************************************************************/
+static const struct sset_val_name *persistentready_name(int persistent_ready)
+{
+  switch (persistent_ready) {
+  NAME_CASE(PERSISTENTR_DISABLED, "DISABLED",
+            N_("Disabled"));
+  NAME_CASE(PERSISTENTR_CONNECTED, "CONNECTED",
+            N_("As long as connected"));
+  }
+
+  return NULL;
+}
+
+/****************************************************************************
   Victory conditions setting names accessor.
 ****************************************************************************/
 static const struct sset_val_name *victory_conditions_name(int condition_bit)
@@ -1467,6 +1482,15 @@
              "all AI players will be removed."), NULL,
           aifill_action, GAME_MIN_AIFILL, GAME_MAX_AIFILL,
           GAME_DEFAULT_AIFILL)
+
+  GEN_ENUM("persistentready", game.info.persistent_ready,
+           SSET_META, SSET_NETWORK, SSET_RARE, SSET_TO_CLIENT,
+         N_("When the Readiness of a player gets autotoggled off"),
+         N_("In pre-game, usually when new players join or old ones leave, "
+             "those who have already accepted game to start by toggling 
\"Ready\" "
+             "get that autotoggled off in the changed situation. This setting "
+             "can be used to make readiness more persistent."),
+           NULL, NULL, persistentready_name, GAME_DEFAULT_PERSISTENTREADY)
 
   GEN_STRING("nationset", game.server.nationset,
              SSET_PLAYERS, SSET_INTERNAL, SSET_RARE, SSET_TO_CLIENT,

Modified: trunk/server/stdinhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/stdinhand.c?rev=28710&r1=28709&r2=28710&view=diff
==============================================================================
--- trunk/server/stdinhand.c    (original)
+++ trunk/server/stdinhand.c    Sun Apr  5 02:20:41 2015
@@ -1039,7 +1039,7 @@
   send_player_info_c(pplayer, game.est_connections);
 
   aifill(game.info.aifill);
-  reset_all_start_commands();
+  reset_all_start_commands(TRUE);
   (void) send_server_info_to_metaserver(META_INFO);
 
   if (newplayer != NULL) {
@@ -2969,7 +2969,7 @@
      * in client/packhand.c#handle_game_info() 
      */
     send_game_info(NULL);
-    reset_all_start_commands();
+    reset_all_start_commands(FALSE);
     send_server_info_to_metaserver(META_INFO);
   }
 


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to