2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, 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 * emp_config.c: Allows config file to control server config. from a file
30 * Known contributors to this file:
32 * Steve McClure, 1998-2000
38 * 1. Change other constants - such as Num Countries etc.
39 * Just requires variables to be assigned, then dynamic allocation in
40 * a few places. Some checks needed in the server to check the world
41 * hasn't changed size etc.
42 * 2. Could look at loading in planes, units etc. Should be easy enough.
47 #include <stdlib.h> /* atoi free atol */
57 #include "gen.h" /* parse */
59 /* for systems without strdup */
61 extern char *strdup();
65 /* All the configurable variables ... */
66 extern s_char *infodir, *datadir, *loginport, *privname,
69 extern double buil_tower_bt, buil_tower_bc;
70 extern double buytax, flakscale, maxmult, minmult, tradetax, uwbrate;
71 extern double buil_bc, buil_bt, combat_mob, edu_cons, hap_cons, money_civ;
72 extern double money_land, money_mil, money_plane, money_res, money_ship;
73 extern double money_uw, people_damage, powe_cost, unit_damage, babyeat;
74 extern double collateral_dam, assault_penalty;
75 extern double bankint, eatrate, fcrate, fgrate, obrate, mission_mob_cost;
77 extern float btu_build_rate, easy_tech, hard_tech, land_mob_scale;
78 extern float level_age_rate, plane_mob_scale, sect_mob_scale;
79 extern float ship_mob_scale, tech_log_base, ally_factor, edu_avg, hap_avg;
81 extern int buil_tower_bh;
82 extern int startmob, at_least_one_100, buil_bh, etu_per_update;
83 extern int land_grow_scale, land_mob_max, m_m_p_d, max_btus, max_idle;
84 extern int plane_grow_scale, plane_mob_max, players_at_00, sect_mob_max;
85 extern int ship_grow_scale, ship_mob_max, torpedo_damage;
86 extern int fort_max_interdiction_range;
87 extern int land_max_interdiction_range;
88 extern int ship_max_interdiction_range;
89 extern int sect_mob_neg_factor;
90 extern int lost_items_timeout;
93 extern int MARK_DELAY;
94 extern int TRADE_DELAY;
96 extern int morale_base;
97 extern float fire_range_factor;
99 extern long adj_update;
101 extern int update_policy;
102 extern s_char *update_times;
104 extern int update_window;
105 extern int blitz_time;
106 extern int update_demandpolicy;
107 extern s_char *update_demandtimes;
108 extern int update_wantmin;
109 extern int update_missed;
110 extern s_char *game_days;
111 extern s_char *game_hours;
113 /* conditional ones */
114 extern double decay_per_etu, fallout_spread;
116 extern int fuel_mult;
119 extern long last_demand_update;
121 extern float drnuke_const;
122 extern float start_education, start_happiness;
123 extern float start_technology, start_research;
125 extern int trade_1_dist, trade_2_dist, trade_3_dist;
126 extern float trade_1, trade_2, trade_3, trade_ally_bonus, trade_ally_cut;
130 static int emp_config_dummy;
132 static void optstrset(struct keymatch *kp, s_char **av);
133 static void intset(struct keymatch *kp, s_char **av);
134 static void floatset(struct keymatch *kp, s_char **av);
135 static void doubleset(struct keymatch *kp, s_char **av);
136 static void longset(struct keymatch *kp, s_char **av);
137 static void optionset(struct keymatch *kp, s_char **av);
138 static void optiondel(struct keymatch *kp, s_char **av);
139 static void worldxset(struct keymatch *kp, s_char **av);
141 /* things that can be changed */
142 struct keymatch configkeys[] = {
143 {"", intset, (caddr_t)&emp_config_dummy, 0,
144 "\n### Server configuration and information"},
145 {"data", optstrset, (caddr_t)&datadir, 0,
146 "Directory the data is stored in"},
147 {"info", optstrset, (caddr_t)&infodir, 0,
148 "Directory the info pages are stored in"},
149 {"port", optstrset, (caddr_t)&loginport, 0,
150 "TCP/IP port the server will start up on"},
151 {"privname", optstrset, (caddr_t)&privname, 0,
152 "Name of the deity"},
153 {"privlog", optstrset, (caddr_t)&privlog, 0,
154 "E-mail of the deity"},
155 {"WORLD_X", worldxset, (caddr_t)&WORLD_X, 0,
156 "World size X dimension (enforced to be even by subtracting 1 if necessary)"},
157 {"WORLD_Y", intset, (caddr_t)&WORLD_Y, 0,
158 "World size Y dimension"},
160 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Update policy"},
161 {"update_policy", intset, (caddr_t)&update_policy, 0,
162 "0 - normal, 1 - update_times, 2 - blitz, 3 - demand only"},
163 {"etu_per_update", intset, (caddr_t)&etu_per_update, 0,
164 "Number of ETUs per update"},
165 {"s_p_etu", longset, (caddr_t)&s_p_etu, 0,
166 "Seconds per etu, updates will occur every s_p_etu * etu_per_update seconds"},
167 {"adj_update", longset, (caddr_t)&adj_update, 0,
168 "Move the update forward or backward (in seconds)"},
169 {"update_window", intset, (caddr_t)&update_window, 0,
170 "Window the update will occur in (in seconds) before and after the update time"},
171 {"update_times", optstrset, (caddr_t)&update_times, 0,
172 "Times when updates occur under policy #1. Must coincide with schedule."},
173 {"hourslop", intset, (caddr_t)&hourslop, 0,
174 "Number of minutes update check can slip to match update_times"},
175 {"blitz_time", intset, (caddr_t)&blitz_time, 0,
176 "Number of minutes between updates under policy #2."},
178 {"", intset, (caddr_t)&emp_config_dummy, 0,
179 "\n\n### Demand update policy"},
180 {"update_demandpolicy", intset, (caddr_t)&update_demandpolicy, 0,
181 "0 - emp_tm checks, 1 - after setting, 2 - demand updates disabled"},
182 {"update_wantmin", intset, (caddr_t)&update_wantmin, 0,
183 "number of requests needed for demand update"},
184 {"update_missed", intset, (caddr_t)&update_missed, 0,
185 "number of demand updates country can miss before veto update"},
186 {"update_demandtimes", optstrset, (caddr_t)&update_demandtimes, 0,
187 "Times when demand updates can occur. Ranges CANNOT cross midnight."},
189 {"", intset, (caddr_t)&emp_config_dummy, 0,
190 "\n\n### Game hours restrictions"},
191 {"game_days", optstrset, (caddr_t)&game_days, 0,
192 "Days game is up and running (Su Mo Tu We Th Fr Sa)"},
193 {"game_hours", optstrset, (caddr_t)&game_hours, 0,
194 "Hours game is up and running (6:00-18:00)"},
196 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Options\n"},
197 {"option", optionset, (caddr_t)NULL, 0, NULL},
198 {"nooption", optiondel, (caddr_t)NULL, 0, NULL},
201 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Countries"},
202 {"btu_build_rate", floatset, (caddr_t)&btu_build_rate, 0,
203 "Rate at which BTUs accumulate (etu * civ * eff * btu_build_rate)"},
204 {"m_m_p_d", intset, (caddr_t)&m_m_p_d, 0,
205 "Maximum minutes per day a country is allowed to be logged in"},
206 {"max_btus", intset, (caddr_t)&max_btus, 0,
207 "Maximum number of BTUs a country can have"},
208 {"max_idle", intset, (caddr_t)&max_idle, 0,
209 "Maximum number of minutes a player can sit idle while logged in"},
210 {"players_at_00", intset, (caddr_t)&players_at_00, 0,
211 "Players have their coordinate system at deity 0,0 (0 - no, 1 - yes)"},
212 {"at_least_one_100", intset, (caddr_t)&at_least_one_100, 0,
213 "Initialize new countries with at least one sector with 100 of all resource"},
214 {"powe_cost", doubleset, (caddr_t)&powe_cost, 0,
215 "Number of BTUs needed to generate a new power report"},
216 {"war_cost", intset, (caddr_t)&War_Cost, 0,
217 "Cost to declare war (if SLOW_WAR is on)"},
219 {"", intset, (caddr_t)&emp_config_dummy, 0,
220 "\n\n### Technology/Research/Education/Happiness"},
221 {"easy_tech", floatset, (caddr_t)&easy_tech, 0,
222 "Amount of tech built with no penalty"},
223 {"hard_tech", floatset, (caddr_t)&hard_tech, 0,
224 "Amount of in-efficiently built tech"},
225 {"start_tech", floatset, (caddr_t)&start_technology, 0,
226 "Starting technology for new countries"},
227 {"start_happy", floatset, (caddr_t)&start_happiness, 0,
228 "Starting happiness for new countries"},
229 {"start_research", floatset, (caddr_t)&start_research, 0,
230 "Starting research for new countries"},
231 {"start_edu", floatset, (caddr_t)&start_education, 0,
232 "Starting education for new countries"},
233 {"level_age_rate", floatset, (caddr_t)&level_age_rate, 0,
234 "ETU rate at which tech decays (0 -> no decline)"},
235 {"tech_log_base", floatset, (caddr_t)&tech_log_base, 0,
236 "Log base to apply to tech breakthroughs above the easy tech level"},
237 {"ally_factor", floatset, (caddr_t)&ally_factor, 0,
238 "Shared tech with allies (1 / ally_factor)"},
239 {"edu_avg", floatset, (caddr_t)&edu_avg, 0,
240 "Number of ETUs education is averaged over"},
241 {"hap_avg", floatset, (caddr_t)&hap_avg, 0,
242 "Number of ETUs happiness is averaged over"},
243 {"edu_cons", doubleset, (caddr_t)&edu_cons, 0,
244 "Education consumption (1 breakthrough per edu_cons)"},
245 {"hap_cons", doubleset, (caddr_t)&hap_cons, 0,
246 "Happiness consumption (1 breakthrough per hap_cons)"},
248 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Sectors"},
249 {"startmob", intset, (caddr_t)&startmob, 0,
250 "Starting mobility for sanctuaries"},
251 {"sect_mob_scale", floatset, (caddr_t)§_mob_scale, 0,
252 "Sector mobility accumulation (sect_mob_scale * ETUs per update)"},
253 {"sect_mob_max", intset, (caddr_t)§_mob_max, 0,
254 "Maximum mobility for sectors"},
255 {"buil_bh", intset, (caddr_t)&buil_bh, 0,
256 "Number of hcms required to build a bridge span"},
257 {"buil_bc", doubleset, (caddr_t)&buil_bc, 0,
258 "Cash required to build a bridge span"},
259 {"buil_bt", doubleset, (caddr_t)&buil_bt, 0,
260 "Technology required to build a bridge span"},
261 {"buil_tower_bh", intset, (caddr_t)&buil_tower_bh, 0,
262 "Number of hcms required to build a bridge tower"},
263 {"buil_tower_bc", doubleset, (caddr_t)&buil_tower_bc, 0,
264 "Cash required to build a bridge tower"},
265 {"buil_tower_bt", doubleset, (caddr_t)&buil_tower_bt, 0,
266 "Technology required to build a bridge tower"},
268 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Land Units"},
269 {"land_mob_scale", floatset, (caddr_t)&land_mob_scale, 0,
270 "Land unit mobility accumulation (land_mob_scale * ETUs per update)"},
271 {"land_grow_scale", intset, (caddr_t)&land_grow_scale, 0,
272 "How fast efficiency grows for land units each update (* ETUs)"},
273 {"land_mob_max", intset, (caddr_t)&land_mob_max, 0,
274 "Maximum mobility for land units"},
275 {"money_land", doubleset, (caddr_t)&money_land, 0,
276 "Cost per ETU to maintain land units (percentage of unit price)"},
277 {"morale_base", intset, (caddr_t)&morale_base, 0,
278 "Base level for setting morale of land units"},
280 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Planes"},
281 {"plane_mob_scale", floatset, (caddr_t)&plane_mob_scale, 0,
282 "Plane mobility accumulation (plane_mob_scale * ETUs per update)"},
283 {"plane_grow_scale", intset, (caddr_t)&plane_grow_scale, 0,
284 "How fast efficiency grows for planes each update (* ETUs)"},
285 {"plane_mob_max", intset, (caddr_t)&plane_mob_max, 0,
286 "Maximum mobility for planes"},
287 {"money_plane", doubleset, (caddr_t)&money_plane, 0,
288 "Cost per ETU to maintain planes (percentage of plane price)"},
290 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Ships"},
291 {"ship_mob_scale", floatset, (caddr_t)&ship_mob_scale, 0,
292 "Ship mobility accumulation (ship_mob_scale * ETUs per update)"},
293 {"ship_grow_scale", intset, (caddr_t)&ship_grow_scale, 0,
294 "How fast efficiency grows for ships each update (* ETUs)"},
295 {"ship_mob_max", intset, (caddr_t)&ship_mob_max, 0,
296 "Maximum mobility for ships"},
297 {"money_ship", doubleset, (caddr_t)&money_ship, 0,
298 "Cost per ETU to maintain ships (percentage of ship price)"},
299 {"torpedo_damage", intset, (caddr_t)&torpedo_damage, 0,
300 "Torpedo damage (damage is X + 1dX + 1dX)"},
302 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Combat/Damage"},
303 {"fort_max_interdiction_range", intset,
304 (caddr_t)&fort_max_interdiction_range, 0,
305 "Maximum range (in sectors) a fort will try to interdict another country"},
306 {"land_max_interdiction_range", intset,
307 (caddr_t)&land_max_interdiction_range, 0,
308 "Maximum range (in sectors) a land unit will try to interdict another country"},
309 {"ship_max_interdiction_range", intset,
310 (caddr_t)&ship_max_interdiction_range, 0,
311 "Maximum range (in sectors) a ship will try to interdict another country"},
312 {"flakscale", doubleset, (caddr_t)&flakscale, 0,
313 "Scale factor for flak damage"},
314 {"combat_mob", doubleset, (caddr_t)&combat_mob, 0,
315 "How much mobility do units spend for combat (* casualties/bodies)"},
316 {"people_damage", doubleset, (caddr_t)&people_damage, 0,
317 "People take this amount of normal damage"},
318 {"unit_damage", doubleset, (caddr_t)&unit_damage, 0,
319 "Land units take this amount of normal damage"},
320 {"collateral_dam", doubleset, (caddr_t)&collateral_dam, 0,
321 "Side effect damage amount done to sector"},
322 {"assault_penalty", doubleset, (caddr_t)&assault_penalty, 0,
323 "Amount of normal attacking efficiency for paratroopers and assaulting"},
324 {"fire_range_factor", floatset, (caddr_t)&fire_range_factor, 0,
325 "Scale normal firing ranges by this amount"},
326 {"sect_mob_neg_factor", intset, (caddr_t)§_mob_neg_factor, 0,
327 "Amount of negative mobility a sector has after takeover (ETU / x) (MOB_ACCESS)"},
328 {"mission_mob_cost", doubleset, (caddr_t)&mission_mob_cost, 0,
329 "Cost to put something on a mission (percentage of max mob)"},
331 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Populace"},
332 {"uwbrate", doubleset, (caddr_t)&uwbrate, 0,
333 "Birth rate for uw's"},
334 {"money_civ", doubleset, (caddr_t)&money_civ, 0,
335 "Money gained from taxes on a civilian in one ETU"},
336 {"money_mil", doubleset, (caddr_t)&money_mil, 0,
337 "Money gained from taxes on an active soldier in one ETU"},
338 {"money_res", doubleset, (caddr_t)&money_res, 0,
339 "Money gained from taxes on a soldier on active reserve in one ETU"},
340 {"money_uw", doubleset, (caddr_t)&money_uw, 0,
341 "Money gained from taxes on an uncompensated worker in one ETU"},
342 {"babyeat", doubleset, (caddr_t)&babyeat, 0,
343 "Amount of food to mature 1 baby into a civilian"},
344 {"bankint", doubleset, (caddr_t)&bankint, 0,
345 "Bank dollar gain (per bar per etu)"},
346 {"eatrate", doubleset, (caddr_t)&eatrate, 0,
347 "Food eating rate for mature people"},
348 {"fcrate", doubleset, (caddr_t)&fcrate, 0,
349 "Food cultivation rate (* workforce in sector)"},
350 {"fgrate", doubleset, (caddr_t)&fgrate, 0,
351 "Food growth rate (* fertility of sector)"},
352 {"obrate", doubleset, (caddr_t)&obrate, 0,
353 "Civilian birth rate"},
355 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Nukes"},
356 {"decay_per_etu", doubleset, (caddr_t)&decay_per_etu, 0,
357 "Decay of fallout per ETU"},
358 {"fallout_spread", doubleset, (caddr_t)&fallout_spread, 0,
359 "Amount of fallout that leaks into surrounding sectors"},
360 {"drnuke_const", floatset, (caddr_t)&drnuke_const, 0,
361 "Amount of research to tech needed to build a nuke (if DR_NUKE is on)"},
363 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Market/Trade"},
364 {"MARK_DELAY", intset, (caddr_t)&MARK_DELAY, 0,
365 "Number of seconds commodities stay on the market for bidding"},
366 {"TRADE_DELAY", intset, (caddr_t)&TRADE_DELAY, 0,
367 "Number of seconds ships, planes, and units stay on the market for bidding"},
368 {"maxmult", doubleset, (caddr_t)&maxmult, 0,
369 "Maximum trade multiple (used for mult command)"},
370 {"minmult", doubleset, (caddr_t)&minmult, 0,
371 "Minimum trade multiple (used for mult command)"},
372 {"buytax", doubleset, (caddr_t)&buytax, 0,
373 "Tax (in percentage points) charged to the buyer on market purchases"},
374 {"tradetax", doubleset, (caddr_t)&tradetax, 0,
375 "Amount of a trade transaction the seller makes (the rest is tax)"},
377 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Trade ships"},
378 {"trade_1_dist", intset, (caddr_t)&trade_1_dist, 0,
379 "Less than this distance no money for cashing in"},
380 {"trade_2_dist", intset, (caddr_t)&trade_2_dist, 0,
381 "Less than this distance gets trade_1 money for cashing in"},
382 {"trade_3_dist", intset, (caddr_t)&trade_3_dist, 0,
383 "Less than this distance gets trade_2 money for cashing in (>= gets trade_3"},
384 {"trade_1", floatset, (caddr_t)&trade_1, 0,
385 "Return per sector on trade_1 distance amount"},
386 {"trade_2", floatset, (caddr_t)&trade_2, 0,
387 "Return per sector on trade_2 distance amount"},
388 {"trade_3", floatset, (caddr_t)&trade_3, 0,
389 "Return per sector on trade_3 distance amount"},
390 {"trade_ally_bonus", floatset, (caddr_t)&trade_ally_bonus, 0,
391 "Bonus you get for cashing in with an ally"},
392 {"trade_ally_cut", floatset, (caddr_t)&trade_ally_cut, 0,
393 "Bonus your ally gets for you cashing in with them"},
395 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Misc."},
396 {"fuel_mult", intset, (caddr_t)&fuel_mult, 0,
397 "Multiplier for fuel to mobility calculation"},
398 {"lost_items_timeout", intset, (caddr_t)&lost_items_timeout, 0,
399 "Seconds before a lost item is timed out of the database"},
400 {"last_demand_update", longset, (caddr_t)&last_demand_update, 0,
401 "When was the last demand update occured"},
403 {NULL, NULL, (caddr_t)0, 0, NULL}
406 static void fixup_files(void);
407 static struct keymatch *keylookup(s_char *key, struct keymatch tbl[]);
411 * read in empire configuration
414 emp_config(char *file)
417 s_char scanspace[1024];
422 if (file == NULL || (fp = fopen(file, "r")) == NULL) {
426 while (fgets(buf, sizeof buf, fp) != NULL) {
427 if (buf[0] == '#' || buf[0] == '\n')
429 if (parse(buf, av, 0, scanspace, 0) < 0) {
430 fprintf(stderr, "Can't parse line %s", buf);
433 if ((kp = keylookup(av[0], configkeys)) != NULL) {
434 (*kp->km_func) (kp, av + 1);
436 fprintf(stderr, "Unknown config key %s\n", av[0]);
450 extern s_char *upfil, *downfil, *disablefil, *banfil, *authfil;
451 extern s_char *commfil, *annfil, *telfil, *teldir, *timestampfil;
453 /* list of other well known files... -maybe tailor these oneday
454 * anyway - meantime they are all relative to datadir */
455 static struct otherfiles ofiles[] = {
458 {&disablefil, "disable"},
463 {×tampfil, "timestamp"},
466 {&telfil, "tel/tel"},
468 {&telfil, "tel\\tel"},
473 /* fix up the empfile struct to reference full path names */
478 struct otherfiles *op;
481 for (ep = empfile; ep < &empfile[EF_MAX]; ep++) {
483 sprintf(buf, "%s/%s", datadir, ep->name);
485 sprintf(buf, "%s\\%s", datadir, ep->name);
487 ep->file = strdup(buf);
490 for (op = ofiles; op->files; op++) {
492 sprintf(buf, "%s/%s", datadir, op->name);
494 sprintf(buf, "%s\\%s", datadir, op->name);
496 *op->files = strdup(buf);
500 /* find the key in the table */
501 static struct keymatch *
502 keylookup(register s_char *command, struct keymatch *tbl)
504 register struct keymatch *kp;
506 if (command == 0 || *command == 0)
508 for (kp = tbl; kp->km_key != 0; kp++) {
509 if (strcmp(kp->km_key, command) == 0)
515 /* worldx int setting function */
517 worldxset(struct keymatch *kp, s_char **av)
519 int *intptr = (int *)kp->km_data;
521 if (*av == NULL || intptr == NULL)
524 if (!((*intptr % 2) == 0)) {
525 /* Must be div / 2, so subtract one */
526 *intptr = *intptr - 1;
530 /* generic int setting function */
532 intset(struct keymatch *kp, s_char **av)
534 int *intptr = (int *)kp->km_data;
536 if (*av == NULL || intptr == NULL)
541 /* generic float set function */
543 floatset(struct keymatch *kp, s_char **av)
545 float *floatptr = (float *)kp->km_data;
547 if (*av == NULL || floatptr == NULL)
549 *floatptr = atof(*av);
554 /* generic string set function */
556 optstrset(struct keymatch *kp, s_char **av)
558 s_char **confstrp = (s_char **)kp->km_data;
560 if (*av == NULL || confstrp == NULL)
562 if (kp->km_flags & KM_ALLOC)
564 *confstrp = strdup(*av);
565 kp->km_flags |= KM_ALLOC;
568 /* generic double set function */
570 doubleset(struct keymatch *kp, s_char **av)
572 double *doublep = (double *)kp->km_data;
574 if (*av == NULL || doublep == NULL)
576 *doublep = atof(*av);
579 /* generic long set function */
581 longset(struct keymatch *kp, s_char **av)
583 long int *longp = (long int *)kp->km_data;
585 if (*av == NULL || longp == NULL)
591 print_config(FILE * fp)
594 struct otherfiles *op;
597 fprintf(fp, "# Empire Configuration File:\n");
598 for (kp = configkeys; kp->km_key; kp++) {
599 /* We print a few special things here */
600 if (kp->km_comment) {
601 if (kp->km_comment[0]) {
602 if (kp->km_comment[0] != '\n')
604 fprintf(fp, "%s\n", kp->km_comment);
609 if (kp->km_func == optstrset) {
610 fprintf(fp, "%s \"%s\"\n", kp->km_key,
611 *(s_char **)kp->km_data);
612 } else if (kp->km_func == intset) {
613 fprintf(fp, "%s %d\n", kp->km_key, *(int *)kp->km_data);
614 } else if (kp->km_func == worldxset) {
615 fprintf(fp, "%s %d\n", kp->km_key, *(int *)kp->km_data);
616 } else if (kp->km_func == floatset) {
617 fprintf(fp, "%s %g\n", kp->km_key, *(float *)kp->km_data);
618 } else if (kp->km_func == doubleset) {
619 fprintf(fp, "%s %g\n", kp->km_key, *(double *)kp->km_data);
620 } else if (kp->km_func == longset) {
621 fprintf(fp, "%s %ld\n", kp->km_key, *(long *)kp->km_data);
622 } else if (kp->km_func == optionset) {
623 struct option_list *op;
625 for (op = Options; op->opt_key; op++) {
627 fprintf(fp, "%s %s\n", kp->km_key, op->opt_key);
629 } else if (kp->km_func == optiondel) {
630 struct option_list *op;
632 for (op = Options; op->opt_key; op++) {
633 if (*op->opt_valuep == 0)
634 fprintf(fp, "%s %s\n", kp->km_key, op->opt_key);
637 fprintf(fp, "# Unknown format %s\n", kp->km_key);
641 for (ep = empfile; ep < &empfile[EF_MAX]; ep++)
642 fprintf(fp, "# File %s -> %s\n", ep->name, ep->file);
643 for (op = ofiles; op->files; op++)
644 fprintf(fp, "# File %s -> %s\n", op->name, *(op->files));
649 /* add an option to the list */
651 set_option(const char *s)
653 struct option_list *op;
655 for (op = Options; op->opt_key; op++) {
656 if (strcmp(op->opt_key, s) == 0)
661 /* delete an option from the list */
663 delete_option(const char *s)
665 struct option_list *op;
667 for (op = Options; op->opt_key; op++) {
668 if (strcmp(op->opt_key, s) == 0)
673 /* config interface */
675 optionset(struct keymatch *kp, s_char **av)
676 /* unused - we have a well known global */
680 for (cpp = (char **)av; *cpp; cpp++)
684 /* config interface */
686 optiondel(struct keymatch *kp, s_char **av)
687 /* unused - we have a well known global */
691 for (cpp = (char **)av; *cpp; cpp++)