rnd-20020407-2-src
authorHolger Schemel <info@artsoft.org>
Sun, 7 Apr 2002 16:39:05 +0000 (18:39 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:36:52 +0000 (10:36 +0200)
src/events.c
src/game.c
src/game.h
src/init.c
src/libgame/system.c
src/libgame/system.h
src/screens.c
src/timestamp.h

index a4b60829e90a139f35aeff1bc19a9cbfab278b3e..879b5396dd22f13549eb52245e15e97d1fa71db5 100644 (file)
@@ -594,7 +594,7 @@ void HandleKey(Key key, int key_status)
       switch(key)
       {
         case KSYM_Escape:
       switch(key)
       {
         case KSYM_Escape:
-         RequestQuitGame();
+         RequestQuitGame(setup.ask_on_escape);
          break;
 
 #ifdef DEBUG
          break;
 
 #ifdef DEBUG
index 6d536ec61824da1b027d525fa4620b2cc341e2d5..f0bf7dd9600b8bef766243fad5256c9fdd382372 100644 (file)
@@ -6305,10 +6305,10 @@ void RaiseScoreElement(int element)
   }
 }
 
   }
 }
 
-void RequestQuitGame()
+void RequestQuitGame(boolean ask_if_really_quit)
 {
   if (AllPlayersGone ||
 {
   if (AllPlayersGone ||
-      !setup.ask_on_escape ||
+      !ask_if_really_quit ||
       level_editor_test_game ||
       Request("Do you really want to quit the game ?",
              REQ_ASK | REQ_STAY_CLOSED))
       level_editor_test_game ||
       Request("Do you really want to quit the game ?",
              REQ_ASK | REQ_STAY_CLOSED))
@@ -6478,7 +6478,7 @@ static void HandleGameButtons(struct GadgetInfo *gi)
   switch (id)
   {
     case GAME_CTRL_ID_STOP:
   switch (id)
   {
     case GAME_CTRL_ID_STOP:
-      RequestQuitGame();
+      RequestQuitGame(TRUE);
       break;
 
     case GAME_CTRL_ID_PAUSE:
       break;
 
     case GAME_CTRL_ID_PAUSE:
index 3a66264e4f57df98a6648880d76ffeea90340573..acd25c1b80c1265137addb5999141f9eaf6b1c00 100644 (file)
@@ -92,7 +92,7 @@ boolean PlaceBomb(struct PlayerInfo *);
 void PlaySoundLevel(int, int, int);
 void RaiseScore(int);
 void RaiseScoreElement(int);
 void PlaySoundLevel(int, int, int);
 void RaiseScore(int);
 void RaiseScoreElement(int);
-void RequestQuitGame(void);
+void RequestQuitGame(boolean);
 
 void CreateGameButtons();
 void UnmapGameButtons();
 
 void CreateGameButtons();
 void UnmapGameButtons();
index 3118aa35a76b2d294e2b62d3495f8860a02d96ed..bc29424e6636cc9afefffe2c1d8b35e9cb7a0243 100644 (file)
@@ -297,6 +297,9 @@ void InitTileClipmasks()
     }
   }
 #endif /* TARGET_X11_NATIVE */
     }
   }
 #endif /* TARGET_X11_NATIVE */
+
+  XFreeGC(display, copy_clipmask_gc);
+
 #endif /* TARGET_X11 */
 }
 
 #endif /* TARGET_X11 */
 }
 
@@ -343,7 +346,6 @@ void InitGfx()
   }
 
   InitFontInfo(pix[PIX_BIGFONT], pix[PIX_MEDIUMFONT], pix[PIX_SMALLFONT]);
   }
 
   InitFontInfo(pix[PIX_BIGFONT], pix[PIX_MEDIUMFONT], pix[PIX_SMALLFONT]);
-
   InitTileClipmasks();
 }
 
   InitTileClipmasks();
 }
 
@@ -355,9 +357,9 @@ void InitGfxBackground()
   fieldbuffer = pix[PIX_DB_FIELD];
   SetDrawtoField(DRAW_BACKBUFFER);
 
   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; x<MAX_BUF_XSIZE; x++)
     for(y=0; y<MAX_BUF_YSIZE; y++)
 
   for(x=0; x<MAX_BUF_XSIZE; x++)
     for(y=0; y<MAX_BUF_YSIZE; y++)
@@ -370,12 +372,47 @@ void ReloadCustomArtwork()
 {
   if (artwork.graphics_set_current != artwork.gfx_current->name)
   {
 {
   if (artwork.graphics_set_current != artwork.gfx_current->name)
   {
+    Bitmap *pix_new[NUM_PICTURES];
     int i;
 
     int i;
 
+    ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
+    for(i=0; i<NUM_PICTURES; i++)
+    {
+      DrawInitText(image_filename[i], 150, FC_YELLOW);
+      pix_new[i] = ReloadCustomImage(&pix[i], image_filename[i]);
+
+#if 0
+      if (pix_new[i] != NULL)
+       pix[i] = pix_new[i];
+#endif
+    }
+
+#if 0
+    InitFontInfo(pix[PIX_BIGFONT], pix[PIX_MEDIUMFONT], pix[PIX_SMALLFONT]);
+    InitTileClipmasks();
+    InitGfxBackground();
+#endif
+
+#if 1
+    for(i=0; i<NUM_PICTURES; i++)
+    {
+      if (pix_new[i] != NULL)
+       TransferBitmapPointers(pix_new[i], pix[i]);
+    }
+#else
     for(i=0; i<NUM_PICTURES; i++)
     for(i=0; i<NUM_PICTURES; i++)
-      ReloadCustomImage(&pix[i], image_filename[i]);
+    {
+      if (pix_new[i] != NULL)
+       FreeBitmap(pix_old[i]);
+    }
+#endif
 
 
+#if 1
+    InitFontInfo(pix[PIX_BIGFONT], pix[PIX_MEDIUMFONT], pix[PIX_SMALLFONT]);
+    InitTileClipmasks();
     InitGfxBackground();
     InitGfxBackground();
+#endif
+
     SetDoorState(DOOR_OPEN_1 | DOOR_CLOSE_2);
 
     artwork.graphics_set_current = artwork.gfx_current->name;
     SetDoorState(DOOR_OPEN_1 | DOOR_CLOSE_2);
 
     artwork.graphics_set_current = artwork.gfx_current->name;
index 7eaadf68aae617e52ae4c2e56aa9644e178f1f91..2ffce00752cf5c9348f839c7d3b8381a5e8be7e3 100644 (file)
@@ -281,7 +281,7 @@ inline Bitmap *CreateBitmap(int width, int height, int depth)
   return new_bitmap;
 }
 
   return new_bitmap;
 }
 
-inline void FreeBitmap(Bitmap *bitmap)
+inline static void FreeBitmapPointers(Bitmap *bitmap)
 {
   if (bitmap == NULL)
     return;
 {
   if (bitmap == NULL)
     return;
@@ -298,10 +298,29 @@ inline void FreeBitmap(Bitmap *bitmap)
     XFreePixmap(display, bitmap->clip_mask);
   if (bitmap->stored_clip_gc)
     XFreeGC(display, bitmap->stored_clip_gc);
     XFreePixmap(display, bitmap->clip_mask);
   if (bitmap->stored_clip_gc)
     XFreeGC(display, bitmap->stored_clip_gc);
+  /* the other GCs are only pointers to GCs used elsewhere */
 #endif
 
   if (bitmap->source_filename)
     free(bitmap->source_filename);
 #endif
 
   if (bitmap->source_filename)
     free(bitmap->source_filename);
+}
+
+inline void TransferBitmapPointers(Bitmap *src_bitmap, Bitmap *dst_bitmap)
+{
+  if (src_bitmap == NULL || dst_bitmap == NULL)
+    return;
+
+  FreeBitmapPointers(dst_bitmap);
+
+  *dst_bitmap = *src_bitmap;
+}
+
+inline void FreeBitmap(Bitmap *bitmap)
+{
+  if (bitmap == NULL)
+    return;
+
+  FreeBitmapPointers(bitmap);
 
   free(bitmap);
 }
 
   free(bitmap);
 }
@@ -647,7 +666,7 @@ Bitmap *LoadCustomImage(char *basename)
   return new_bitmap;
 }
 
   return new_bitmap;
 }
 
-void ReloadCustomImage(Bitmap **bitmap, char *basename)
+Bitmap *ReloadCustomImage(Bitmap **bitmap, char *basename)
 {
   char *filename = getCustomImageFilename(basename);
   Bitmap *old_bitmap = *bitmap;
 {
   char *filename = getCustomImageFilename(basename);
   Bitmap *old_bitmap = *bitmap;
@@ -656,7 +675,7 @@ void ReloadCustomImage(Bitmap **bitmap, char *basename)
   if (filename == NULL)                /* (should never happen) */
   {
     Error(ERR_WARN, "ReloadCustomImage(): cannot find file '%s'", basename);
   if (filename == NULL)                /* (should never happen) */
   {
     Error(ERR_WARN, "ReloadCustomImage(): cannot find file '%s'", basename);
-    return;
+    return NULL;
   }
 
   if (strcmp(filename, old_bitmap->source_filename) == 0)
   }
 
   if (strcmp(filename, old_bitmap->source_filename) == 0)
@@ -665,13 +684,13 @@ void ReloadCustomImage(Bitmap **bitmap, char *basename)
        This usually means that this image does not exist in this graphic set
        and a fallback to the existing image is done. */
 
        This usually means that this image does not exist in this graphic set
        and a fallback to the existing image is done. */
 
-    return;
+    return NULL;
   }
 
   if ((new_bitmap = LoadImage(filename)) == NULL)
   {
     Error(ERR_WARN, "LoadImage() failed: %s", GetError());
   }
 
   if ((new_bitmap = LoadImage(filename)) == NULL)
   {
     Error(ERR_WARN, "LoadImage() failed: %s", GetError());
-    return;
+    return NULL;
   }
 
   if (old_bitmap->width != new_bitmap->width ||
   }
 
   if (old_bitmap->width != new_bitmap->width ||
@@ -679,9 +698,10 @@ void ReloadCustomImage(Bitmap **bitmap, char *basename)
   {
     Error(ERR_WARN, "ReloadCustomImage: new image has wrong dimensions");
     FreeBitmap(new_bitmap);
   {
     Error(ERR_WARN, "ReloadCustomImage: new image has wrong dimensions");
     FreeBitmap(new_bitmap);
-    return;
+    return NULL;
   }
 
   }
 
+#if 0
   /* copy filename for new image */
   free(old_bitmap->source_filename);
   old_bitmap->source_filename = getStringCopy(filename);
   /* copy filename for new image */
   free(old_bitmap->source_filename);
   old_bitmap->source_filename = getStringCopy(filename);
@@ -691,6 +711,12 @@ void ReloadCustomImage(Bitmap **bitmap, char *basename)
             old_bitmap->width, old_bitmap->height, 0,0);
 
   FreeBitmap(new_bitmap);
             old_bitmap->width, old_bitmap->height, 0,0);
 
   FreeBitmap(new_bitmap);
+#else
+  /*
+  *bitmap = new_bitmap;
+  */
+  return new_bitmap;
+#endif
 }
 
 
 }
 
 
index 145bac1dddea768910ff0556548b9b1f6f4065ab..19fdf64538fb42b88e55bac7d30f759065366305 100644 (file)
@@ -443,6 +443,7 @@ inline void CloseVideoDisplay(void);
 inline void InitVideoBuffer(DrawBuffer **,DrawWindow **, int,int,int, boolean);
 inline Bitmap *CreateBitmapStruct(void);
 inline Bitmap *CreateBitmap(int, int, int);
 inline void InitVideoBuffer(DrawBuffer **,DrawWindow **, int,int,int, boolean);
 inline Bitmap *CreateBitmapStruct(void);
 inline Bitmap *CreateBitmap(int, int, int);
+inline void TransferBitmapPointers(Bitmap *, Bitmap *);
 inline void FreeBitmap(Bitmap *);
 inline void BlitBitmap(Bitmap *, Bitmap *, int, int, int, int, int, int);
 inline void ClearRectangle(Bitmap *, int, int, int, int);
 inline void FreeBitmap(Bitmap *);
 inline void BlitBitmap(Bitmap *, Bitmap *, int, int, int, int, int, int);
 inline void ClearRectangle(Bitmap *, int, int, int, int);
@@ -465,7 +466,7 @@ inline boolean ChangeVideoModeIfNeeded(boolean);
 
 Bitmap *LoadImage(char *);
 Bitmap *LoadCustomImage(char *);
 
 Bitmap *LoadImage(char *);
 Bitmap *LoadCustomImage(char *);
-void ReloadCustomImage(Bitmap **, char *);
+Bitmap *ReloadCustomImage(Bitmap **, char *);
 
 inline void OpenAudio(void);
 inline void CloseAudio(void);
 
 inline void OpenAudio(void);
 inline void CloseAudio(void);
index e6556da224aef86a4f328ecd4370c326fc547aef..ece8b097db923651cbc872a395e33111231c8b1c 100644 (file)
@@ -234,7 +234,6 @@ void DrawMainMenu()
 #if 0
   ClearEventQueue();
 #endif
 #if 0
   ClearEventQueue();
 #endif
-
 }
 
 static void gotoTopLevelDir()
 }
 
 static void gotoTopLevelDir()
index 078b3c9b4db735ee27c9a8bdd8bfa6c28b286079..4a85f3d79d50511bb6677c09fa35d06bb6f6fb8f 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2002-04-07 13:13]"
+#define COMPILE_DATE_STRING "[2002-04-07 18:38]"