From: Holger Schemel Date: Wed, 5 Feb 2025 19:35:36 +0000 (+0100) Subject: added support for multiple pre-defined ".class" parameters X-Git-Tag: 4.4.0.4~11 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=6ebfba11d580c9af73e31a9be5953f910d848e5a;p=rocksndiamonds.git added support for multiple pre-defined ".class" parameters --- diff --git a/src/files.c b/src/files.c index 07698558..fe306f03 100644 --- a/src/files.c +++ b/src/files.c @@ -13380,8 +13380,25 @@ static int get_anim_action_parameter_value(char *token) static int get_class_parameter_value(char *value) { - int result = (strEqual(value, ARG_UNDEFINED) ? ARG_UNDEFINED_VALUE : - get_hash_from_string(value)); + int result = CLASS_DEFAULT; + + if (strEqual(value, ARG_UNDEFINED)) + return ARG_UNDEFINED_VALUE; + + if (string_has_parameter(value, "mm_engine_only")) + result |= CLASS_MM_ENGINE_ONLY; + + if (string_has_parameter(value, "extra_panel_items")) + result |= CLASS_EXTRA_PANEL_ITEMS; + + if (string_has_parameter(value, "bd_pre_hatching")) + result |= CLASS_BD_PRE_HATCHING; + + if (string_has_parameter(value, "bd_post_hatching")) + result |= CLASS_BD_POST_HATCHING; + + if (result == CLASS_DEFAULT) + result = get_hash_from_string(value); return result; } @@ -13567,6 +13584,15 @@ boolean isClass(int class, char *value) return (class == get_hash_from_string(value)); } +boolean hasClass(int class, int value) +{ + if (class < CLASS_NONE || + class > CLASS_MAX) + return FALSE; + + return ((class & value) != 0); +} + void InitMenuDesignSettings_FromHash(SetupFileHash *setup_file_hash, boolean ignore_defaults) { diff --git a/src/files.h b/src/files.h index 415d00db..9ecea420 100644 --- a/src/files.h +++ b/src/files.h @@ -127,5 +127,6 @@ int GetGlobalAnimEventValueCount(int); int get_parameter_value(char *, char *, int); boolean isClass(int, char *); +boolean hasClass(int, int); #endif // FILES_H diff --git a/src/game.c b/src/game.c index cb25d06a..b240c1f9 100644 --- a/src/game.c +++ b/src/game.c @@ -3051,15 +3051,15 @@ static void DisplayGameControlValues(void) if (PANEL_DEACTIVATED(pos)) continue; - if (isClass(pos->class, "extra_panel_items") && + if (hasClass(pos->class, CLASS_EXTRA_PANEL_ITEMS) && !setup.prefer_extra_panel_items) continue; - if (isClass(pos->class, "bd_pre_hatching") && + if (hasClass(pos->class, CLASS_BD_PRE_HATCHING) && (level.game_engine_type != GAME_ENGINE_TYPE_BD || game_bd.game->cave->hatched)) continue; - if (isClass(pos->class, "bd_post_hatching") && + if (hasClass(pos->class, 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 = (isClass(pos->class, "mm_engine_only") && + boolean skip = (hasClass(pos->class, CLASS_MM_ENGINE_ONLY) && level.game_engine_type != GAME_ENGINE_TYPE_MM); if (graphic != IMG_UNDEFINED && !skip) diff --git a/src/libgame/system.h b/src/libgame/system.h index 6ca2afbe..c9ae6d09 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -429,6 +429,19 @@ // values for special global animation delay actions #define ANIM_DELAY_ACTION_NONE -1 +// values for special drawing classes +#define CLASS_NONE 0 + +// values used for game panel graphics +#define CLASS_MM_ENGINE_ONLY (1 << 0) +#define CLASS_EXTRA_PANEL_ITEMS (1 << 1) +#define CLASS_BD_PRE_HATCHING (1 << 2) +#define CLASS_BD_POST_HATCHING (1 << 3) + +#define CLASS_MAX ((1 << 4) - 1) + +#define CLASS_DEFAULT CLASS_NONE + // values for special drawing styles and event handling #define STYLE_NONE 0