From: Holger Schemel Date: Wed, 3 Dec 2003 00:58:46 +0000 (+0100) Subject: rnd-20031203-3-src X-Git-Tag: 3.0.8^2~7 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=ec50fda335d6dc628abc56320bfd3a42711edd1d;p=rocksndiamonds.git rnd-20031203-3-src --- diff --git a/src/conftime.h b/src/conftime.h index 71221517..cfd9fb62 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-12-03 00:38]" +#define COMPILE_DATE_STRING "[2003-12-03 01:50]" diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 66d10649..a1321209 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1864,7 +1864,7 @@ static boolean token_suffix_match(char *token, char *suffix, int start_pos) return FALSE; } -#define KNOWN_TOKEN_VALUE "[KNOWN_TOKEN]" +#define KNOWN_TOKEN_VALUE "[KNOWN_TOKEN_VALUE]" static void read_token_parameters(SetupFileHash *setup_file_hash, struct ConfigInfo *suffix_list, @@ -1981,7 +1981,8 @@ static void LoadArtworkConfigFromFilename(struct ArtworkListInfo *artwork_info, int num_ext2_suffixes = artwork_info->num_ext2_suffixes; int num_ext3_suffixes = artwork_info->num_ext3_suffixes; int num_ignore_tokens = artwork_info->num_ignore_tokens; - SetupFileHash *setup_file_hash, *extra_file_hash; + SetupFileHash *setup_file_hash, *valid_file_hash; + SetupFileHash *extra_file_hash, *empty_file_hash; char *known_token_value = KNOWN_TOKEN_VALUE; int i, j, k, l; @@ -1995,26 +1996,42 @@ static void LoadArtworkConfigFromFilename(struct ArtworkListInfo *artwork_info, if ((setup_file_hash = loadSetupFileHash(filename)) == NULL) return; + /* separate valid (defined) from empty (undefined) config token values */ + valid_file_hash = newSetupFileHash(); + empty_file_hash = newSetupFileHash(); + BEGIN_HASH_ITERATION(setup_file_hash, itr) + { + char *value = HASH_ITERATION_VALUE(itr); + + setHashEntry(*value ? valid_file_hash : empty_file_hash, + HASH_ITERATION_TOKEN(itr), value); + } + END_HASH_ITERATION(setup_file_hash, itr) + + /* at this point, we do not need the setup file hash anymore -- free it */ + freeSetupFileHash(setup_file_hash); + /* read parameters for all known config file tokens */ for (i = 0; i < num_file_list_entries; i++) - read_token_parameters(setup_file_hash, suffix_list, &file_list[i]); + read_token_parameters(valid_file_hash, suffix_list, &file_list[i]); /* set all tokens that can be ignored here to "known" keyword */ for (i = 0; i < num_ignore_tokens; i++) - setHashEntry(setup_file_hash, ignore_tokens[i], known_token_value); + setHashEntry(valid_file_hash, ignore_tokens[i], known_token_value); - /* copy all unknown config file tokens to extra config list */ + /* copy all unknown config file tokens to extra config hash */ extra_file_hash = newSetupFileHash(); - BEGIN_HASH_ITERATION(setup_file_hash, itr) + BEGIN_HASH_ITERATION(valid_file_hash, itr) { - if (strcmp(HASH_ITERATION_VALUE(itr), known_token_value) != 0) - setHashEntry(extra_file_hash, - HASH_ITERATION_TOKEN(itr), HASH_ITERATION_VALUE(itr)); + char *value = HASH_ITERATION_VALUE(itr); + + if (strcmp(value, known_token_value) != 0) + setHashEntry(extra_file_hash, HASH_ITERATION_TOKEN(itr), value); } - END_HASH_ITERATION(setup_file_hash, itr) + END_HASH_ITERATION(valid_file_hash, itr) - /* at this point, we do not need the config file hash anymore -- free it */ - freeSetupFileHash(setup_file_hash); + /* at this point, we do not need the valid file hash anymore -- free it */ + freeSetupFileHash(valid_file_hash); /* now try to determine valid, dynamically defined config tokens */ @@ -2231,11 +2248,12 @@ static void LoadArtworkConfigFromFilename(struct ArtworkListInfo *artwork_info, artwork_info->sizeof_artwork_list_entry); } - if (extra_file_hash != NULL && options.verbose && IS_PARENT_PROCESS()) + if (options.verbose && IS_PARENT_PROCESS()) { SetupFileList *setup_file_list, *list; boolean dynamic_tokens_found = FALSE; boolean unknown_tokens_found = FALSE; + boolean undefined_values_found = (hashtable_count(empty_file_hash) != 0); if ((setup_file_list = loadSetupFileList(filename)) == NULL) Error(ERR_EXIT, "loadSetupFileHash works, but loadSetupFileList fails"); @@ -2283,10 +2301,28 @@ static void LoadArtworkConfigFromFilename(struct ArtworkListInfo *artwork_info, Error(ERR_RETURN_LINE, "-"); } + if (undefined_values_found) + { + Error(ERR_RETURN_LINE, "-"); + Error(ERR_RETURN, "warning: undefined values found in config file:"); + Error(ERR_RETURN, "- config file: '%s'", filename); + + for (list = setup_file_list; list != NULL; list = list->next) + { + char *value = getHashEntry(empty_file_hash, list->token); + + if (value != NULL) + Error(ERR_RETURN, "- undefined value for token: '%s'", list->token); + } + + Error(ERR_RETURN_LINE, "-"); + } + freeSetupFileList(setup_file_list); } freeSetupFileHash(extra_file_hash); + freeSetupFileHash(empty_file_hash); #if 0 for (i = 0; i < num_file_list_entries; i++) diff --git a/src/libgame/setup.c b/src/libgame/setup.c index ac0bfd4c..65ba26c7 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -1391,6 +1391,14 @@ void setHashEntry(SetupFileHash *hash, char *token, char *value) Error(ERR_EXIT, "cannot insert into hash -- aborting"); } +char *removeHashEntry(SetupFileHash *hash, char *token) +{ + if (hash == NULL) + return NULL; + + return remove_hash_entry(hash, token); +} + #if 0 #ifdef DEBUG static void printSetupFileHash(SetupFileHash *hash) @@ -1506,10 +1514,12 @@ static void *loadSetupFileData(char *filename, boolean use_hash) if (*value != ' ' && *value != '\t') break; +#if 0 if (*value == '\0') value = "true"; /* treat tokens without value as "true" */ +#endif - if (*token && *value) + if (*token) { if (use_hash) setHashEntry((SetupFileHash *)setup_file_data, token, value); diff --git a/src/libgame/setup.h b/src/libgame/setup.h index 7d99fec3..807351d3 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -254,6 +254,7 @@ SetupFileHash *newSetupFileHash(); void freeSetupFileHash(SetupFileHash *); char *getHashEntry(SetupFileHash *, char *); void setHashEntry(SetupFileHash *, char *, char *); +char *removeHashEntry(SetupFileHash *, char *); SetupFileHash *loadSetupFileHash(char *); void checkSetupFileHashIdentifier(SetupFileHash *, char *); void setSetupInfo(struct TokenInfo *, int, char *);