#endif /* EMP_CONFIG_C_OUTPUT || EMP_CONFIG_H_OUTPUT */
#define EMPCF_COMMENT(comment) \
-EMPCFONLYC("", emp_config_dummy, , intset, 0, (comment))
+EMPCFONLYC("", emp_config_dummy, , NSC_NOTYPE, 0, (comment))
/* things that can be changed */
EMPCF_COMMENT("\n### Server configuration and information")
-EMPCFBOTH("data", datadir, s_char *, optstrset, 0,
+EMPCFBOTH("data", datadir, char *, NSC_STRING, KM_INTERNAL,
"Directory the data is stored in")
-EMPCFBOTH("info", infodir, s_char *, optstrset, 0,
+EMPCFBOTH("info", infodir, char *, NSC_STRING, KM_INTERNAL,
"Directory the info pages are stored in")
-EMPCFBOTH("port", loginport, s_char *, optstrset, 0,
+EMPCFBOTH("port", loginport, char *, NSC_STRING, KM_INTERNAL,
"TCP/IP port the server will start up on")
-EMPCFBOTH("privname", privname, s_char *, optstrset, 0,
+EMPCFBOTH("privname", privname, char *, NSC_STRING, 0,
"Name of the deity")
-EMPCFBOTH("privlog", privlog, s_char *, optstrset, 0,
+EMPCFBOTH("privlog", privlog, char *, NSC_STRING, 0,
"E-mail of the deity")
-EMPCFBOTH("WORLD_X", WORLD_X, int, worldxset, 0,
+EMPCFBOTH("WORLD_X", WORLD_X, int, NSC_INT, 0,
"World size X dimension (enforced to be even by subtracting 1 if necessary)")
-EMPCFBOTH("WORLD_Y", WORLD_Y, int, intset, 0,
+EMPCFBOTH("WORLD_Y", WORLD_Y, int, NSC_INT, 0,
"World size Y dimension")
EMPCF_COMMENT("\n\n### Update policy")
-EMPCFBOTH("update_policy", update_policy, int, intset, 0,
+EMPCFBOTH("update_policy", update_policy, int, NSC_INT, 0,
"0 - normal, 1 - update_times, 2 - blitz, 3 - demand only")
-EMPCFBOTH("etu_per_update", etu_per_update, int, intset, 0,
+EMPCFBOTH("etu_per_update", etu_per_update, int, NSC_INT, 0,
"Number of ETUs per update")
-EMPCFBOTH("s_p_etu", s_p_etu, int, intset, 0,
+EMPCFBOTH("s_p_etu", s_p_etu, int, NSC_INT, 0,
"Seconds per etu, updates will occur every s_p_etu * etu_per_update seconds")
-EMPCFBOTH("adj_update", adj_update, int, intset, 0,
+EMPCFBOTH("adj_update", adj_update, int, NSC_INT, KM_INTERNAL,
"Move the update forward or backward (in seconds)")
-EMPCFBOTH("update_window", update_window, int, intset, 0,
+EMPCFBOTH("update_window", update_window, int, NSC_INT, 0,
"Window the update will occur in (in seconds) before and after the update time")
-EMPCFBOTH("update_times", update_times, s_char *, optstrset, 0,
+EMPCFBOTH("update_times", update_times, char *, NSC_STRING, 0,
"Times when updates occur under policy #1. Must coincide with schedule.")
-EMPCFBOTH("hourslop", hourslop, int, intset, 0,
+EMPCFBOTH("hourslop", hourslop, int, NSC_INT, KM_INTERNAL,
"Number of minutes update check can slip to match update_times")
-EMPCFBOTH("blitz_time", blitz_time, int, intset, 0,
+EMPCFBOTH("blitz_time", blitz_time, int, NSC_INT, 0,
"Number of minutes between updates under policy #2.")
EMPCF_COMMENT("\n\n### Demand update policy")
-EMPCFBOTH("update_demandpolicy", update_demandpolicy, int, intset, 0,
+EMPCFBOTH("update_demandpolicy", update_demandpolicy, int, NSC_INT, 0,
"0 - emp_tm checks, 1 - after setting, 2 - demand updates disabled")
-EMPCFBOTH("update_wantmin", update_wantmin, int, intset, 0,
+EMPCFBOTH("update_wantmin", update_wantmin, int, NSC_INT, 0,
"number of requests needed for demand update")
-EMPCFBOTH("update_missed", update_missed, int, intset, 0,
+EMPCFBOTH("update_missed", update_missed, int, NSC_INT, 0,
"number of demand updates country can miss before veto update")
-EMPCFBOTH("update_demandtimes", update_demandtimes, s_char *, optstrset, 0,
+EMPCFBOTH("update_demandtimes", update_demandtimes, char *, NSC_STRING, 0,
"Times when demand updates can occur. Ranges CANNOT cross midnight.")
EMPCF_COMMENT("\n\n### Game hours restrictions")
-EMPCFBOTH("game_days", game_days, s_char *, optstrset, 0,
+EMPCFBOTH("game_days", game_days, char *, NSC_STRING, 0,
"Days game is up and running (Su Mo Tu We Th Fr Sa)")
-EMPCFBOTH("game_hours", game_hours, s_char *, optstrset, 0,
+EMPCFBOTH("game_hours", game_hours, char *, NSC_STRING, 0,
"Hours game is up and running (6:00-18:00)")
EMPCF_COMMENT("\n\n### Options\n")
-EMPCFONLYC("option", emp_config_dummy, , optionset, 0, NULL)
-EMPCFONLYC("nooption", emp_config_dummy, , optiondel, 0, NULL)
+EMPCFONLYC("option", emp_config_dummy, , NSC_NOTYPE, 0, NULL)
+EMPCFONLYC("nooption", emp_config_dummy, , NSC_NOTYPE, 0, NULL)
EMPCF_COMMENT("\n\n### Countries")
-EMPCFBOTH("btu_build_rate", btu_build_rate, float, floatset, 0,
+EMPCFBOTH("btu_build_rate", btu_build_rate, float, NSC_FLOAT, 0,
"Rate at which BTUs accumulate (etu * civ * eff * btu_build_rate)")
-EMPCFBOTH("m_m_p_d", m_m_p_d, int, intset, 0,
+EMPCFBOTH("m_m_p_d", m_m_p_d, int, NSC_INT, 0,
"Maximum minutes per day a country is allowed to be logged in")
-EMPCFBOTH("max_btus", max_btus, int, intset, 0,
+EMPCFBOTH("max_btus", max_btus, int, NSC_INT, 0,
"Maximum number of BTUs a country can have")
-EMPCFBOTH("max_idle", max_idle, int, intset, 0,
+EMPCFBOTH("max_idle", max_idle, int, NSC_INT, 0,
"Maximum number of minutes a player can sit idle while logged in")
-EMPCFBOTH("players_at_00", players_at_00, int, intset, 0,
+EMPCFBOTH("players_at_00", players_at_00, int, NSC_INT, 0,
"Players have their coordinate system at deity 0,0 (0 - no, 1 - yes)")
-EMPCFBOTH("at_least_one_100", at_least_one_100, int, intset, 0,
+EMPCFBOTH("at_least_one_100", at_least_one_100, int, NSC_INT, KM_INTERNAL,
"Initialize new countries with at least one sector with 100 of all resource")
-EMPCFBOTH("powe_cost", powe_cost, double, doubleset, 0,
+EMPCFBOTH("powe_cost", powe_cost, double, NSC_DOUBLE, 0,
"Number of BTUs needed to generate a new power report")
-EMPCFBOTH("war_cost", War_Cost, int, intset, 0,
+EMPCFBOTH("war_cost", War_Cost, int, NSC_INT, 0,
"Cost to declare war (if SLOW_WAR is on)")
EMPCF_COMMENT("\n\n### Technology/Research/Education/Happiness")
-EMPCFBOTH("easy_tech", easy_tech, float, floatset, 0,
+EMPCFBOTH("easy_tech", easy_tech, float, NSC_FLOAT, 0,
"Amount of tech built with no penalty")
-EMPCFBOTH("start_tech", start_technology, float, floatset, 0,
+EMPCFBOTH("start_tech", start_technology, float, NSC_FLOAT, KM_INTERNAL,
"Starting technology for new countries")
-EMPCFBOTH("start_happy", start_happiness, float, floatset, 0,
+EMPCFBOTH("start_happy", start_happiness, float, NSC_FLOAT, KM_INTERNAL,
"Starting happiness for new countries")
-EMPCFBOTH("start_research", start_research, float, floatset, 0,
+EMPCFBOTH("start_research", start_research, float, NSC_FLOAT, KM_INTERNAL,
"Starting research for new countries")
-EMPCFBOTH("start_edu", start_education, float, floatset, 0,
+EMPCFBOTH("start_edu", start_education, float, NSC_FLOAT, KM_INTERNAL,
"Starting education for new countries")
-EMPCFBOTH("level_age_rate", level_age_rate, float, floatset, 0,
+EMPCFBOTH("level_age_rate", level_age_rate, float, NSC_FLOAT, 0,
"ETU rate at which tech decays (0 -> no decline)")
-EMPCFBOTH("tech_log_base", tech_log_base, float, floatset, 0,
+EMPCFBOTH("tech_log_base", tech_log_base, float, NSC_FLOAT, 0,
"Log base to apply to tech breakthroughs above the easy tech level")
-EMPCFBOTH("ally_factor", ally_factor, float, floatset, 0,
+EMPCFBOTH("ally_factor", ally_factor, float, NSC_FLOAT, 0,
"Shared tech with allies (1 / ally_factor)")
-EMPCFBOTH("edu_avg", edu_avg, float, floatset, 0,
+EMPCFBOTH("edu_avg", edu_avg, float, NSC_FLOAT, 0,
"Number of ETUs education is averaged over")
-EMPCFBOTH("hap_avg", hap_avg, float, floatset, 0,
+EMPCFBOTH("hap_avg", hap_avg, float, NSC_FLOAT, 0,
"Number of ETUs happiness is averaged over")
-EMPCFBOTH("edu_cons", edu_cons, double, doubleset, 0,
+EMPCFBOTH("edu_cons", edu_cons, double, NSC_DOUBLE, 0,
"Education consumption (1 breakthrough per edu_cons)")
-EMPCFBOTH("hap_cons", hap_cons, double, doubleset, 0,
+EMPCFBOTH("hap_cons", hap_cons, double, NSC_DOUBLE, 0,
"Happiness consumption (1 breakthrough per hap_cons)")
EMPCF_COMMENT("\n\n### Sectors")
-EMPCFBOTH("startmob", startmob, int, intset, 0,
+EMPCFBOTH("startmob", startmob, int, NSC_INT, KM_INTERNAL,
"Starting mobility for sanctuaries")
-EMPCFBOTH("sect_mob_scale", sect_mob_scale, float, floatset, 0,
+EMPCFBOTH("sect_mob_scale", sect_mob_scale, float, NSC_FLOAT, 0,
"Sector mobility accumulation (sect_mob_scale * ETUs per update)")
-EMPCFBOTH("sect_mob_max", sect_mob_max, int, intset, 0,
+EMPCFBOTH("sect_mob_max", sect_mob_max, int, NSC_INT, 0,
"Maximum mobility for sectors")
-EMPCFBOTH("buil_bh", buil_bh, int, intset, 0,
+EMPCFBOTH("buil_bh", buil_bh, int, NSC_INT, 0,
"Number of hcms required to build a bridge span")
-EMPCFBOTH("buil_bc", buil_bc, double, doubleset, 0,
+EMPCFBOTH("buil_bc", buil_bc, double, NSC_DOUBLE, 0,
"Cash required to build a bridge span")
-EMPCFBOTH("buil_bt", buil_bt, double, doubleset, 0,
+EMPCFBOTH("buil_bt", buil_bt, double, NSC_DOUBLE, 0,
"Technology required to build a bridge span")
-EMPCFBOTH("buil_tower_bh", buil_tower_bh, int, intset, 0,
+EMPCFBOTH("buil_tower_bh", buil_tower_bh, int, NSC_INT, 0,
"Number of hcms required to build a bridge tower")
-EMPCFBOTH("buil_tower_bc", buil_tower_bc, double, doubleset, 0,
+EMPCFBOTH("buil_tower_bc", buil_tower_bc, double, NSC_DOUBLE, 0,
"Cash required to build a bridge tower")
-EMPCFBOTH("buil_tower_bt", buil_tower_bt, double, doubleset, 0,
+EMPCFBOTH("buil_tower_bt", buil_tower_bt, double, NSC_DOUBLE, 0,
"Technology required to build a bridge tower")
EMPCF_COMMENT("\n\n### Land Units")
-EMPCFBOTH("land_mob_scale", land_mob_scale, float, floatset, 0,
+EMPCFBOTH("land_mob_scale", land_mob_scale, float, NSC_FLOAT, 0,
"Land unit mobility accumulation (land_mob_scale * ETUs per update)")
-EMPCFBOTH("land_grow_scale", land_grow_scale, int, intset, 0,
+EMPCFBOTH("land_grow_scale", land_grow_scale, int, NSC_INT, 0,
"How fast efficiency grows for land units each update (* ETUs)")
-EMPCFBOTH("land_mob_max", land_mob_max, int, intset, 0,
+EMPCFBOTH("land_mob_max", land_mob_max, int, NSC_INT, 0,
"Maximum mobility for land units")
-EMPCFBOTH("money_land", money_land, double, doubleset, 0,
+EMPCFBOTH("money_land", money_land, double, NSC_DOUBLE, 0,
"Cost per ETU to maintain land units (percentage of unit price)")
-EMPCFBOTH("morale_base", morale_base, int, intset, 0,
+EMPCFBOTH("morale_base", morale_base, int, NSC_INT, KM_INTERNAL,
"Base level for setting morale of land units")
EMPCF_COMMENT("\n\n### Planes")
-EMPCFBOTH("plane_mob_scale", plane_mob_scale, float, floatset, 0,
+EMPCFBOTH("plane_mob_scale", plane_mob_scale, float, NSC_FLOAT, 0,
"Plane mobility accumulation (plane_mob_scale * ETUs per update)")
-EMPCFBOTH("plane_grow_scale", plane_grow_scale, int, intset, 0,
+EMPCFBOTH("plane_grow_scale", plane_grow_scale, int, NSC_INT, 0,
"How fast efficiency grows for planes each update (* ETUs)")
-EMPCFBOTH("plane_mob_max", plane_mob_max, int, intset, 0,
+EMPCFBOTH("plane_mob_max", plane_mob_max, int, NSC_INT, 0,
"Maximum mobility for planes")
-EMPCFBOTH("money_plane", money_plane, double, doubleset, 0,
+EMPCFBOTH("money_plane", money_plane, double, NSC_DOUBLE, 0,
"Cost per ETU to maintain planes (percentage of plane price)")
EMPCF_COMMENT("\n\n### Ships")
-EMPCFBOTH("ship_mob_scale", ship_mob_scale, float, floatset, 0,
+EMPCFBOTH("ship_mob_scale", ship_mob_scale, float, NSC_FLOAT, 0,
"Ship mobility accumulation (ship_mob_scale * ETUs per update)")
-EMPCFBOTH("ship_grow_scale", ship_grow_scale, int, intset, 0,
+EMPCFBOTH("ship_grow_scale", ship_grow_scale, int, NSC_INT, 0,
"How fast efficiency grows for ships each update (* ETUs)")
-EMPCFBOTH("ship_mob_max", ship_mob_max, int, intset, 0,
+EMPCFBOTH("ship_mob_max", ship_mob_max, int, NSC_INT, 0,
"Maximum mobility for ships")
-EMPCFBOTH("money_ship", money_ship, double, doubleset, 0,
+EMPCFBOTH("money_ship", money_ship, double, NSC_DOUBLE, 0,
"Cost per ETU to maintain ships (percentage of ship price)")
-EMPCFBOTH("torpedo_damage", torpedo_damage, int, intset, 0,
+EMPCFBOTH("torpedo_damage", torpedo_damage, int, NSC_INT, 0,
"Torpedo damage (damage is X + 1dX + 1dX)")
EMPCF_COMMENT("\n\n### Combat/Damage")
-EMPCFBOTH("fort_max_interdiction_range", fort_max_interdiction_range, int, intset, 0,
+EMPCFBOTH("fort_max_interdiction_range", fort_max_interdiction_range, int, NSC_INT, 0,
"Maximum range (in sectors) a fort will try to interdict another country")
-EMPCFBOTH("land_max_interdiction_range", land_max_interdiction_range, int, intset, 0,
+EMPCFBOTH("land_max_interdiction_range", land_max_interdiction_range, int, NSC_INT, 0,
"Maximum range (in sectors) a land unit will try to interdict another country")
-EMPCFBOTH("ship_max_interdiction_range", ship_max_interdiction_range, int, intset, 0,
+EMPCFBOTH("ship_max_interdiction_range", ship_max_interdiction_range, int, NSC_INT, 0,
"Maximum range (in sectors) a ship will try to interdict another country")
-EMPCFBOTH("flakscale", flakscale, double, doubleset, 0,
+EMPCFBOTH("flakscale", flakscale, double, NSC_DOUBLE, 0,
"Scale factor for flak damage")
-EMPCFBOTH("combat_mob", combat_mob, double, doubleset, 0,
+EMPCFBOTH("combat_mob", combat_mob, double, NSC_DOUBLE, 0,
"How much mobility do units spend for combat (* casualties/bodies)")
-EMPCFBOTH("people_damage", people_damage, double, doubleset, 0,
+EMPCFBOTH("people_damage", people_damage, double, NSC_DOUBLE, 0,
"People take this amount of normal damage")
-EMPCFBOTH("unit_damage", unit_damage, double, doubleset, 0,
+EMPCFBOTH("unit_damage", unit_damage, double, NSC_DOUBLE, 0,
"Land units take this amount of normal damage")
-EMPCFBOTH("collateral_dam", collateral_dam, double, doubleset, 0,
+EMPCFBOTH("collateral_dam", collateral_dam, double, NSC_DOUBLE, 0,
"Side effect damage amount done to sector")
-EMPCFBOTH("assault_penalty", assault_penalty, double, doubleset, 0,
+EMPCFBOTH("assault_penalty", assault_penalty, double, NSC_DOUBLE, 0,
"Amount of normal attacking efficiency for paratroopers and assaulting")
-EMPCFBOTH("fire_range_factor", fire_range_factor, float, floatset, 0,
+EMPCFBOTH("fire_range_factor", fire_range_factor, float, NSC_FLOAT, 0,
"Scale normal firing ranges by this amount")
-EMPCFBOTH("sect_mob_neg_factor", sect_mob_neg_factor, int, intset, 0,
+EMPCFBOTH("sect_mob_neg_factor", sect_mob_neg_factor, int, NSC_INT, 0,
"Amount of negative mobility a sector has after takeover (ETU / x) (MOB_ACCESS)")
-EMPCFBOTH("mission_mob_cost", mission_mob_cost, double, doubleset, 0,
+EMPCFBOTH("mission_mob_cost", mission_mob_cost, double, NSC_DOUBLE, 0,
"Cost to put something on a mission (percentage of max mob)")
EMPCF_COMMENT("\n\n### Populace")
-EMPCFBOTH("uwbrate", uwbrate, double, doubleset, 0,
+EMPCFBOTH("uwbrate", uwbrate, double, NSC_DOUBLE, 0,
"Birth rate for uw's")
-EMPCFBOTH("money_civ", money_civ, double, doubleset, 0,
+EMPCFBOTH("money_civ", money_civ, double, NSC_DOUBLE, 0,
"Money gained from taxes on a civilian in one ETU")
-EMPCFBOTH("money_mil", money_mil, double, doubleset, 0,
+EMPCFBOTH("money_mil", money_mil, double, NSC_DOUBLE, 0,
"Money gained from taxes on an active soldier in one ETU")
-EMPCFBOTH("money_res", money_res, double, doubleset, 0,
+EMPCFBOTH("money_res", money_res, double, NSC_DOUBLE, 0,
"Money gained from taxes on a soldier on active reserve in one ETU")
-EMPCFBOTH("money_uw", money_uw, double, doubleset, 0,
+EMPCFBOTH("money_uw", money_uw, double, NSC_DOUBLE, 0,
"Money gained from taxes on an uncompensated worker in one ETU")
-EMPCFBOTH("babyeat", babyeat, double, doubleset, 0,
+EMPCFBOTH("babyeat", babyeat, double, NSC_DOUBLE, 0,
"Amount of food to mature 1 baby into a civilian")
-EMPCFBOTH("bankint", bankint, double, doubleset, 0,
+EMPCFBOTH("bankint", bankint, double, NSC_DOUBLE, 0,
"Bank dollar gain (per bar per etu)")
-EMPCFBOTH("eatrate", eatrate, double, doubleset, 0,
+EMPCFBOTH("eatrate", eatrate, double, NSC_DOUBLE, 0,
"Food eating rate for mature people")
-EMPCFBOTH("fcrate", fcrate, double, doubleset, 0,
+EMPCFBOTH("fcrate", fcrate, double, NSC_DOUBLE, 0,
"Food cultivation rate (* workforce in sector)")
-EMPCFBOTH("fgrate", fgrate, double, doubleset, 0,
+EMPCFBOTH("fgrate", fgrate, double, NSC_DOUBLE, 0,
"Food growth rate (* fertility of sector)")
-EMPCFBOTH("obrate", obrate, double, doubleset, 0,
+EMPCFBOTH("obrate", obrate, double, NSC_DOUBLE, 0,
"Civilian birth rate")
-EMPCFBOTH("rollover_avail_max", rollover_avail_max, int, intset, 0,
+EMPCFBOTH("rollover_avail_max", rollover_avail_max, int, NSC_INT, 0,
"Maximum avail that can roll over an update")
EMPCF_COMMENT("\n\n### Nukes")
-EMPCFBOTH("decay_per_etu", decay_per_etu, double, doubleset, 0,
+EMPCFBOTH("decay_per_etu", decay_per_etu, double, NSC_DOUBLE, 0,
"Decay of fallout per ETU")
-EMPCFBOTH("fallout_spread", fallout_spread, double, doubleset, 0,
+EMPCFBOTH("fallout_spread", fallout_spread, double, NSC_DOUBLE, 0,
"Amount of fallout that leaks into surrounding sectors")
-EMPCFBOTH("drnuke_const", drnuke_const, float, floatset, 0,
+EMPCFBOTH("drnuke_const", drnuke_const, float, NSC_FLOAT, 0,
"Amount of research to tech needed to build a nuke (if DR_NUKE is on)")
EMPCF_COMMENT("\n\n### Market/Trade")
-EMPCFBOTH("MARK_DELAY", MARK_DELAY, int, intset, 0,
+EMPCFBOTH("MARK_DELAY", MARK_DELAY, int, NSC_INT, 0,
"Number of seconds commodities stay on the market for bidding")
-EMPCFBOTH("TRADE_DELAY", TRADE_DELAY, int, intset, 0,
+EMPCFBOTH("TRADE_DELAY", TRADE_DELAY, int, NSC_INT, 0,
"Number of seconds ships, planes, and units stay on the market for bidding")
-EMPCFBOTH("buytax", buytax, double, doubleset, 0,
+EMPCFBOTH("buytax", buytax, double, NSC_DOUBLE, 0,
"Tax (in percentage points) charged to the buyer on market purchases")
-EMPCFBOTH("tradetax", tradetax, double, doubleset, 0,
+EMPCFBOTH("tradetax", tradetax, double, NSC_DOUBLE, 0,
"Amount of a trade transaction the seller makes (the rest is tax)")
EMPCF_COMMENT("\n\n### Trade ships")
-EMPCFBOTH("trade_1_dist", trade_1_dist, int, intset, 0,
+EMPCFBOTH("trade_1_dist", trade_1_dist, int, NSC_INT, 0,
"Less than this distance no money for cashing in")
-EMPCFBOTH("trade_2_dist", trade_2_dist, int, intset, 0,
+EMPCFBOTH("trade_2_dist", trade_2_dist, int, NSC_INT, 0,
"Less than this distance gets trade_1 money for cashing in")
-EMPCFBOTH("trade_3_dist", trade_3_dist, int, intset, 0,
+EMPCFBOTH("trade_3_dist", trade_3_dist, int, NSC_INT, 0,
"Less than this distance gets trade_2 money for cashing in (>= gets trade_3")
-EMPCFBOTH("trade_1", trade_1, float, floatset, 0,
+EMPCFBOTH("trade_1", trade_1, float, NSC_FLOAT, 0,
"Return per sector on trade_1 distance amount")
-EMPCFBOTH("trade_2", trade_2, float, floatset, 0,
+EMPCFBOTH("trade_2", trade_2, float, NSC_FLOAT, 0,
"Return per sector on trade_2 distance amount")
-EMPCFBOTH("trade_3", trade_3, float, floatset, 0,
+EMPCFBOTH("trade_3", trade_3, float, NSC_FLOAT, 0,
"Return per sector on trade_3 distance amount")
-EMPCFBOTH("trade_ally_bonus", trade_ally_bonus, float, floatset, 0,
+EMPCFBOTH("trade_ally_bonus", trade_ally_bonus, float, NSC_FLOAT, 0,
"Bonus you get for cashing in with an ally")
-EMPCFBOTH("trade_ally_cut", trade_ally_cut, float, floatset, 0,
+EMPCFBOTH("trade_ally_cut", trade_ally_cut, float, NSC_FLOAT, 0,
"Bonus your ally gets for you cashing in with them")
EMPCF_COMMENT("\n\n### Misc.")
-EMPCFBOTH("anno_keep_days", anno_keep_days, int, intset, 0,
+EMPCFBOTH("anno_keep_days", anno_keep_days, int, NSC_INT, KM_INTERNAL,
"How long until announcements expire (<0 means never)")
-EMPCFBOTH("fuel_mult", fuel_mult, int, intset, 0,
+EMPCFBOTH("fuel_mult", fuel_mult, int, NSC_INT, 0,
"Multiplier for fuel to mobility calculation")
-EMPCFBOTH("lost_items_timeout", lost_items_timeout, int, intset, 0,
+EMPCFBOTH("lost_items_timeout", lost_items_timeout, int, NSC_INT, KM_INTERNAL,
"Seconds before a lost item is timed out of the database")
-EMPCFONLYC(NULL, emp_config_dummy, NULL, NULL, 0, NULL)
+EMPCFONLYC(NULL, emp_config_dummy, NULL, NSC_NOTYPE, 0, NULL)
#undef EMPCFONLYC
#undef EMPCFBOTH
*
*/
+#include <assert.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h> /* atoi free atol */
#include <string.h>
/* Dummy one */
static int emp_config_dummy;
-static void optstrset(struct keymatch *kp, s_char **av);
-static void intset(struct keymatch *kp, s_char **av);
-static void floatset(struct keymatch *kp, s_char **av);
-static void doubleset(struct keymatch *kp, s_char **av);
-static void longset(struct keymatch *kp, s_char **av);
-static void optionset(struct keymatch *kp, s_char **av);
-static void optiondel(struct keymatch *kp, s_char **av);
-static void worldxset(struct keymatch *kp, s_char **av);
-
/* things that can be changed */
struct keymatch configkeys[] = {
#define EMP_CONFIG_C_OUTPUT
static void fixup_files(void);
static struct keymatch *keylookup(s_char *key, struct keymatch tbl[]);
-
+static int set_option(const char *, int);
/*
* read in empire configuration
emp_config(char *file)
{
FILE *fp;
- s_char scanspace[1024];
- s_char *av[65];
+ char scanspace[1024];
+ char *av[65];
char buf[BUFSIZ];
struct keymatch *kp;
+ int lno = 0;
+ int errors = 0;
+ int i;
- if (file == NULL || (fp = fopen(file, "r")) == NULL) {
+ if (file == NULL) {
fixup_files();
- return RET_OK;
+ return 0;
}
+ if ((fp = fopen(file, "r")) == NULL) {
+ fprintf(stderr, "Can't open %s for reading (%s)\n",
+ file, strerror(errno));
+ return -1;
+ }
+
while (fgets(buf, sizeof buf, fp) != NULL) {
- if (buf[0] == '#' || buf[0] == '\n')
+ ++lno;
+ for (i = 0; buf[i] && isspace(buf[i]); ++i) ;
+ if (!buf[i] || buf[i] == '#')
continue;
if (parse(buf, av, 0, scanspace, 0) < 0) {
- fprintf(stderr, "Can't parse line %s", buf);
+ fprintf(stderr, "%s:%d: Can't parse line %s", file, lno, buf);
+ errors = 1;
continue;
}
- if ((kp = keylookup(av[0], configkeys)) != NULL) {
- (*kp->km_func) (kp, av + 1);
- } else {
- fprintf(stderr, "Unknown config key %s\n", av[0]);
+ if ((kp = keylookup(av[0], configkeys)) == NULL) {
+ fprintf(stderr, "%s:%d: Unknown config key %s\n",
+ file, lno, av[0]);
+ errors = 1;
+ continue;
+ }
+ if (av[1] == NULL) {
+ fprintf(stderr, "%s:%d: Config key %s needs a value\n",
+ file, lno, av[0]);
+ errors = 1;
+ continue;
+ }
+ i = 2;
+ switch (kp->km_type) {
+ case NSC_INT:
+ *(int *)kp->km_data = atoi(av[1]);
+ break;
+ case NSC_FLOAT:
+ *(float *)kp->km_data = atof(av[1]);
+ break;
+ case NSC_DOUBLE:
+ *(double *)kp->km_data = atof(av[1]);
+ break;
+ case NSC_LONG:
+ *(long *)kp->km_data = atol(av[1]);
+ break;
+ case NSC_STRING:
+ if (kp->km_flags & KM_ALLOC)
+ free(*(char **)kp->km_data);
+ *(char **)kp->km_data = strdup(av[1]);
+ kp->km_flags |= KM_ALLOC;
+ break;
+ case NSC_NOTYPE:
+ for (i = 1; av[i]; ++i) {
+ if (set_option(av[i], kp->km_key[0] != 'n') < 0) {
+ fprintf(stderr, "%s:%d: Unknown option %s\n",
+ file, lno, av[i]);
+ errors = 1;
+ }
+ }
+ break;
+ default:
+ assert(0);
+ }
+ if (av[i] != NULL) {
+ fprintf(stderr, "%s:%d: Junk after value of config key %s\n",
+ file, lno, av[0]);
+ errors = 1;
}
}
fclose(fp);
fixup_files();
+ WORLD_X &= ~1; /* make even */
- return RET_OK;
+ return -errors;
}
struct otherfiles {
- s_char **files;
+ char **files;
char *name;
};
return NULL;
}
-/* worldx int setting function */
-static void
-worldxset(struct keymatch *kp, s_char **av)
-{
- int *intptr = (int *)kp->km_data;
-
- if (*av == NULL || intptr == NULL)
- return;
- *intptr = atoi(*av);
- if (!((*intptr % 2) == 0)) {
- /* Must be div / 2, so subtract one */
- *intptr = *intptr - 1;
- }
-}
-
-/* generic int setting function */
-static void
-intset(struct keymatch *kp, s_char **av)
-{
- int *intptr = (int *)kp->km_data;
-
- if (*av == NULL || intptr == NULL)
- return;
- *intptr = atoi(*av);
-}
-
-/* generic float set function */
-static void
-floatset(struct keymatch *kp, s_char **av)
-{
- float *floatptr = (float *)kp->km_data;
-
- if (*av == NULL || floatptr == NULL)
- return;
- *floatptr = atof(*av);
-}
-
-
-
-/* generic string set function */
-static void
-optstrset(struct keymatch *kp, s_char **av)
-{
- s_char **confstrp = (s_char **)kp->km_data;
-
- if (*av == NULL || confstrp == NULL)
- return;
- if (kp->km_flags & KM_ALLOC)
- free(*confstrp);
- *confstrp = strdup(*av);
- kp->km_flags |= KM_ALLOC;
-}
-
-/* generic double set function */
-static void
-doubleset(struct keymatch *kp, s_char **av)
-{
- double *doublep = (double *)kp->km_data;
-
- if (*av == NULL || doublep == NULL)
- return;
- *doublep = atof(*av);
-}
-
-/* generic long set function */
-static void
-longset(struct keymatch *kp, s_char **av)
-{
- long int *longp = (long int *)kp->km_data;
-
- if (*av == NULL || longp == NULL)
- return;
- *longp = atol(*av);
-}
-
void
-print_config(FILE * fp)
+print_config(FILE *fp)
{
struct empfile *ep;
- struct otherfiles *op;
+ struct option_list *op;
+ struct otherfiles *ofp;
struct keymatch *kp;
fprintf(fp, "# Empire Configuration File:\n");
for (kp = configkeys; kp->km_key; kp++) {
- /* We print a few special things here */
- if (kp->km_comment) {
- if (kp->km_comment[0]) {
- if (kp->km_comment[0] != '\n')
- fprintf(fp, "\n# ");
- fprintf(fp, "%s\n", kp->km_comment);
- }
- }
+ if (kp->km_comment)
+ fprintf(fp, "\n# %s\n", kp->km_comment);
if (!kp->km_key[0])
continue;
- if (kp->km_func == optstrset) {
- fprintf(fp, "%s \"%s\"\n", kp->km_key,
- *(s_char **)kp->km_data);
- } else if (kp->km_func == intset) {
+ switch (kp->km_type) {
+ case NSC_STRING:
+ fprintf(fp, "%s \"%s\"\n", kp->km_key, *(char **)kp->km_data);
+ break;
+ case NSC_INT:
fprintf(fp, "%s %d\n", kp->km_key, *(int *)kp->km_data);
- } else if (kp->km_func == worldxset) {
- fprintf(fp, "%s %d\n", kp->km_key, *(int *)kp->km_data);
- } else if (kp->km_func == floatset) {
+ break;
+ case NSC_FLOAT:
fprintf(fp, "%s %g\n", kp->km_key, *(float *)kp->km_data);
- } else if (kp->km_func == doubleset) {
+ break;
+ case NSC_DOUBLE:
fprintf(fp, "%s %g\n", kp->km_key, *(double *)kp->km_data);
- } else if (kp->km_func == longset) {
+ break;
+ case NSC_LONG:
fprintf(fp, "%s %ld\n", kp->km_key, *(long *)kp->km_data);
- } else if (kp->km_func == optionset) {
- struct option_list *op;
-
- for (op = Options; op->opt_key; op++) {
- if (*op->opt_valuep)
- fprintf(fp, "%s %s\n", kp->km_key, op->opt_key);
- }
- } else if (kp->km_func == optiondel) {
- struct option_list *op;
-
- for (op = Options; op->opt_key; op++) {
- if (*op->opt_valuep == 0)
+ break;
+ case NSC_NOTYPE:
+ for (op = Options; op->opt_key; op++)
+ if (*op->opt_valuep != (kp->km_key[0] == 'n'))
fprintf(fp, "%s %s\n", kp->km_key, op->opt_key);
- }
- } else
- fprintf(fp, "# Unknown format %s\n", kp->km_key);
+ break;
+ default:
+ assert(0);
+ }
}
fprintf(fp, "\n");
for (ep = empfile; ep < &empfile[EF_MAX]; ep++)
fprintf(fp, "# File %s -> %s\n", ep->name, ep->file);
- for (op = ofiles; op->files; op++)
- fprintf(fp, "# File %s -> %s\n", op->name, *(op->files));
+ for (ofp = ofiles; ofp->files; ofp++)
+ fprintf(fp, "# File %s -> %s\n", ofp->name, *(ofp->files));
}
-/* add an option to the list */
-static void
-set_option(const char *s)
-{
- struct option_list *op;
-
- for (op = Options; op->opt_key; op++) {
- if (strcmp(op->opt_key, s) == 0) {
- *op->opt_valuep = 1;
- return;
- }
- }
- fprintf(stderr, "Unknown option %s\n", s);
-}
-
-/* delete an option from the list */
-static void
-delete_option(const char *s)
+/* Set option S to value VAL; return 0 on success, -1 on failure. */
+static int
+set_option(const char *s, int val)
{
struct option_list *op;
for (op = Options; op->opt_key; op++) {
if (strcmp(op->opt_key, s) == 0) {
- *op->opt_valuep = 0;
- return;
+ *op->opt_valuep = val;
+ return 0;
}
}
- fprintf(stderr, "Unknown option %s\n", s);
-}
-
-/* config interface */
-static void
-optionset(struct keymatch *kp, s_char **av)
- /* unused - we have a well known global */
-{
- char **cpp;
-
- for (cpp = (char **)av; *cpp; cpp++)
- set_option(*cpp);
-}
-
-/* config interface */
-static void
-optiondel(struct keymatch *kp, s_char **av)
- /* unused - we have a well known global */
-{
- char **cpp;
-
- for (cpp = (char **)av; *cpp; cpp++)
- delete_option(*cpp);
+ return -1;
}