rnd-20020329-2-src
authorHolger Schemel <info@artsoft.org>
Fri, 29 Mar 2002 18:16:34 +0000 (19:16 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:36:33 +0000 (10:36 +0200)
src/init.c
src/libgame/sdl.h
src/libgame/setup.c
src/libgame/system.c
src/libgame/system.h
src/libgame/x11.h
src/main.c
src/main.h

index 70604f2a9392854cd4bda2dc4fc30ad16bcb6105..2ddbbcd5769c56c30cadc67d8092fc3fefb3f9f2 100644 (file)
@@ -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; i<NUM_BITMAPS; i++)
-  {
-    FreeBitmap(pix_default[i]);
-    FreeBitmap(pix_custom[i]);
-  }
+    FreeBitmap(pix[i]);
 
   CloseVideoDisplay();
   ClosePlatformDependantStuff();
index b29e1950ac7ce72a9070bd963c891e10bad49da2..543e90ab89965ab304b6a94796810bffbf7d42c2 100644 (file)
@@ -60,6 +60,7 @@ typedef int                   Colormap;
 
 struct SDLSurfaceInfo
 {
+  char *source_filename;
   SDL_Surface *surface;
   SDL_Surface *surface_masked;
   GC gc;
index d5b2b51dc42303f4acbb24c58ddfb6d72f7025a1..def8fa9e715bad821e011abc843893996707b3d1 100644 (file)
@@ -247,6 +247,24 @@ char *getImageFilename(char *basename)
   return filename;
 }
 
+char *getCustomImageFilename(char *basename)
+{
+#if 0
+  if (strcmp(basename, "RocksFont.pcx") == 0)
+  {
+    char *dir = options.graphics_directory;
+
+    printf("checking directory '%s' ...\n", dir);
+
+    /*
+    dir = getPath2(options.graphics_directory);
+    */
+  }
+#endif
+
+  return getImageFilename(basename);
+}
+
 void InitTapeDirectory(char *level_subdir)
 {
   createDirectory(getUserDataDir(), "user data", PERMS_PRIVATE);
index 423570ddf4536407ecee19db0cf22e5045236797..f5125c611a14e5f21b600873ddef0cec3024bd0e 100644 (file)
@@ -299,6 +299,9 @@ inline void FreeBitmap(Bitmap *bitmap)
     XFreeGC(display, bitmap->stored_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                                                           */
index e1456a96edb7c316489223535fac269c0e810755..184af955db30eccc303162ced43fa2d23fb6af4c 100644 (file)
@@ -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);
index 9903e8c977ca172acab32a7f74ed68a694e814c7..76c34d8a2a5c3ef64ff86283ddc8c022bcd08fff 100644 (file)
@@ -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') */
index 210bf381973e4bd09589e4a715eb23f792cc1c17..8533d336d74f9b5479151118d3a12a00f2668bc7 100644 (file)
@@ -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;
index 40b0676458638b99d7c8ac6e97724c81f4707513..844b725c105a2a61774f5e780532d95f553b5c5c 100644 (file)
@@ -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;