Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r_showbboxes_filter accepts edict number prefixed with # #307

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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