forked from github/server
remove the functions struct from settings (next: remove wage, too)
This commit is contained in:
parent
8cfcffc4aa
commit
8d8173def3
|
@ -811,8 +811,8 @@ minimum_wage(const region * r, const faction * f, const race * rc, int in_turn)
|
||||||
* die Bauern wenn f == NULL. */
|
* die Bauern wenn f == NULL. */
|
||||||
int wage(const region * r, const faction * f, const race * rc, int in_turn)
|
int wage(const region * r, const faction * f, const race * rc, int in_turn)
|
||||||
{
|
{
|
||||||
if (global.functions.wage) {
|
if (global.wage) {
|
||||||
return global.functions.wage(r, f, rc, in_turn);
|
return global.wage(r, f, rc, in_turn);
|
||||||
}
|
}
|
||||||
return default_wage(r, f, rc, in_turn);
|
return default_wage(r, f, rc, in_turn);
|
||||||
}
|
}
|
||||||
|
|
|
@ -796,7 +796,7 @@ bool config_token(const char *key, const char *tok) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_config(void) {
|
void free_config(void) {
|
||||||
global.functions.wage = NULL;
|
global.wage = NULL;
|
||||||
free_params(&configuration);
|
free_params(&configuration);
|
||||||
++config_cache_key;
|
++config_cache_key;
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,10 +110,8 @@ extern "C" {
|
||||||
typedef struct settings {
|
typedef struct settings {
|
||||||
struct attrib *attribs;
|
struct attrib *attribs;
|
||||||
void *vm_state;
|
void *vm_state;
|
||||||
struct global_functions {
|
|
||||||
int(*wage) (const struct region * r, const struct faction * f,
|
int(*wage) (const struct region * r, const struct faction * f,
|
||||||
const struct race * rc, int in_turn);
|
const struct race * rc, int in_turn);
|
||||||
} functions;
|
|
||||||
} settings;
|
} settings;
|
||||||
|
|
||||||
void set_param(struct param **p, const char *key, const char *value);
|
void set_param(struct param **p, const char *key, const char *value);
|
||||||
|
|
|
@ -907,7 +907,7 @@ static int parse_rules(xmlDocPtr doc)
|
||||||
}
|
}
|
||||||
assert(propValue != NULL);
|
assert(propValue != NULL);
|
||||||
if (strcmp((const char *)propValue, "wage") == 0) {
|
if (strcmp((const char *)propValue, "wage") == 0) {
|
||||||
global.functions.wage =
|
global.wage =
|
||||||
(int(*)(const struct region *, const struct faction *,
|
(int(*)(const struct region *, const struct faction *,
|
||||||
const struct race *, int))fun;
|
const struct race *, int))fun;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1452,7 +1452,7 @@ static void test_immigration(CuTest * tc)
|
||||||
{
|
{
|
||||||
region *r;
|
region *r;
|
||||||
double inject[] = { 1 };
|
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();
|
test_setup();
|
||||||
r = test_create_region(0, 0, 0);
|
r = test_create_region(0, 0, 0);
|
||||||
|
@ -1472,10 +1472,10 @@ static void test_immigration(CuTest * tc)
|
||||||
|
|
||||||
random_source_inject_array(inject, 2);
|
random_source_inject_array(inject, 2);
|
||||||
|
|
||||||
global.functions.wage = low_wage;
|
global.wage = low_wage;
|
||||||
immigration();
|
immigration();
|
||||||
CuAssertIntEquals(tc, 2, rpeasants(r));
|
CuAssertIntEquals(tc, 2, rpeasants(r));
|
||||||
global.functions.wage = old_wage;
|
global.wage = old_wage;
|
||||||
|
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue