X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Flibgame%2Fgadgets.c;h=9c07371bc31a7321e6422ea839f45133af95143f;hb=abe44529b439ad39b4d8dbf19cbd67c9b9844279;hp=2113b8247c74c12718af7f72103792f3f066ce7e;hpb=80aa0e4b2b060112407417a9d2896395023a21cc;p=rocksndiamonds.git diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index 2113b824..9c07371b 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -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 #include @@ -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; @@ -706,9 +707,21 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) gi->selectbox.x, gi->selectbox.y); } else + { +#if 1 + int x = gi->x; + int y = gi->y; + + redraw_mask |= (IN_GFX_FIELD_FULL(x, y) ? REDRAW_FIELD : + IN_GFX_DOOR_1(x, y) ? REDRAW_DOOR_1 : + IN_GFX_DOOR_2(x, y) ? REDRAW_DOOR_2 : + IN_GFX_DOOR_3(x, y) ? REDRAW_DOOR_3 : REDRAW_ALL); +#else redraw_mask |= (gi->x < gfx.sx + gfx.sxsize ? REDRAW_FIELD : gi->y < gfx.dy + gfx.dysize ? REDRAW_DOOR_1 : gi->y > gfx.vy ? REDRAW_DOOR_2 : REDRAW_DOOR_3); +#endif + } } static int get_minimal_size_for_numeric_input(int minmax_value) @@ -1248,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; @@ -1292,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; @@ -1324,9 +1340,11 @@ void UnmapGadget(struct GadgetInfo *gi) #define MULTIMAP_PLAYFIELD (1 << 3) #define MULTIMAP_DOOR_1 (1 << 4) #define MULTIMAP_DOOR_2 (1 << 5) +#define MULTIMAP_DOOR_3 (1 << 6) #define MULTIMAP_ALL (MULTIMAP_PLAYFIELD | \ - MULTIMAP_DOOR_1 | \ - MULTIMAP_DOOR_2) + MULTIMAP_DOOR_1 | \ + MULTIMAP_DOOR_2 | \ + MULTIMAP_DOOR_3) static void MultiMapGadgets(int mode) { @@ -1336,6 +1354,16 @@ static void MultiMapGadgets(int mode) while (gi != NULL) { +#if 1 + int x = gi->x; + int y = gi->y; + + if ((mode & MULTIMAP_PLAYFIELD && IN_GFX_FIELD_FULL(x, y)) || + (mode & MULTIMAP_DOOR_1 && IN_GFX_DOOR_1(x, y)) || + (mode & MULTIMAP_DOOR_2 && IN_GFX_DOOR_2(x, y)) || + (mode & MULTIMAP_DOOR_3 && IN_GFX_DOOR_3(x, y)) || + (mode & MULTIMAP_ALL) == MULTIMAP_ALL) +#else if ((mode & MULTIMAP_PLAYFIELD && gi->x < gfx.sx + gfx.sxsize) || (mode & MULTIMAP_DOOR_1 && @@ -1343,6 +1371,7 @@ static void MultiMapGadgets(int mode) (mode & MULTIMAP_DOOR_2 && gi->x >= gfx.dx && gi->y > gfx.dy + gfx.dysize) || (mode & MULTIMAP_ALL) == MULTIMAP_ALL) +#endif { if (mode & MULTIMAP_UNMAP) {