From: Holger Schemel Date: Sat, 7 Sep 2002 10:07:47 +0000 (+0200) Subject: rnd-20020907-1-src X-Git-Tag: 3.0.0^2~249 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=b13dc8e30a0c07bea53bf168ae6d1017394d3c22;p=rocksndiamonds.git rnd-20020907-1-src --- diff --git a/Makefile b/Makefile index 96b73c56..f4921768 100644 --- a/Makefile +++ b/Makefile @@ -89,6 +89,9 @@ clean: run: @$(MAKE_CMD) TARGET=$(DEFAULT_TARGET) && ./rocksndiamonds --verbose +gdb: + @$(MAKE_CMD) TARGET=$(DEFAULT_TARGET) && gdb ./rocksndiamonds + backup: ./Scripts/make_backup.sh src diff --git a/src/conftime.h b/src/conftime.h index 8e53e013..0be54307 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2002-09-06 22:45]" +#define COMPILE_DATE_STRING "[2002-09-07 12:06]" diff --git a/src/init.c b/src/init.c index bb5dd450..4c49a237 100644 --- a/src/init.c +++ b/src/init.c @@ -55,6 +55,7 @@ static void InitGadgets(void); static void InitElementProperties(void); static void InitElementInfo(void); static void InitGraphicInfo(void); +static void InitSoundInfo(); static void Execute_Debug_Command(char *); void OpenAll(void) @@ -175,37 +176,19 @@ void InitNetworkServer() static void InitImages() { - static char *suffix_list[] = - { - ".frame_xpos", - ".frame_ypos", - ".num_frames", - NULL - }; - - image_files = - getFileListFromConfigList(image_config, suffix_list, NUM_IMAGE_FILES); - - InitImageList(image_files, NUM_IMAGE_FILES); + InitImageList(image_config, image_config_suffix, NUM_IMAGE_FILES); /* load custom images */ ReloadCustomImages(); + InitGraphicInfo(); } static void InitMixer() { - static char *suffix_list[] = - { - NULL - }; - OpenAudio(); - sound_files = - getFileListFromConfigList(sound_config, suffix_list, NUM_SOUND_FILES); - - InitSoundList(sound_files, NUM_SOUND_FILES); + InitSoundList(sound_config, sound_config_suffix, NUM_SOUND_FILES); StartMixer(); } @@ -216,8 +199,7 @@ static void InitSound() InitReloadSounds(artwork.snd_current->identifier); InitReloadMusic(artwork.mus_current->identifier); - /* initialize sound effect lookup table for element actions */ - InitGameSound(); + InitSoundInfo(); } static void InitTileClipmasks() @@ -869,13 +851,15 @@ void InitElementInfo() } } -void InitGraphicInfo() +static void InitGraphicInfo() { int i; - /* always start with reliable default values */ + image_files = getCurrentImageList(); + for(i=0; ifile_list; +} - if (image_info->artwork_list == NULL) - image_info->artwork_list = - checked_calloc(num_list_entries * sizeof(ImageInfo *)); +void InitImageList(struct ConfigInfo *config_list, char *config_suffix_list[], + int num_file_list_entries) +{ + int i; + + image_info = checked_calloc(sizeof(struct ArtworkListInfo)); image_info->type = ARTWORK_TYPE_GRAPHICS; - image_info->num_list_entries = num_list_entries; - image_info->file_list = file_list; + + image_info->num_file_list_entries = num_file_list_entries; + image_info->num_suffix_list_entries = 0; + for (i=0; config_suffix_list[i] != NULL; i++) + image_info->num_suffix_list_entries++; + + image_info->file_list = + getFileListFromConfigList(config_list, config_suffix_list, + num_file_list_entries); + image_info->suffix_list = config_suffix_list; + + image_info->artwork_list = + checked_calloc(num_file_list_entries * sizeof(ImageInfo *)); + image_info->content_list = NULL; + image_info->load_artwork = Load_PCX; image_info->free_artwork = FreeImage; } diff --git a/src/libgame/image.h b/src/libgame/image.h index f96b6170..b968fee1 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 FileInfo *, int); +struct FileInfo *getCurrentImageList(); +void InitImageList(struct ConfigInfo *, char **, int); void ReloadCustomImages(); void FreeAllImages(); diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 5d4a4acc..3c61d46d 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1350,13 +1350,35 @@ boolean FileIsArtworkType(char *basename, int type) struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list, char *suffix_list[], - int num_list_entries) + int num_file_list_entries) { - struct FileInfo *file_list = - checked_calloc(num_list_entries * sizeof(struct FileInfo)); - int list_pos = 0; + struct FileInfo *file_list; + int num_suffix_list_entries = 0; + int list_pos = -1; int i, j; + file_list = checked_calloc(num_file_list_entries * sizeof(struct FileInfo)); + + for (i=0; suffix_list[i] != NULL; i++) + num_suffix_list_entries++; + + if (num_suffix_list_entries > 0) + { + for (i=0; i= num_list_entries) + list_pos++; + + if (list_pos >= num_file_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) + if (list_pos != num_file_list_entries - 1) Error(ERR_EXIT, "inconsistant config list information -- please fix"); return file_list; @@ -1395,33 +1419,41 @@ struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list, static void LoadArtworkConfig(struct ArtworkListInfo *artwork_info) { - int num_list_entries = artwork_info->num_list_entries; + int num_file_list_entries = artwork_info->num_file_list_entries; + int num_suffix_list_entries = artwork_info->num_suffix_list_entries; struct FileInfo *file_list = artwork_info->file_list; char *filename = getCustomArtworkConfigFilename(artwork_info->type); struct SetupFileList *setup_file_list; - int i; + int i, j; #if 0 printf("GOT CUSTOM ARTWORK CONFIG FILE '%s'\n", filename); #endif /* always start with reliable default values */ - for (i=0; iartwork_list == NULL || - list_pos >= artwork_info->num_list_entries) + list_pos >= artwork_info->num_file_list_entries) return; #if 0 @@ -1560,7 +1592,7 @@ void ReloadCustomArtworkList(struct ArtworkListInfo *artwork_info) { "Loading music:", TRUE } }; - int num_list_entries = artwork_info->num_list_entries; + int num_file_list_entries = artwork_info->num_file_list_entries; struct FileInfo *file_list = artwork_info->file_list; int i; @@ -1570,10 +1602,10 @@ void ReloadCustomArtworkList(struct ArtworkListInfo *artwork_info) DrawInitText(draw_init[artwork_info->type].text, 120, FC_GREEN); #if 0 - printf("DEBUG: reloading %d sounds ...\n", num_list_entries); + printf("DEBUG: reloading %d sounds ...\n", num_file_list_entries); #endif - for(i=0; itype].do_it) DrawInitText(file_list[i].token, 150, FC_YELLOW); @@ -1607,7 +1639,7 @@ void FreeCustomArtworkList(struct ArtworkListInfo *artwork_info) IS_CHILD_PROCESS(audio.mixer_pid) ? "CHILD" : "PARENT"); #endif - for(i=0; inum_list_entries; i++) + for(i=0; inum_file_list_entries; i++) deleteArtworkListEntry(artwork_info, &artwork_info->artwork_list[i]); #if 0 @@ -1618,7 +1650,7 @@ void FreeCustomArtworkList(struct ArtworkListInfo *artwork_info) free(artwork_info->artwork_list); artwork_info->artwork_list = NULL; - artwork_info->num_list_entries = 0; + artwork_info->num_file_list_entries = 0; } diff --git a/src/libgame/sound.c b/src/libgame/sound.c index 2124343d..f30c1d4c 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -1721,23 +1721,39 @@ static void *Load_WAV(char *filename) return snd_info; } -void InitSoundList(struct FileInfo *file_list, int num_list_entries) +struct FileInfo *getCurrentSoundList() { - if (sound_info == NULL) - sound_info = checked_calloc(sizeof(struct ArtworkListInfo)); + return sound_info->file_list; +} - if (sound_info->artwork_list == NULL) - sound_info->artwork_list = - checked_calloc(num_list_entries * sizeof(SoundInfo *)); +void InitSoundList(struct ConfigInfo *config_list, char *config_suffix_list[], + int num_file_list_entries) +{ + int i; + + sound_info = checked_calloc(sizeof(struct ArtworkListInfo)); sound_info->type = ARTWORK_TYPE_SOUNDS; - sound_info->num_list_entries = num_list_entries; - sound_info->file_list = file_list; + + sound_info->num_file_list_entries = num_file_list_entries; + sound_info->num_suffix_list_entries = 0; + for (i=0; config_suffix_list[i] != NULL; i++) + sound_info->num_suffix_list_entries++; + + sound_info->file_list = + getFileListFromConfigList(config_list, config_suffix_list, + num_file_list_entries); + sound_info->suffix_list = config_suffix_list; + + sound_info->artwork_list = + checked_calloc(num_file_list_entries * sizeof(SoundInfo *)); + sound_info->content_list = NULL; + sound_info->load_artwork = Load_WAV; sound_info->free_artwork = FreeSound; - num_sounds = sound_info->num_list_entries; + num_sounds = sound_info->num_file_list_entries; Sound = (SoundInfo **)sound_info->artwork_list; } diff --git a/src/libgame/sound.h b/src/libgame/sound.h index 3dcd0acb..4b28e3ff 100644 --- a/src/libgame/sound.h +++ b/src/libgame/sound.h @@ -139,7 +139,8 @@ void StopMusic(void); void StopSound(int); void StopSounds(void); void StopSoundExt(int, int); -void InitSoundList(struct FileInfo *, int); +struct FileInfo *getCurrentSoundList(); +void InitSoundList(struct ConfigInfo *, char **, int); void InitReloadSounds(char *); void InitReloadMusic(char *); void FreeAllSounds(void); diff --git a/src/libgame/system.h b/src/libgame/system.h index 4325ae7f..497a3958 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -445,9 +445,12 @@ struct ConfigInfo struct FileInfo { char *token; - char *default_filename; + char *default_filename; char *filename; + + int *default_parameter; /* array of file parameters */ + int *parameter; /* array of file parameters */ }; struct ListNodeInfo @@ -459,10 +462,17 @@ struct ListNodeInfo struct ArtworkListInfo { int type; /* type of artwork */ - int num_list_entries; - struct FileInfo *file_list; /* static artwork file list */ - struct ListNodeInfo **artwork_list; /* static artwork list */ - struct ListNode *content_list; /* dynamic artwork list */ + + int num_file_list_entries; + int num_suffix_list_entries; + + struct FileInfo *file_list; /* static artwork file array */ + char **suffix_list; /* parameter suffixes array */ + + struct ListNodeInfo **artwork_list; /* static artwork node array */ + + struct ListNode *content_list; /* dynamic artwork node list */ + void *(*load_artwork)(char *); /* constructor function */ void (*free_artwork)(void *); /* destructor function */ }; diff --git a/src/main.c b/src/main.c index a7542a47..68466fe5 100644 --- a/src/main.c +++ b/src/main.c @@ -136,6 +136,19 @@ char *sound_name[NUM_SOUNDS] = "gate.wav" }; +char *image_config_suffix[] = +{ + ".frame_xpos", + ".frame_ypos", + ".num_frames", + NULL +}; + +char *sound_config_suffix[] = +{ + NULL +}; + struct ConfigInfo image_config[] = { /* graphics for Boulder Dash style elements and actions */ diff --git a/src/main.h b/src/main.h index be60bd39..976325da 100644 --- a/src/main.h +++ b/src/main.h @@ -417,6 +417,7 @@ extern struct ElementInfo element_info[]; extern struct GraphicInfo graphic_info[]; extern struct ConfigInfo image_config[], sound_config[]; extern struct FileInfo *image_files, *sound_files; +extern char *image_config_suffix[], *sound_config_suffix[]; /* often used screen positions */ #define SX 8