]> git.pond.sub.org Git - empserver/blobdiff - include/sect.h
ship: Unbreak MOB_ACCESS real-time mobility update for ships
[empserver] / include / sect.h
index 268e31ea4c75b3a035c38b2d4c80b40c52fd2075..d003bbfe542ee71524115a0b3e30d0a699a568f0 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2021, 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/>.
  *
  *  ---
  *
  *     Dave Pare
  *     Ken Stevens, 1995
  *     Steve McClure, 1998
- *     Markus Armbruster, 2004-2009
+ *     Markus Armbruster, 2004-2020
  */
 
 
 #ifndef SECT_H
 #define SECT_H
 
-#include <time.h>
+#include "file.h"
 #include "item.h"
 #include "types.h"
 
@@ -58,10 +57,10 @@ struct sctstr {
     unsigned char sct_off;     /* Should this sector produce? */
     /* end of part matching struct empobj */
     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 */
-    unsigned char sct_terr2;   /* territory 2 id # of sector */
-    unsigned char sct_terr3;   /* territory 3 id # of sector */
+    unsigned char sct_terr;    /* territory 0 number */
+    unsigned char sct_terr1;   /* territory 1 number */
+    unsigned char sct_terr2;   /* territory 2 number */
+    unsigned char sct_terr3;   /* territory 3 number */
     unsigned char sct_dterr;   /* deity's territory # */
     coord sct_dist_x;          /* Dist sector */
     coord sct_dist_y;
@@ -83,7 +82,7 @@ struct sctstr {
     short sct_dist[I_MAX+1];   /* distribution thresholds */
     short sct_mines;           /* number of mines */
     short sct_pstage;          /* plague stage */
-    short sct_ptime;           /* how many etus remain in this stage */
+    short sct_ptime;           /* how many ETUs remain in this stage */
     unsigned char sct_che;     /* number of guerrillas */
     natid sct_che_target;      /* nation targeted by che */
     unsigned short sct_fallout;
@@ -112,18 +111,20 @@ struct dchrstr {
     enum i_packing d_pkg;      /* type of packaging in these sects */
     float d_ostr;              /* offensive strength */
     float d_dstr;              /* defensive strength */
-    int d_value;               /* resale ("collect") value */
-    int d_cost;                        /* cost to designate the sect */
-    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 */
+    short d_mat[I_MAX+1];      /* materials to build 100% */
+                               /* only I_LCM and I_HCM non-zero */
+    int d_bwork;               /* work to build 100% */
+    int d_cost;                        /* cost to build 100% */
     int d_maint;               /* maintenance cost per ETU */
     int d_maxpop;              /* maximum population */
+    int d_flags;               /* capability flags */
     char *d_name;              /* full name of sector type */
 };
 
-       /* sector types (must agree with order in dchr, empglb.c) */
+/* Sector capability flags */
+#define D_DEITY                bit(0)  /* Only the deity can designate this */
 
+/* Sector types, must match sect.config */
 #define SCT_WATER      0       /* basics */
 #define SCT_MOUNT      1
 #define SCT_SANCT      2
@@ -156,20 +157,17 @@ struct dchrstr {
 #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_TYPE_MAX    38
+#define SCT_PLAINS     32      /* plains sector */
+#define SCT_BTOWER     33      /* Bridge tower */
 
 #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))
+#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);
+#define DCHR_SZ 64
+extern struct dchrstr dchr[DCHR_SZ];
 
-extern struct dchrstr dchr[SCT_TYPE_MAX + 2];
 #define IS_BIG_CITY(type) (dchr[(type)].d_pkg == UPKG)
 
 /* Minimal efficiency of sectors that can be knocked down (bridges) */
@@ -196,13 +194,10 @@ extern struct dchrstr dchr[SCT_TYPE_MAX + 2];
 #define SCT_LANDMINES(sp) \
     (SCT_MINES_ARE_SEAMINES((sp)) ? 0 : (sp)->sct_mines)
 
-#define MOB_MOVE    0
-#define MOB_MARCH   1
-#define MOB_RAIL    2
-
-#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 */
@@ -221,14 +216,15 @@ extern struct dchrstr dchr[SCT_TYPE_MAX + 2];
 /* Each cost is per point of efficency */
 struct sctintrins {
     char *in_name;
-    unsigned char in_lcms;     /* construction materials */
-    unsigned char in_hcms;
-    unsigned char in_dcost;    /* dollars */
-    unsigned char in_mcost;    /* mobility */
+    short in_mat[I_MAX+1];     /* materials to build 100% */
+                               /* non-zero only for I_LCM and I_HCM */
+    short in_bmobil;           /* mobility to build 100% */
+    int in_cost;               /* cost to build 100% */
     unsigned char in_enable;   /* enabled iff non-zero */
 };
 
-extern struct sctintrins intrchr[INT_DEF + 2];
+#define INTRCHR_SZ INT_DEF + 2
+extern struct sctintrins intrchr[INTRCHR_SZ];
 
 extern int fort_fire(struct sctstr *);
 extern int sct_rail_track(struct sctstr *);