X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=4c49a23762f59494ae018bca325f64fafc1ee85d;hb=b13dc8e30a0c07bea53bf168ae6d1017394d3c22;hp=38aec9ae656aab1e178dc3bd8fb376a431eb44ca;hpb=87f531efe267aa3d6a27cc3a68c68c1a4df7b18b;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index 38aec9ae..4c49a237 100644 --- a/src/init.c +++ b/src/init.c @@ -46,12 +46,16 @@ static void InitLevelInfo(void); static void InitArtworkInfo(void); static void InitLevelArtworkInfo(void); static void InitNetworkServer(void); +static void InitImages(void); static void InitMixer(void); static void InitSound(void); static void InitGfx(void); static void InitGfxBackground(void); 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) @@ -96,10 +100,12 @@ void OpenAll(void) InitGfx(); InitElementProperties(); /* initializes IS_CHAR() for el2gfx() */ + InitElementInfo(); InitLevelInfo(); InitLevelArtworkInfo(); InitGadgets(); /* needs to know number of level series */ + InitImages(); /* needs to know current level directory */ InitSound(); /* needs to know current level directory */ InitGfxBackground(); @@ -168,10 +174,21 @@ void InitNetworkServer() #endif } +static void InitImages() +{ + InitImageList(image_config, image_config_suffix, NUM_IMAGE_FILES); + + /* load custom images */ + ReloadCustomImages(); + + InitGraphicInfo(); +} + static void InitMixer() { OpenAudio(); - InitSoundList(sound_effects, NUM_SOUND_EFFECTS); + + InitSoundList(sound_config, sound_config_suffix, NUM_SOUND_FILES); StartMixer(); } @@ -182,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() @@ -263,8 +279,8 @@ static void InitTileClipmasks() clip_gc_values.graphics_exposures = False; clip_gc_valuemask = GCGraphicsExposures; - tile_clip_gc = - XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values); + tile_clip_gc = XCreateGC(display, window->drawable, + clip_gc_valuemask, &clip_gc_values); for(i=0; iclip_mask, - clip_gc_valuemask, &clip_gc_values); + copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask, + clip_gc_valuemask, &clip_gc_values); /* create only those clipping Pixmaps we really need */ for(i=0; tile_needs_clipping[i].start>=0; i++) @@ -297,11 +312,11 @@ static void InitTileClipmasks() int tile = tile_needs_clipping[i].start + j; int graphic = tile; int src_x, src_y; - int pixmap_nr; + Bitmap *src_bitmap; Pixmap src_pixmap; - getGraphicSource(graphic, &pixmap_nr, &src_x, &src_y); - src_pixmap = pix[pixmap_nr]->clip_mask; + getGraphicSource(graphic, &src_bitmap, &src_x, &src_y); + src_pixmap = src_bitmap->clip_mask; tile_clipmask[tile] = XCreatePixmap(display, window->drawable, TILEX, TILEY, 1); @@ -453,48 +468,28 @@ void ReloadCustomArtwork() snd_new_identifier = identifier_new; if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) != getTreeInfoFromIdentifier(artwork.mus_first, identifier_new)) - artwork.mus_current_identifier = NULL; + mus_new_identifier = identifier_new; leveldir_current_identifier = leveldir_current->identifier; } /* custom level artwork configured in level series configuration file always overrides custom level artwork stored in level series directory - and (level independant) custom artwork configured in setup menue - (the path entry is needed to send it to the sound child process) */ + and (level independant) custom artwork configured in setup menue */ if (leveldir_current->graphics_set != NULL) - { - if (leveldir_current->graphics_path) - free(leveldir_current->graphics_path); - leveldir_current->graphics_path = NULL; - leveldir_current->graphics_path = - getStringCopy(getLevelArtworkDir(artwork.gfx_first)); gfx_new_identifier = leveldir_current->graphics_set; - } if (leveldir_current->sounds_set != NULL) - { - if (leveldir_current->sounds_path) - free(leveldir_current->sounds_path); - leveldir_current->sounds_path = NULL; - leveldir_current->sounds_path = - getStringCopy(getLevelArtworkDir(artwork.snd_first)); snd_new_identifier = leveldir_current->sounds_set; - } if (leveldir_current->music_set != NULL) - { - if (leveldir_current->music_path) - free(leveldir_current->music_path); - leveldir_current->music_path = NULL; - leveldir_current->music_path = - getStringCopy(getLevelArtworkDir(artwork.mus_first)); mus_new_identifier = leveldir_current->music_set; - } if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 || last_override_level_graphics != setup.override_level_graphics) { int i; + setLevelArtworkDir(artwork.gfx_first); + ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE); for(i=0; i -1) + { + int element = element_to_graphic[i].element; + int graphic = element_to_graphic[i].graphic; + + element_info[element].graphic = graphic; + i++; + } +} + +static void InitGraphicInfo() +{ + int i; + + image_files = getCurrentImageList(); + + for(i=0; i