]> git.pond.sub.org Git - empserver/blobdiff - include/sect.h
Update copyright notice
[empserver] / include / sect.h
index c0d7822240912457b6d23074ebfbbd6488bc5371..259fa630c6ca7546bd400bf3dc0ae35ba65685dd 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2015, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                Ken Stevens, Steve McClure, Markus Armbruster
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  Empire is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  ---
  *
  *  ---
  *
  *  sect.h: Definitions for things having to do with sectors.
- * 
+ *
  *  Known contributors to this file:
  *     Dave Pare
  *     Ken Stevens, 1995
  *     Steve McClure, 1998
- *     Markus Armbruster, 2004-2008
+ *     Markus Armbruster, 2004-2014
  */
 
 
 
 struct sctstr {
     /* initial part must match struct empobj */
-    short ef_type;
-    short sct_uid;             /* equals XYOFFSET(sct_x, sct_y) */
+    signed ef_type: 8;
+    unsigned sct_seqno: 12;
+    unsigned sct_generation: 12;
+    int sct_uid;               /* equals XYOFFSET(sct_x, sct_y) */
     time_t sct_timestamp;      /* Last time this sector was written to */
     natid sct_own;             /* owner's country num */
     coord sct_x;               /* x coord of sector */
     coord sct_y;               /* y coord of sector */
     signed char sct_type;      /* sector type */
+    signed char sct_effic;     /* 0% to 100% */
+    signed char sct_mobil;     /* mobility units */
+    unsigned char sct_off;     /* Should this sector produce? */
     /* end of part matching struct empobj */
-    unsigned char sct_effic;   /* 0% to 100% */
-    short sct_mobil;           /* mobility units */
     unsigned char sct_loyal;   /* updates until civilans "converted" */
     unsigned char sct_terr;    /* territory 0 id # of sector */
     unsigned char sct_terr1;   /* territory 1 id # of sector */
@@ -75,7 +77,6 @@ struct sctstr {
     unsigned char sct_uran;    /* uranium ore content */
     natid sct_oldown;          /* old owner of sector (for liberation) */
     unsigned char sct_updated; /* Has this sect been updated? */
-    unsigned char sct_off;     /* Should this sector produce? */
     short sct_item[I_MAX+1];   /* amount of items stored here */
     short sct_del[I_MAX+1];    /* delivieries */
     short sct_dist[I_MAX+1];   /* distribution thresholds */
@@ -102,6 +103,7 @@ enum d_navigation {
 struct dchrstr {
     unsigned char d_uid;
     char d_mnem;               /* map symbol */
+    unsigned char d_terrain;   /* terrain sector type */
     int d_prd;                 /* product type */
     int d_peffic;              /* process efficiency, in percent */
     float d_mob0, d_mob1;      /* movement cost at 0 and 100% eff */
@@ -114,59 +116,55 @@ struct dchrstr {
     int d_build;               /* cost multiplier for eff */
     int d_lcms;                        /* lcm's needed per point of eff */
     int d_hcms;                        /* hcm's needed per point of eff */
+    int d_maint;               /* maintenance cost per ETU */
     int d_maxpop;              /* maximum population */
     char *d_name;              /* full name of sector type */
 };
 
-       /* sector types (must agree with order in dchr, empglb.c) */
-
-#define        SCT_WATER       0       /* basics */
-#define        SCT_MOUNT       1
-#define        SCT_SANCT       2
-#define        SCT_WASTE       3
-#define        SCT_RURAL       4
-#define        SCT_CAPIT       5
-#define        SCT_URAN        6
-#define        SCT_PARK        7
-#define        SCT_ARMSF       8       /* industries */
-#define        SCT_AMMOF       9
-#define        SCT_MINE        10
-#define        SCT_GMINE       11
-#define        SCT_HARBR       12
-#define        SCT_WAREH       13
-#define        SCT_AIRPT       14
-#define        SCT_AGRI        15
-#define        SCT_OIL         16
-#define        SCT_LIGHT       17
-#define        SCT_HEAVY       18
-#define        SCT_FORTR       19      /* military/scientific */
-#define        SCT_TECH        20
-#define        SCT_RSRCH       21
-#define        SCT_NUKE        22
-#define        SCT_LIBR        23
-#define        SCT_HIWAY       24      /* communications */
-#define        SCT_RADAR       25
-#define        SCT_HEADQ       26      /* headquarters */
-#define        SCT_BHEAD       27      /* Bridge head */
-#define        SCT_BSPAN       28      /* Bridge span */
-#define        SCT_BANK        29      /* financial */
-#define        SCT_REFINE      30      /* refinery */
+/* Sector types, must match sect.config */
+#define SCT_WATER      0       /* basics */
+#define SCT_MOUNT      1
+#define SCT_SANCT      2
+#define SCT_WASTE      3
+#define SCT_RURAL      4
+#define SCT_CAPIT      5
+#define SCT_URAN       6
+#define SCT_PARK       7
+#define SCT_ARMSF      8       /* industries */
+#define SCT_AMMOF      9
+#define SCT_MINE       10
+#define SCT_GMINE      11
+#define SCT_HARBR      12
+#define SCT_WAREH      13
+#define SCT_AIRPT      14
+#define SCT_AGRI       15
+#define SCT_OIL                16
+#define SCT_LIGHT      17
+#define SCT_HEAVY      18
+#define SCT_FORTR      19      /* military/scientific */
+#define SCT_TECH       20
+#define SCT_RSRCH      21
+#define SCT_NUKE       22
+#define SCT_LIBR       23
+#define SCT_HIWAY      24      /* communications */
+#define SCT_RADAR      25
+#define SCT_HEADQ      26      /* headquarters */
+#define SCT_BHEAD      27      /* Bridge head */
+#define SCT_BSPAN      28      /* Bridge span */
+#define SCT_BANK       29      /* financial */
+#define SCT_REFINE     30      /* refinery */
 #define SCT_ENLIST     31      /* enlistment center */
-#define SCT_PLAINS      32     /* plains sector */
-#define SCT_BTOWER      33     /* Bridge tower */
+#define SCT_PLAINS     32      /* plains sector */
+#define SCT_BTOWER     33      /* Bridge tower */
 
-#define SCT_TYPE_MAX    38
+#define SCT_TYPE_MAX   38
 
 #define getsect(x, y, p) ef_read(EF_SECTOR, sctoff((x), (y)), (p))
 #define putsect(p) ef_write(EF_SECTOR, (p)->sct_uid, (p))
 #define getsectp(x, y) (struct sctstr *)ef_ptr(EF_SECTOR, sctoff((x), (y)))
 #define getsectid(id) (struct sctstr *)ef_ptr(EF_SECTOR, (id))
 
-/* things relating to sectors */
-extern int sctoff(coord x, coord y);
-
 extern struct dchrstr dchr[SCT_TYPE_MAX + 2];
-extern struct dchrstr bigcity_dchr;
 #define IS_BIG_CITY(type) (dchr[(type)].d_pkg == UPKG)
 
 /* Minimal efficiency of sectors that can be knocked down (bridges) */
@@ -181,13 +179,22 @@ extern struct dchrstr bigcity_dchr;
 
 #define FORTEFF 5              /* forts must be 5% efficient to fire. */
 
-#define MOB_MOVE    0
-#define MOB_MARCH   1
-#define MOB_RAIL    2
+/* Can trains enter sector SP? */
+#define SCT_HAS_RAIL(sp)                                       \
+    (opt_RAILWAYS ? sct_rail_track((sp)) != 0                  \
+     : intrchr[INT_RAIL].in_enable && (sp)->sct_rail != 0)
+
+#define SCT_MINES_ARE_SEAMINES(sp) \
+    ((sp)->sct_type == SCT_WATER || (sp)->sct_type == SCT_BSPAN)
+#define SCT_SEAMINES(sp) \
+    (SCT_MINES_ARE_SEAMINES((sp)) ? (sp)->sct_mines : 0)
+#define SCT_LANDMINES(sp) \
+    (SCT_MINES_ARE_SEAMINES((sp)) ? 0 : (sp)->sct_mines)
 
-#define INT_ROAD    0
-#define INT_RAIL    1
-#define INT_DEF     2
+/* Sector infrastructure types, must match infra.config */
+#define INT_ROAD       0
+#define INT_RAIL       1
+#define INT_DEF                2
 
 /* Sector flags */
 #define MOVE_IN_PROGRESS       bit(0)  /* move in progress */
@@ -216,5 +223,6 @@ struct sctintrins {
 extern struct sctintrins intrchr[INT_DEF + 2];
 
 extern int fort_fire(struct sctstr *);
+extern int sct_rail_track(struct sctstr *);
 
 #endif