Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2005:
[Freeciv-Dev] (PR#13169) requirements.h shouldn't include other common f
Home

[Freeciv-Dev] (PR#13169) requirements.h shouldn't include other common f

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13169) requirements.h shouldn't include other common files
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 24 May 2005 10:10:43 -0700
Reply-to: bugs@xxxxxxxxxxx

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

This patch changes requirements.h so it doesn't #include any other
common files except fc_types.  This is needed because just about every
other file includes (or will include) requirements.h, and we can't have
circular dependencies.

- The special enum I moved into fc_types.h out of terrain.h.
- Several typedefs are moved into fc_types.h.
- The unit_flag_id enum in requirements.h is changed into an int.  This
is more proper since this value may be a flag or a role (which is very ugly)

-jason

Index: common/fc_types.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/fc_types.h,v
retrieving revision 1.26
diff -u -r1.26 fc_types.h
--- common/fc_types.h   11 May 2005 08:03:27 -0000      1.26
+++ common/fc_types.h   24 May 2005 17:08:14 -0000
@@ -54,6 +54,23 @@
 #define O_COUNT num_output_types
 #define O_MAX O_LAST /* Changing this breaks network compatibility. */
 
+enum tile_special_type {
+  S_NO_SPECIAL =    0,
+  S_SPECIAL_1  =    1,
+  S_ROAD       =    2,
+  S_IRRIGATION =    4,
+  S_RAILROAD   =    8,
+  S_MINE       =   16,
+  S_POLLUTION  =   32,
+  S_HUT        =   64,
+  S_FORTRESS   =  128,
+  S_SPECIAL_2  =  256,
+  S_RIVER      =  512,
+  S_FARMLAND   = 1024,
+  S_AIRBASE    = 2048,
+  S_FALLOUT    = 4096
+};
+
 typedef signed short Continent_id;
 typedef int Terrain_type_id;
 typedef int Specialist_type_id;
@@ -62,6 +79,8 @@
 typedef enum unit_activity Activity_type_id;
 typedef int Nation_type_id;
 typedef int Team_type_id;
+typedef int Tech_type_id;
+typedef int Unit_type_id;
 
 struct city;
 struct government;
Index: common/requirements.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/requirements.h,v
retrieving revision 1.19
diff -u -r1.19 requirements.h
--- common/requirements.h       11 May 2005 14:11:21 -0000      1.19
+++ common/requirements.h       24 May 2005 17:08:14 -0000
@@ -15,8 +15,6 @@
 #define FC__REQUIREMENTS_H
 
 #include "fc_types.h"
-#include "tech.h"
-#include "unittype.h"
 
 /* The type of a requirement source.  This must correspond to req_type_names[]
  * in requirements.c. */
@@ -60,7 +58,7 @@
     Terrain_type_id terrain;            /* source terrain type */
     Nation_type_id nation;              /* source nation type */
     Unit_type_id unittype;              /* source unittype */
-    enum unit_flag_id unitflag;         /* source unit flag */
+    int unitflag;                       /* source unit flag */
     Output_type_id outputtype;          /* source output type */
     Specialist_type_id specialist;      /* specialist type */
     int minsize;                        /* source minsize type */
Index: common/tech.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/tech.h,v
retrieving revision 1.56
diff -u -r1.56 tech.h
--- common/tech.h       5 May 2005 18:32:52 -0000       1.56
+++ common/tech.h       24 May 2005 17:08:14 -0000
@@ -16,14 +16,6 @@
 #include "shared.h"
 
 #include "fc_types.h"
-#include "nation.h" /* Nation_type_id */
-
-typedef int Tech_type_id;
-/*
-  Above typedef replaces old "enum tech_type_id"; see comments about
-  Unit_type_id in unit.h, since mainly apply here too, except don't
-  use Tech_type_id very widely, and don't use (-1) flag values. (?)
-*/
 
 #define A_NONE 0
 #define A_FIRST 1
Index: common/terrain.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/terrain.h,v
retrieving revision 1.34
diff -u -r1.34 terrain.h
--- common/terrain.h    5 May 2005 18:32:52 -0000       1.34
+++ common/terrain.h    24 May 2005 17:08:14 -0000
@@ -21,23 +21,7 @@
   RMV_NORMAL=0, RMV_FAST_STRICT=1, RMV_FAST_RELAXED=2, RMV_FAST_ALWAYS=3
 };
 
-enum tile_special_type {
-  S_NO_SPECIAL =    0,
-  S_SPECIAL_1  =    1,
-  S_ROAD       =    2,
-  S_IRRIGATION =    4,
-  S_RAILROAD   =    8,
-  S_MINE       =   16,
-  S_POLLUTION  =   32,
-  S_HUT        =   64,
-  S_FORTRESS   =  128,
-  S_SPECIAL_2  =  256,
-  S_RIVER      =  512,
-  S_FARMLAND   = 1024,
-  S_AIRBASE    = 2048,
-  S_FALLOUT    = 4096
-};
-
+/* tile_special_type is defined in fc_types.h. */
 #define S_ALL    \
  (  S_SPECIAL_1  \
   | S_ROAD       \
Index: common/unittype.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unittype.h,v
retrieving revision 1.49
diff -u -r1.49 unittype.h
--- common/unittype.h   6 May 2005 23:13:53 -0000       1.49
+++ common/unittype.h   24 May 2005 17:08:14 -0000
@@ -17,28 +17,6 @@
 
 #include "fc_types.h"
 
-typedef int Unit_type_id;
-/*
-  Above typedef replaces old "enum unit_type_id" (since no longer
-  enumerate the unit types); keep as typedef to help code be
-  self-documenting.
-
-  It could potentially be some other type; "unsigned char" would be
-  natural, since there are already built-in assumptions that values
-  are not too large (less than U_LAST = MAX_NUM_ITEMS) since they must
-  fit in 8-bit unsigned int for packets; and normal values are always
-  non-negative.  But note sometimes use (-1) for obsoleted_by and some
-  related uses, though these use already plain int rather than
-  Unit_type_id?  (Ideally, these should probably have used U_LAST as
-  the flag value instead of (-1).)
-  
-  Decided to just use 'int' for several reasons:
-  - "natural integer type" may be faster on some platforms
-    (size advantage of using smaller type probably negligible);
-  - avoids any potential problems with (-1) values as mentioned above;
-  - avoids imposing any more limitations that there are already.
-*/
-  
 #define U_LAST MAX_NUM_ITEMS
 /*
   U_LAST is a value which is guaranteed to be larger than all

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13169) requirements.h shouldn't include other common files, Jason Short <=