refactor: make sure global.paramteres is used only inside config.c

This commit is contained in:
Enno Rehling 2015-11-22 12:24:27 +01:00
parent edcd79d044
commit fe173e9551
3 changed files with 14 additions and 9 deletions

View file

@ -1572,23 +1572,29 @@ bool markets_module(void)
}
void config_set(const char *key, const char *value) {
set_param(&global.parameters, key, value);
set_param(&global.parameters_, key, value);
}
const char *config_get(const char *key) {
return get_param(global.parameters, key);
return get_param(global.parameters_, key);
}
int config_get_int(const char *key, int def) {
return get_param_int(global.parameters, key, def);
return get_param_int(global.parameters_, key, def);
}
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);
return !!check_param(global.parameters_, key, tok);
}
void free_config(void) {
global.functions.maintenance = NULL;
global.functions.wage = NULL;
free_params(&global.parameters_);
}
/** releases all memory associated with the game state.

View file

@ -246,7 +246,7 @@ extern "C" {
const char *gamename;
struct attrib *attribs;
unsigned int data_turn;
struct param *parameters;
struct param *parameters_;
void *vm_state;
int data_version; /* TODO: eliminate in favor of gamedata.version */
struct _dictionary_ *inifile;
@ -297,6 +297,7 @@ extern "C" {
void init_parameters(struct locale *lang);
void free_gamedata(void);
void free_config(void);
extern struct helpmode helpmodes[];
extern const char *parameters[];

View file

@ -78,9 +78,7 @@ void test_cleanup(void)
free_terrains();
free_resources();
global.functions.maintenance = NULL;
global.functions.wage = NULL;
free_params(&global.parameters);
free_config();
default_locale = 0;
close_orders();
free_locales();