From bf1e23dc3ee502d9992bd9713541838cbbc262a2 Mon Sep 17 00:00:00 2001 From: mattn Date: Sun, 16 Mar 2008 20:06:02 +0000 Subject: [PATCH] * added three new filter types for quake2 surface and content flags * fixed ufoai level filters git-svn-id: https://zerowing.idsoftware.com/svn/radiant/GtkRadiant/branches/ZeroRadiant@222 8a3a26a2-13c4-0310-b231-cf6edde360e5 --- contrib/ufoai/ufoai_filters.cpp | 22 +++++++++++--------- include/qertypes.h | 2 ++ radiant/filters.cpp | 37 +++++++++++++++++++++++++++++---- 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/contrib/ufoai/ufoai_filters.cpp b/contrib/ufoai/ufoai_filters.cpp index a7e63db8..cd68f246 100644 --- a/contrib/ufoai/ufoai_filters.cpp +++ b/contrib/ufoai/ufoai_filters.cpp @@ -10,19 +10,21 @@ static bfilter_t* filters[FILTER_MAX]; void UFOAIFilterInit (void) { + // texture name filters filters[FILTER_ACTORCLIP] = FilterAdd(1, 0, "actorclip", 0); filters[FILTER_WEAPONCLIP] = FilterAdd(1, 0, "weaponclip", 0); filters[FILTER_NODRAW] = FilterAdd(1, 0, "nodraw", 0); filters[FILTER_STEPON] = FilterAdd(1, 0, "stepon", 0); - filters[FILTER_LEVEL1] = FilterAdd(2, UFOAI_CONTENTS_LEVEL_1, "level1", 0); - filters[FILTER_LEVEL2] = FilterAdd(2, UFOAI_CONTENTS_LEVEL_2, "level2", 0); - filters[FILTER_LEVEL3] = FilterAdd(2, UFOAI_CONTENTS_LEVEL_3, "level3", 0); - filters[FILTER_LEVEL4] = FilterAdd(2, UFOAI_CONTENTS_LEVEL_4, "level4", 0); - filters[FILTER_LEVEL5] = FilterAdd(2, UFOAI_CONTENTS_LEVEL_5, "level5", 0); - filters[FILTER_LEVEL6] = FilterAdd(2, UFOAI_CONTENTS_LEVEL_6, "level6", 0); - filters[FILTER_LEVEL7] = FilterAdd(2, UFOAI_CONTENTS_LEVEL_7, "level7", 0); - filters[FILTER_LEVEL8] = FilterAdd(2, UFOAI_CONTENTS_LEVEL_8, "level8", 0); + // content flag filters + filters[FILTER_LEVEL1] = FilterAdd(7, UFOAI_CONTENTS_LEVEL_1, "level1", 0); + filters[FILTER_LEVEL2] = FilterAdd(7, UFOAI_CONTENTS_LEVEL_2, "level2", 0); + filters[FILTER_LEVEL3] = FilterAdd(7, UFOAI_CONTENTS_LEVEL_3, "level3", 0); + filters[FILTER_LEVEL4] = FilterAdd(7, UFOAI_CONTENTS_LEVEL_4, "level4", 0); + filters[FILTER_LEVEL5] = FilterAdd(7, UFOAI_CONTENTS_LEVEL_5, "level5", 0); + filters[FILTER_LEVEL6] = FilterAdd(7, UFOAI_CONTENTS_LEVEL_6, "level6", 0); + filters[FILTER_LEVEL7] = FilterAdd(7, UFOAI_CONTENTS_LEVEL_7, "level7", 0); + filters[FILTER_LEVEL8] = FilterAdd(7, UFOAI_CONTENTS_LEVEL_8, "level8", 0); Sys_Printf("UFO:AI Filters initialized\n"); } @@ -36,10 +38,10 @@ void PerformFiltering (int type) if (filters[type]->active) { filters[type]->active = false; - Sys_Printf("filter %i deactivated\n", type); + //Sys_Printf("filter %i deactivated (mask %i 0x%x)\n", type, filters[type]->mask, filters[type]->mask); } else { filters[type]->active = true; - Sys_Printf("filter %i activated\n", type); + //Sys_Printf("filter %i activated (mask %i 0x%x)\n", type, filters[type]->mask, filters[type]->mask); } FiltersActivate(); diff --git a/include/qertypes.h b/include/qertypes.h index ad785cfe..a3b8caac 100644 --- a/include/qertypes.h +++ b/include/qertypes.h @@ -753,6 +753,8 @@ struct bfilter_t //c++ style // 2=brush->pPatch->pShader->getFlags() // 3=brush->owner->eclass->name // 4=brush->owner->eclass->nShowFlags + // 5=brush->face->texdef.flags (q2) + // 6=brush->face->texdef.contents (q2) int mask; char *string; bool active; diff --git a/radiant/filters.cpp b/radiant/filters.cpp index 4931d4d3..5e0b069e 100644 --- a/radiant/filters.cpp +++ b/radiant/filters.cpp @@ -34,13 +34,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // type 3 = entity filter (name) // type 2 = QER_* shader flags // type 4 = entity classes +// type 5 = surface flags (q2) +// type 6 = content flags (q2) +// type 7 = content flags - no match (q2) bfilter_t *FilterAdd(bfilter_t *pFilter, int type, int bmask, char *str, int exclude) { bfilter_t *pNew = new bfilter_t; pNew->next = pFilter; pNew->attribute = type; if (type == 1 || type == 3) pNew->string = str; - if (type == 2 || type == 4) pNew->mask = bmask; + if (type == 2 || type == 4 || type == 5 || type == 6 || type == 7) pNew->mask = bmask; if (g_qeglobals.d_savedinfo.exclude & exclude) pNew->active = true; else @@ -164,8 +167,10 @@ bool FilterBrush(brush_t *pb) filters != NULL; filters = filters->next) { + if (!filters->active) + continue; // exclude by attribute 1 brush->face->pShader->getName() - if (filters->active && filters->attribute == 1) + if (filters->attribute == 1) { if (strstr(f->pShader->getName(),filters->string)) { @@ -174,14 +179,38 @@ bool FilterBrush(brush_t *pb) } } // exclude by attribute 2 brush->face->pShader->getFlags() - else if (filters->active - && filters->attribute == 2) + else if (filters->attribute == 2) { if (f->pShader->getFlags() & filters->mask) { filterbrush=true; break; } + // quake2 - 5 == surface flags, 6 == content flags + } + else if (filters->attribute == 5) + { + if (f->texdef.flags && f->texdef.flags & filters->mask) + { + filterbrush=true; + break; + } + } + else if (filters->attribute == 6) + { + if (f->texdef.contents && f->texdef.contents & filters->mask) + { + filterbrush=true; + break; + } + } + else if (filters->attribute == 7) + { + if (f->texdef.contents && !(f->texdef.contents & filters->mask)) + { + filterbrush=true; + break; + } } } if (!filterbrush) -- 2.39.2