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 andrei-drexler#42
  • Loading branch information
andrey-budko committed Mar 5, 2024
1 parent a352e9c commit 67b8b30
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions Quake/gl_rmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ 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];
Expand All @@ -1305,22 +1305,32 @@ static qboolean R_ShowBoundingBoxesFilter (edict_t *ed)
if (!r_showbboxes_filter_strings[0])
return true;

int entnum = NUM_FOR_EDICT(ed);

const char *classname = NULL;
if (ed->v.classname)
classname = PR_GetString (ed->v.classname);

const char *str = r_showbboxes_filter_strings;
qboolean is_allowed = false;
while (*str && !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 (*str == '#')
{
char buffer[16];
sprintf (buffer, "%d", entnum);
is_allowed = !strcmp (buffer, str + 1);
}
if (!is_allowed && classname)
{
if (*str == '=')
is_allowed = !strcmp (classname, str + 1);
else
is_allowed = strstr (classname, str) != NULL;
str += strlen (str) + 1;
}
return is_allowed;
str += strlen (str) + 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 +1440,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 67b8b30

Please sign in to comment.