From edcd79d044f41b1a370b2b7754b0d889ca7fc88e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Nov 2015 12:20:33 +0100 Subject: [PATCH] add a config_token function to look for a token inside a list --- src/economy.c | 2 +- src/kernel/building.c | 2 +- src/kernel/config.c | 4 ++++ src/kernel/config.h | 1 + src/reports.c | 2 +- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/economy.c b/src/economy.c index 64a2a6771..26eb5251b 100644 --- a/src/economy.c +++ b/src/economy.c @@ -731,7 +731,7 @@ static bool maintain(building * b, bool first) return false; } /* If the owner is the region owner, check if dontpay flag is set for the building where he is in */ - if (check_param(global.parameters, "rules.region_owner_pay_building", b->type->_name)) { + if (config_token("rules.region_owner_pay_building", b->type->_name)) { if (fval(u->building, BLD_DONTPAY)) { return false; } diff --git a/src/kernel/building.c b/src/kernel/building.c index 4867b3687..715b4de0f 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -591,7 +591,7 @@ static unit *building_owner_ex(const building * bld, const struct faction * last } } } - if (!heir && check_param(global.parameters, "rules.region_owner_pay_building", bld->type->_name)) { + if (!heir && config_token("rules.region_owner_pay_building", bld->type->_name)) { if (rule_region_owners()) { u = building_owner(largestbuilding(bld->region, &cmp_taxes, false)); } diff --git a/src/kernel/config.c b/src/kernel/config.c index 1ba1f6c7f..956c622fe 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -1587,6 +1587,10 @@ double config_get_flt(const char *key, double def) { return get_param_flt(global.parameters, key, def); } +bool config_token(const char *key, const char *tok) { + return !!check_param(global.parameters, key, tok); +} + /** 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 817850166..fc6ce99f3 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -279,6 +279,7 @@ extern "C" { 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 config_token(const char *key, const char *tok); bool ExpensiveMigrants(void); int NMRTimeout(void); diff --git a/src/reports.c b/src/reports.c index 44e79324e..29b459f20 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1397,7 +1397,7 @@ static void prepare_reports(void) } /* Region owner get always the Lighthouse report */ - if (bt_lighthouse && check_param(global.parameters, "rules.region_owner_pay_building", bt_lighthouse->_name)) { + if (bt_lighthouse && config_token("rules.region_owner_pay_building", bt_lighthouse->_name)) { for (b = rbuildings(r); b; b = b->next) { if (b && b->type == bt_lighthouse) { u = building_owner(b);