add a config_token function to look for a token inside a list

This commit is contained in:
Enno Rehling 2015-11-22 12:20:33 +01:00
parent a4cb5e2906
commit edcd79d044
5 changed files with 8 additions and 3 deletions

View File

@ -731,7 +731,7 @@ static bool maintain(building * b, bool first)
return false; return false;
} }
/* If the owner is the region owner, check if dontpay flag is set for the building where he is in */ /* 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)) { if (fval(u->building, BLD_DONTPAY)) {
return false; return false;
} }

View File

@ -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()) { if (rule_region_owners()) {
u = building_owner(largestbuilding(bld->region, &cmp_taxes, false)); u = building_owner(largestbuilding(bld->region, &cmp_taxes, false));
} }

View File

@ -1587,6 +1587,10 @@ double config_get_flt(const char *key, double def) {
return get_param_flt(global.parameters, key, 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. /** releases all memory associated with the game state.
* call this function before calling read_game() to load a new game * call this function before calling read_game() to load a new game
* if you have a previously loaded state in memory. * if you have a previously loaded state in memory.

View File

@ -279,6 +279,7 @@ extern "C" {
const char *config_get(const char *key); const char *config_get(const char *key);
int config_get_int(const char *key, int def); int config_get_int(const char *key, int def);
double config_get_flt(const char *key, double def); double config_get_flt(const char *key, double def);
bool config_token(const char *key, const char *tok);
bool ExpensiveMigrants(void); bool ExpensiveMigrants(void);
int NMRTimeout(void); int NMRTimeout(void);

View File

@ -1397,7 +1397,7 @@ static void prepare_reports(void)
} }
/* Region owner get always the Lighthouse report */ /* 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) { for (b = rbuildings(r); b; b = b->next) {
if (b && b->type == bt_lighthouse) { if (b && b->type == bt_lighthouse) {
u = building_owner(b); u = building_owner(b);