X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=ef6586f701c4f6465f59766db271a4c1a7fb0555;hb=d0e7ff980c3d4d73ac39c2670177e6030b966760;hp=3118aa35a76b2d294e2b62d3495f8860a02d96ed;hpb=dfe0a71a9939e0c55bb54dcc92db1749e8e21747;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index 3118aa35..ef6586f7 100644 --- a/src/init.c +++ b/src/init.c @@ -45,6 +45,7 @@ static void InitPlayerInfo(void); static void InitLevelInfo(void); static void InitArtworkInfo(void); static void InitNetworkServer(void); +static void InitSoundServer(void); static void InitSound(void); static void InitGfx(void); static void InitGfxBackground(void); @@ -74,7 +75,7 @@ void OpenAll(void) InitArtworkInfo(); /* needed before loading gfx, sound & music */ InitCounter(); - InitSound(); + InitSoundServer(); InitJoysticks(); InitRND(NEW_RANDOMIZE); @@ -89,6 +90,7 @@ void OpenAll(void) InitLevelInfo(); InitGadgets(); /* needs to know number of level series */ + InitSound(); /* needs to know current level directory */ InitGfxBackground(); InitToons(); @@ -151,38 +153,55 @@ void InitNetworkServer() #endif } -void InitSound() +static void ReloadCustomSounds() { int i; - OpenAudio(); +#if 1 + printf("DEBUG: reloading sounds '%s' ...\n", artwork.sounds_set_current); +#endif + + FreeAllSounds(); + InitSoundList(NUM_SOUNDS); for(i=0; iname); + InitReloadMusic(artwork.mus_current->name); +} + +static void InitTileClipmasks() { #if defined(TARGET_X11) - GC copy_clipmask_gc; XGCValues clip_gc_values; unsigned long clip_gc_valuemask; -#endif #if defined(TARGET_X11_NATIVE) + GC copy_clipmask_gc; + static struct { int start; @@ -234,7 +253,8 @@ void InitTileClipmasks() { GFX2_SHIELD_ACTIVE, 3 }, { -1, 0 } }; -#endif +#endif /* TARGET_X11_NATIVE */ +#endif /* TARGET_X11 */ int i; @@ -248,13 +268,6 @@ void InitTileClipmasks() To prevent this, create small (tile-sized) mask Pixmaps which will then be set much faster with XSetClipOrigin() and speed things up a lot. */ - /* create graphic context structures needed for clipping */ - clip_gc_values.graphics_exposures = False; - clip_gc_valuemask = GCGraphicsExposures; - copy_clipmask_gc = - XCreateGC(display, pix[PIX_BACK]->clip_mask, - clip_gc_valuemask, &clip_gc_values); - clip_gc_values.graphics_exposures = False; clip_gc_valuemask = GCGraphicsExposures; tile_clip_gc = @@ -268,11 +281,19 @@ void InitTileClipmasks() clip_gc_values.clip_mask = pix[i]->clip_mask; clip_gc_valuemask = GCGraphicsExposures | GCClipMask; pix[i]->stored_clip_gc = XCreateGC(display, window->drawable, - clip_gc_valuemask,&clip_gc_values); + clip_gc_valuemask, &clip_gc_values); } } #if defined(TARGET_X11_NATIVE) + + /* create graphic context structures needed for clipping */ + clip_gc_values.graphics_exposures = False; + clip_gc_valuemask = GCGraphicsExposures; + 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++) { @@ -296,10 +317,42 @@ void InitTileClipmasks() src_x, src_y, TILEX, TILEY, 0, 0); } } + + XFreeGC(display, copy_clipmask_gc); + #endif /* TARGET_X11_NATIVE */ #endif /* TARGET_X11 */ } +void FreeTileClipmasks() +{ +#if defined(TARGET_X11) + int i; + + for(i=0; istored_clip_gc) + { + XFreeGC(display, pix[i]->stored_clip_gc); + pix[i]->stored_clip_gc = None; + } + } +#endif /* TARGET_X11 */ +} + void InitGfx() { int i; @@ -355,9 +408,9 @@ void InitGfxBackground() fieldbuffer = pix[PIX_DB_FIELD]; SetDrawtoField(DRAW_BACKBUFFER); - BlitBitmap(pix[PIX_BACK], backbuffer, 0,0, WIN_XSIZE,WIN_YSIZE, 0,0); - ClearRectangle(backbuffer, REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE); - ClearRectangle(pix[PIX_DB_DOOR], 0,0, 3*DXSIZE,DYSIZE+VYSIZE); + BlitBitmap(pix[PIX_BACK], backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0); + ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); + ClearRectangle(pix[PIX_DB_DOOR], 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE); for(x=0; xname; @@ -383,14 +444,14 @@ void ReloadCustomArtwork() if (artwork.sounds_set_current != artwork.snd_current->name) { - printf("reload sounds ...\n"); + InitReloadSounds(artwork.snd_current->name); artwork.sounds_set_current = artwork.snd_current->name; } if (artwork.music_set_current != artwork.mus_current->name) { - printf("reload music ...\n"); + InitReloadMusic(artwork.mus_current->name); artwork.music_set_current = artwork.mus_current->name; } @@ -1559,9 +1620,11 @@ void CloseAllAndExit(int exit_value) int i; StopSounds(); - FreeSounds(NUM_SOUNDS); - CloseAudio(); + FreeAllSounds(); + FreeAllMusic(); + CloseAudio(); /* called after freeing sounds (needed for SDL) */ + FreeTileClipmasks(); for(i=0; i