From 873cb5d35fc7ff4a83085f66b8030c9628038839 Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Tue, 23 Feb 2021 09:10:28 +0100 Subject: [PATCH] In use function for extra flags. Add the new function extra_flag_is_in_use() It checks if the specified flag is used in the current ruleset. See osdn #41636 --- common/extras.c | 19 +++++++++++++++++++ common/extras.h | 1 + 2 files changed, 20 insertions(+) diff --git a/common/extras.c b/common/extras.c index d830e34fb4..8d906408f7 100644 --- a/common/extras.c +++ b/common/extras.c @@ -863,6 +863,25 @@ const char *extra_flag_helptxt(enum extra_flag_id id) return user_extra_flags[id - EF_USER_FLAG_1].helptxt; } +/**********************************************************************//** + Returns TRUE iff the specified extra type flag is in use by any extra + type. + @param id the extra type flag to check if is in use. + @returns TRUE if the extra type flag is used in the current ruleset. +**************************************************************************/ +bool extra_flag_is_in_use(enum extra_flag_id id) +{ + extra_type_re_active_iterate(pextra) { + if (extra_has_flag(pextra, id)) { + /* Found a user. */ + return TRUE; + } + } extra_type_re_active_iterate_end; + + /* No users detected. */ + return FALSE; +} + /************************************************************************//** Can two extras coexist in same tile? ****************************************************************************/ diff --git a/common/extras.h b/common/extras.h index 143f1f8eea..72906d3ee7 100644 --- a/common/extras.h +++ b/common/extras.h @@ -255,6 +255,7 @@ void set_user_extra_flag_name(enum extra_flag_id id, const char *name, const char *helptxt); const char *extra_flag_helptxt(enum extra_flag_id id); +bool extra_flag_is_in_use(enum extra_flag_id id); bool extra_causes_env_upset(struct extra_type *pextra, enum environment_upset_type upset); -- 2.20.1