rnd-20020406-1-src
[rocksndiamonds.git] / src / libgame / system.c
index f5125c611a14e5f21b600873ddef0cec3024bd0e..0e221548949504e1a3f65254638f08432cdd70aa 100644 (file)
@@ -40,8 +40,8 @@ struct ArtworkInfo    artwork;
 struct JoystickInfo    joystick;
 struct SetupInfo       setup;
 
-struct LevelDirInfo    *leveldir_first = NULL;
-struct LevelDirInfo    *leveldir_current = NULL;
+LevelDirTree          *leveldir_first = NULL;
+LevelDirTree          *leveldir_current = NULL;
 int                    level_nr;
 
 Display                       *display = NULL;
@@ -157,6 +157,8 @@ void InitGfxFieldInfo(int sx, int sy, int sxsize, int sysize,
   gfx.real_sy = real_sy;
   gfx.full_sxsize = full_sxsize;
   gfx.full_sysize = full_sysize;
+
+  SetDrawDeactivationMask(REDRAW_NONE);                /* do not deactivate drawing */
 }
 
 void InitGfxDoor1Info(int dx, int dy, int dxsize, int dysize)
@@ -182,6 +184,11 @@ void InitGfxScrollbufferInfo(int scrollbuffer_width, int scrollbuffer_height)
   gfx.scrollbuffer_height = scrollbuffer_height;
 }
 
+void SetDrawDeactivationMask(int draw_deactivation_mask)
+{
+  gfx.draw_deactivation_mask = draw_deactivation_mask;
+}
+
 
 /* ========================================================================= */
 /* video functions                                                           */
@@ -208,6 +215,7 @@ inline void CloseVideoDisplay(void)
 #if defined(TARGET_SDL)
   SDL_QuitSubSystem(SDL_INIT_VIDEO);
 #else
+
   if (display)
     XCloseDisplay(display);
 #endif
@@ -318,11 +326,26 @@ inline void CloseWindow(DrawWindow *window)
 #endif
 }
 
+inline boolean DrawingDeactivated(int x, int y, int width, int height)
+{
+  if (gfx.draw_deactivation_mask != REDRAW_NONE)
+  {
+    if ((gfx.draw_deactivation_mask & REDRAW_FIELD) &&
+       x < gfx.sx + gfx.sxsize)
+      return TRUE;
+  }
+
+  return FALSE;
+}
+
 inline void BlitBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap,
                       int src_x, int src_y,
                       int width, int height,
                       int dst_x, int dst_y)
 {
+  if (DrawingDeactivated(dst_x, dst_y, width, height))
+    return;
+
 #ifdef TARGET_SDL
   SDLCopyArea(src_bitmap, dst_bitmap,
              src_x, src_y, width, height, dst_x, dst_y, SDLCOPYAREA_OPAQUE);
@@ -334,6 +357,9 @@ inline void BlitBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap,
 
 inline void ClearRectangle(Bitmap *bitmap, int x, int y, int width, int height)
 {
+  if (DrawingDeactivated(x, y, width, height))
+    return;
+
 #ifdef TARGET_SDL
   SDLFillRectangle(bitmap, x, y, width, height, 0x000000);
 #else
@@ -380,6 +406,9 @@ inline void BlitBitmapMasked(Bitmap *src_bitmap, Bitmap *dst_bitmap,
                             int width, int height,
                             int dst_x, int dst_y)
 {
+  if (DrawingDeactivated(dst_x, dst_y, width, height))
+    return;
+
 #ifdef TARGET_SDL
   SDLCopyArea(src_bitmap, dst_bitmap,
              src_x, src_y, width, height, dst_x, dst_y, SDLCOPYAREA_MASKED);
@@ -611,13 +640,16 @@ Bitmap *LoadImage(char *filename)
 
 Bitmap *LoadCustomImage(char *basename)
 {
-  char *filename = getStringCopy(getCustomImageFilename(basename));
+  char *filename = getCustomImageFilename(basename);
   Bitmap *new_bitmap;
 
+  if (filename == NULL)
+    Error(ERR_EXIT, "LoadCustomImage(): cannot find file '%s'", basename);
+
   if ((new_bitmap = LoadImage(filename)) == NULL)
     Error(ERR_EXIT, "LoadImage() failed: %s", GetError());
 
-  new_bitmap->source_filename = filename;
+  new_bitmap->source_filename = getStringCopy(filename);
 
   return new_bitmap;
 }