From cf08cdf3fb84a6815295a2fc6119dd80251aac74 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 11 Sep 2015 10:04:08 +0200 Subject: [PATCH] configuration type-fixes: int to bool where appropriate (possibly incomplete) rename some rules to make it more obvious that they are flags or other integer values. --- conf/e2/config.json | 2 +- conf/e3/config.json | 49 +++++++++++++++--------------- conf/e4/config.json | 53 ++++++++++++++++----------------- scripts/tests/common.lua | 16 +++++----- scripts/tests/e2/e2features.lua | 2 +- scripts/tests/e2/guard.lua | 2 +- scripts/tests/e2/spells.lua | 2 +- scripts/tests/e2/stealth.lua | 4 +-- scripts/tests/e3/rules.lua | 6 ++-- scripts/tests/e3/spells-e2.lua | 2 +- scripts/tests/e3/stealth.lua | 2 +- scripts/tests/orders.lua | 2 +- scripts/tests/pool.lua | 2 +- scripts/tests/study.lua | 2 +- src/battle.c | 2 +- src/kernel/config.c | 18 +++++------ src/kernel/config.h | 33 ++++++++++---------- src/kernel/unit.c | 2 +- src/laws.c | 2 +- src/magic.c | 4 +-- src/magic.h | 20 ++++++------- src/upkeep.c | 2 +- src/upkeep.test.c | 10 +++---- 23 files changed, 118 insertions(+), 121 deletions(-) diff --git a/conf/e2/config.json b/conf/e2/config.json index 0d3a94203..1ac8fc195 100644 --- a/conf/e2/config.json +++ b/conf/e2/config.json @@ -19,7 +19,7 @@ "seed.population.max": 8, "rules.ship.damage_drift": 0.00, "rules.reserve.twophase": true, - "rules.give.max_men": "-1", + "rules.give.max_men": -1, "rules.check_overload": false, "rules.limit.faction": 2500, "rules.maxskills.magic": 5, diff --git a/conf/e3/config.json b/conf/e3/config.json index fede39d1e..33b0aa52d 100644 --- a/conf/e3/config.json +++ b/conf/e3/config.json @@ -7,9 +7,9 @@ "game.name": "E3", "database.gameid": 7, "NewbieImmunity": 4, - "modules.astralspace": 0, - "modules.wormholes": 0, - "modules.markets": 1, + "modules.astralspace": false, + "modules.wormholes": false, + "modules.markets": true, "magic.regeneration": 0.75, "magic.power": 0.5, "resource.factor": 0.25, @@ -19,55 +19,54 @@ "nmr.timeout": 5, "nmr.removenewbie": 0, "GiveRestriction": 3, - "hunger.long": 0, - "hunger.demon.skill": 1, + "hunger.long": false, + "hunger.demon.skill": true, "hunger.damage": "1d9+9", - "hunger.demons": 1, + "hunger.demons": true, "init_spells": 0, - "recruit.allow_merge": 1, - "study.expensivemigrants": 1, + "recruit.allow_merge": true, + "study.expensivemigrants": true, "study.speedup": 2, "world.era": 3, "seed.population.min": 8, "seed.population.max": 8, - "rules.migrants": 0, - "rules.reserve.twophase": 1, - "rules.owners.force_leave": 0, + "rules.migrants.max": 0, + "rules.reserve.twophase": true, + "rules.owners.force_leave": false, "rules.monsters.attack_chance": 0.0, - "rules.transfermen": 0, - "rules.stealth.faction": 1, - "rules.stealth.anon_battle": 0, - "rules.check_overload": 0, + "rules.transfermen": false, + "rules.stealth.faction": true, + "rules.stealth.anon_battle": false, + "rules.check_overload": false, "rules.combat.goblinbonus": 3, "rules.ship.damage_drift": 0.00, - "rules.alliances": 1, + "rules.alliances": true, "rules.combat.herospeed": 3, "rules.combat.demon_vampire": 5, "rules.combat.skill_bonus": 0, "rules.combat.nat_armor": 1, "rules.items.loot_divisor": 2, "rules.items.give_divisor": 2, - "rules.move.owner_leave": 1, - "rules.region_owners": 1, + "rules.move.owner_leave": true, + "rules.region_owners": true, "rules.cavalry.skill": 2, "rules.cavalry.mode": 1, "rules.magic.multipotion": 1, "rules.magic.wol_effect": 5, "rules.magic.factionlist": 1, "rules.magic.wol_type": 2, - "rules.magic.blessed_harvest": 1, - "rules.magic.elfpower": 1, + "rules.blessed_harvest.flags": 1, + "rules.magic.elfpower": true, "rules.magic.playerschools": "gwyrrd illaun draig cerddor", - "rules.build.other_buildings": 1, + "rules.build.other_buildings": true, "rules.economy.taxation": 1, - "rules.economy.food": 2, - "rules.economy.wages": 1, + "rules.food.flags": 2, "rules.economy.roqf": 5, "rules.economy.herbrot": 0, "rules.region_owner_pay_building": "market harbour lighthouse", - "rules.dwarf_castles": 1, + "rules.dwarf_castles": true, "rules.limit.faction": 250, - "rules.economy.grow": 1, + "rules.grow.formula": 1, "rules.tactics.formula": 1, "rules.help.mask": "fight guard money give", "movement.shipspeed.skillbonus": 6, diff --git a/conf/e4/config.json b/conf/e4/config.json index 020ebafc1..0f31d8362 100644 --- a/conf/e4/config.json +++ b/conf/e4/config.json @@ -7,9 +7,9 @@ "game.name": "Deveron", "database.gameid": 7, "NewbieImmunity": 4, - "modules.astralspace": 0, - "modules.wormholes": 0, - "modules.markets": 1, + "modules.astralspace": false, + "modules.wormholes": false, + "modules.markets": true, "magic.regeneration": 0.75, "magic.power": 0.5, "resource.factor": 0.25, @@ -19,52 +19,51 @@ "nmr.timeout": 5, "nmr.removenewbie": 0, "GiveRestriction": 3, - "hunger.long": 0, - "hunger.demon.skill": 1, + "hunger.long": false, + "hunger.demon.skill": true, "hunger.damage": "1d9+9", - "hunger.demons": 1, + "hunger.demons": true, "init_spells": 0, - "recruit.allow_merge": 1, - "study.expensivemigrants": 1, + "recruit.allow_merge": true, + "study.expensivemigrants": true, "study.speedup": 2, "world.era": 3, - "rules.migrants": 0, - "rules.reserve.twophase": 1, - "rules.owners.force_leave": 0, - "rules.transfermen": 0, - "rules.stealth.faction": 1, - "rules.stealth.anon_battle": 0, - "rules.check_overload": 0, + "rules.migrants.max": 0, + "rules.reserve.twophase": true, + "rules.owners.force_leave": false, + "rules.transfermen": false, + "rules.stealth.faction": true, + "rules.stealth.anon_battle": false, + "rules.check_overload": false, "rules.combat.goblinbonus": 3, "rules.ship.damage_drift": 0.00, - "rules.alliances": 1, + "rules.alliances": true, "rules.combat.herospeed": 3, "rules.combat.demon_vampire": 5, "rules.combat.skill_bonus": 0, - "rules.combat.nat_armor": 1, + "rules.combat.nat_armor": true, "rules.items.loot_divisor": 2, "rules.items.give_divisor": 2, - "rules.move.owner_leave": 1, - "rules.region_owners": 1, + "rules.move.owner_leave": true, + "rules.region_owners": true, "rules.cavalry.skill": 2, "rules.cavalry.mode": 1, - "rules.magic.multipotion": 1, + "rules.magic.multipotion": true, "rules.magic.wol_effect": 5, - "rules.magic.factionlist": 1, + "rules.magic.factionlist": true, "rules.magic.wol_type": 2, - "rules.magic.blessed_harvest": 1, - "rules.magic.elfpower": 1, + "rules.blessed_harvest.flags": 1, + "rules.magic.elfpower": true, "rules.magic.playerschools": "gwyrrd illaun draig cerddor", "rules.build.other_buildings": 1, "rules.economy.taxation": 1, - "rules.economy.food": 2, - "rules.economy.wages": 1, + "rules.food.flags": 2, "rules.economy.roqf": 5, "rules.economy.herbrot": 0, "rules.region_owner_pay_building": "market harbour lighthouse", - "rules.dwarf_castles": 1, + "rules.dwarf_castles": true, "rules.limit.faction": 250, - "rules.economy.grow": 1, + "rules.grow.formula": 1, "rules.tactics.formula": 1, "rules.help.mask": "fight guard money give", "movement.shipspeed.skillbonus": 6, diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index 316ff1e71..8ca7e478e 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -28,7 +28,7 @@ function setup() eressea.free_game() eressea.settings.set("nmr.timeout", "0") eressea.settings.set("NewbieImmunity", "0") - eressea.settings.set("rules.economy.food", "4") + eressea.settings.set("rules.food.flags", "4") eressea.settings.set("rules.encounters", "0") eressea.settings.set("rules.peasants.growth", "1") eressea.settings.set("study.random_progress", "0") @@ -92,7 +92,7 @@ function test_demon_food() local u = unit.create(f, r, 1) local p = r:get_resource("peasant") r:set_resource("peasant", 2000) - eressea.settings.set("rules.economy.food", "0") + eressea.settings.set("rules.food.flags", "0") eressea.settings.set("rules.peasants.growth", "0") process_orders() assert_not_nil(u) @@ -460,7 +460,7 @@ function test_work() end function test_upkeep() - eressea.settings.set("rules.economy.food", "0") + eressea.settings.set("rules.food.flags", "0") local r = region.create(0, 0, "plain") local f = faction.create("noreply10@eressea.de", "human", "de") local u = unit.create(f, r, 5) @@ -782,7 +782,7 @@ function test_food_is_consumed() u:add_item("money", 100) u:clear_orders() u:add_order("LERNEN Reiten") -- don't work - eressea.settings.set("rules.economy.food", "4") + eressea.settings.set("rules.food.flags", "4") process_orders() assert_equal(100, u:get_item("money")) end @@ -794,7 +794,7 @@ function test_food_can_override() u:add_item("money", 100) u:clear_orders() u:add_order("LERNEN Reiten") -- don't work - eressea.settings.set("rules.economy.food", "0") + eressea.settings.set("rules.food.flags", "0") process_orders() assert_equal(90, u:get_item("money")) end @@ -921,7 +921,7 @@ module("tests.recruit", package.seeall, lunit.testcase) function setup() eressea.free_game() - eressea.settings.set("rules.economy.food", "4") + eressea.settings.set("rules.food.flags", "4") eressea.settings.set("rules.peasants.growth", "0") end @@ -962,7 +962,7 @@ module("tests.report", package.seeall, lunit.testcase) function setup() eressea.free_game() eressea.settings.set("nmr.timeout", "0") - eressea.settings.set("rules.economy.food", "4") + eressea.settings.set("rules.food.flags", "4") end local function find_in_report(f, pattern, extension) @@ -1062,7 +1062,7 @@ module("tests.parser", package.seeall, lunit.testcase) function setup() eressea.free_game() - eressea.settings.set("rules.economy.food", "4") -- FOOD_IS_FREE + eressea.settings.set("rules.food.flags", "4") -- FOOD_IS_FREE eressea.settings.set("rules.encounters", "0") eressea.settings.set("rules.move.owner_leave", "0") end diff --git a/scripts/tests/e2/e2features.lua b/scripts/tests/e2/e2features.lua index 8e57983e2..f5e40d42a 100644 --- a/scripts/tests/e2/e2features.lua +++ b/scripts/tests/e2/e2features.lua @@ -22,7 +22,7 @@ end function setup() eressea.free_game() eressea.settings.set("nmr.timeout", "0") - eressea.settings.set("rules.economy.food", "4") + eressea.settings.set("rules.food.flags", "4") eressea.settings.set("rules.ship.storms", "0") end diff --git a/scripts/tests/e2/guard.lua b/scripts/tests/e2/guard.lua index b1c9d9c4f..f5be800c2 100644 --- a/scripts/tests/e2/guard.lua +++ b/scripts/tests/e2/guard.lua @@ -6,7 +6,7 @@ function setup() eressea.free_game() eressea.settings.set("nmr.timeout", "0") eressea.settings.set("NewbieImmunity", "0") - eressea.settings.set("rules.economy.food", "4") + eressea.settings.set("rules.food.flags", "4") end function test_guard_unarmed() diff --git a/scripts/tests/e2/spells.lua b/scripts/tests/e2/spells.lua index 2eb54c406..6b1123a6f 100644 --- a/scripts/tests/e2/spells.lua +++ b/scripts/tests/e2/spells.lua @@ -7,7 +7,7 @@ function setup() eressea.settings.set("nmr.removenewbie", "0") eressea.settings.set("nmr.timeout", "0") eressea.settings.set("NewbieImmunity", "0") - eressea.settings.set("rules.economy.food", "4") + eressea.settings.set("rules.food.flags", "4") end function test_shapeshift() diff --git a/scripts/tests/e2/stealth.lua b/scripts/tests/e2/stealth.lua index aa0341c00..7644b3c6c 100644 --- a/scripts/tests/e2/stealth.lua +++ b/scripts/tests/e2/stealth.lua @@ -18,7 +18,7 @@ end function setup() eressea.game.reset() - set_rule('rules.economy.food', '4') + set_rule('rules.food.flags', '4') set_rule('rules.magic.playerschools', '') local r = region.create(0,0, "plain") @@ -28,7 +28,7 @@ function setup() end function teardown() - set_rule('rules.economy.food') + set_rule('rules.food.flags') set_rule('rules.magic.playerschools') set_rule('rules.stealth.faction') end diff --git a/scripts/tests/e3/rules.lua b/scripts/tests/e3/rules.lua index 2ed0e9e5c..81bd1abe9 100644 --- a/scripts/tests/e3/rules.lua +++ b/scripts/tests/e3/rules.lua @@ -17,14 +17,14 @@ function setup() eressea.game.reset() settings = {} set_rule("rules.move.owner_leave", "1") - set_rule("rules.economy.food", "4") + set_rule("rules.food.flags", "4") set_rule("rules.ship.drifting", "0") set_rule("rules.ship.storms", "0") end function teardown() set_rule("rules.move.owner_leave") - set_rule("rules.economy.food") + set_rule("rules.food.flags") set_rule("rules.ship.drifting") set_rule("rules.ship.storms") end @@ -221,7 +221,7 @@ function test_xmastree() end function test_fishing() - eressea.settings.set("rules.economy.food", "0") + eressea.settings.set("rules.food.flags", "0") local r = region.create(0,0, "ocean") local r2 = region.create(1,0, "plain") local f = faction.create("noreply@eressea.de", "human", "de") diff --git a/scripts/tests/e3/spells-e2.lua b/scripts/tests/e3/spells-e2.lua index a8ff7b943..bf3fa1d6c 100644 --- a/scripts/tests/e3/spells-e2.lua +++ b/scripts/tests/e3/spells-e2.lua @@ -8,7 +8,7 @@ function setup() eressea.free_game() eressea.settings.set("magic.regeneration.enable", "0") eressea.settings.set("magic.fumble.enable", "0") - eressea.settings.set("rules.economy.food", "4") + eressea.settings.set("rules.food.flags", "4") r = region.create(0, 0, "plain") f = faction.create("spell_payment@eressea.de", "elf", "de") diff --git a/scripts/tests/e3/stealth.lua b/scripts/tests/e3/stealth.lua index 687e2bfe4..bc78db006 100644 --- a/scripts/tests/e3/stealth.lua +++ b/scripts/tests/e3/stealth.lua @@ -7,7 +7,7 @@ local u function setup() eressea.game.reset() - eressea.settings.set("rules.economy.food", "4") + eressea.settings.set("rules.food.flags", "4") local r = region.create(0,0, "plain") f = faction.create("stealth1@eressea.de", "human", "de") diff --git a/scripts/tests/orders.lua b/scripts/tests/orders.lua index 21ecbe644..e0d42258f 100644 --- a/scripts/tests/orders.lua +++ b/scripts/tests/orders.lua @@ -15,7 +15,7 @@ function setup() f = _G.faction.create("noreply@eressea.de", "human", "de") u = _G.unit.create(f, r, 1) u:clear_orders() - eressea.settings.set("rules.economy.food", "4") + eressea.settings.set("rules.food.flags", "4") eressea.settings.set("nmr.timeout", "0") eressea.settings.set("NewbieImmunity", "0") end diff --git a/scripts/tests/pool.lua b/scripts/tests/pool.lua index bf32eda87..d9b336919 100644 --- a/scripts/tests/pool.lua +++ b/scripts/tests/pool.lua @@ -5,7 +5,7 @@ module("tests.eressea.pool", package.seeall, lunit.testcase ) function setup() eressea.game.reset() eressea.config.reset() - eressea.settings.set("rules.economy.food", "0") + eressea.settings.set("rules.food.flags", "0") eressea.settings.set("nmr.timeout", "0") eressea.settings.set("rules.magic.playerschools", "") conf = [[{ diff --git a/scripts/tests/study.lua b/scripts/tests/study.lua index 9185535d7..9bb8cda5e 100644 --- a/scripts/tests/study.lua +++ b/scripts/tests/study.lua @@ -17,7 +17,7 @@ function setup() eressea.game.reset() eressea.config.reset(); eressea.settings.set('rules.magic.playerschools', '') - eressea.settings.set("rules.economy.food", "4") + eressea.settings.set("rules.food.flags", "4") eressea.settings.set('study.random_progress', '0') eressea.config.parse(conf) end diff --git a/src/battle.c b/src/battle.c index 718f2620c..075e2327c 100644 --- a/src/battle.c +++ b/src/battle.c @@ -3210,7 +3210,7 @@ side * find_side(battle * b, const faction * f, const group * g, unsigned int fl if (s->faction == f && s->group == g) { unsigned int s1flags = flags | SIDE_HASGUARDS; unsigned int s2flags = s->flags | SIDE_HASGUARDS; - if (rule_anon_battle && s->stealthfaction != stealthfaction) { + if (rule_anon_battle!=0 && s->stealthfaction != stealthfaction) { continue; } if (s1flags == s2flags) { diff --git a/src/kernel/config.c b/src/kernel/config.c index 9a350245d..747bfad80 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -611,7 +611,7 @@ int count_maxmigrants(const faction * f) static int migrants = -1; if (migrants < 0) { - migrants = get_param_int(global.parameters, "rules.migrants", INT_MAX); + migrants = get_param_int(global.parameters, "rules.migrants.max", INT_MAX); } if (migrants == INT_MAX) { int x = 0; @@ -1404,19 +1404,19 @@ int cmp_current_owner(const building * b, const building * a) return -1; } -int rule_stealth_faction(void) +bool rule_stealth_faction(void) { static int gamecookie = -1; static int rule = -1; if (rule < 0 || gamecookie != global.cookie) { - rule = get_param_int(global.parameters, "rules.stealth.faction", 0xFF); + rule = get_param_int(global.parameters, "rules.stealth.faction", 1); gamecookie = global.cookie; assert(rule >= 0); } - return rule; + return rule!=0; } -int rule_region_owners(void) +bool rule_region_owners(void) { static int gamecookie = -1; static int rule = -1; @@ -1425,7 +1425,7 @@ int rule_region_owners(void) gamecookie = global.cookie; assert(rule >= 0); } - return rule; + return rule!=0; } int rule_auto_taxation(void) @@ -1447,7 +1447,7 @@ int rule_blessed_harvest(void) static int rule = -1; if (rule < 0 || gamecookie != global.cookie) { rule = - get_param_int(global.parameters, "rules.magic.blessed_harvest", + get_param_int(global.parameters, "rules.blessed_harvest.flags", HARVEST_WORK); gamecookie = global.cookie; assert(rule >= 0); @@ -1479,7 +1479,7 @@ int rule_faction_limit(void) return rule; } -int rule_transfermen(void) +bool rule_transfermen(void) { static int gamecookie = -1; static int rule = -1; @@ -1488,7 +1488,7 @@ int rule_transfermen(void) gamecookie = global.cookie; assert(rule >= 0); } - return rule; + return rule!=0; } static int diff --git a/src/kernel/config.h b/src/kernel/config.h index 2f71f7e01..23d887b99 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -151,18 +151,26 @@ extern "C" { int cmp_current_owner(const struct building *b, const struct building *bother); -#define TAX_ORDER 0x00 -#define TAX_OWNER 0x01 - int rule_auto_taxation(void); - int rule_transfermen(void); - int rule_region_owners(void); - int rule_stealth_faction(void); + bool rule_transfermen(void); + bool rule_region_owners(void); + bool rule_stealth_faction(void); + int rule_alliance_limit(void); + int rule_faction_limit(void); #define HARVEST_WORK 0x00 #define HARVEST_TAXES 0x01 int rule_blessed_harvest(void); +#define TAX_ORDER 0x00 +#define TAX_OWNER 0x01 + int rule_auto_taxation(void); +#define GIVE_SELF 1 +#define GIVE_PEASANTS 2 +#define GIVE_LUXURIES 4 +#define GIVE_HERBS 8 +#define GIVE_GOODS 16 +#define GIVE_ONDEATH 32 +#define GIVE_ALLITEMS (GIVE_GOODS|GIVE_HERBS|GIVE_LUXURIES) +#define GIVE_DEFAULT (GIVE_SELF|GIVE_PEASANTS|GIVE_LUXURIES|GIVE_HERBS|GIVE_GOODS) int rule_give(void); - int rule_alliance_limit(void); - int rule_faction_limit(void); #define COUNT_MONSTERS 0x01 #define COUNT_MIGRANTS 0x02 @@ -296,15 +304,6 @@ extern "C" { void free_gamedata(void); -#define GIVE_SELF 1 -#define GIVE_PEASANTS 2 -#define GIVE_LUXURIES 4 -#define GIVE_HERBS 8 -#define GIVE_GOODS 16 -#define GIVE_ONDEATH 32 -#define GIVE_ALLITEMS (GIVE_GOODS|GIVE_HERBS|GIVE_LUXURIES) -#define GIVE_DEFAULT (GIVE_SELF|GIVE_PEASANTS|GIVE_LUXURIES|GIVE_HERBS|GIVE_GOODS) - extern struct attrib_type at_guard; extern struct helpmode helpmodes[]; extern const char *parameters[]; diff --git a/src/kernel/unit.c b/src/kernel/unit.c index b3ff5462e..95608e709 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -858,7 +858,7 @@ bool can_leave(unit * u) rule_leave = get_param_int(global.parameters, "rules.move.owner_leave", 0); } - if (rule_leave && u->building && u == building_owner(u->building)) { + if (rule_leave!=0 && u->building && u == building_owner(u->building)) { return false; } return true; diff --git a/src/laws.c b/src/laws.c index 6e42bc736..20dd6010a 100755 --- a/src/laws.c +++ b/src/laws.c @@ -793,7 +793,7 @@ void demographics(void) if (plant_rules < 0) { plant_rules = - get_param_int(global.parameters, "rules.economy.grow", 0); + get_param_int(global.parameters, "rules.grow.formula", 0); } for (dmd = r->land->demands; dmd; dmd = dmd->next) { if (dmd->value > 0 && dmd->value < MAXDEMAND) { diff --git a/src/magic.c b/src/magic.c index 2e9b7199c..fcefb0d80 100644 --- a/src/magic.c +++ b/src/magic.c @@ -213,14 +213,14 @@ static void free_mage(attrib * a) free(mage); } -int FactionSpells(void) +bool FactionSpells(void) { static int rules_factionspells = -1; if (rules_factionspells < 0) { rules_factionspells = get_param_int(global.parameters, "rules.magic.factionlist", 0); } - return rules_factionspells; + return rules_factionspells!=0; } void read_spells(struct quicklist **slistp, magic_t mtype, diff --git a/src/magic.h b/src/magic.h index 055182ded..ee4c20996 100644 --- a/src/magic.h +++ b/src/magic.h @@ -346,23 +346,23 @@ extern "C" { extern void create_newclone(struct unit *mage, struct unit *familiar); extern struct unit *has_clone(struct unit *mage); - extern const char *spell_info(const struct spell *sp, + const char *spell_info(const struct spell *sp, const struct locale *lang); - extern const char *spell_name(const struct spell *sp, + const char *spell_name(const struct spell *sp, const struct locale *lang); - extern const char *curse_name(const struct curse_type *ctype, + const char *curse_name(const struct curse_type *ctype, const struct locale *lang); - extern struct message *msg_unitnotfound(const struct unit *mage, + struct message *msg_unitnotfound(const struct unit *mage, struct order *ord, const struct spllprm *spobj); - extern int FactionSpells(void); + bool FactionSpells(void); - extern void write_spells(struct quicklist *slist, struct storage *store); - extern void read_spells(struct quicklist **slistp, magic_t mtype, - struct storage *store); + void write_spells(struct quicklist *slist, struct storage *store); + void read_spells(struct quicklist **slistp, magic_t mtype, + struct storage *store); - extern struct spellbook * get_spellbook(const char * name); - extern void free_spellbooks(void); + struct spellbook * get_spellbook(const char * name); + void free_spellbooks(void); #ifdef __cplusplus } #endif diff --git a/src/upkeep.c b/src/upkeep.c index c23746b07..162f41b75 100644 --- a/src/upkeep.c +++ b/src/upkeep.c @@ -121,7 +121,7 @@ void get_food(region * r) if (food_rules < 0 || gamecookie != global.cookie) { gamecookie = global.cookie; - food_rules = get_param_int(global.parameters, "rules.economy.food", 0); + food_rules = get_param_int(global.parameters, "rules.food.flags", 0); } if (food_rules & FOOD_IS_FREE) { diff --git a/src/upkeep.test.c b/src/upkeep.test.c index 46d9a6d04..424d5034c 100644 --- a/src/upkeep.test.c +++ b/src/upkeep.test.c @@ -32,7 +32,7 @@ void test_upkeep_default(CuTest * tc) u2 = test_create_unit(f2, r); assert(r && u1 && u2); - set_param(&global.parameters, "rules.economy.food", "0"); + set_param(&global.parameters, "rules.food.flags", "0"); i_change(&u1->items, i_silver, 20); get_food(r); // since u1 and u2 are not allied, u1 should not help u2 with upkeep @@ -60,7 +60,7 @@ void test_upkeep_hunger_damage(CuTest * tc) u1 = test_create_unit(f1, r); assert(r && u1); - set_param(&global.parameters, "rules.economy.food", "0"); + set_param(&global.parameters, "rules.food.flags", "0"); u1->hp = 100; get_food(r); // since u1 and u2 are not allied, u1 should not help u2 with upkeep @@ -86,7 +86,7 @@ void test_upkeep_from_pool(CuTest * tc) u2 = test_create_unit(u1->faction, r); assert(r && u1 && u2); - set_param(&global.parameters, "rules.economy.food", "0"); + set_param(&global.parameters, "rules.food.flags", "0"); i_change(&u1->items, i_silver, 30); get_food(r); CuAssertIntEquals(tc, 10, i_get(u1->items, i_silver)); @@ -122,7 +122,7 @@ void test_upkeep_from_friend(CuTest * tc) u2 = test_create_unit(f2, r); assert(r && u1 && u2); - set_param(&global.parameters, "rules.economy.food", "0"); + set_param(&global.parameters, "rules.food.flags", "0"); i_change(&u1->items, i_silver, 30); get_food(r); CuAssertIntEquals(tc, 10, i_get(u1->items, i_silver)); @@ -151,7 +151,7 @@ void test_upkeep_free(CuTest * tc) u = test_create_unit(test_create_faction(test_create_race("human")), r); assert(r && u); - set_param(&global.parameters, "rules.economy.food", "4"); // FOOD_IS_FREE + set_param(&global.parameters, "rules.food.flags", "4"); // FOOD_IS_FREE get_food(r); CuAssertIntEquals(tc, 0, i_get(u->items, i_silver)); CuAssertIntEquals(tc, 0, fval(u, UFL_HUNGER));