From 8d8173def3fefdb02aaaa9058f2019ccc9ace76a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 13 Mar 2017 09:30:20 +0100 Subject: [PATCH] remove the functions struct from settings (next: remove wage, too) --- src/kernel/building.c | 4 ++-- src/kernel/config.c | 2 +- src/kernel/config.h | 6 ++---- src/kernel/xmlreader.c | 2 +- src/laws.test.c | 6 +++--- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/kernel/building.c b/src/kernel/building.c index 6d0db8f43..1a9e826e6 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -811,8 +811,8 @@ minimum_wage(const region * r, const faction * f, const race * rc, int in_turn) * die Bauern wenn f == NULL. */ int wage(const region * r, const faction * f, const race * rc, int in_turn) { - if (global.functions.wage) { - return global.functions.wage(r, f, rc, in_turn); + if (global.wage) { + return global.wage(r, f, rc, in_turn); } return default_wage(r, f, rc, in_turn); } diff --git a/src/kernel/config.c b/src/kernel/config.c index 3bbb0fd69..6d84a7c73 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -796,7 +796,7 @@ bool config_token(const char *key, const char *tok) { } void free_config(void) { - global.functions.wage = NULL; + global.wage = NULL; free_params(&configuration); ++config_cache_key; } diff --git a/src/kernel/config.h b/src/kernel/config.h index 86eda7c5c..c8c2e4be9 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -110,10 +110,8 @@ extern "C" { typedef struct settings { struct attrib *attribs; void *vm_state; - struct global_functions { - int(*wage) (const struct region * r, const struct faction * f, - const struct race * rc, int in_turn); - } functions; + int(*wage) (const struct region * r, const struct faction * f, + const struct race * rc, int in_turn); } settings; void set_param(struct param **p, const char *key, const char *value); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 4db528853..dcaf97580 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -907,7 +907,7 @@ static int parse_rules(xmlDocPtr doc) } assert(propValue != NULL); if (strcmp((const char *)propValue, "wage") == 0) { - global.functions.wage = + global.wage = (int(*)(const struct region *, const struct faction *, const struct race *, int))fun; } diff --git a/src/laws.test.c b/src/laws.test.c index e8391b67c..9ed457af7 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1452,7 +1452,7 @@ static void test_immigration(CuTest * tc) { region *r; double inject[] = { 1 }; - int (*old_wage)(const region*, const faction*, const race*, int) = global.functions.wage; + int (*old_wage)(const region*, const faction*, const race*, int) = global.wage; test_setup(); r = test_create_region(0, 0, 0); @@ -1472,10 +1472,10 @@ static void test_immigration(CuTest * tc) random_source_inject_array(inject, 2); - global.functions.wage = low_wage; + global.wage = low_wage; immigration(); CuAssertIntEquals(tc, 2, rpeasants(r)); - global.functions.wage = old_wage; + global.wage = old_wage; test_cleanup(); }