From 8463faa849cb72606da50f71eaf037fcb3b7a197 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 10 Sep 2015 18:54:49 +0200 Subject: [PATCH 01/10] https://bugs.eressea.de/view.php?id=2133 add missing seed.population.* configuration --- conf/e2/config.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/conf/e2/config.xml b/conf/e2/config.xml index 2001d5f62..6263e6095 100644 --- a/conf/e2/config.xml +++ b/conf/e2/config.xml @@ -100,6 +100,9 @@ + + + @@ -115,7 +118,6 @@ - From 2b46c4c4a9e2c778f512b406b76338235b839cd3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 10 Sep 2015 21:22:55 +0200 Subject: [PATCH 02/10] kill stray semicolon --- src/donations.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/donations.c b/src/donations.c index 09d572177..8f820df2b 100644 --- a/src/donations.c +++ b/src/donations.c @@ -69,7 +69,7 @@ static void report_transfer(faction *f1, faction *f2, region *r, int amount) { void report_donations(void) { - ql_iter qli = qli_init(&transfers);; + ql_iter qli = qli_init(&transfers); while (qli_more(qli)) { transfer *tf = (transfer *)qli_next(&qli); From 1969c165d3d1e621c72895dea99b13f816c601e9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 10 Sep 2015 23:16:17 +0200 Subject: [PATCH 03/10] allow settings in json configuration file move E2 settings from XML to JSON --- conf/e2/config.json | 31 ++++++++++++++++++++++++++++++- conf/e2/config.xml | 28 ---------------------------- src/kernel/jsonconf.c | 21 +++++++++++++++++++++ src/kernel/jsonconf.test.c | 17 +++++++++++++++++ 4 files changed, 68 insertions(+), 29 deletions(-) diff --git a/conf/e2/config.json b/conf/e2/config.json index b2acffcb3..67ae85bce 100644 --- a/conf/e2/config.json +++ b/conf/e2/config.json @@ -1,5 +1,34 @@ { "include": [ "keywords.json" - ] + ], + "settings": { + "NewbieImmunity": 8, + "modules.wormholes": 1, + "entertain.base": 0, + "entertain.perlevel": 20, + "nmr.timeout": 5, + "nmr.removenewbie": 0, + "GiveRestriction": 3, + "hunger.long": 1, + "init_spells": 0, + "world.era": 2, + "seed.population.min": 8, + "seed.population.max": 8, + "rules.ship.damage_drift": 0.00, + "rules.reserve.twophase": 1, + "rules.give.max_men": "-1", + "rules.check_overload": 0, + "rules.limit.faction": 2500, + "rules.maxskills.magic": 5, + "rules.guard.base_stop_prob": 0.30, + "rules.guard.skill_stop_prob": 0.05, + "rules.guard.amulet_stop_prob": 0.10, + "rules.guard.guard_number_stop_prob": 0.001, + "rules.guard.castle_stop_prob": 0.05, + "rules.guard.region_type_stop_prob": 0.05, + "rules.economy.repopulate_maximum": 500, + "game.id": 2, + "game.name": "Eressea" + } } diff --git a/conf/e2/config.xml b/conf/e2/config.xml index 6263e6095..367f43c29 100644 --- a/conf/e2/config.xml +++ b/conf/e2/config.xml @@ -90,34 +90,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index f9a025432..465478775 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -638,6 +638,24 @@ static void json_keywords(cJSON *json) { } } +static void json_settings(cJSON *json) { + cJSON *child; + if (json->type != cJSON_Object) { + log_error("settings is not a json object: %d", json->type); + return; + } + for (child = json->child; child; child = child->next) { + if (child->valuestring) { + set_param(&global.parameters, child->string, child->valuestring); + } + else { + char value[32]; + _snprintf(value, sizeof(value), "%lf", child->valuedouble); + set_param(&global.parameters, child->string, value); + } + } +} + static void json_races(cJSON *json) { cJSON *child; if (json->type != cJSON_Object) { @@ -714,6 +732,9 @@ void json_config(cJSON *json) { else if (strcmp(child->string, "keywords") == 0) { json_keywords(child); } + else if (strcmp(child->string, "settings") == 0) { + json_settings(child); + } else if (strcmp(child->string, "skills") == 0) { json_skills(child); } diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c index 50cba3891..38fd41ae9 100644 --- a/src/kernel/jsonconf.test.c +++ b/src/kernel/jsonconf.test.c @@ -57,6 +57,22 @@ static void test_flags(CuTest *tc) { test_cleanup(); } +static void test_settings(CuTest * tc) +{ + const char * data = "{\"settings\": { " + "\"string\" : \"1d4\"," + "\"integer\" : 14," + "\"float\" : 0.5 }}"; + cJSON *json = cJSON_Parse(data); + + test_cleanup(); + json_config(json); + CuAssertStrEquals(tc, "1d4", get_param(global.parameters, "string")); + CuAssertIntEquals(tc, 14, get_param_int(global.parameters, "integer", 0)); + CuAssertDblEquals(tc, 0.5f, get_param_flt(global.parameters, "float", 0), 0.01); + test_cleanup(); +} + static void test_races(CuTest * tc) { const char * data = "{\"races\": { \"orc\" : { " @@ -510,6 +526,7 @@ CuSuite *get_jsonconf_suite(void) SUITE_ADD_TEST(suite, test_strings); SUITE_ADD_TEST(suite, test_spells); SUITE_ADD_TEST(suite, test_flags); + SUITE_ADD_TEST(suite, test_settings); SUITE_ADD_TEST(suite, test_infinitive_from_config); return suite; } From 7c565050579c7e41854c9d336455404adf80e3d9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 10 Sep 2015 23:27:14 +0200 Subject: [PATCH 04/10] move settings from XML to JSON for all games --- conf/e2/config.json | 6 ++-- conf/e3/config.json | 74 +++++++++++++++++++++++++++++++++++++++++- conf/e3/config.xml | 78 --------------------------------------------- conf/e4/config.json | 71 ++++++++++++++++++++++++++++++++++++++++- conf/e4/config.xml | 76 ------------------------------------------- 5 files changed, 146 insertions(+), 159 deletions(-) diff --git a/conf/e2/config.json b/conf/e2/config.json index 67ae85bce..5828ca261 100644 --- a/conf/e2/config.json +++ b/conf/e2/config.json @@ -3,6 +3,8 @@ "keywords.json" ], "settings": { + "game.id": 2, + "game.name": "Eressea", "NewbieImmunity": 8, "modules.wormholes": 1, "entertain.base": 0, @@ -27,8 +29,6 @@ "rules.guard.guard_number_stop_prob": 0.001, "rules.guard.castle_stop_prob": 0.05, "rules.guard.region_type_stop_prob": 0.05, - "rules.economy.repopulate_maximum": 500, - "game.id": 2, - "game.name": "Eressea" + "rules.economy.repopulate_maximum": 500 } } diff --git a/conf/e3/config.json b/conf/e3/config.json index b2acffcb3..fede39d1e 100644 --- a/conf/e3/config.json +++ b/conf/e3/config.json @@ -1,5 +1,77 @@ { "include": [ "keywords.json" - ] + ], + "settings": { + "game.id": 3, + "game.name": "E3", + "database.gameid": 7, + "NewbieImmunity": 4, + "modules.astralspace": 0, + "modules.wormholes": 0, + "modules.markets": 1, + "magic.regeneration": 0.75, + "magic.power": 0.5, + "resource.factor": 0.25, + "skills.cost.tactics": 500, + "entertain.base": 0, + "entertain.perlevel": 20, + "nmr.timeout": 5, + "nmr.removenewbie": 0, + "GiveRestriction": 3, + "hunger.long": 0, + "hunger.demon.skill": 1, + "hunger.damage": "1d9+9", + "hunger.demons": 1, + "init_spells": 0, + "recruit.allow_merge": 1, + "study.expensivemigrants": 1, + "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.monsters.attack_chance": 0.0, + "rules.transfermen": 0, + "rules.stealth.faction": 1, + "rules.stealth.anon_battle": 0, + "rules.check_overload": 0, + "rules.combat.goblinbonus": 3, + "rules.ship.damage_drift": 0.00, + "rules.alliances": 1, + "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.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.magic.playerschools": "gwyrrd illaun draig cerddor", + "rules.build.other_buildings": 1, + "rules.economy.taxation": 1, + "rules.economy.food": 2, + "rules.economy.wages": 1, + "rules.economy.roqf": 5, + "rules.economy.herbrot": 0, + "rules.region_owner_pay_building": "market harbour lighthouse", + "rules.dwarf_castles": 1, + "rules.limit.faction": 250, + "rules.economy.grow": 1, + "rules.tactics.formula": 1, + "rules.help.mask": "fight guard money give", + "movement.shipspeed.skillbonus": 6, + "alliance.auto": "fight", + "alliance.restricted": "fight" + } } diff --git a/conf/e3/config.xml b/conf/e3/config.xml index 31d9b31a7..a1dff207a 100644 --- a/conf/e3/config.xml +++ b/conf/e3/config.xml @@ -46,8 +46,6 @@ - - @@ -89,82 +87,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/conf/e4/config.json b/conf/e4/config.json index b2acffcb3..020ebafc1 100644 --- a/conf/e4/config.json +++ b/conf/e4/config.json @@ -1,5 +1,74 @@ { "include": [ "keywords.json" - ] + ], + "settings": { + "game.id": 4, + "game.name": "Deveron", + "database.gameid": 7, + "NewbieImmunity": 4, + "modules.astralspace": 0, + "modules.wormholes": 0, + "modules.markets": 1, + "magic.regeneration": 0.75, + "magic.power": 0.5, + "resource.factor": 0.25, + "skills.cost.tactics": 500, + "entertain.base": 0, + "entertain.perlevel": 20, + "nmr.timeout": 5, + "nmr.removenewbie": 0, + "GiveRestriction": 3, + "hunger.long": 0, + "hunger.demon.skill": 1, + "hunger.damage": "1d9+9", + "hunger.demons": 1, + "init_spells": 0, + "recruit.allow_merge": 1, + "study.expensivemigrants": 1, + "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.combat.goblinbonus": 3, + "rules.ship.damage_drift": 0.00, + "rules.alliances": 1, + "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.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.magic.playerschools": "gwyrrd illaun draig cerddor", + "rules.build.other_buildings": 1, + "rules.economy.taxation": 1, + "rules.economy.food": 2, + "rules.economy.wages": 1, + "rules.economy.roqf": 5, + "rules.economy.herbrot": 0, + "rules.region_owner_pay_building": "market harbour lighthouse", + "rules.dwarf_castles": 1, + "rules.limit.faction": 250, + "rules.economy.grow": 1, + "rules.tactics.formula": 1, + "rules.help.mask": "fight guard money give", + "movement.shipspeed.skillbonus": 6, + "alliance.auto": "fight", + "alliance.restricted": "fight" + } } diff --git a/conf/e4/config.xml b/conf/e4/config.xml index c8d6b21a3..8e0fad67c 100644 --- a/conf/e4/config.xml +++ b/conf/e4/config.xml @@ -45,9 +45,6 @@ - - - @@ -89,79 +86,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 1a7d6dd91d06116a797bdbcdb9f272e3bc2ccf4d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 10 Sep 2015 23:29:18 +0200 Subject: [PATCH 05/10] xmlreader no longer needs to parse settings, that's all in json now. --- src/kernel/xmlreader.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index eb122e116..faf1de423 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -2231,17 +2231,6 @@ static int parse_main(xmlDocPtr doc) xmlXPathFreeObject(result); - /* reading eressea/game/param */ - xpath->node = node; - result = xmlXPathEvalExpression(BAD_CAST "param", xpath); - nodes = result->nodesetval; - for (i = 0; i != nodes->nodeNr; ++i) { - xmlNodePtr node = nodes->nodeTab[i]; - parse_param(&global.parameters, node); - } - - xmlXPathFreeObject(result); - /* reading eressea/game/order */ result = xmlXPathEvalExpression(BAD_CAST "order", xpath); nodes = result->nodesetval; From 9bb2a625f9baae07faa0e5e62f26b70cc2414e16 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 11 Sep 2015 09:10:00 +0200 Subject: [PATCH 06/10] fix xmlreader bug introduced by last commit (xpath->node not initialized) --- scripts/tests/e3/rules.lua | 15 +++++++++++++++ src/kernel/xmlreader.c | 1 + src/util/language.c | 6 +++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/scripts/tests/e3/rules.lua b/scripts/tests/e3/rules.lua index 902a91741..2ed0e9e5c 100644 --- a/scripts/tests/e3/rules.lua +++ b/scripts/tests/e3/rules.lua @@ -146,6 +146,21 @@ function test_no_stealth() assert_equal(-1, u:get_skill("stealth")) end +function test_no_teach() + local r = region.create(0,0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u1 = unit.create(f, r, 1) + local u2 = unit.create(f, r, 1) + + u1:clear_orders() + u2:clear_orders() + u1:set_skill("riding", 3) + u2:add_order("LERNE Reiten") + u1:add_order("LEHRE " .. itoa36(u2.id)) + process_orders() + -- TODO: assert something (reflecting skills sucks!) +end + function test_seecast() local r = region.create(0,0, "plain") for i = 1,10 do diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index faf1de423..2deb15be7 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -2231,6 +2231,7 @@ static int parse_main(xmlDocPtr doc) xmlXPathFreeObject(result); + xpath->node = node; /* reading eressea/game/order */ result = xmlXPathEvalExpression(BAD_CAST "order", xpath); nodes = result->nodesetval; diff --git a/src/util/language.c b/src/util/language.c index 9409ab3c7..1972b38da 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -270,10 +270,10 @@ void init_translations(const struct locale *lang, int ut, const char * (*string_ for (i = 0; i != maxstrings; ++i) { // TODO: swap the name of s and key const char * s = string_cb(i); - const char * key = s ? locale_string(lang, s, false) : 0; - key = key ? key : s; - if (key) { + if (s) { struct critbit_tree ** cb = (struct critbit_tree **)tokens; + const char * key = locale_string(lang, s, false); + if (!key) key = s; add_translation(cb, key, i); } } From c5e14c85a635aad1d6bd226a4542ce43f1a70427 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 11 Sep 2015 09:17:07 +0200 Subject: [PATCH 07/10] read boolean json values be smarter about reading number values that are integers --- src/kernel/jsonconf.c | 7 ++++++- src/kernel/jsonconf.test.c | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index 465478775..7b2297146 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -650,7 +650,12 @@ static void json_settings(cJSON *json) { } else { char value[32]; - _snprintf(value, sizeof(value), "%lf", child->valuedouble); + if (child->type == cJSON_Number && child->valuedouble && child->valueintvaluedouble) { + _snprintf(value, sizeof(value), "%lf", child->valuedouble); + } + else { + _snprintf(value, sizeof(value), "%d", child->valueint); + } set_param(&global.parameters, child->string, value); } } diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c index 38fd41ae9..c317fc15a 100644 --- a/src/kernel/jsonconf.test.c +++ b/src/kernel/jsonconf.test.c @@ -62,14 +62,18 @@ static void test_settings(CuTest * tc) const char * data = "{\"settings\": { " "\"string\" : \"1d4\"," "\"integer\" : 14," - "\"float\" : 0.5 }}"; + "\"true\": true," + "\"false\": false," + "\"float\" : 1.5 }}"; cJSON *json = cJSON_Parse(data); test_cleanup(); json_config(json); + CuAssertStrEquals(tc, "1", get_param(global.parameters, "true")); + CuAssertStrEquals(tc, "0", get_param(global.parameters, "false")); CuAssertStrEquals(tc, "1d4", get_param(global.parameters, "string")); CuAssertIntEquals(tc, 14, get_param_int(global.parameters, "integer", 0)); - CuAssertDblEquals(tc, 0.5f, get_param_flt(global.parameters, "float", 0), 0.01); + CuAssertDblEquals(tc, 1.5f, get_param_flt(global.parameters, "float", 0), 0.01); test_cleanup(); } From 1a9dd531c5fd8c85a570785ed5bb0406b6983872 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 11 Sep 2015 09:34:38 +0200 Subject: [PATCH 08/10] use boolean values in E2 config. add a runtests.bat file for windows developers. make some tests clean up after themselves (os.remove on files they create). --- .gitignore | 2 ++ conf/e2/config.json | 8 ++++---- scripts/tests/common.lua | 4 +++- scripts/tests/orders.lua | 2 +- scripts/tests/storage.lua | 1 + tests/runtests.bat | 9 +++++++++ 6 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 tests/runtests.bat diff --git a/.gitignore b/.gitignore index 24a918963..fd1a7c349 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,5 @@ Thumbs.db *.cmd tmp/ tests/config.lua +tests/reports/ +tests/data/185.dat diff --git a/conf/e2/config.json b/conf/e2/config.json index 5828ca261..0d3a94203 100644 --- a/conf/e2/config.json +++ b/conf/e2/config.json @@ -6,21 +6,21 @@ "game.id": 2, "game.name": "Eressea", "NewbieImmunity": 8, - "modules.wormholes": 1, + "modules.wormholes": true, "entertain.base": 0, "entertain.perlevel": 20, "nmr.timeout": 5, "nmr.removenewbie": 0, "GiveRestriction": 3, - "hunger.long": 1, + "hunger.long": true, "init_spells": 0, "world.era": 2, "seed.population.min": 8, "seed.population.max": 8, "rules.ship.damage_drift": 0.00, - "rules.reserve.twophase": 1, + "rules.reserve.twophase": true, "rules.give.max_men": "-1", - "rules.check_overload": 0, + "rules.check_overload": false, "rules.limit.faction": 2500, "rules.maxskills.magic": 5, "rules.guard.base_stop_prob": 0.30, diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index fb1a29965..316ff1e71 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -45,7 +45,7 @@ function test_flags() eressea.write_game("test.dat") eressea.free_game() eressea.read_game("test.dat") - os.remove('test.dat') + os.remove('data/test.dat') f = get_faction(no) assert_equal(flags, f.flags) end @@ -194,6 +194,7 @@ function test_descriptions() eressea.write_game(filename) eressea.free_game() eressea.read_game(filename) + os.remove("data/test.dat") assert_equal(info, get_ship(sno).info) assert_equal(info, get_unit(uno).info) assert_equal(info, get_faction(fno).info) @@ -1081,5 +1082,6 @@ function test_parser() eressea.read_orders(filename) process_orders() + os.remove(filename) assert_equal("Goldene Herde", u.name) end diff --git a/scripts/tests/orders.lua b/scripts/tests/orders.lua index d9443c9c4..21ecbe644 100644 --- a/scripts/tests/orders.lua +++ b/scripts/tests/orders.lua @@ -104,7 +104,7 @@ function test_process_quit() eressea.write_game('test.dat') eressea.free_game() eressea.read_game('test.dat') - os.remove('test.dat') + os.remove('data/test.dat') assert_equal(nil, _G.get_faction(fno)) end diff --git a/scripts/tests/storage.lua b/scripts/tests/storage.lua index 5c86cf90a..7e4e775e7 100644 --- a/scripts/tests/storage.lua +++ b/scripts/tests/storage.lua @@ -26,6 +26,7 @@ function test_store_unit() assert_not_nil(store) u = store:read_unit() store:close() + os.remove(filename) assert_not_nil(u) assert_equal(u:get_item("money"), u.number * 100) end diff --git a/tests/runtests.bat b/tests/runtests.bat new file mode 100644 index 000000000..3bb41c982 --- /dev/null +++ b/tests/runtests.bat @@ -0,0 +1,9 @@ +@ECHO OFF +SET BUILD=..\build-vs12\eressea\Debug\ +SET SERVER=%BUILD%\eressea.exe +%BUILD%\test_eressea.exe +%SERVER% ..\scripts\run-tests.lua +%SERVER% ..\scripts\run-tests-e2.lua +%SERVER% ..\scripts\run-tests-e3.lua +PAUSE +RMDIR /s /q reports From cf08cdf3fb84a6815295a2fc6119dd80251aac74 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 11 Sep 2015 10:04:08 +0200 Subject: [PATCH 09/10] 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)); From d15d0cc0f41ee64aef2fc37a38cbbbc0468680df Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 11 Sep 2015 11:08:10 +0200 Subject: [PATCH 10/10] remove unused xml_i function --- src/util/xml.c | 7 ------- src/util/xml.h | 2 -- 2 files changed, 9 deletions(-) diff --git a/src/util/xml.c b/src/util/xml.c index 741165027..80cec1092 100644 --- a/src/util/xml.c +++ b/src/util/xml.c @@ -28,13 +28,6 @@ #include #ifdef USE_LIBXML2 -const xmlChar *xml_i(double number) -{ - static char buffer[128]; // FIXME: static return value - _snprintf(buffer, sizeof(buffer), "%.0f", number); - return (const xmlChar *)buffer; -} - int xml_ivalue(xmlNodePtr node, const char *name, int dflt) { int i = dflt; diff --git a/src/util/xml.h b/src/util/xml.h index b2235b521..b5beee233 100644 --- a/src/util/xml.h +++ b/src/util/xml.h @@ -26,8 +26,6 @@ extern "C" { extern double xml_fvalue(xmlNodePtr node, const char *name, double dflt); extern int xml_ivalue(xmlNodePtr node, const char *name, int dflt); extern bool xml_bvalue(xmlNodePtr node, const char *name, bool dflt); - - const xmlChar *xml_i(double number); #endif extern int read_xml(const char *filename, const char *catalog);