From b05fe9316ab86473dc29937f3d3ed3c249590326 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Nov 2015 10:33:31 +0100 Subject: [PATCH] introducing config_set and config_get so we don't have to refer to globals.parameters everywhere --- src/CMakeLists.txt | 3 +-- src/alchemy.c | 7 +++--- src/attributes/otherfaction.test.c | 14 ++++++------ src/bind_process.c | 2 +- src/bind_settings.c | 14 ------------ src/bind_settings.h | 13 ------------ src/give.test.c | 10 ++++----- src/gmtool.c | 4 ++-- src/kernel/config.c | 16 ++++++++++++++ src/kernel/config.h | 7 +++++- src/kernel/jsonconf.c | 6 +++--- src/kernel/ship.test.c | 4 ++-- src/kernel/unit.test.c | 8 +++---- src/laws.test.c | 34 +++++++++++++++--------------- src/main.c | 2 +- src/market.test.c | 2 +- src/move.test.c | 2 +- src/piracy.test.c | 2 +- src/settings.pkg | 6 +++--- src/settings.pkg.c | 6 +++--- src/study.test.c | 2 +- src/upkeep.test.c | 10 ++++----- 22 files changed, 83 insertions(+), 91 deletions(-) delete mode 100755 src/bind_settings.c delete mode 100755 src/bind_settings.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ada49aad9..e30cd56d9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -73,7 +73,7 @@ TOLUA_BINDING(config.pkg bind_config.h) TOLUA_BINDING(process.pkg bind_process.h) TOLUA_BINDING(game.pkg bind_eressea.h config.h) TOLUA_BINDING(eressea.pkg bind_eressea.h) -TOLUA_BINDING(settings.pkg bind_settings.h) +TOLUA_BINDING(settings.pkg kenel/config.h) ENDIF() set (ERESSEA_SRC @@ -144,7 +144,6 @@ set(SERVER_SRC bind_monsters.c bind_process.c bind_region.c - bind_settings.c bind_ship.c bind_storage.c bind_unit.c diff --git a/src/alchemy.c b/src/alchemy.c index 9042fee9b..166cde00b 100644 --- a/src/alchemy.c +++ b/src/alchemy.c @@ -98,8 +98,7 @@ static int begin_potion(unit * u, const potion_type * ptype, struct order *ord) if (rule_multipotion < 0) { /* should we allow multiple different potions to be used the same turn? */ - rule_multipotion = - get_param_int(global.parameters, "rules.magic.multipotion", 0); + rule_multipotion = config_get_int("rules.magic.multipotion", 0); } if (!rule_multipotion) { const potion_type *use = ugetpotionuse(u); @@ -130,9 +129,9 @@ static int do_potion(unit * u, region *r, const potion_type * ptype, int amount) static int tree_type = -1; static int tree_count = -1; if (tree_type < 0) { - tree_type = get_param_int(global.parameters, "rules.magic.wol_type", 1); + tree_type = config_get_int("rules.magic.wol_type", 1); tree_count = - get_param_int(global.parameters, "rules.magic.wol_effect", 10); + config_get_int("rules.magic.wol_effect", 10); } /* mallorn is required to make mallorn forests, wood for regular ones */ if (fval(r, RF_MALLORN)) { diff --git a/src/attributes/otherfaction.test.c b/src/attributes/otherfaction.test.c index 0b38901eb..8e3d09b0a 100644 --- a/src/attributes/otherfaction.test.c +++ b/src/attributes/otherfaction.test.c @@ -17,18 +17,18 @@ static void test_rules(CuTest *tc) { test_cleanup(); - set_param(&global.parameters, "stealth.faction.other", NULL); + config_set("stealth.faction.other", NULL); CuAssertIntEquals(tc, true, rule_stealth_other()); - set_param(&global.parameters, "stealth.faction.other", "0"); + config_set("stealth.faction.other", "0"); CuAssertIntEquals(tc, false, rule_stealth_other()); - set_param(&global.parameters, "stealth.faction.other", "1"); + config_set("stealth.faction.other", "1"); CuAssertIntEquals(tc, true, rule_stealth_other()); - set_param(&global.parameters, "stealth.faction.anon", NULL); + config_set("stealth.faction.anon", NULL); CuAssertIntEquals(tc, true, rule_stealth_anon()); - set_param(&global.parameters, "stealth.faction.anon", "0"); + config_set("stealth.faction.anon", "0"); CuAssertIntEquals(tc, false, rule_stealth_anon()); - set_param(&global.parameters, "stealth.faction.anon", "1"); + config_set("stealth.faction.anon", "1"); CuAssertIntEquals(tc, true, rule_stealth_anon()); test_cleanup(); } @@ -40,7 +40,7 @@ static void test_otherfaction(CuTest *tc) { test_cleanup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); f = test_create_faction(0); - set_param(&global.parameters, "stealth.faction.other", "1"); + config_set("stealth.faction.other", "1"); CuAssertIntEquals(tc, true, rule_stealth_other()); CuAssertPtrEquals(tc, u->faction, visible_faction(f, u)); a_add(&u->attribs, make_otherfaction(f)); diff --git a/src/bind_process.c b/src/bind_process.c index 2e883d38a..fcf2bd55c 100755 --- a/src/bind_process.c +++ b/src/bind_process.c @@ -223,7 +223,7 @@ void process_explain(void) { } void process_reserve(void) { - int rule = get_param_int(global.parameters, "rules.reserve.twophase", 0); + int rule = config_get_int("rules.reserve.twophase", 0); if (rule) { process_cmd(K_RESERVE, reserve_self, 0); } diff --git a/src/bind_settings.c b/src/bind_settings.c deleted file mode 100755 index b0a82baaa..000000000 --- a/src/bind_settings.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "bind_settings.h" - -#include -#include - -const char * settings_get(const char *key) -{ - return get_param(global.parameters, key); -} - -void settings_set(const char *key, const char *value) -{ - set_param(&global.parameters, key, value); -} diff --git a/src/bind_settings.h b/src/bind_settings.h deleted file mode 100755 index 7f01c3856..000000000 --- a/src/bind_settings.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef BIND_ERESSEA_SETTINGS_H -#define BIND_ERESSEA_SETTINGS_H -#ifdef __cplusplus -extern "C" { -#endif - - const char * settings_get(const char *key); - void settings_set(const char *key, const char *value); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/give.test.c b/src/give.test.c index 76726c044..c6c3aafc8 100644 --- a/src/give.test.c +++ b/src/give.test.c @@ -75,11 +75,11 @@ static void test_give_unit(CuTest * tc) { env.f2 = test_create_faction(0); setup_give(&env); env.r->terrain = test_create_terrain("ocean", SEA_REGION); - set_param(&global.parameters, "rules.give.max_men", "0"); + config_set("rules.give.max_men", "0"); give_unit(env.src, env.dst, NULL); CuAssertPtrEquals(tc, env.f1, env.src->faction); CuAssertIntEquals(tc, 0, env.f2->newbies); - set_param(&global.parameters, "rules.give.max_men", "-1"); + config_set("rules.give.max_men", "-1"); give_unit(env.src, env.dst, NULL); CuAssertPtrEquals(tc, env.f2, env.src->faction); CuAssertIntEquals(tc, 1, env.f2->newbies); @@ -117,7 +117,7 @@ static void test_give_men_limit(CuTest * tc) { env.f2 = test_create_faction(0); env.f1 = test_create_faction(0); setup_give(&env); - set_param(&global.parameters, "rules.give.max_men", "1"); + config_set("rules.give.max_men", "1"); /* below the limit, give men, increase newbies counter */ usetcontact(env.dst, env.src); @@ -308,7 +308,7 @@ static void test_give_okay(CuTest * tc) { env.f2 = env.f1 = test_create_faction(0); setup_give(&env); - set_param(&global.parameters, "rules.give.flags", "0"); + config_set("rules.give.flags", "0"); CuAssertPtrEquals(tc, 0, check_give(env.src, env.dst, 0)); test_cleanup(); } @@ -322,7 +322,7 @@ static void test_give_denied_by_rules(CuTest * tc) { env.f2 = test_create_faction(0); setup_give(&env); - set_param(&global.parameters, "rules.give.flags", "0"); + config_set("rules.give.flags", "0"); CuAssertPtrNotNull(tc, msg = check_give(env.src, env.dst, 0)); msg_release(msg); test_cleanup(); diff --git a/src/gmtool.c b/src/gmtool.c index 2c15f6b29..92080b63b 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -853,8 +853,8 @@ static void handlekey(state * st, int c) new_players = read_newfactions(sbuffer); } cnormalize(&st->cursor, &nx, &ny); - minpop = get_param_int(global.parameters, "seed.population.min", 8); - maxpop = get_param_int(global.parameters, "seed.population.max", minpop); + minpop = config_get_int("seed.population.min", 8); + maxpop = config_get_int("seed.population.max", minpop); if (maxpop > minpop) { n = rng_int() % (maxpop - minpop) + minpop; } diff --git a/src/kernel/config.c b/src/kernel/config.c index 3e3651c88..1f44530f9 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -1572,6 +1572,22 @@ bool markets_module(void) return get_param_int(global.parameters, "modules.markets", 0); } +void config_set(const char *key, const char *value) { + set_param(&global.parameters, key, value); +} + +const char *config_get(const char *key) { + return get_param(global.parameters, key); +} + +int config_get_int(const char *key, int def) { + return get_param_int(global.parameters, key, def); +} + +double config_get_flt(const char *key, double def) { + return get_param_flt(global.parameters, key, def); +} + /** releases all memory associated with the game state. * call this function before calling read_game() to load a new game * if you have a previously loaded state in memory. diff --git a/src/kernel/config.h b/src/kernel/config.h index 1ada1cd5c..817850166 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -268,13 +268,18 @@ extern "C" { const char *dbrace(const struct race *rc); - void set_param(struct param **p, const char *key, const char *data); + void set_param(struct param **p, const char *key, const char *value); const char *get_param(const struct param *p, const char *key); int get_param_int(const struct param *p, const char *key, int def); int check_param(const struct param *p, const char *key, const char *searchvalue); double get_param_flt(const struct param *p, const char *key, double def); void free_params(struct param **pp); + void config_set(const char *key, const char *value); + const char *config_get(const char *key); + int config_get_int(const char *key, int def); + double config_get_flt(const char *key, double def); + bool ExpensiveMigrants(void); int NMRTimeout(void); int LongHunger(const struct unit *u); diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index 9efbc0250..eed4d4480 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -533,7 +533,7 @@ static void disable_feature(const char *str) { } _snprintf(name, sizeof(name), "%s.enabled", str); log_info("disable feature %s\n", name); - set_param(&global.parameters, name, "0"); + config_set(name, "0"); } static void json_disable_features(cJSON *json) { @@ -788,7 +788,7 @@ static void json_settings(cJSON *json) { } for (child = json->child; child; child = child->next) { if (child->valuestring) { - set_param(&global.parameters, child->string, child->valuestring); + config_set(child->string, child->valuestring); } else { char value[32]; @@ -798,7 +798,7 @@ static void json_settings(cJSON *json) { else { _snprintf(value, sizeof(value), "%d", child->valueint); } - set_param(&global.parameters, child->string, value); + config_set(child->string, value); } } } diff --git a/src/kernel/ship.test.c b/src/kernel/ship.test.c index dc125cd9b..b003f74b9 100644 --- a/src/kernel/ship.test.c +++ b/src/kernel/ship.test.c @@ -399,7 +399,7 @@ static ship *setup_ship(void) { region *r; ship_type *stype; - set_param(&global.parameters, "movement.shipspeed.skillbonus", "0"); + config_set("movement.shipspeed.skillbonus", "0"); r = test_create_region(0, 0, test_create_terrain("ocean", 0)); stype = test_create_shiptype("longboat"); stype->cptskill = 1; @@ -558,7 +558,7 @@ static void test_shipspeed_max_range(CuTest *tc) { test_cleanup(); sh = setup_ship(); setup_crew(sh, 0, &cap, &crew); - set_param(&global.parameters, "movement.shipspeed.skillbonus", "5"); + config_set("movement.shipspeed.skillbonus", "5"); r = sh->region; f = test_create_faction(0); assert(r && f); diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index db2751026..4486d344a 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -284,15 +284,15 @@ static void test_skill_hunger(CuTest *tc) { set_level(u, SK_SAILING, 6); fset(u, UFL_HUNGER); - set_param(&global.parameters, "rules.hunger.reduces_skill", "0"); + config_set("rules.hunger.reduces_skill", "0"); CuAssertIntEquals(tc, 6, effskill(u, SK_ARMORER, 0)); CuAssertIntEquals(tc, 6, effskill(u, SK_SAILING, 0)); - set_param(&global.parameters, "rules.hunger.reduces_skill", "1"); + config_set("rules.hunger.reduces_skill", "1"); CuAssertIntEquals(tc, 3, effskill(u, SK_ARMORER, 0)); CuAssertIntEquals(tc, 3, effskill(u, SK_SAILING, 0)); - set_param(&global.parameters, "rules.hunger.reduces_skill", "2"); + config_set("rules.hunger.reduces_skill", "2"); CuAssertIntEquals(tc, 3, effskill(u, SK_ARMORER, 0)); CuAssertIntEquals(tc, 5, effskill(u, SK_SAILING, 0)); set_level(u, SK_SAILING, 2); @@ -371,7 +371,7 @@ static void test_produceexp(CuTest *tc) { g_tc = tc; test_cleanup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); - set_param(&global.parameters, "study.from_use", "0.5"); + config_set("study.from_use", "0.5"); produceexp_ex(u, SK_ALCHEMY, 1, cb_learn_one); produceexp_ex(u, SK_ALCHEMY, 2, cb_learn_two); test_cleanup(); diff --git a/src/laws.test.c b/src/laws.test.c index e829eff27..43936abfc 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -233,16 +233,16 @@ static void test_display_cmd(CuTest *tc) { } static void test_rule_force_leave(CuTest *tc) { - set_param(&global.parameters, "rules.owners.force_leave", "0"); + config_set("rules.owners.force_leave", "0"); CuAssertIntEquals(tc, false, rule_force_leave(FORCE_LEAVE_ALL)); CuAssertIntEquals(tc, false, rule_force_leave(FORCE_LEAVE_POSTCOMBAT)); - set_param(&global.parameters, "rules.owners.force_leave", "1"); + config_set("rules.owners.force_leave", "1"); CuAssertIntEquals(tc, false, rule_force_leave(FORCE_LEAVE_ALL)); CuAssertIntEquals(tc, true, rule_force_leave(FORCE_LEAVE_POSTCOMBAT)); - set_param(&global.parameters, "rules.owners.force_leave", "2"); + config_set("rules.owners.force_leave", "2"); CuAssertIntEquals(tc, true, rule_force_leave(FORCE_LEAVE_ALL)); CuAssertIntEquals(tc, false, rule_force_leave(FORCE_LEAVE_POSTCOMBAT)); - set_param(&global.parameters, "rules.owners.force_leave", "3"); + config_set("rules.owners.force_leave", "3"); CuAssertIntEquals(tc, true, rule_force_leave(FORCE_LEAVE_ALL)); CuAssertIntEquals(tc, true, rule_force_leave(FORCE_LEAVE_POSTCOMBAT)); } @@ -413,13 +413,13 @@ static void test_fishing_gets_reset(CuTest * tc) static void test_unit_limit(CuTest * tc) { - set_param(&global.parameters, "rules.limit.faction", "250"); + config_set("rules.limit.faction", "250"); CuAssertIntEquals(tc, 250, rule_faction_limit()); - set_param(&global.parameters, "rules.limit.faction", "200"); + config_set("rules.limit.faction", "200"); CuAssertIntEquals(tc, 200, rule_faction_limit()); - set_param(&global.parameters, "rules.limit.alliance", "250"); + config_set("rules.limit.alliance", "250"); CuAssertIntEquals(tc, 250, rule_alliance_limit()); } @@ -432,12 +432,12 @@ static void test_cannot_create_unit_above_limit(CuTest * tc) test_cleanup(); test_create_world(); f = test_create_faction(NULL); - set_param(&global.parameters, "rules.limit.faction", "4"); + config_set("rules.limit.faction", "4"); CuAssertIntEquals(tc, 0, checkunitnumber(f, 4)); CuAssertIntEquals(tc, 2, checkunitnumber(f, 5)); - set_param(&global.parameters, "rules.limit.alliance", "3"); + config_set("rules.limit.alliance", "3"); CuAssertIntEquals(tc, 0, checkunitnumber(f, 3)); CuAssertIntEquals(tc, 1, checkunitnumber(f, 4)); } @@ -533,8 +533,8 @@ static void test_pay_cmd_other_building(CuTest *tc) { setup_pay_cmd(&fix); f = fix.u1->faction; b = test_create_building(fix.u1->region, bt_get_or_create("lighthouse")); - set_param(&global.parameters, "rules.region_owners", "1"); - set_param(&global.parameters, "rules.region_owner_pay_building", "lighthouse"); + config_set("rules.region_owners", "1"); + config_set("rules.region_owner_pay_building", "lighthouse"); update_owners(b->region); _snprintf(cmd, sizeof(cmd), "NOT %s", itoa36(b->no)); @@ -633,7 +633,7 @@ static void test_newbie_cannot_guard(CuTest *tc) { guard_fixture fix; setup_guard(&fix, true); - set_param(&global.parameters, "NewbieImmunity", "4"); + config_set("NewbieImmunity", "4"); CuAssertTrue(tc, IsImmune(fix.u->faction)); update_guards(); CuAssertTrue(tc, !fval(fix.u, UFL_GUARD)); @@ -726,15 +726,15 @@ static void statistic_test(CuTest *tc, int peasants, int luck, int maxp, static void test_peasant_luck_effect(CuTest *tc) { test_cleanup(); - set_param(&global.parameters, "rules.peasants.peasantluck.factor", "10"); - set_param(&global.parameters, "rules.peasants.growth.factor", "0.001"); + config_set("rules.peasants.peasantluck.factor", "10"); + config_set("rules.peasants.growth.factor", "0.001"); statistic_test(tc, 100, 0, 1000, 0, 0, 0); statistic_test(tc, 100, 2, 1000, 0, 1, 1); statistic_test(tc, 1000, 400, 1000, 0, 3, 3); statistic_test(tc, 1000, 1000, 2000, .5, 1, 501); - set_param(&global.parameters, "rules.peasants.growth.factor", "1"); + config_set("rules.peasants.growth.factor", "1"); statistic_test(tc, 1000, 1000, 1000, 0, 501, 501); test_cleanup(); } @@ -1003,7 +1003,7 @@ static void test_long_order_hungry(CuTest *tc) { // see also default_order unit *u; test_cleanup(); - set_param(&global.parameters, "hunger.long", "1"); + config_set("hunger.long", "1"); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); fset(u, UFL_HUNGER); u->faction->locale = get_or_create_locale("de"); @@ -1081,7 +1081,7 @@ static void test_ally_cmd(CuTest *tc) { static void test_nmr_warnings(CuTest *tc) { faction *f1, *f2; test_cleanup(); - set_param(&global.parameters, "nmr.timeout", "3"); + config_set("nmr.timeout", "3"); f1 = test_create_faction(0); f2 = test_create_faction(0); f2->age = 2; diff --git a/src/main.c b/src/main.c index fee0eaab0..6eac28470 100644 --- a/src/main.c +++ b/src/main.c @@ -162,7 +162,7 @@ static int parse_args(int argc, char **argv, int *exitcode) switch (argi[1]) { case 'r': i = get_arg(argc, argv, 2, i, &arg, 0); - set_param(&global.parameters, "config.rules", arg); + config_set("config.rules", arg); break; case 'f': i = get_arg(argc, argv, 2, i, &luafile, 0); diff --git a/src/market.test.c b/src/market.test.c index 12c9cab3f..6132db39b 100644 --- a/src/market.test.c +++ b/src/market.test.c @@ -43,7 +43,7 @@ static void test_market_curse(CuTest * tc) ltype->rtype->flags |= (RTF_ITEM | RTF_POOLED); lux = new_luxurytype(ltype, 0); - set_param(&global.parameters, "rules.region_owners", "1"); + config_set("rules.region_owners", "1"); btype = (building_type *)calloc(1, sizeof(building_type)); btype->_name = _strdup("market"); diff --git a/src/move.test.c b/src/move.test.c index 5c24ca72e..91dcbd2b4 100644 --- a/src/move.test.c +++ b/src/move.test.c @@ -212,7 +212,7 @@ static void test_walkingcapacity(CuTest *tc) { assert(itype); i_change(&u->items, itype, 1); CuAssertIntEquals(tc, cap + (STRENGTHMULTIPLIER-1) * u->_race->capacity, walkingcapacity(u)); - set_param(&global.parameters, "rules.trollbelt.multiplier", "5"); + config_set("rules.trollbelt.multiplier", "5"); CuAssertIntEquals(tc, cap + 4 * u->_race->capacity, walkingcapacity(u)); test_cleanup(); diff --git a/src/piracy.test.c b/src/piracy.test.c index 53907f4df..4ed735c45 100644 --- a/src/piracy.test.c +++ b/src/piracy.test.c @@ -21,7 +21,7 @@ static void setup_piracy(void) { ship_type *st_boat; test_cleanup(); - set_param(&global.parameters, "rules.ship.storms", "0"); + config_set("rules.ship.storms", "0"); lang = get_or_create_locale("de"); locale_setstring(lang, directions[D_EAST], "OSTEN"); init_directions(lang); diff --git a/src/settings.pkg b/src/settings.pkg index e216bf8b6..002ece6a9 100755 --- a/src/settings.pkg +++ b/src/settings.pkg @@ -1,10 +1,10 @@ $#undef tolua_reg_types $#define tolua_reg_types tolua_reg_types_config -$#include "bind_settings.h" +$#include module eressea { module settings { - void settings_set @ set(const char *key, const char *value); - const char * settings_get @ get(const char *key); + void config_set @ set(const char *key, const char *value); + const char * config_get @ get(const char *key); } } diff --git a/src/settings.pkg.c b/src/settings.pkg.c index 0dcd3df61..79ea280cb 100644 --- a/src/settings.pkg.c +++ b/src/settings.pkg.c @@ -20,7 +20,7 @@ LUALIB_API int luaopen_settings (lua_State* tolua_S); #undef tolua_reg_types #define tolua_reg_types tolua_reg_types_settings -#include "bind_settings.h" +#include /* function to register type */ static void tolua_reg_types (lua_State* tolua_S) @@ -44,7 +44,7 @@ static int tolua_settings_eressea_settings_set00(lua_State* tolua_S) const char* key = ((const char*) tolua_tostring(tolua_S,1,0)); const char* value = ((const char*) tolua_tostring(tolua_S,2,0)); { - settings_set(key,value); + config_set(key,value); } } return 0; @@ -70,7 +70,7 @@ static int tolua_settings_eressea_settings_get00(lua_State* tolua_S) { const char* key = ((const char*) tolua_tostring(tolua_S,1,0)); { - const char* tolua_ret = (const char*) settings_get(key); + const char* tolua_ret = (const char*) config_get(key); tolua_pushstring(tolua_S,(const char*)tolua_ret); } } diff --git a/src/study.test.c b/src/study.test.c index ac9d3947a..4b30ae842 100644 --- a/src/study.test.c +++ b/src/study.test.c @@ -27,7 +27,7 @@ static void setup_study(study_fixture *fix, skill_t sk) { assert(fix); test_cleanup(); - set_param(&global.parameters, "study.random_progress", "0"); + config_set("study.random_progress", "0"); test_create_world(); r = test_create_region(0, 0, 0); f = test_create_faction(0); diff --git a/src/upkeep.test.c b/src/upkeep.test.c index 424d5034c..bba43a95f 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.food.flags", "0"); + config_set("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.food.flags", "0"); + config_set("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.food.flags", "0"); + config_set("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.food.flags", "0"); + config_set("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.food.flags", "4"); // FOOD_IS_FREE + config_set("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));