* added three new filter types for quake2 surface and content flags
authormattn <mattn>
Sun, 16 Mar 2008 20:06:02 +0000 (20:06 +0000)
committermattn <mattn>
Sun, 16 Mar 2008 20:06:02 +0000 (20:06 +0000)
* fixed ufoai level filters

git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/branches/ZeroRadiant@222 8a3a26a2-13c4-0310-b231-cf6edde360e5

contrib/ufoai/ufoai_filters.cpp
include/qertypes.h
radiant/filters.cpp

index a7e63db83bfc4b29e5bc64c1575b47d1cdc22dcd..cd68f2461c64faded2705959b46d73ec11fe9de8 100644 (file)
@@ -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();
index ad785cfe30bb35f919db7a9813a5946f2d195209..a3b8caaca83bbad994038689c18c9bd4a124865d 100644 (file)
@@ -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;
index 4931d4d3974e1b2538b59bd0a3187137c214d93e..5e0b069e85bae39ab2c98b722bfb04db78bd11ed 100644 (file)
@@ -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)