]> git.pond.sub.org Git - empserver/blob - include/sect.h
Change dchrstr member d_mnem to char.
[empserver] / include / sect.h
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
4  *                           Ken Stevens, Steve McClure
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  *  ---
21  *
22  *  See files README, COPYING and CREDITS in the root of the source
23  *  tree for related information and legal notices.  It is expected
24  *  that future projects/authors will amend these files as needed.
25  *
26  *  ---
27  *
28  *  sect.h: Definitions for things having to do with sectors.
29  * 
30  *  Known contributors to this file:
31  *     Dave Pare
32  *     Ken Stevens, 1995
33  *     Steve McClure, 1998
34  */
35
36
37 #ifndef SECT_H
38 #define SECT_H
39
40 #include "item.h"
41
42 /* The order of the following elements is there to match up with genitem */
43
44 struct sctstr {
45     /* initial part must match struct genitem */
46     short ef_type;
47     natid sct_own;              /* owner's country num */
48     short sct_elev;             /* elevation/depth */
49     coord sct_x;                /* x coord of sector */
50     coord sct_y;                /* y coord of sector */
51     /* end of part matching struct genitem */
52     u_char sct_type;            /* sector type */
53     u_char sct_effic;           /* 0% to 100% */
54     short sct_mobil;            /* mobility units */
55     u_char sct_loyal;           /* updates until civilans "converted" */
56     u_char sct_terr;            /* territory 0 id # of sector */
57     u_char sct_terr1;           /* territory 1 id # of sector */
58     u_char sct_terr2;           /* territory 2 id # of sector */
59     u_char sct_terr3;           /* territory 3 id # of sector */
60     coord sct_dist_x;           /* Dist sector */
61     coord sct_dist_y;
62     short sct_avail;            /* available workforce for "other things" */
63     short sct_flags;            /* temporary flags */
64     short sct_fill;             /* gunk */
65     u_char sct_work;            /* pct of civ actually working */
66     u_char sct_coastal;         /* is this a coastal sector? */
67     u_char sct_newtype;         /* for changing designations */
68     u_char sct_min;             /* ease of mining ore */
69     u_char sct_gmin;            /* amount of gold ore */
70     u_char sct_fertil;          /* fertility of soil */
71     u_char sct_oil;             /* oil content */
72     u_char sct_uran;            /* uranium ore content */
73     natid sct_oldown;           /* old owner of sector (for liberation) */
74     u_char sct_updated;         /* Has this sect been updated? */
75     u_char sct_off;             /* Should this sector produce? */
76     short sct_item[I_MAX+1];    /* amount of items stored here */
77     short sct_del[I_MAX+1];     /* delivieries */
78     short sct_dist[I_MAX+1];    /* distribution thresholds */
79     short sct_mines;            /* number of mines */
80     short sct_pstage;           /* plague stage */
81     short sct_ptime;            /* how many etus remain in this stage */
82     u_char sct_che;             /* number of guerrillas */
83     natid sct_che_target;       /* nation targeted by che */
84     u_short sct_fallout;
85     time_t sct_access;          /* Last time mob was updated (MOB_ACCESS) */
86     u_char sct_road;            /* Road value of a sector */
87     u_char sct_rail;            /* Rail value of a sector */
88     u_char sct_defense;         /* Defensive value of a sector */
89     time_t sct_timestamp;       /* Last time this sector was written to */
90 };
91
92 typedef enum {
93     NAV_NONE,   /* ships can't navigate */
94     NAVOK,      /* ships can always navigate */
95     NAV_02,     /* requires 2% effic to navigate */
96     NAV_CANAL,  /* requires 2% effic to navigate and M_CANAL capability */
97     NAV_60      /* requires 60% effic to navigate */
98 } d_navigation;
99
100 struct dchrstr {
101     unsigned char d_uid;
102     char d_mnem;                /* map symbol */
103     int d_prd;                  /* product type */
104     int d_mcst;                 /* movement cost */
105     d_navigation d_nav;                 /* navigation capability */
106     i_packing d_pkg;            /* type of packaging in these sects */
107     float d_ostr;               /* offensive strength */
108     float d_dstr;               /* defensive strength */
109     int d_value;                /* resale ("collect") value */
110     int d_cost;                 /* cost to designate the sect */
111     int d_build;                /* cost multiplier for eff */
112     int d_lcms;                 /* lcm's needed per point of eff */
113     int d_hcms;                 /* hcm's needed per point of eff */
114     int d_maxpop;               /* maximum population */
115     char *d_name;               /* full name of sector type */
116 };
117
118         /* sector types (must agree with order in dchr, empglb.c) */
119
120 #define SCT_WATER       0       /* basics */
121 #define SCT_MOUNT       1
122 #define SCT_SANCT       2
123 #define SCT_WASTE       3
124 #define SCT_RURAL       4
125 #define SCT_CAPIT       5
126 #define SCT_URAN        6
127 #define SCT_PARK        7
128 #define SCT_ARMSF       8       /* industries */
129 #define SCT_AMMOF       9
130 #define SCT_MINE        10
131 #define SCT_GMINE       11
132 #define SCT_HARBR       12
133 #define SCT_WAREH       13
134 #define SCT_AIRPT       14
135 #define SCT_AGRI        15
136 #define SCT_OIL         16
137 #define SCT_LIGHT       17
138 #define SCT_HEAVY       18
139 #define SCT_FORTR       19      /* military/scientific */
140 #define SCT_TECH        20
141 #define SCT_RSRCH       21
142 #define SCT_NUKE        22
143 #define SCT_LIBR        23
144 #define SCT_HIWAY       24      /* communications */
145 #define SCT_RADAR       25
146 #define SCT_HEADQ       26      /* headquarters */
147 #define SCT_BHEAD       27      /* Bridge head */
148 #define SCT_BSPAN       28      /* Bridge span */
149 #define SCT_BANK        29      /* financial */
150 #define SCT_REFINE      30      /* refinery */
151 #define SCT_ENLIST      31      /* enlistment center */
152 #define SCT_PLAINS      32      /* plains sector */
153 #define SCT_BTOWER      33      /* Bridge tower */
154
155 #define SCT_EFFIC       34      /* used in update & budget */
156 #define SCT_MAXDEF      34      /* highest sector type in header files */
157
158 #define getsect(x, y, p) \
159         ef_read(EF_SECTOR, sctoff((x), (y)), (p))
160 #define putsect(p) \
161         ef_write(EF_SECTOR, sctoff((p)->sct_x, (p)->sct_y), (p))
162 #define getsectp(x, y) \
163         (struct sctstr *)ef_ptr(EF_SECTOR, sctoff((x), (y)))
164 #define getsectid(id) \
165         (struct sctstr *)ef_ptr(EF_SECTOR, id)
166
167 /* things relating to sectors */
168 extern int sctoff(coord x, coord y);
169
170 extern struct dchrstr dchr[SCT_MAXDEF + 1];
171 extern struct dchrstr bigcity_dchr;
172 #define IS_BIG_CITY(sect) (dchr[sect].d_pkg == UPKG)
173
174 /* Minimal efficiency of sectors that can be knocked down (bridges) */
175 #define SCT_MINEFF 20
176
177 /* Work required for building */
178 #define SCT_BLD_WORK(lcm, hcm) ((lcm) + 2 * (hcm))
179
180 #define MIN_MOBCOST  0.001      /* lowest cost a sector can have to move into */
181 #define FORTEFF 5               /* forts must be 5% efficient to fire. */
182
183 #define MOB_NONE    0
184 #define MOB_ROAD    1
185 #define MOB_RAIL    2
186
187 #define INT_ROAD    0
188 #define INT_RAIL    1
189 #define INT_DEF     2
190
191 /* Sector flags */
192 #define MOVE_IN_PROGRESS        bit(0)  /* move in progress */
193
194 /* maximum item amount, must fit into sct_item[], sct_del[], sct_dist[] */
195 #define ITEM_MAX 9999
196 /* maximum number of mines, must fit into struct sctstr member sct_mines */
197 #define MINES_MAX 32767
198 /* maximum number of che, must fit into struct sctstr member sct_che */
199 #define CHE_MAX 255
200 /* maximum fallout, must fit into struct sctstr member sct_fallout */
201 #define FALLOUT_MAX 9999
202
203 /* Each cost is per point of efficency */
204 struct sctintrins {
205     char *in_name;
206     u_char in_lcms;
207     u_char in_hcms;
208     u_char in_dcost;
209     u_char in_mcost;
210 };
211
212 extern struct sctintrins intrchr[INT_DEF + 2];
213
214 #endif