added function to check for ".class" parameter
authorHolger Schemel <info@artsoft.org>
Wed, 5 Feb 2025 19:08:07 +0000 (20:08 +0100)
committerHolger Schemel <info@artsoft.org>
Wed, 5 Feb 2025 19:08:07 +0000 (20:08 +0100)
src/anim.c
src/files.c
src/files.h
src/game.c

index 5e7b0d8e33b2a9793761211806eb37024447f225..aa00588c33c5ebe4872816f29cfca0b3c74ff316 100644 (file)
@@ -599,7 +599,7 @@ static void InitGlobalAnimControls(void)
        }
 
        // apply special settings to pointer-style animations
-       if (part->control_info.class == get_hash_from_string("pointer"))
+       if (isClass(part->control_info.class, "pointer"))
        {
          // force pointer-style animations to be checked for clicks first
          part->control_info.draw_order = 1000000;
@@ -984,7 +984,7 @@ static boolean SetGlobalAnimPart_Viewport(struct GlobalAnimPartControlInfo *part
   boolean changed = FALSE;
 
   if (part->last_anim_status == global.anim_status &&
-      part->control_info.class != get_hash_from_string("pointer"))
+      !isClass(part->control_info.class, "pointer"))
     return FALSE;
 
   part->last_anim_status = global.anim_status;
@@ -993,8 +993,8 @@ static boolean SetGlobalAnimPart_Viewport(struct GlobalAnimPartControlInfo *part
 
   part->class_playfield_or_door = FALSE;
 
-  if (part->control_info.class == get_hash_from_string("window") ||
-      part->control_info.class == get_hash_from_string("border"))
+  if (isClass(part->control_info.class, "window") ||
+      isClass(part->control_info.class, "border"))
   {
     viewport_x = 0;
     viewport_y = 0;
@@ -1003,7 +1003,7 @@ static boolean SetGlobalAnimPart_Viewport(struct GlobalAnimPartControlInfo *part
 
     part->drawing_stage = DRAW_GLOBAL_ANIM_STAGE_2;
   }
-  else if (part->control_info.class == get_hash_from_string("pointer"))
+  else if (isClass(part->control_info.class, "pointer"))
   {
     int mx = MIN(MAX(0, gfx.mouse_x), WIN_XSIZE - 1);
     int my = MIN(MAX(0, gfx.mouse_y), WIN_YSIZE - 1);
@@ -1024,7 +1024,7 @@ static boolean SetGlobalAnimPart_Viewport(struct GlobalAnimPartControlInfo *part
     if (global.anim_status != GAME_MODE_LOADING)
       gfx.cursor_mode_override = CURSOR_NONE;
   }
-  else if (part->control_info.class == get_hash_from_string("door_1"))
+  else if (isClass(part->control_info.class, "door_1"))
   {
     viewport_x = DX;
     viewport_y = DY;
@@ -1033,7 +1033,7 @@ static boolean SetGlobalAnimPart_Viewport(struct GlobalAnimPartControlInfo *part
 
     part->class_playfield_or_door = TRUE;
   }
-  else if (part->control_info.class == get_hash_from_string("door_2"))
+  else if (isClass(part->control_info.class, "door_2"))
   {
     if (part->mode_nr == GAME_MODE_EDITOR)
     {
@@ -1072,7 +1072,7 @@ static boolean SetGlobalAnimPart_Viewport(struct GlobalAnimPartControlInfo *part
     part->viewport_width  = viewport_width;
     part->viewport_height = viewport_height;
 
-    if (part->control_info.class != get_hash_from_string("pointer"))
+    if (!isClass(part->control_info.class, "pointer"))
       changed = TRUE;
   }
 
@@ -1610,7 +1610,7 @@ static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part,
       part->step_yoffset = 0;
     }
 
-    if (part->control_info.class != get_hash_from_string("pointer"))
+    if (!isClass(part->control_info.class, "pointer"))
     {
       if (c->x != ARG_UNDEFINED_VALUE)
        part->x = c->x;
@@ -2073,7 +2073,7 @@ static boolean InitGlobalAnim_Clicked(int mx, int my, int clicked_event)
 
     // if request dialog is active, only handle pointer-style animations
     if (game.request_active &&
-       part->control_info.class != get_hash_from_string("pointer"))
+       !isClass(part->control_info.class, "pointer"))
       continue;
 
     if (clicked_event == ANIM_CLICKED_RESET)
index 45ae19320398ef52fa953664de6f1c7141badec1..076985589e02fbaa2a7605d9c02f2c5774a99453 100644 (file)
@@ -13562,6 +13562,11 @@ static int get_token_parameter_value(char *token, char *value_raw)
   return get_parameter_value(value_raw, suffix, TYPE_INTEGER);
 }
 
+boolean isClass(int class, char *value)
+{
+  return (class == get_hash_from_string(value));
+}
+
 void InitMenuDesignSettings_FromHash(SetupFileHash *setup_file_hash,
                                     boolean ignore_defaults)
 {
index cf379db6264ebf1a61291e18bbf3672a3ab55342..415d00dbcd3ef96b28f4e8725f399e6ff7b5ee1d 100644 (file)
@@ -126,4 +126,6 @@ int GetGlobalAnimEventValueCount(int);
 
 int get_parameter_value(char *, char *, int);
 
+boolean isClass(int, char *);
+
 #endif // FILES_H
index 825e595c84c5120e94e30b44911c3ddfc234c70b..cb25d06a3f192c7e6d51cf2ff3b9bffaf0ecb973 100644 (file)
@@ -3051,15 +3051,15 @@ static void DisplayGameControlValues(void)
     if (PANEL_DEACTIVATED(pos))
       continue;
 
-    if (pos->class == get_hash_from_string("extra_panel_items") &&
+    if (isClass(pos->class, "extra_panel_items") &&
        !setup.prefer_extra_panel_items)
       continue;
 
-    if (pos->class == get_hash_from_string("bd_pre_hatching") &&
+    if (isClass(pos->class, "bd_pre_hatching") &&
         (level.game_engine_type != GAME_ENGINE_TYPE_BD || game_bd.game->cave->hatched))
       continue;
 
-    if (pos->class == get_hash_from_string("bd_post_hatching") &&
+    if (isClass(pos->class, "bd_post_hatching") &&
         (level.game_engine_type == GAME_ENGINE_TYPE_BD && !game_bd.game->cave->hatched))
       continue;
 
@@ -3151,7 +3151,7 @@ static void DisplayGameControlValues(void)
       int width, height;
       int dst_x = PANEL_XPOS(pos);
       int dst_y = PANEL_YPOS(pos);
-      boolean skip = (pos->class == get_hash_from_string("mm_engine_only") &&
+      boolean skip = (isClass(pos->class, "mm_engine_only") &&
                      level.game_engine_type != GAME_ENGINE_TYPE_MM);
 
       if (graphic != IMG_UNDEFINED && !skip)