| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
#include "stdafx.h" |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
bfilter_t *FilterAdd(bfilter_t *pFilter, int type, int bmask, const char *str, int exclude) |
|---|
| 41 |
{ |
|---|
| 42 |
bfilter_t *pNew = new bfilter_t; |
|---|
| 43 |
pNew->next = pFilter; |
|---|
| 44 |
pNew->attribute = type; |
|---|
| 45 |
if (type == 1 || type == 3) pNew->string = str; |
|---|
| 46 |
if (type == 2 || type == 4 || type == 5 || type == 6 || type == 7) pNew->mask = bmask; |
|---|
| 47 |
if (g_qeglobals.d_savedinfo.exclude & exclude) |
|---|
| 48 |
pNew->active = true; |
|---|
| 49 |
else |
|---|
| 50 |
pNew->active = false; |
|---|
| 51 |
return pNew; |
|---|
| 52 |
} |
|---|
| 53 |
|
|---|
| 54 |
bfilter_t *FilterCreate (int type, int bmask, const char *str, int exclude) |
|---|
| 55 |
{ |
|---|
| 56 |
g_qeglobals.d_savedinfo.filters = FilterAdd(g_qeglobals.d_savedinfo.filters, type, bmask, str, exclude); |
|---|
| 57 |
Syn_Printf("Added filter %s (type: %i, bmask: %i, exclude: %i)\n", str, type, bmask, exclude); |
|---|
| 58 |
return g_qeglobals.d_savedinfo.filters; |
|---|
| 59 |
} |
|---|
| 60 |
|
|---|
| 61 |
extern void PerformFiltering(); |
|---|
| 62 |
|
|---|
| 63 |
void FiltersActivate (void) |
|---|
| 64 |
{ |
|---|
| 65 |
PerformFiltering(); |
|---|
| 66 |
Sys_UpdateWindows(W_XY|W_CAMERA); |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
bfilter_t *FilterListDelete(bfilter_t *pFilter) |
|---|
| 71 |
{ |
|---|
| 72 |
if (pFilter != NULL) |
|---|
| 73 |
{ |
|---|
| 74 |
FilterListDelete(pFilter->next); |
|---|
| 75 |
delete pFilter; |
|---|
| 76 |
} |
|---|
| 77 |
return NULL; |
|---|
| 78 |
} |
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
bfilter_t *FilterUpdate(bfilter_t *pFilter) |
|---|
| 83 |
{ |
|---|
| 84 |
pFilter = FilterAdd(pFilter,1,0,"clip",EXCLUDE_CLIP); |
|---|
| 85 |
pFilter = FilterAdd(pFilter,1,0,"caulk",EXCLUDE_CAULK); |
|---|
| 86 |
pFilter = FilterAdd(pFilter,1,0,"liquids",EXCLUDE_LIQUIDS); |
|---|
| 87 |
pFilter = FilterAdd(pFilter,1,0,"hint",EXCLUDE_HINTSSKIPS); |
|---|
| 88 |
pFilter = FilterAdd(pFilter,1,0,"clusterportal",EXCLUDE_CLUSTERPORTALS); |
|---|
| 89 |
pFilter = FilterAdd(pFilter,1,0,"areaportal",EXCLUDE_AREAPORTALS); |
|---|
| 90 |
pFilter = FilterAdd(pFilter,2,QER_TRANS,NULL,EXCLUDE_TRANSLUCENT); |
|---|
| 91 |
pFilter = FilterAdd(pFilter,3,0,"trigger",EXCLUDE_TRIGGERS); |
|---|
| 92 |
pFilter = FilterAdd(pFilter,3,0,"misc_model",EXCLUDE_MODELS); |
|---|
| 93 |
pFilter = FilterAdd(pFilter,3,0,"misc_gamemodel",EXCLUDE_MODELS); |
|---|
| 94 |
pFilter = FilterAdd(pFilter,4,ECLASS_LIGHT,NULL,EXCLUDE_LIGHTS); |
|---|
| 95 |
pFilter = FilterAdd(pFilter,4,ECLASS_PATH,NULL,EXCLUDE_PATHS); |
|---|
| 96 |
pFilter = FilterAdd(pFilter,1,0,"lightgrid",EXCLUDE_LIGHTGRID); |
|---|
| 97 |
pFilter = FilterAdd(pFilter,1,0,"botclip",EXCLUDE_BOTCLIP); |
|---|
| 98 |
pFilter = FilterAdd(pFilter,1,0,"clipmonster",EXCLUDE_BOTCLIP); |
|---|
| 99 |
return pFilter; |
|---|
| 100 |
} |
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
bool FilterBrush(brush_t *pb) |
|---|
| 109 |
{ |
|---|
| 110 |
|
|---|
| 111 |
if (!pb->owner) |
|---|
| 112 |
return FALSE; |
|---|
| 113 |
|
|---|
| 114 |
if (pb->hiddenBrush) |
|---|
| 115 |
return TRUE; |
|---|
| 116 |
|
|---|
| 117 |
if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_WORLD) |
|---|
| 118 |
{ |
|---|
| 119 |
if (strcmp(pb->owner->eclass->name, "worldspawn") == 0 || !strcmp(pb->owner->eclass->name,"func_group")) |
|---|
| 120 |
{ |
|---|
| 121 |
return TRUE; |
|---|
| 122 |
} |
|---|
| 123 |
} |
|---|
| 124 |
|
|---|
| 125 |
if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_ENT) |
|---|
| 126 |
{ |
|---|
| 127 |
if (strcmp(pb->owner->eclass->name, "worldspawn") != 0 && strcmp(pb->owner->eclass->name,"func_group")) |
|---|
| 128 |
{ |
|---|
| 129 |
return TRUE; |
|---|
| 130 |
} |
|---|
| 131 |
} |
|---|
| 132 |
|
|---|
| 133 |
if ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_CURVES ) |
|---|
| 134 |
{ |
|---|
| 135 |
if (pb->patchBrush) |
|---|
| 136 |
{ |
|---|
| 137 |
return TRUE; |
|---|
| 138 |
} |
|---|
| 139 |
} |
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
if ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_DETAILS ) |
|---|
| 143 |
{ |
|---|
| 144 |
if (!pb->patchBrush && pb->brush_faces->texdef.contents & CONTENTS_DETAIL ) |
|---|
| 145 |
{ |
|---|
| 146 |
return TRUE; |
|---|
| 147 |
} |
|---|
| 148 |
} |
|---|
| 149 |
if ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_STRUCTURAL ) |
|---|
| 150 |
{ |
|---|
| 151 |
if (!pb->patchBrush && !( pb->brush_faces->texdef.contents & CONTENTS_DETAIL )) |
|---|
| 152 |
{ |
|---|
| 153 |
return TRUE; |
|---|
| 154 |
} |
|---|
| 155 |
} |
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
if ( ( strcmp(pb->owner->eclass->name, "worldspawn") == 0 |
|---|
| 159 |
|| !strncmp( pb->owner->eclass->name, "func", 4) |
|---|
| 160 |
|| !strncmp( pb->owner->eclass->name, "trigger", 7) ) && !pb->patchBrush ) |
|---|
| 161 |
{ |
|---|
| 162 |
bool filterbrush = false; |
|---|
| 163 |
for (face_t *f=pb->brush_faces;f!=NULL;f = f->next) |
|---|
| 164 |
{ |
|---|
| 165 |
filterbrush=false; |
|---|
| 166 |
for (bfilter_t *filters = g_qeglobals.d_savedinfo.filters; |
|---|
| 167 |
filters != NULL; |
|---|
| 168 |
filters = filters->next) |
|---|
| 169 |
{ |
|---|
| 170 |
if (!filters->active) |
|---|
| 171 |
continue; |
|---|
| 172 |
|
|---|
| 173 |
if (filters->attribute == 1) |
|---|
| 174 |
{ |
|---|
| 175 |
if (strstr(f->pShader->getName(),filters->string)) |
|---|
| 176 |
{ |
|---|
| 177 |
filterbrush=true; |
|---|
| 178 |
break; |
|---|
| 179 |
} |
|---|
| 180 |
} |
|---|
| 181 |
|
|---|
| 182 |
else if (filters->attribute == 2) |
|---|
| 183 |
{ |
|---|
| 184 |
if (f->pShader->getFlags() & filters->mask) |
|---|
| 185 |
{ |
|---|
| 186 |
filterbrush=true; |
|---|
| 187 |
break; |
|---|
| 188 |
} |
|---|
| 189 |
|
|---|
| 190 |
} |
|---|
| 191 |
else if (filters->attribute == 5) |
|---|
| 192 |
{ |
|---|
| 193 |
if (f->texdef.flags && f->texdef.flags & filters->mask) |
|---|
| 194 |
{ |
|---|
| 195 |
filterbrush=true; |
|---|
| 196 |
break; |
|---|
| 197 |
} |
|---|
| 198 |
} |
|---|
| 199 |
else if (filters->attribute == 6) |
|---|
| 200 |
{ |
|---|
| 201 |
if (f->texdef.contents && f->texdef.contents & filters->mask) |
|---|
| 202 |
{ |
|---|
| 203 |
filterbrush=true; |
|---|
| 204 |
break; |
|---|
| 205 |
} |
|---|
| 206 |
} |
|---|
| 207 |
else if (filters->attribute == 7) |
|---|
| 208 |
{ |
|---|
| 209 |
if (f->texdef.contents && !(f->texdef.contents & filters->mask)) |
|---|
| 210 |
{ |
|---|
| 211 |
filterbrush=true; |
|---|
| 212 |
break; |
|---|
| 213 |
} |
|---|
| 214 |
} |
|---|
| 215 |
} |
|---|
| 216 |
if (!filterbrush) |
|---|
| 217 |
break; |
|---|
| 218 |
} |
|---|
| 219 |
if (filterbrush) |
|---|
| 220 |
return true; |
|---|
| 221 |
} |
|---|
| 222 |
|
|---|
| 223 |
|
|---|
| 224 |
if ( pb->patchBrush ) |
|---|
| 225 |
{ |
|---|
| 226 |
bool drawpatch=true; |
|---|
| 227 |
for (bfilter_t *filters = g_qeglobals.d_savedinfo.filters; |
|---|
| 228 |
filters != NULL; |
|---|
| 229 |
filters = filters->next) |
|---|
| 230 |
{ |
|---|
| 231 |
|
|---|
| 232 |
if (filters->active |
|---|
| 233 |
&& filters->attribute == 1) |
|---|
| 234 |
{ |
|---|
| 235 |
if (strstr(pb->pPatch->pShader->getName(),filters->string)) |
|---|
| 236 |
{ |
|---|
| 237 |
drawpatch=false; |
|---|
| 238 |
break; |
|---|
| 239 |
} |
|---|
| 240 |
} |
|---|
| 241 |
|
|---|
| 242 |
|
|---|
| 243 |
if (filters->active |
|---|
| 244 |
&& filters->attribute == 2) |
|---|
| 245 |
{ |
|---|
| 246 |
if (pb->pPatch->pShader->getFlags() & filters->mask) |
|---|
| 247 |
{ |
|---|
| 248 |
drawpatch=false; |
|---|
| 249 |
break; |
|---|
| 250 |
} |
|---|
| 251 |
} |
|---|
| 252 |
} |
|---|
| 253 |
if (!drawpatch) |
|---|
| 254 |
return TRUE; |
|---|
| 255 |
} |
|---|
| 256 |
|
|---|
| 257 |
if (strcmp(pb->owner->eclass->name, "worldspawn") != 0) |
|---|
| 258 |
{ |
|---|
| 259 |
bool drawentity=true; |
|---|
| 260 |
for (bfilter_t *filters = g_qeglobals.d_savedinfo.filters; |
|---|
| 261 |
filters != NULL; |
|---|
| 262 |
filters = filters->next) |
|---|
| 263 |
{ |
|---|
| 264 |
|
|---|
| 265 |
if (filters->active |
|---|
| 266 |
&& filters->attribute == 3) |
|---|
| 267 |
{ |
|---|
| 268 |
if (strstr(pb->owner->eclass->name,filters->string)) |
|---|
| 269 |
{ |
|---|
| 270 |
drawentity=false; |
|---|
| 271 |
break; |
|---|
| 272 |
} |
|---|
| 273 |
} |
|---|
| 274 |
|
|---|
| 275 |
|
|---|
| 276 |
else if (filters->active |
|---|
| 277 |
&& filters->attribute == 4) |
|---|
| 278 |
{ |
|---|
| 279 |
if ( pb->owner->eclass->nShowFlags & filters->mask ) |
|---|
| 280 |
{ |
|---|
| 281 |
drawentity=false; |
|---|
| 282 |
break; |
|---|
| 283 |
} |
|---|
| 284 |
} |
|---|
| 285 |
} |
|---|
| 286 |
if (!drawentity) |
|---|
| 287 |
return TRUE; |
|---|
| 288 |
} |
|---|
| 289 |
return FALSE; |
|---|
| 290 |
} |
|---|