updated contact info in source file headers
[rocksndiamonds.git] / src / libgame / gadgets.c
index 26454d470ae616c55063fbb8577d10e78c8547ad..9c07371bc31a7321e6422ea839f45133af95143f 100644 (file)
@@ -1,15 +1,13 @@
-/***********************************************************
-* Artsoft Retro-Game Library                               *
-*----------------------------------------------------------*
-* (c) 1994-2006 Artsoft Entertainment                      *
-*               Holger Schemel                             *
-*               Detmolder Strasse 189                      *
-*               33604 Bielefeld                            *
-*               Germany                                    *
-*               e-mail: info@artsoft.org                   *
-*----------------------------------------------------------*
-* gadgets.c                                                *
-***********************************************************/
+// ============================================================================
+// Artsoft Retro-Game Library
+// ----------------------------------------------------------------------------
+// (c) 1995-2014 by Artsoft Entertainment
+//                         Holger Schemel
+//                 info@artsoft.org
+//                 http://www.artsoft.org/
+// ----------------------------------------------------------------------------
+// gadgets.c
+// ============================================================================
 
 #include <stdarg.h>
 #include <string.h>
@@ -26,6 +24,9 @@
 #define DG_BUFFERED            0
 #define DG_DIRECT              1
 
+#define GADGET_DEACTIVATED(g)  ((g)->x < 0 || (g)->y < 0)
+
+
 static struct GadgetInfo *gadget_list_first_entry = NULL;
 static struct GadgetInfo *gadget_list_last_entry = NULL;
 static struct GadgetInfo *last_info_gi = NULL;
@@ -1260,6 +1261,9 @@ void FreeGadget(struct GadgetInfo *gi)
 {
   struct GadgetInfo *gi_previous = gadget_list_first_entry;
 
+  if (gi == NULL)
+    return;
+
   /* prevent "last_info_gi" from pointing to memory that will be freed */
   if (last_info_gi == gi)
     last_info_gi = NULL;
@@ -1304,7 +1308,7 @@ static struct GadgetInfo *last_gi = NULL;
 
 static void MapGadgetExt(struct GadgetInfo *gi, boolean redraw)
 {
-  if (gi == NULL || gi->mapped)
+  if (gi == NULL || gi->mapped || GADGET_DEACTIVATED(gi))
     return;
 
   gi->mapped = TRUE;