Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2004:
[Freeciv-Dev] (PR#8555) move sset_type into common
Home

[Freeciv-Dev] (PR#8555) move sset_type into common

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8555) move sset_type into common
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 20 Apr 2004 11:24:53 -0700
Reply-to: rt@xxxxxxxxxxx

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

Currently the client and server independently declare the sset_type.  If 
the server were to change the ordering, this would break things badly. 
But this isn't documented.  The code is also not very readible as it is.

This patch moves sset_type into common.  It's put into game.h for lack 
of any better place.  Mike had said this wasn't worthwhile but I 
strongly disagree.

jason

? cma_weirdness
? client/diff
? data/civ3
? data/womoks
Index: client/repodlgs_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/repodlgs_common.c,v
retrieving revision 1.8
diff -u -r1.8 repodlgs_common.c
--- client/repodlgs_common.c    10 Apr 2004 03:47:48 -0000      1.8
+++ client/repodlgs_common.c    20 Apr 2004 18:22:45 -0000
@@ -267,21 +267,21 @@
   settable_options[i].category = packet->category;
 
   switch (packet->type) {
-  case 0:
+  case SSET_BOOL:
     settable_options[i].val = packet->val;
     settable_options[i].min = FALSE;
     settable_options[i].max = TRUE;
     settable_options[i].strval = NULL;
     settable_options[i].default_strval = NULL;
     break;
-  case 1:
+  case SSET_INT:
     settable_options[i].val = packet->val;
     settable_options[i].min = packet->min;
     settable_options[i].max = packet->max;
     settable_options[i].strval = NULL;
     settable_options[i].default_strval = NULL;
     break;
-  case 2:
+  case SSET_STRING:
     settable_options[i].strval = mystrdup(packet->strval);
     settable_options[i].default_strval = mystrdup(packet->default_strval);
     break;
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.134
diff -u -r1.134 game.h
--- common/game.h       14 Apr 2004 10:57:26 -0000      1.134
+++ common/game.h       20 Apr 2004 18:22:45 -0000
@@ -246,6 +246,11 @@
   int advspeed;
 };
 
+/* Server setting types.  Changing these will break network compatability. */
+enum sset_type {
+  SSET_BOOL, SSET_INT, SSET_STRING
+};
+
 void game_init(void);
 void game_free(void);
 void ruleset_data_free(void);
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.20
diff -u -r1.20 packets.def
--- common/packets.def  14 Apr 2004 11:19:44 -0000      1.20
+++ common/packets.def  20 Apr 2004 18:22:45 -0000
@@ -172,6 +172,7 @@
 type IMPR_RANGE                = uint8(enum impr_range)
 type DIRECTION         = uint8(enum direction8)
 type ORDERS            = uint8(enum unit_orders)
+type SSET_TYPE         = uint8(enum sset_type)
 
 # typedefs for IDs
 type PLAYER            = UINT8
@@ -1261,7 +1262,7 @@
   STRING name[MAX_LEN_NAME];
   STRING short_help[MAX_LEN_PACKET];
   STRING extra_help[MAX_LEN_PACKET];
-  UINT8  type;                                 /* 0:bool, 1:int, 2:string */
+  SSET_TYPE type;
 
   SINT32 val;                                  /* value for bool or int */
   SINT32 default_val;                          /* default for bool or int */
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.314
diff -u -r1.314 stdinhand.c
--- server/stdinhand.c  17 Apr 2004 04:48:20 -0000      1.314
+++ server/stdinhand.c  20 Apr 2004 18:22:47 -0000
@@ -151,13 +151,6 @@
                               N_("Internal"),
                               N_("Networking") };
 
-/*
- * The type of the setting.
- */
-enum sset_type {
-  SSET_BOOL, SSET_INT, SSET_STRING
-};
-
 #define SSET_MAX_LEN  16             /* max setting name length (plus nul) */
 #define TOKEN_DELIMITERS " \t\n,"
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#8555) move sset_type into common, Jason Short <=