Skip to content

Commit

Permalink
r_showbboxes_filter accepts edict number prefixed with #
Browse files Browse the repository at this point in the history
Example:
r_showbboxes_filter #42
  • Loading branch information
andrey-budko committed Mar 5, 2024
1 parent a352e9c commit 8b6f35f
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions Quake/gl_rmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 8b6f35f

Please sign in to comment.