Revert "Revert "bugfix cheat saving""

This reverts commit 98625796106ea6453102b67ac4108b856ed3b9a3.
This commit is contained in:
twinaphex 2018-10-11 03:27:06 +02:00
parent c443d6b475
commit 49a3514147
2 changed files with 7 additions and 1 deletions

View File

@ -406,6 +406,7 @@ static config_file_t *config_file_new_internal(
conf->path = NULL; conf->path = NULL;
conf->entries = NULL; conf->entries = NULL;
conf->tail = NULL; conf->tail = NULL;
conf->last = NULL;
conf->includes = NULL; conf->includes = NULL;
conf->include_depth = 0; conf->include_depth = 0;
conf->guaranteed_no_duplicates = false ; conf->guaranteed_no_duplicates = false ;
@ -558,6 +559,7 @@ config_file_t *config_file_new_from_string(const char *from_string)
conf->path = NULL; conf->path = NULL;
conf->entries = NULL; conf->entries = NULL;
conf->tail = NULL; conf->tail = NULL;
conf->last = NULL;
conf->includes = NULL; conf->includes = NULL;
conf->include_depth = 0; conf->include_depth = 0;
conf->guaranteed_no_duplicates = false ; conf->guaranteed_no_duplicates = false ;
@ -842,7 +844,7 @@ bool config_get_bool(config_file_t *conf, const char *key, bool *in)
void config_set_string(config_file_t *conf, const char *key, const char *val) void config_set_string(config_file_t *conf, const char *key, const char *val)
{ {
struct config_entry_list *last = conf->entries; struct config_entry_list *last = (conf->guaranteed_no_duplicates && conf->last) ? conf->last : conf->entries;
struct config_entry_list *entry = conf->guaranteed_no_duplicates?NULL:config_get_entry(conf, key, &last); struct config_entry_list *entry = conf->guaranteed_no_duplicates?NULL:config_get_entry(conf, key, &last);
if (entry && !entry->readonly) if (entry && !entry->readonly)
@ -868,6 +870,9 @@ void config_set_string(config_file_t *conf, const char *key, const char *val)
last->next = entry; last->next = entry;
else else
conf->entries = entry; conf->entries = entry;
conf->last = entry ;
} }
void config_unset(config_file_t *conf, const char *key) void config_unset(config_file_t *conf, const char *key)

View File

@ -57,6 +57,7 @@ struct config_file
char *path; char *path;
struct config_entry_list *entries; struct config_entry_list *entries;
struct config_entry_list *tail; struct config_entry_list *tail;
struct config_entry_list *last;
unsigned include_depth; unsigned include_depth;
bool guaranteed_no_duplicates; bool guaranteed_no_duplicates;