From: Holger Schemel Date: Fri, 29 Mar 2002 18:16:34 +0000 (+0100) Subject: rnd-20020329-2-src X-Git-Tag: 2.1.0^2~79 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=fe158e864d3fa4b0221e9c88d8dfff0157051396;p=rocksndiamonds.git rnd-20020329-2-src --- diff --git a/src/init.c b/src/init.c index 70604f2a..2ddbbcd5 100644 --- a/src/init.c +++ b/src/init.c @@ -39,6 +39,7 @@ static char *image_filename[NUM_PICTURES] = }; static void InitPlayerInfo(void); +static void InitSetup(void); static void InitLevelInfo(void); static void InitNetworkServer(void); static void InitSound(void); @@ -66,6 +67,7 @@ void OpenAll(void) MSDOS_POINTER_FILENAME, COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL); + InitSetup(); InitPlayerInfo(); InitCounter(); @@ -93,6 +95,11 @@ void OpenAll(void) InitNetworkServer(); } +void InitSetup() +{ + LoadSetup(); /* global setup info */ +} + void InitPlayerInfo() { int i; @@ -104,8 +111,6 @@ void InitPlayerInfo() stored_player[i].connected = FALSE; local_player->connected = TRUE; - - LoadSetup(); /* global setup info */ } void InitLevelInfo() @@ -289,7 +294,6 @@ void InitTileClipmasks() void InitGfx() { - char *filename; int i; /* initialize some global variables */ @@ -308,11 +312,7 @@ void InitGfx() pix[PIX_DB_DOOR] = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH); pix[PIX_DB_FIELD] = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH); - filename = getImageFilename(image_filename[PIX_SMALLFONT]); - if ((pix_default[PIX_SMALLFONT] = LoadImage(filename)) == NULL) - Error(ERR_EXIT, "LoadImage() failed: %s", GetError()); - pix_custom[PIX_SMALLFONT] = NULL; - pix[PIX_SMALLFONT] = pix_default[PIX_SMALLFONT]; + pix[PIX_SMALLFONT] = LoadCustomImage(image_filename[PIX_SMALLFONT]); InitFontInfo(NULL, NULL, pix[PIX_SMALLFONT]); @@ -330,11 +330,7 @@ void InitGfx() { DrawInitText(image_filename[i], 150, FC_YELLOW); - filename = getImageFilename(image_filename[i]); - if ((pix_default[i] = LoadImage(filename)) == NULL) - Error(ERR_EXIT, "LoadImage() failed: %s", GetError()); - pix_custom[i] = NULL; - pix[i] = pix_default[i]; + pix[i] = LoadCustomImage(image_filename[i]); } } @@ -1572,10 +1568,7 @@ void CloseAllAndExit(int exit_value) CloseAudio(); for(i=0; istored_clip_gc); #endif + if (bitmap->source_filename) + free(bitmap->source_filename); + free(bitmap); } @@ -606,6 +609,19 @@ Bitmap *LoadImage(char *filename) return new_bitmap; } +Bitmap *LoadCustomImage(char *basename) +{ + char *filename = getStringCopy(getCustomImageFilename(basename)); + Bitmap *new_bitmap; + + if ((new_bitmap = LoadImage(filename)) == NULL) + Error(ERR_EXIT, "LoadImage() failed: %s", GetError()); + + new_bitmap->source_filename = filename; + + return new_bitmap; +} + /* ========================================================================= */ /* audio functions */ diff --git a/src/libgame/system.h b/src/libgame/system.h index e1456a96..184af955 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -410,6 +410,7 @@ inline boolean SetVideoMode(boolean); inline boolean ChangeVideoModeIfNeeded(boolean); Bitmap *LoadImage(char *); +Bitmap *LoadCustomImage(char *); inline void OpenAudio(void); inline void CloseAudio(void); diff --git a/src/libgame/x11.h b/src/libgame/x11.h index 9903e8c9..76c34d8a 100644 --- a/src/libgame/x11.h +++ b/src/libgame/x11.h @@ -59,6 +59,7 @@ typedef XClientMessageEvent ClientMessageEvent; struct X11DrawableInfo { + char *source_filename; Drawable drawable; Drawable clip_mask; GC gc; /* GC for normal drawing (inheritated from 'window') */ diff --git a/src/main.c b/src/main.c index 210bf381..8533d336 100644 --- a/src/main.c +++ b/src/main.c @@ -20,8 +20,6 @@ GC tile_clip_gc; Bitmap *pix[NUM_BITMAPS]; -Bitmap *pix_default[NUM_BITMAPS]; -Bitmap *pix_custom[NUM_BITMAPS]; Pixmap tile_clipmask[NUM_TILES]; DrawBuffer *fieldbuffer; DrawBuffer *drawto_field; diff --git a/src/main.h b/src/main.h index 40b06764..844b725c 100644 --- a/src/main.h +++ b/src/main.h @@ -337,8 +337,6 @@ struct GlobalInfo extern GC tile_clip_gc; extern Bitmap *pix[]; -extern Bitmap *pix_default[]; -extern Bitmap *pix_custom[]; extern Pixmap tile_clipmask[]; extern DrawBuffer *fieldbuffer; extern DrawBuffer *drawto_field;