From fffaec4e69e54c74cf5eea689191e81b8c19b85a Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Fri, 6 Sep 2002 22:45:51 +0200 Subject: [PATCH] rnd-20020906-3-src --- Makefile | 6 ++- src/conftime.h | 2 +- src/game.c | 23 +++++----- src/init.c | 34 ++++++++++++--- src/libgame/image.c | 11 +++-- src/libgame/image.h | 3 +- src/libgame/misc.c | 101 +++++++++++++++++++++++++++++++------------ src/libgame/misc.h | 1 + src/libgame/sound.c | 6 +-- src/libgame/sound.h | 4 +- src/libgame/system.h | 18 +++++--- src/main.c | 11 ++++- src/main.h | 8 ++-- 13 files changed, 158 insertions(+), 70 deletions(-) diff --git a/Makefile b/Makefile index a986996e..96b73c56 100644 --- a/Makefile +++ b/Makefile @@ -49,8 +49,10 @@ CROSS_PATH_WIN32=/usr/local/cross-tools/i386-mingw32msvc SRC_DIR = src MAKE_CMD = $(MAKE) -C $(SRC_DIR) +DEFAULT_TARGET = sdl + all: - @$(MAKE_CMD) TARGET=x11 + @$(MAKE_CMD) TARGET=$(DEFAULT_TARGET) x11: @$(MAKE_CMD) TARGET=x11 @@ -85,7 +87,7 @@ clean: #-----------------------------------------------------------------------------# run: - @$(MAKE_CMD) TARGET=x11 && ./rocksndiamonds --verbose + @$(MAKE_CMD) TARGET=$(DEFAULT_TARGET) && ./rocksndiamonds --verbose backup: ./Scripts/make_backup.sh src diff --git a/src/conftime.h b/src/conftime.h index bd4614a2..8e53e013 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2002-09-06 19:21]" +#define COMPILE_DATE_STRING "[2002-09-06 22:45]" diff --git a/src/game.c b/src/game.c index f64d2593..5ac7b6c2 100644 --- a/src/game.c +++ b/src/game.c @@ -153,7 +153,7 @@ static struct { NULL, 0, 0 }, }; static int element_action_sound[NUM_LEVEL_ELEMENTS][NUM_SND_ACTIONS]; -static boolean is_loop_sound[NUM_SOUND_CONFIG_ENTRIES]; +static boolean is_loop_sound[NUM_SOUND_FILES]; #define IS_LOOP_SOUND(x) (is_loop_sound[x]) @@ -507,7 +507,7 @@ void DrawGameDoorValues() void InitGameSound() { - int sound_effect_properties[NUM_SOUND_CONFIG_ENTRIES]; + int sound_effect_properties[NUM_SOUND_FILES]; int i, j; #if 0 @@ -518,22 +518,21 @@ void InitGameSound() for (j=0; jtype = ARTWORK_TYPE_GRAPHICS; image_info->num_list_entries = num_list_entries; - image_info->config_list = config_list; - image_info->file_list = NULL; + image_info->file_list = file_list; + image_info->content_list = NULL; image_info->load_artwork = Load_PCX; image_info->free_artwork = FreeImage; } @@ -720,3 +720,8 @@ void ReloadCustomImages() ReloadCustomArtworkList(image_info); } + +void FreeAllImages() +{ + FreeCustomArtworkList(image_info); +} diff --git a/src/libgame/image.h b/src/libgame/image.h index 8f998fba..f96b6170 100644 --- a/src/libgame/image.h +++ b/src/libgame/image.h @@ -72,7 +72,8 @@ int Read_PCX_to_Pixmap(Display *, Window, GC, char *, Pixmap *, Pixmap *); #endif /* TARGET_X11 */ -void InitImageList(struct ArtworkConfigInfo *, int); +void InitImageList(struct FileInfo *, int); void ReloadCustomImages(); +void FreeAllImages(); #endif /* IMAGE_H */ diff --git a/src/libgame/misc.c b/src/libgame/misc.c index f222f31e..5d4a4acc 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1285,7 +1285,7 @@ void dumpList(ListNode *node_first) while (node) { printf("['%s' (%d)]\n", node->key, - ((struct ArtworkListNodeInfo *)node->content)->num_references); + ((struct ListNodeInfo *)node->content)->num_references); node = node->next; } @@ -1348,10 +1348,55 @@ boolean FileIsArtworkType(char *basename, int type) /* functions for loading artwork configuration information */ /* ========================================================================= */ +struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list, + char *suffix_list[], + int num_list_entries) +{ + struct FileInfo *file_list = + checked_calloc(num_list_entries * sizeof(struct FileInfo)); + int list_pos = 0; + int i, j; + + for (i=0; config_list[i].token != NULL; i++) + { + int len_config_token = strlen(config_list[i].token); + boolean is_file_entry = TRUE; + + for (j=0; suffix_list[j] != NULL; j++) + { + int len_suffix = strlen(suffix_list[j]); + + if (len_suffix < len_config_token && + strcmp(&config_list[i].token[len_config_token - len_suffix], + suffix_list[j]) == 0) + { + is_file_entry = FALSE; + break; + } + } + + if (is_file_entry) + { + if (list_pos >= num_list_entries) + Error(ERR_EXIT, "inconsistant config list information -- please fix"); + + file_list[list_pos].token = config_list[i].token; + file_list[list_pos].default_filename = config_list[i].value; + + list_pos++; + } + } + + if (list_pos != num_list_entries) + Error(ERR_EXIT, "inconsistant config list information -- please fix"); + + return file_list; +} + static void LoadArtworkConfig(struct ArtworkListInfo *artwork_info) { int num_list_entries = artwork_info->num_list_entries; - struct ArtworkConfigInfo *config_list = artwork_info->config_list; + struct FileInfo *file_list = artwork_info->file_list; char *filename = getCustomArtworkConfigFilename(artwork_info->type); struct SetupFileList *setup_file_list; int i; @@ -1362,7 +1407,7 @@ static void LoadArtworkConfig(struct ArtworkListInfo *artwork_info) /* always start with reliable default values */ for (i=0; i '%s'\n", config_list[i].filename); + printf("'%s' ", file_list[i].token); + if (file_list[i].filename) + printf("-> '%s'\n", file_list[i].filename); else - printf("-> UNDEFINED [-> '%s']\n", config_list[i].default_filename); + printf("-> UNDEFINED [-> '%s']\n", file_list[i].default_filename); } #endif } } -void deleteArtworkListEntry(struct ArtworkListInfo *artwork_info, - struct ArtworkListNodeInfo **listnode) +static void deleteArtworkListEntry(struct ArtworkListInfo *artwork_info, + struct ListNodeInfo **listnode) { if (*listnode) { @@ -1405,7 +1450,7 @@ void deleteArtworkListEntry(struct ArtworkListInfo *artwork_info, printf("[deleting artwork '%s']\n", filename); #endif - deleteNodeFromList(&artwork_info->file_list, filename, + deleteNodeFromList(&artwork_info->content_list, filename, artwork_info->free_artwork); } @@ -1414,7 +1459,7 @@ void deleteArtworkListEntry(struct ArtworkListInfo *artwork_info, } static void replaceArtworkListEntry(struct ArtworkListInfo *artwork_info, - struct ArtworkListNodeInfo **listnode, + struct ListNodeInfo **listnode, char *filename) { ListNode *node; @@ -1437,25 +1482,25 @@ static void replaceArtworkListEntry(struct ArtworkListInfo *artwork_info, deleteArtworkListEntry(artwork_info, listnode); /* check if the new artwork file already exists in the list of artworks */ - if ((node = getNodeFromKey(artwork_info->file_list, filename)) != NULL) + if ((node = getNodeFromKey(artwork_info->content_list, filename)) != NULL) { #if 0 printf("[artwork '%s' already exists (other list entry)]\n", filename); #endif - *listnode = (struct ArtworkListNodeInfo *)node->content; + *listnode = (struct ListNodeInfo *)node->content; (*listnode)->num_references++; } else if ((*listnode = artwork_info->load_artwork(filename)) != NULL) { (*listnode)->num_references = 1; - addNodeToList(&artwork_info->file_list, (*listnode)->source_filename, + addNodeToList(&artwork_info->content_list, (*listnode)->source_filename, *listnode); } } static void LoadCustomArtwork(struct ArtworkListInfo *artwork_info, - struct ArtworkListNodeInfo **listnode, + struct ListNodeInfo **listnode, char *basename) { char *filename = getCustomArtworkFilename(basename, artwork_info->type); @@ -1479,8 +1524,8 @@ static void LoadCustomArtwork(struct ArtworkListInfo *artwork_info, replaceArtworkListEntry(artwork_info, listnode, filename); } -void LoadArtworkToList(struct ArtworkListInfo *artwork_info, - char *basename, int list_pos) +static void LoadArtworkToList(struct ArtworkListInfo *artwork_info, + char *basename, int list_pos) { if (artwork_info->artwork_list == NULL || list_pos >= artwork_info->num_list_entries) @@ -1488,7 +1533,7 @@ void LoadArtworkToList(struct ArtworkListInfo *artwork_info, #if 0 printf("loading artwork '%s' ... [%d]\n", - basename, getNumNodes(artwork_info->file_list)); + basename, getNumNodes(artwork_info->content_list)); #endif LoadCustomArtwork(artwork_info, &artwork_info->artwork_list[list_pos], @@ -1496,7 +1541,7 @@ void LoadArtworkToList(struct ArtworkListInfo *artwork_info, #if 0 printf("loading artwork '%s' done [%d]\n", - basename, getNumNodes(artwork_info->file_list)); + basename, getNumNodes(artwork_info->content_list)); #endif } @@ -1516,7 +1561,7 @@ void ReloadCustomArtworkList(struct ArtworkListInfo *artwork_info) }; int num_list_entries = artwork_info->num_list_entries; - struct ArtworkConfigInfo *config_list = artwork_info->config_list; + struct FileInfo *file_list = artwork_info->file_list; int i; LoadArtworkConfig(artwork_info); @@ -1531,22 +1576,22 @@ void ReloadCustomArtworkList(struct ArtworkListInfo *artwork_info) for(i=0; itype].do_it) - DrawInitText(config_list[i].token, 150, FC_YELLOW); + DrawInitText(file_list[i].token, 150, FC_YELLOW); - if (config_list[i].filename) - LoadArtworkToList(artwork_info, config_list[i].filename, i); + if (file_list[i].filename) + LoadArtworkToList(artwork_info, file_list[i].filename, i); else - LoadArtworkToList(artwork_info, config_list[i].default_filename, i); + LoadArtworkToList(artwork_info, file_list[i].default_filename, i); } draw_init[artwork_info->type].do_it = FALSE; /* - printf("list size == %d\n", getNumNodes(artwork_info->file_list)); + printf("list size == %d\n", getNumNodes(artwork_info->content_list)); */ #if 0 - dumpList(artwork_info->file_list); + dumpList(artwork_info->content_list); #endif } diff --git a/src/libgame/misc.h b/src/libgame/misc.h index 521ba1b1..8d0a5dce 100644 --- a/src/libgame/misc.h +++ b/src/libgame/misc.h @@ -126,6 +126,7 @@ boolean FileIsSound(char *); boolean FileIsMusic(char *); boolean FileIsArtworkType(char *, int); +struct FileInfo *getFileListFromConfigList(struct ConfigInfo *, char **, int); void ReloadCustomArtworkList(struct ArtworkListInfo *); void FreeCustomArtworkList(struct ArtworkListInfo *); diff --git a/src/libgame/sound.c b/src/libgame/sound.c index e44d2dcd..2124343d 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -1721,7 +1721,7 @@ static void *Load_WAV(char *filename) return snd_info; } -void InitSoundList(struct ArtworkConfigInfo *config_list, int num_list_entries) +void InitSoundList(struct FileInfo *file_list, int num_list_entries) { if (sound_info == NULL) sound_info = checked_calloc(sizeof(struct ArtworkListInfo)); @@ -1732,8 +1732,8 @@ void InitSoundList(struct ArtworkConfigInfo *config_list, int num_list_entries) sound_info->type = ARTWORK_TYPE_SOUNDS; sound_info->num_list_entries = num_list_entries; - sound_info->config_list = config_list; - sound_info->file_list = NULL; + sound_info->file_list = file_list; + sound_info->content_list = NULL; sound_info->load_artwork = Load_WAV; sound_info->free_artwork = FreeSound; diff --git a/src/libgame/sound.h b/src/libgame/sound.h index a018ec91..3dcd0acb 100644 --- a/src/libgame/sound.h +++ b/src/libgame/sound.h @@ -14,7 +14,7 @@ #ifndef SOUND_H #define SOUND_H -#include "platform.h" +#include "system.h" #if defined(PLATFORM_UNIX) && !defined(TARGET_SDL) @@ -139,7 +139,7 @@ void StopMusic(void); void StopSound(int); void StopSounds(void); void StopSoundExt(int, int); -void InitSoundList(struct ArtworkConfigInfo *, int); +void InitSoundList(struct FileInfo *, int); void InitReloadSounds(char *); void InitReloadMusic(char *); void FreeAllSounds(void); diff --git a/src/libgame/system.h b/src/libgame/system.h index 4bd6305a..4325ae7f 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -436,7 +436,13 @@ struct ArtworkInfo char *mus_current_identifier; }; -struct ArtworkConfigInfo +struct ConfigInfo +{ + char *token; + char *value; +}; + +struct FileInfo { char *token; char *default_filename; @@ -444,9 +450,9 @@ struct ArtworkConfigInfo char *filename; }; -struct ArtworkListNodeInfo +struct ListNodeInfo { - char *source_filename; + char *source_filename; /* primary key for node list */ int num_references; }; @@ -454,9 +460,9 @@ struct ArtworkListInfo { int type; /* type of artwork */ int num_list_entries; - struct ArtworkConfigInfo *config_list; /* static config list */ - struct ArtworkListNodeInfo **artwork_list; /* static artwork list */ - ListNode *file_list; /* dynamic artwork list */ + struct FileInfo *file_list; /* static artwork file list */ + struct ListNodeInfo **artwork_list; /* static artwork list */ + struct ListNode *content_list; /* dynamic artwork list */ void *(*load_artwork)(char *); /* constructor function */ void (*free_artwork)(void *); /* destructor function */ }; diff --git a/src/main.c b/src/main.c index 324c4f57..a7542a47 100644 --- a/src/main.c +++ b/src/main.c @@ -136,7 +136,7 @@ char *sound_name[NUM_SOUNDS] = "gate.wav" }; -struct ArtworkConfigInfo image_config[] = +struct ConfigInfo image_config[] = { /* graphics for Boulder Dash style elements and actions */ { "bd_diamond", "bd_diamond.pcx" }, @@ -145,9 +145,11 @@ struct ArtworkConfigInfo image_config[] = { "robot_wheel", "bd_diamond.pcx" }, { "robot_wheel.frame_xpos", "0" }, { "robot_wheel.num_frames", "4" }, + + { NULL, NULL }, }; -struct ArtworkConfigInfo sound_config[] = +struct ConfigInfo sound_config[] = { /* sounds for Boulder Dash style elements and actions */ { "bd_empty_space.digging", "empty.wav" }, @@ -362,8 +364,13 @@ struct ArtworkConfigInfo sound_config[] = { "[not used]", "whoosh.wav" }, { "[not used]", "boom.wav" }, #endif + + { NULL, NULL }, }; +struct FileInfo *image_files; +struct FileInfo *sound_files; + struct ElementInfo element_info[MAX_ELEMENTS] = { { "empty_space", "empty space" }, /* 0 */ diff --git a/src/main.h b/src/main.h index ae05e918..be60bd39 100644 --- a/src/main.h +++ b/src/main.h @@ -415,7 +415,8 @@ extern struct GameInfo game; extern struct GlobalInfo global; extern struct ElementInfo element_info[]; extern struct GraphicInfo graphic_info[]; -extern struct ArtworkConfigInfo image_config[], sound_config[]; +extern struct ConfigInfo image_config[], sound_config[]; +extern struct FileInfo *image_files, *sound_files; /* often used screen positions */ #define SX 8 @@ -1460,8 +1461,9 @@ extern struct ArtworkConfigInfo image_config[], sound_config[]; /* values for image configuration */ #define GFX_BD_DIAMOND 0 +#define GFX_ROBOT_WHEEL 1 -#define NUM_IMAGE_CONFIG_ENTRIES 1 +#define NUM_IMAGE_FILES 2 /* values for sound configuration */ @@ -1635,7 +1637,7 @@ extern struct ArtworkConfigInfo image_config[], sound_config[]; #define SND_MENU_HALL_OF_FAME 167 #define SND_MENU_INFO_SCREEN 168 -#define NUM_SOUND_CONFIG_ENTRIES 169 +#define NUM_SOUND_FILES 169 /* values for game_status */ -- 2.34.1