include/sect.h

Go to the documentation of this file.
00001 /*
00002  *  Empire - A multi-player, client/server Internet based war game.
00003  *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
00004  *                           Ken Stevens, Steve McClure
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  *  ---
00021  *
00022  *  See files README, COPYING and CREDITS in the root of the source
00023  *  tree for related information and legal notices.  It is expected
00024  *  that future projects/authors will amend these files as needed.
00025  *
00026  *  ---
00027  *
00028  *  sect.h: Definitions for things having to do with sectors.
00029  * 
00030  *  Known contributors to this file:
00031  *     Dave Pare
00032  *     Ken Stevens, 1995
00033  *     Steve McClure, 1998
00034  */
00035 
00036 
00037 #ifndef SECT_H
00038 #define SECT_H
00039 
00040 #include <time.h>
00041 #include "item.h"
00042 #include "types.h"
00043 
00044 struct sctstr {
00045     /* initial part must match struct empobj */
00046     short ef_type;
00047     natid sct_own;              /* owner's country num */
00048     short sct_elev;             /* elevation/depth */
00049     coord sct_x;                /* x coord of sector */
00050     coord sct_y;                /* y coord of sector */
00051     /* end of part matching struct empobj */
00052     unsigned char sct_type;     /* sector type */
00053     unsigned char sct_effic;    /* 0% to 100% */
00054     short sct_mobil;            /* mobility units */
00055     unsigned char sct_loyal;    /* updates until civilans "converted" */
00056     unsigned char sct_terr;     /* territory 0 id # of sector */
00057     unsigned char sct_terr1;    /* territory 1 id # of sector */
00058     unsigned char sct_terr2;    /* territory 2 id # of sector */
00059     unsigned char sct_terr3;    /* territory 3 id # of sector */
00060     unsigned char sct_dterr;    /* deity's territory # */
00061     coord sct_dist_x;           /* Dist sector */
00062     coord sct_dist_y;
00063     short sct_avail;            /* available workforce for "other things" */
00064     short sct_flags;            /* temporary flags */
00065     short sct_fill;             /* gunk */
00066     unsigned char sct_work;     /* pct of civ actually working */
00067     unsigned char sct_coastal;  /* is this a coastal sector? */
00068     unsigned char sct_newtype;  /* for changing designations */
00069     unsigned char sct_min;      /* ease of mining ore */
00070     unsigned char sct_gmin;     /* amount of gold ore */
00071     unsigned char sct_fertil;   /* fertility of soil */
00072     unsigned char sct_oil;      /* oil content */
00073     unsigned char sct_uran;     /* uranium ore content */
00074     natid sct_oldown;           /* old owner of sector (for liberation) */
00075     unsigned char sct_updated;  /* Has this sect been updated? */
00076     unsigned char sct_off;      /* Should this sector produce? */
00077     short sct_item[I_MAX+1];    /* amount of items stored here */
00078     short sct_del[I_MAX+1];     /* delivieries */
00079     short sct_dist[I_MAX+1];    /* distribution thresholds */
00080     short sct_mines;            /* number of mines */
00081     short sct_pstage;           /* plague stage */
00082     short sct_ptime;            /* how many etus remain in this stage */
00083     unsigned char sct_che;      /* number of guerrillas */
00084     natid sct_che_target;       /* nation targeted by che */
00085     unsigned short sct_fallout;
00086     short sct_access;           /* Last tick mob was updated (MOB_ACCESS) */
00087     unsigned char sct_road;     /* Road value of a sector */
00088     unsigned char sct_rail;     /* Rail value of a sector */
00089     unsigned char sct_defense;  /* Defensive value of a sector */
00090     time_t sct_timestamp;       /* Last time this sector was written to */
00091 };
00092 
00093 typedef enum {
00094     NAV_NONE,   /* ships can't navigate */
00095     NAVOK,      /* ships can always navigate */
00096     NAV_02,     /* requires 2% effic to navigate */
00097     NAV_CANAL,  /* requires 2% effic to navigate and M_CANAL capability */
00098     NAV_60      /* requires 60% effic to navigate */
00099 } d_navigation;
00100 
00101 struct dchrstr {
00102     unsigned char d_uid;
00103     char d_mnem;                /* map symbol */
00104     int d_prd;                  /* product type */
00105     int d_peffic;               /* process efficiency, in percent */
00106     float d_mob0, d_mob1;       /* movement cost at 0 and 100% eff */
00107     d_navigation d_nav;         /* navigation capability */
00108     i_packing d_pkg;            /* type of packaging in these sects */
00109     float d_ostr;               /* offensive strength */
00110     float d_dstr;               /* defensive strength */
00111     int d_value;                /* resale ("collect") value */
00112     int d_cost;                 /* cost to designate the sect */
00113     int d_build;                /* cost multiplier for eff */
00114     int d_lcms;                 /* lcm's needed per point of eff */
00115     int d_hcms;                 /* hcm's needed per point of eff */
00116     int d_maxpop;               /* maximum population */
00117     char *d_name;               /* full name of sector type */
00118 };
00119 
00120         /* sector types (must agree with order in dchr, empglb.c) */
00121 
00122 #define SCT_WATER       0       /* basics */
00123 #define SCT_MOUNT       1
00124 #define SCT_SANCT       2
00125 #define SCT_WASTE       3
00126 #define SCT_RURAL       4
00127 #define SCT_CAPIT       5
00128 #define SCT_URAN        6
00129 #define SCT_PARK        7
00130 #define SCT_ARMSF       8       /* industries */
00131 #define SCT_AMMOF       9
00132 #define SCT_MINE        10
00133 #define SCT_GMINE       11
00134 #define SCT_HARBR       12
00135 #define SCT_WAREH       13
00136 #define SCT_AIRPT       14
00137 #define SCT_AGRI        15
00138 #define SCT_OIL         16
00139 #define SCT_LIGHT       17
00140 #define SCT_HEAVY       18
00141 #define SCT_FORTR       19      /* military/scientific */
00142 #define SCT_TECH        20
00143 #define SCT_RSRCH       21
00144 #define SCT_NUKE        22
00145 #define SCT_LIBR        23
00146 #define SCT_HIWAY       24      /* communications */
00147 #define SCT_RADAR       25
00148 #define SCT_HEADQ       26      /* headquarters */
00149 #define SCT_BHEAD       27      /* Bridge head */
00150 #define SCT_BSPAN       28      /* Bridge span */
00151 #define SCT_BANK        29      /* financial */
00152 #define SCT_REFINE      30      /* refinery */
00153 #define SCT_ENLIST      31      /* enlistment center */
00154 #define SCT_PLAINS      32      /* plains sector */
00155 #define SCT_BTOWER      33      /* Bridge tower */
00156 
00157 #define SCT_TYPE_MAX    38
00158 
00159 #define getsect(x, y, p) ef_read(EF_SECTOR, sctoff((x), (y)), (p))
00160 #define putsect(p) ef_write(EF_SECTOR, sctoff((p)->sct_x, (p)->sct_y), (p))
00161 #define getsectp(x, y) (struct sctstr *)ef_ptr(EF_SECTOR, sctoff((x), (y)))
00162 #define getsectid(id) (struct sctstr *)ef_ptr(EF_SECTOR, (id))
00163 
00164 /* things relating to sectors */
00165 extern int sctoff(coord x, coord y);
00166 
00167 extern struct dchrstr dchr[SCT_TYPE_MAX + 2];
00168 extern struct dchrstr bigcity_dchr;
00169 #define IS_BIG_CITY(type) (dchr[(type)].d_pkg == UPKG)
00170 
00171 /* Minimal efficiency of sectors that can be knocked down (bridges) */
00172 #define SCT_MINEFF 20
00173 
00174 /* Work required for building */
00175 #define SCT_BLD_WORK(lcm, hcm) ((lcm) + 2 * (hcm))
00176 
00177 /* Return SP's defense efficiency */
00178 #define SCT_DEFENSE(sp) \
00179     (intrchr[INT_DEF].in_enable ? (sp)->sct_defense : (sp)->sct_effic)
00180 
00181 #define FORTEFF 5               /* forts must be 5% efficient to fire. */
00182 
00183 #define MOB_MOVE    0
00184 #define MOB_MARCH   1
00185 #define MOB_RAIL    2
00186 
00187 #define INT_ROAD    0
00188 #define INT_RAIL    1
00189 #define INT_DEF     2
00190 
00191 /* Sector flags */
00192 #define MOVE_IN_PROGRESS        bit(0)  /* move in progress */
00193 
00194 /* maximum item amount, must fit into sct_item[], sct_del[], sct_dist[] */
00195 #define ITEM_MAX 9999
00196 /* maximum number of mines, must fit into struct sctstr member sct_mines */
00197 #define MINES_MAX 32767
00198 /* maximum number of che, must fit into struct sctstr member sct_che */
00199 #define CHE_MAX 255
00200 /* maximum fallout, must fit into struct sctstr member sct_fallout */
00201 #define FALLOUT_MAX 9999
00202 /* maximum territory, must fit into struct sctstr members sct_terr etc */
00203 #define TERR_MAX 99
00204 
00205 /* Each cost is per point of efficency */
00206 struct sctintrins {
00207     char *in_name;
00208     unsigned char in_lcms;      /* construction materials */
00209     unsigned char in_hcms;
00210     unsigned char in_dcost;     /* dollars */
00211     unsigned char in_mcost;     /* mobility */
00212     unsigned char in_enable;    /* enabled iff non-zero */
00213 };
00214 
00215 extern struct sctintrins intrchr[INT_DEF + 2];
00216 
00217 #endif

Generated on Fri Mar 28 11:01:11 2008 for empserver by  doxygen 1.5.2