From 5bf78e3789689719eafd78ef8c1bc52db34c041a Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 5 Feb 2025 20:08:07 +0100 Subject: [PATCH] added function to check for ".class" parameter --- src/anim.c | 20 ++++++++++---------- src/files.c | 5 +++++ src/files.h | 2 ++ src/game.c | 8 ++++---- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/anim.c b/src/anim.c index 5e7b0d8e..aa00588c 100644 --- a/src/anim.c +++ b/src/anim.c @@ -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) diff --git a/src/files.c b/src/files.c index 45ae1932..07698558 100644 --- a/src/files.c +++ b/src/files.c @@ -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) { diff --git a/src/files.h b/src/files.h index cf379db6..415d00db 100644 --- a/src/files.h +++ b/src/files.h @@ -126,4 +126,6 @@ int GetGlobalAnimEventValueCount(int); int get_parameter_value(char *, char *, int); +boolean isClass(int, char *); + #endif // FILES_H diff --git a/src/game.c b/src/game.c index 825e595c..cb25d06a 100644 --- a/src/game.c +++ b/src/game.c @@ -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) -- 2.34.1