From 8b6f35f5ba5e69782059bd2a098664ac963c27bf Mon Sep 17 00:00:00 2001 From: "U-DESKTOP-68SHKBH\\entryway" Date: Tue, 5 Mar 2024 23:30:58 +0200 Subject: [PATCH] r_showbboxes_filter accepts edict number prefixed with # Example: r_showbboxes_filter #42 --- Quake/gl_rmain.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/Quake/gl_rmain.c b/Quake/gl_rmain.c index 1baca521d..499a5e8b2 100644 --- a/Quake/gl_rmain.c +++ b/Quake/gl_rmain.c @@ -1295,32 +1295,43 @@ static void R_EmitEdictLink (const edict_t *from, const edict_t *to, showbboxfla ================ R_ShowBoundingBoxesFilter -r_showbboxes_filter artifact =trigger_secret +r_showbboxes_filter artifact =trigger_secret #42 ================ */ char r_showbboxes_filter_strings[MAXCMDLINE]; static qboolean R_ShowBoundingBoxesFilter (edict_t *ed) { + char entnum[16]; + const char *classname = NULL; + const char *filter_p = r_showbboxes_filter_strings; + qboolean is_allowed = false; + if (!r_showbboxes_filter_strings[0]) return true; + sprintf (entnum, "%d", NUM_FOR_EDICT(ed)); + if (ed->v.classname) + classname = PR_GetString (ed->v.classname); + + while (*filter_p && !is_allowed) { - const char *classname = PR_GetString (ed->v.classname); - const char *str = r_showbboxes_filter_strings; - qboolean is_allowed = false; - while (*str && !is_allowed) + if (*filter_p == '#') + is_allowed = !strcmp (entnum, filter_p + 1); + + if (!is_allowed && classname) { - if (*str == '=') - is_allowed = !strcmp (classname, str + 1); + if (*filter_p == '=') + is_allowed = !strcmp (classname, filter_p + 1); else - is_allowed = strstr (classname, str) != NULL; - str += strlen (str) + 1; + is_allowed = strstr (classname, filter_p) != NULL; } - return is_allowed; + + filter_p += strlen (filter_p) + 1; } - return false; + + return is_allowed; } static edict_t **bbox_edicts = NULL; // all edicts shown by r_showbboxes & co @@ -1430,7 +1441,7 @@ static void R_ShowBoundingBoxes (void) if (R_CullBox (mins, maxs)) continue; - // Classname filter + // Classname or edict num filter if (!R_ShowBoundingBoxesFilter(ed)) continue;