From: Holger Schemel Date: Wed, 3 Apr 2002 23:10:50 +0000 (+0200) Subject: rnd-20020404-1-src X-Git-Tag: 2.1.0^2~65 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=06caafc8481189a73ffc5beb2105aaec5ac0acb5;p=rocksndiamonds.git rnd-20020404-1-src --- diff --git a/src/files.c b/src/files.c index 2a723971..e39ba567 100644 --- a/src/files.c +++ b/src/files.c @@ -1181,8 +1181,11 @@ void SaveScore(int level_nr) #define SETUP_TOKEN_TIME_LIMIT 13 #define SETUP_TOKEN_FULLSCREEN 14 #define SETUP_TOKEN_ASK_ON_ESCAPE 15 +#define SETUP_TOKEN_GRAPHICS_DIR 16 +#define SETUP_TOKEN_SOUNDS_DIR 17 +#define SETUP_TOKEN_MUSIC_DIR 18 -#define NUM_GLOBAL_SETUP_TOKENS 16 +#define NUM_GLOBAL_SETUP_TOKENS 19 /* shortcut setup */ #define SETUP_TOKEN_SAVE_GAME 0 @@ -1231,8 +1234,11 @@ static struct TokenInfo global_setup_tokens[] = { TYPE_SWITCH, &si.team_mode, "team_mode" }, { TYPE_SWITCH, &si.handicap, "handicap" }, { TYPE_SWITCH, &si.time_limit, "time_limit" }, + { TYPE_SWITCH, &si.fullscreen, "fullscreen" }, { TYPE_SWITCH, &si.ask_on_escape, "ask_on_escape" }, - { TYPE_SWITCH, &si.fullscreen, "fullscreen" } + { TYPE_STRING, &si.graphics_dir, "graphics_dir" }, + { TYPE_STRING, &si.sounds_dir, "sounds_dir" }, + { TYPE_STRING, &si.music_dir, "music_dir" }, }; static struct TokenInfo shortcut_setup_tokens[] = @@ -1287,6 +1293,10 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->fullscreen = FALSE; si->ask_on_escape = TRUE; + si->graphics_dir = getStringCopy(GRAPHICS_DIRECTORY); + si->sounds_dir = getStringCopy(SOUNDS_DIRECTORY); + si->music_dir = getStringCopy(MUSIC_DIRECTORY); + si->shortcut.save_game = DEFAULT_KEY_SAVE_GAME; si->shortcut.load_game = DEFAULT_KEY_LOAD_GAME; @@ -1412,7 +1422,7 @@ void SaveSetup() fprintf(file, "%s\n", getSetupLine(global_setup_tokens, "", i)); /* just to make things nicer :) */ - if (i == SETUP_TOKEN_PLAYER_NAME) + if (i == SETUP_TOKEN_PLAYER_NAME || i == SETUP_TOKEN_GRAPHICS_DIR - 1) fprintf(file, "\n"); } diff --git a/src/init.c b/src/init.c index fe585257..b45aa038 100644 --- a/src/init.c +++ b/src/init.c @@ -71,6 +71,7 @@ void OpenAll(void) InitSetup(); InitPlayerInfo(); + InitArtworkInfo(); /* needed before loading gfx, sound & music */ InitCounter(); InitSound(); @@ -83,7 +84,6 @@ void OpenAll(void) InitEventFilter(FilterMouseMotionEvents); - InitArtworkInfo(); InitGfx(); InitElementProperties(); /* initializes IS_CHAR() for el2gfx() */ diff --git a/src/libgame/setup.c b/src/libgame/setup.c index d9b62634..451e4742 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -543,9 +543,11 @@ void dumpTreeInfo(TreeInfo *node, int depth) { int i; + printf("Dumping TreeInfo:\n"); + while (node) { - for (i=0; ifilename, node->name); @@ -1074,12 +1076,9 @@ static struct TokenInfo levelinfo_tokens[] = { TYPE_BOOLEAN, &ldi.readonly, "readonly" } }; -static void setTreeInfoToDefaults(TreeInfo *ldi) +static void setTreeInfoToDefaults(TreeInfo *ldi, int type) { - /* ldi->type is expected to be already set! */ - - if (ldi->type == 0) - Error(ERR_EXIT, "ldi->type == 0"); + ldi->type = type; ldi->node_top = (ldi->type == TREE_TYPE_LEVEL_DIR ? &leveldir_first : ldi->type == TREE_TYPE_GRAPHICS_DIR ? &artwork.gfx_first : @@ -1124,7 +1123,9 @@ static void setTreeInfoToDefaultsFromParent(TreeInfo *ldi, TreeInfo *parent) { if (parent == NULL) { - setTreeInfoToDefaults(ldi); + Error(ERR_WARN, "setTreeInfoToDefaultsFromParent(): parent == NULL"); + + setTreeInfoToDefaults(ldi, TREE_TYPE_GENERIC); return; } @@ -1230,9 +1231,7 @@ static void createParentTreeInfoNode(TreeInfo *node_parent) return; ti_new = newTreeInfo(); - ti_new->type = node_parent->type; - - setTreeInfoToDefaults(ti_new); + setTreeInfoToDefaults(ti_new, node_parent->type); ti_new->node_parent = node_parent; ti_new->parent_link = TRUE; @@ -1275,10 +1274,13 @@ static boolean LoadLevelInfoFromLevelConf(TreeInfo **node_first, } leveldir_new = newTreeInfo(); - leveldir_new->type = TREE_TYPE_LEVEL_DIR; + + if (node_parent) + setTreeInfoToDefaultsFromParent(leveldir_new, node_parent); + else + setTreeInfoToDefaults(leveldir_new, TREE_TYPE_LEVEL_DIR); checkSetupFileListIdentifier(setup_file_list, getCookie("LEVELINFO")); - setTreeInfoToDefaultsFromParent(leveldir_new, node_parent); /* set all structure fields according to the token/value pairs */ ldi = *leveldir_new; @@ -1478,13 +1480,15 @@ static boolean LoadArtworkInfoFromArtworkConf(TreeInfo **node_first, } artwork_new = newTreeInfo(); - artwork_new->type = type; - setTreeInfoToDefaultsFromParent(artwork_new, node_parent); + if (node_parent) + setTreeInfoToDefaultsFromParent(artwork_new, node_parent); + else + setTreeInfoToDefaults(artwork_new, type); artwork_new->filename = getStringCopy(directory_name); - if (setup_file_list) + if (setup_file_list) /* (before defining ".color" and ".class_desc") */ { #if 0 checkSetupFileListIdentifier(setup_file_list, getCookie("...")); @@ -1505,19 +1509,6 @@ static boolean LoadArtworkInfoFromArtworkConf(TreeInfo **node_first, if (artwork_new->name_sorting == NULL) artwork_new->name_sorting = getStringCopy(artwork_new->name); } - else - { - if (artwork_new->name != NULL) - free(artwork_new->name); - - if (strcmp(artwork_new->filename, ".") == 0) - artwork_new->name = getStringCopy("default"); - else - artwork_new->name = getStringCopy(artwork_new->filename); - - artwork_new->name_short = getStringCopy(artwork_new->name); - artwork_new->name_sorting = getStringCopy(artwork_new->name); - } if (node_parent == NULL) /* top level group */ { @@ -1536,10 +1527,28 @@ static boolean LoadArtworkInfoFromArtworkConf(TreeInfo **node_first, artwork_new->user_defined = (artwork_new->basepath == check_dir ? FALSE : TRUE); -#if 0 + /* (may use ".sort_priority" from "setup_file_list" above) */ artwork_new->color = LEVELCOLOR(artwork_new); artwork_new->class_desc = getLevelClassDescription(artwork_new); -#endif + + if (setup_file_list == NULL) /* (after determining ".user_defined") */ + { + if (artwork_new->name != NULL) + free(artwork_new->name); + + if (strcmp(artwork_new->filename, ".") == 0) + { + if (artwork_new->user_defined) + artwork_new->name = getStringCopy("private"); + else + artwork_new->name = getStringCopy("default"); + } + else + artwork_new->name = getStringCopy(artwork_new->filename); + + artwork_new->name_short = getStringCopy(artwork_new->name); + artwork_new->name_sorting = getStringCopy(artwork_new->name); + } pushTreeInfo(node_first, artwork_new); @@ -1637,6 +1646,7 @@ void LoadArtworkInfo() getUserMusicDir(NULL), TREE_TYPE_MUSIC_DIR); + /* before sorting, the first entries will be from the user directory */ artwork.gfx_current = artwork.gfx_first; artwork.snd_current = artwork.snd_first; artwork.mus_current = artwork.mus_first; @@ -1645,7 +1655,7 @@ void LoadArtworkInfo() sortTreeInfo(&artwork.snd_first, compareTreeInfoEntries); sortTreeInfo(&artwork.mus_first, compareTreeInfoEntries); -#if 0 +#if 1 dumpTreeInfo(artwork.gfx_first, 0); dumpTreeInfo(artwork.snd_first, 0); dumpTreeInfo(artwork.mus_first, 0); @@ -1668,7 +1678,7 @@ static void SaveUserLevelInfo() } /* always start with reliable default values */ - setTreeInfoToDefaults(&ldi); + setTreeInfoToDefaults(&ldi, TREE_TYPE_LEVEL_DIR); ldi.name = getLoginName(); ldi.author = getRealName(); diff --git a/src/libgame/system.h b/src/libgame/system.h index 3dbae599..5f630fa3 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -307,6 +307,10 @@ struct SetupInfo boolean fullscreen; boolean ask_on_escape; + char *graphics_dir; + char *sounds_dir; + char *music_dir; + struct SetupShortcutInfo shortcut; struct SetupInputInfo input[MAX_PLAYERS]; }; diff --git a/src/timestamp.h b/src/timestamp.h index 3a865842..11501978 100644 --- a/src/timestamp.h +++ b/src/timestamp.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2002-04-03 00:02]" +#define COMPILE_DATE_STRING "[2002-04-04 01:09]"