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