2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2004, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
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.
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.
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
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * nsc.c: Empire selection global structures
30 * Known contributors to this file:
31 * Markus Armbruster, 2004
52 #include "commodity.h"
55 #define fldoff(str, fld) offsetof(struct str, fld)
57 #define NSC_IELT(name, pfx, sfx, base, itype) \
58 {NSC_SHORT, 0, 0, ((base) + (itype)*sizeof(u_short)), \
59 sizeof(sfx) == 1 ? name : pfx sfx}
61 #define NSC_IVEC(base, sfx) \
62 NSC_IELT("civil", "c", sfx, base, I_CIVIL), \
63 NSC_IELT("milit", "m", sfx, base, I_MILIT), \
64 NSC_IELT("shell", "s", sfx, base, I_SHELL), \
65 NSC_IELT("gun", "g", sfx, base, I_GUN), \
66 NSC_IELT("petrol", "p", sfx, base, I_PETROL), \
67 NSC_IELT("iron", "i", sfx, base, I_IRON), \
68 NSC_IELT("dust", "d", sfx, base, I_DUST), \
69 NSC_IELT("bar", "b", sfx, base, I_BAR), \
70 NSC_IELT("food", "f", sfx, base, I_FOOD), \
71 NSC_IELT("oil", "o", sfx, base, I_OIL), \
72 NSC_IELT("lcm", "l", sfx, base, I_LCM), \
73 NSC_IELT("hcm", "h", sfx, base, I_HCM), \
74 NSC_IELT("uw", "u", sfx, base, I_UW), \
75 NSC_IELT("rad", "r", sfx, base, I_RAD)
77 struct castr sect_ca[] = {
78 {NSC_NATID, 0, 0, fldoff(sctstr, sct_own), "owner"},
79 {NSC_XCOORD, 0, 0, fldoff(sctstr, sct_x), "xloc"},
80 {NSC_YCOORD, 0, 0, fldoff(sctstr, sct_y), "yloc"},
81 {NSC_TYPEID, 0, 0, fldoff(sctstr, sct_type), "des"},
82 {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_effic), "effic"},
83 {NSC_SHORT, 0, 0, fldoff(sctstr, sct_mobil), "mobil"},
84 {NSC_UCHAR, NSC_DEITY, 0, fldoff(sctstr, sct_loyal), "loyal"},
85 {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_terr), "terr"},
86 {NSC_UCHAR, NSC_EXTRA, 0, fldoff(sctstr, sct_terr), "terr0"},
87 {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_terr1), "terr1"},
88 {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_terr2), "terr2"},
89 {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_terr3), "terr3"},
90 {NSC_XCOORD, 0, 0, fldoff(sctstr, sct_dist_x), "xdist"},
91 {NSC_YCOORD, 0, 0, fldoff(sctstr, sct_dist_y), "ydist"},
92 {NSC_SHORT, 0, 0, fldoff(sctstr, sct_avail), "avail"},
93 {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_work), "work"},
94 {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_coastal), "coastal"},
95 {NSC_TYPEID, 0, 0, fldoff(sctstr, sct_newtype), "newdes"},
96 {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_min), "min"},
97 {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_gmin), "gold"},
98 {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_fertil), "fert"},
99 {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_oil), "ocontent"},
100 {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_uran), "uran"},
101 {NSC_NATID, 0, 0, fldoff(sctstr, sct_oldown), "oldown"},
102 {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_off), "off"},
103 NSC_IVEC(fldoff(sctstr, sct_item), ""),
104 NSC_IVEC(fldoff(sctstr, sct_dist), "_dist"),
105 NSC_IVEC(fldoff(sctstr, sct_del), "_del"),
106 {NSC_SHORT, NSC_DEITY, 0, fldoff(sctstr, sct_mines), "mines"},
107 {NSC_USHORT, NSC_DEITY, 0, fldoff(sctstr, sct_pstage), "pstage"},
108 {NSC_USHORT, NSC_DEITY, 0, fldoff(sctstr, sct_ptime), "ptime"},
109 {NSC_UCHAR, NSC_DEITY, 0, fldoff(sctstr, sct_che), "che"},
110 {NSC_NATID, NSC_DEITY, 0, fldoff(sctstr, sct_che_target), "che_target"},
111 {NSC_USHORT, 0, 0, fldoff(sctstr, sct_fallout), "fallout"},
112 {NSC_TIME, 0, 0, fldoff(sctstr, sct_access), "access"},
113 {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_road), "road"},
114 {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_rail), "rail"},
115 {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_defense), "dfense"},
116 {NSC_TIME, 0, 0, fldoff(sctstr, sct_timestamp), "timestamp"},
117 {NSC_NOTYPE, 0, 0, 0, NULL}
120 #define NSC_GENITEM \
121 { NSC_NATID, 0, 0, fldoff(genitem, own), "owner"}, \
122 { NSC_SHORT, 0, 0, fldoff(genitem, uid), "uid"}, \
123 { NSC_XCOORD, 0, 0, fldoff(genitem, x), "xloc"}, \
124 { NSC_YCOORD, 0, 0, fldoff(genitem, y), "yloc"}, \
125 { NSC_TYPEID, 0, 0, fldoff(genitem, type), "type"}, \
126 { NSC_CHAR, 0, 0, fldoff(genitem, effic), "effic"}, \
127 { NSC_CHAR , 0, 0, fldoff(genitem, mobil), "mobil"}, \
128 { NSC_SHORT, 0, 0, fldoff(genitem, tech), "tech"}, \
129 { NSC_CHAR, NSC_EXTRA, 0, fldoff(genitem, group), "group"}, \
130 { NSC_XCOORD, 0, 0, fldoff(genitem, opx), "opx"}, \
131 { NSC_YCOORD, 0, 0, fldoff(genitem, opy), "opy"}, \
132 { NSC_SHORT, 0, 0, fldoff(genitem, mission), "mission"}, \
133 { NSC_SHORT, 0, 0, fldoff(genitem, radius), "radius"}
135 struct castr ship_ca[] = {
137 {NSC_CHAR, 0, 0, fldoff(shpstr, shp_fleet), "fleet"},
138 {NSC_UCHAR, 0, 0, fldoff(shpstr, shp_nplane), "nplane"},
139 {NSC_UCHAR, 0, 0, fldoff(shpstr, shp_nland), "nland"},
140 /* FIXME most autonav stuff missing */
141 {NSC_UCHAR, 0, 0, fldoff(shpstr, shp_autonav), "autonav"},
142 NSC_IVEC(fldoff(shpstr, shp_item), ""),
143 {NSC_USHORT, NSC_DEITY, 0, fldoff(shpstr, shp_pstage), "pstage"},
144 {NSC_USHORT, NSC_DEITY, 0, fldoff(shpstr, shp_ptime), "ptime"},
145 {NSC_TIME, 0, 0, fldoff(shpstr, shp_access), "access"},
146 {NSC_TIME, 0, 0, fldoff(shpstr, shp_timestamp), "timestamp"},
147 /* FIXME sail stuff missing */
148 {NSC_STRINGY, 0, MAXSHPNAMLEN, fldoff(shpstr, shp_name), "name"},
149 {NSC_UCHAR, 0, 0, fldoff(shpstr, shp_fuel), "fuel"},
150 {NSC_UCHAR, 0, 0, fldoff(shpstr, shp_nchoppers), "nchoppers"},
151 {NSC_UCHAR, 0, 0, fldoff(shpstr, shp_nxlight), "nxlight"},
152 /* could let builder access these, but we can't express that yet: */
153 {NSC_XCOORD, NSC_DEITY, 0, fldoff(shpstr, shp_orig_x), "xbuilt"},
154 {NSC_YCOORD, NSC_DEITY, 0, fldoff(shpstr, shp_orig_y), "ybuilt"},
155 {NSC_NATID, NSC_DEITY, 0, fldoff(shpstr, shp_orig_own), "builder"},
156 {NSC_INT, 0, 0, fldoff(shpstr, shp_rflags), "rflags"},
157 {NSC_STRINGY, 0, RET_LEN, fldoff(shpstr, shp_rpath), "rpath"},
158 {NSC_NOTYPE, 0, 0, 0, NULL}
161 struct castr plane_ca[] = {
163 {NSC_CHAR, 0, 0, fldoff(plnstr, pln_wing), "wing"},
164 {NSC_UCHAR, 0, 0, fldoff(plnstr, pln_range), "range"},
165 {NSC_SHORT, 0, 0, fldoff(plnstr, pln_ship), "ship"},
166 {NSC_SHORT, 0, 0, fldoff(plnstr, pln_land), "land"},
167 {NSC_INT, NSC_EXTRA, 0, fldoff(plnstr, pln_att), "att"},
168 {NSC_INT, NSC_EXTRA, 0, fldoff(plnstr, pln_def), "def"},
169 {NSC_CHAR, 0, 0, fldoff(plnstr, pln_harden), "harden"},
170 {NSC_CHAR, 0, 0, fldoff(plnstr, pln_nuketype), "nuketype"},
171 {NSC_CHAR, 0, 0, fldoff(plnstr, pln_flags), "flags"},
172 {NSC_TIME, 0, 0, fldoff(plnstr, pln_access), "access"},
173 {NSC_TIME, 0, 0, fldoff(plnstr, pln_timestamp), "timestamp"},
174 {NSC_FLOAT, 0, 0, fldoff(plnstr, pln_theta), "theta"},
175 {NSC_NOTYPE, 0, 0, 0, NULL}
178 struct castr land_ca[] = {
180 {NSC_CHAR, 0, 0, fldoff(lndstr, lnd_army), "army"},
181 {NSC_SHORT, 0, 0, fldoff(lndstr, lnd_ship), "ship"},
182 {NSC_CHAR, 0, 0, fldoff(lndstr, lnd_harden), "harden"},
183 {NSC_SHORT, 0, 0, fldoff(lndstr, lnd_retreat), "retreat"},
184 {NSC_UCHAR, 0, 0, fldoff(lndstr, lnd_fuel), "fuel"},
185 {NSC_UCHAR, 0, 0, fldoff(lndstr, lnd_nxlight), "nxlight"},
186 {NSC_INT, 0, 0, fldoff(lndstr, lnd_rflags), "rflags"},
187 {NSC_STRINGY, 0, RET_LEN, fldoff(lndstr, lnd_rpath), "rpath"},
188 {NSC_UCHAR, 0, 0, fldoff(lndstr, lnd_rad_max), "react"},
189 NSC_IVEC(fldoff(lndstr, lnd_item), ""),
190 {NSC_USHORT, NSC_DEITY, 0, fldoff(lndstr, lnd_pstage), "pstage"},
191 {NSC_USHORT, NSC_DEITY, 0, fldoff(lndstr, lnd_ptime), "ptime"},
192 {NSC_SHORT, 0, 0, fldoff(lndstr, lnd_land), "land"},
193 {NSC_UCHAR, 0, 0, fldoff(lndstr, lnd_nland), "nland"},
194 {NSC_TIME, 0, 0, fldoff(lndstr, lnd_access), "access"},
195 {NSC_FLOAT, NSC_EXTRA, 0, fldoff(lndstr, lnd_att), "att"},
196 {NSC_FLOAT, NSC_EXTRA, 0, fldoff(lndstr, lnd_def), "def"},
197 {NSC_INT, NSC_EXTRA, 0, fldoff(lndstr, lnd_vul), "vul"},
198 {NSC_INT, NSC_EXTRA, 0, fldoff(lndstr, lnd_spd), "spd"},
199 {NSC_INT, NSC_EXTRA, 0, fldoff(lndstr, lnd_vis), "vis"},
200 {NSC_INT, NSC_EXTRA, 0, fldoff(lndstr, lnd_spy), "spy"},
201 {NSC_INT, NSC_EXTRA, 0, fldoff(lndstr, lnd_rad), "rad"},
202 {NSC_INT, NSC_EXTRA, 0, fldoff(lndstr, lnd_frg), "frg"},
203 {NSC_INT, NSC_EXTRA, 0, fldoff(lndstr, lnd_acc), "acc"},
204 {NSC_INT, NSC_EXTRA, 0, fldoff(lndstr, lnd_dam), "dam"},
205 {NSC_INT, NSC_EXTRA, 0, fldoff(lndstr, lnd_ammo), "ammo"},
206 {NSC_INT, NSC_EXTRA, 0, fldoff(lndstr, lnd_aaf), "aaf"},
207 {NSC_UCHAR, NSC_EXTRA, 0, fldoff(lndstr, lnd_fuelc), "fuelc"},
208 {NSC_UCHAR, NSC_EXTRA, 0, fldoff(lndstr, lnd_fuelu), "fuelu"},
209 {NSC_UCHAR, NSC_EXTRA, 0, fldoff(lndstr, lnd_maxlight), "maxlight"},
210 {NSC_TIME, 0, 0, fldoff(lndstr, lnd_timestamp), "timestamp"},
211 {NSC_NOTYPE, 0, 0, 0, NULL}
214 struct castr nuke_ca[] = {
215 {NSC_NATID, 0, 0, fldoff(nukstr, nuk_own), "owner"},
216 {NSC_SHORT, 0, 0, fldoff(nukstr, nuk_uid), "uid"},
217 {NSC_XCOORD, 0, 0, fldoff(nukstr, nuk_x), "xloc"},
218 {NSC_YCOORD, 0, 0, fldoff(nukstr, nuk_y), "yloc"},
219 {NSC_CHAR, 0, 0, fldoff(nukstr, nuk_n), "number"},
220 {NSC_SHORT, 0, N_MAXNUKE, fldoff(nukstr, nuk_types[0]), "types"},
221 {NSC_TIME, 0, 0, fldoff(nukstr, nuk_timestamp), "timestamp"},
222 {NSC_NOTYPE, 0, 0, 0, NULL}
225 struct castr treaty_ca[] = {
226 {NSC_NATID, 0, 0, fldoff(trtstr, trt_cna), "cna"},
227 {NSC_NATID, 0, 0, fldoff(trtstr, trt_cnb), "cnb"},
228 {NSC_CHAR, 0, 0, fldoff(trtstr, trt_status), "status"},
229 {NSC_SHORT, 0, 0, fldoff(trtstr, trt_acond), "acond"},
230 {NSC_SHORT, 0, 0, fldoff(trtstr, trt_bcond), "bcond"},
231 {NSC_TIME, 0, 0, fldoff(trtstr, trt_exp), "exp"},
232 {NSC_NOTYPE, 0, 0, 0, NULL}
235 struct castr loan_ca[] = {
236 {NSC_NATID, 0, 0, fldoff(lonstr, l_loner), "loaner"},
237 {NSC_SHORT, 0, 0, fldoff(lonstr, l_uid), "uid"},
238 {NSC_NATID, 0, 0, fldoff(lonstr, l_lonee), "loanee"},
239 {NSC_CHAR, 0, 0, fldoff(lonstr, l_status), "status"},
240 {NSC_INT, 0, 0, fldoff(lonstr, l_irate), "irate"},
241 {NSC_INT, 0, 0, fldoff(lonstr, l_ldur), "ldur"},
242 {NSC_LONG, 0, 0, fldoff(lonstr, l_amtpaid), "amtpaid"},
243 {NSC_LONG, 0, 0, fldoff(lonstr, l_amtdue), "amtdue"},
244 {NSC_TIME, 0, 0, fldoff(lonstr, l_lastpay), "lastpay"},
245 {NSC_TIME, 0, 0, fldoff(lonstr, l_duedate), "duedate"},
246 {NSC_NOTYPE, 0, 0, 0, NULL}
249 struct castr news_ca[] = {
250 {NSC_NATID, 0, 0, fldoff(nwsstr, nws_ano), "actor"},
251 {NSC_TYPEID, 0, 0, fldoff(nwsstr, nws_vrb), "action"},
252 {NSC_NATID, 0, 0, fldoff(nwsstr, nws_vno), "victim"},
253 {NSC_CHAR, 0, 0, fldoff(nwsstr, nws_ntm), "times"},
254 {NSC_TIME, 0, 0, fldoff(nwsstr, nws_when), "time"},
255 {NSC_NOTYPE, 0, 0, 0, NULL}
258 struct castr lost_ca[] = {
259 {NSC_NATID, 0, 0, fldoff(loststr, lost_owner), "owner"},
260 {NSC_INT, 0, 0, fldoff(loststr, lost_uid), "uid"},
261 {NSC_CHAR, 0, 0, fldoff(loststr, lost_type), "type"},
262 {NSC_SHORT, 0, 0, fldoff(loststr, lost_id), "id"},
263 {NSC_XCOORD, 0, 0, fldoff(loststr, lost_x), "x"},
264 {NSC_YCOORD, 0, 0, fldoff(loststr, lost_y), "y"},
265 {NSC_TIME, 0, 0, fldoff(loststr, lost_timestamp), "timestamp"},
266 {NSC_NOTYPE, 0, 0, 0, NULL}
269 struct castr commodity_ca[] = {
270 {NSC_NATID, 0, 0, fldoff(comstr, com_owner), "owner"},
271 {NSC_SHORT, 0, 0, fldoff(comstr, com_uid), "uid"},
272 {NSC_INT, 0, 0, fldoff(comstr, com_type), "type"},
273 {NSC_INT, 0, 0, fldoff(comstr, com_amount), "amount"},
274 {NSC_INT, 0, 0, fldoff(comstr, com_maxbidder), "maxbidder"},
275 {NSC_TIME, 0, 0, fldoff(comstr, com_markettime), "markettime"},
276 /* could let maxbidder access these, but we can't express that yet: */
277 {NSC_XCOORD, NSC_DEITY, 0, fldoff(comstr, com_x), "xbuy"},
278 {NSC_XCOORD, NSC_DEITY, 0, fldoff(comstr, com_y), "ybuy"},
279 /* could let the owner access these, but we can't express that yet: */
280 {NSC_XCOORD, NSC_DEITY, 0, fldoff(comstr, sell_x), "xsell"},
281 {NSC_YCOORD, NSC_DEITY, 0, fldoff(comstr, sell_y), "ysell"},
282 {NSC_FLOAT, 0, 0, fldoff(comstr, com_price), "price"},
283 {NSC_NOTYPE, 0, 0, 0, NULL}
286 struct castr trade_ca[] = {
287 {NSC_NATID, 0, 0, fldoff(trdstr, trd_owner), "owner"},
288 {NSC_SHORT, 0, 0, fldoff(trdstr, trd_uid), "uid"},
289 {NSC_CHAR, 0, 0, fldoff(trdstr, trd_type), "type"},
290 {NSC_SHORT, 0, 0, fldoff(trdstr, trd_unitid), "unitid"},
291 {NSC_LONG, 0, 0, fldoff(trdstr, trd_price), "price"},
292 {NSC_INT, 0, 0, fldoff(trdstr, trd_maxbidder), "maxbidder"},
293 {NSC_TIME, 0, 0, fldoff(trdstr, trd_markettime), "markettime"},
294 /* could let the owner access these, but we can't express that yet: */
295 {NSC_XCOORD, NSC_DEITY, 0, fldoff(trdstr, trd_x), "xloc"},
296 {NSC_YCOORD, NSC_DEITY, 0, fldoff(trdstr, trd_y), "yloc"},
297 {NSC_NOTYPE, 0, 0, 0, NULL}
300 struct castr nat_ca[] = {
301 {NSC_CHAR, 0, 20, fldoff(natstr, nat_cnam[0]), "cnam"},
302 {NSC_CHAR, NSC_DEITY, 20, fldoff(natstr, nat_pnam[0]), "pnam"},
303 {NSC_XCOORD, 0, 0, fldoff(natstr, nat_xstart), "xstart"},
304 {NSC_YCOORD, 0, 0, fldoff(natstr, nat_ystart), "ystart"},
305 {NSC_XCOORD, 0, 0, fldoff(natstr, nat_xcap), "xcap"},
306 {NSC_YCOORD, 0, 0, fldoff(natstr, nat_ycap), "ycap"},
307 {NSC_XCOORD, NSC_DEITY, 0, fldoff(natstr, nat_xorg), "xorg"},
308 {NSC_YCOORD, NSC_DEITY, 0, fldoff(natstr, nat_yorg), "yorg"},
309 {NSC_NATID, 0, 0, fldoff(natstr, nat_cnum), "cnum"},
311 {NSC_CHAR, 0, 0, fldoff(natstr, nat_stat), "stat"},
312 {NSC_CHAR, 0, 0, fldoff(natstr, nat_dayno), "dayno"},
313 {NSC_CHAR, 0, 0, fldoff(natstr, nat_update), "update"},
314 {NSC_UCHAR, 0, 0, fldoff(natstr, nat_missed), "missed"},
315 #endif /* MAYBE_LATER */
316 {NSC_USHORT, 0, 0, fldoff(natstr, nat_tgms), "tgms"},
317 {NSC_USHORT, 0, 0, fldoff(natstr, nat_ann), "ann"},
318 {NSC_USHORT, 0, 0, fldoff(natstr, nat_minused), "minused"},
319 {NSC_SHORT, 0, 0, fldoff(natstr, nat_btu), "btu"},
320 {NSC_LONG, 0, 0, fldoff(natstr, nat_reserve), "reserve"},
321 {NSC_LONG, 0, 0, fldoff(natstr, nat_money), "money"},
323 {NSC_TIME, 0, 0, fldoff(natstr, nat_last_login), "last_login"},
324 {NSC_TIME, 0, 0, fldoff(natstr, nat_last_logout), "last_logout"},
325 {NSC_TIME, 0, 0, fldoff(natstr, nat_newstim), "newstim"},
326 #endif /* MAYBE_LATER */
327 {NSC_FLOAT, 0, 0, fldoff(natstr, nat_level[NAT_TLEV]), "tech"},
328 {NSC_FLOAT, 0, 0, fldoff(natstr, nat_level[NAT_RLEV]), "research"},
329 {NSC_FLOAT, 0, 0, fldoff(natstr, nat_level[NAT_ELEV]), "education"},
330 {NSC_FLOAT, 0, 0, fldoff(natstr, nat_level[NAT_HLEV]), "happiness"},
332 {NSC_SHORT, 0, MAXNOC, fldoff(natstr, nat_relate[0]),"relate"},
333 {NSC_CHAR, 0, PRI_MAX+1, fldoff(natstr, nat_priorities[0]),"priorities"},
334 {NSC_LONG, 0, 0, fldoff(natstr, nat_flags),"flags",0},
336 {NSC_NOTYPE, 0, 0, 0, NULL}