* fixed ufoai surface plugin (don't give a stack variable pointer to the button callb...
[xonotic/netradiant.git] / contrib / ufoai / ufoai_filters.cpp
1
2 #include "plugin.h"
3 #include "ufoai_filters.h"
4 #include "ifilters.h"
5
6 #define FilterAdd g_FuncTable.m_pfnFilterAdd
7 #define FiltersActivate g_FuncTable.m_pfnFiltersActivate
8
9 static bfilter_t* filters[FILTER_MAX];
10
11 void UFOAIFilterInit (void)
12 {
13         filters[FILTER_ACTORCLIP] = FilterAdd(2, 0, "actorclip", UFOAI_CONTENTS_ACTORCLIP);
14         filters[FILTER_WEAPONCLIP] = FilterAdd(2, 0, "weaponclip", UFOAI_CONTENTS_WEAPONCLIP);
15         filters[FILTER_NODRAW] = FilterAdd(2, 0, "nodraw", UFOAI_SURF_NODRAW);
16         filters[FILTER_STEPON] = FilterAdd(2, 0, "stepon", UFOAI_CONTENTS_STEPON);
17
18         filters[FILTER_LEVEL1] = FilterAdd(2, 0, "level1", UFOAI_CONTENTS_LEVEL_1);
19         filters[FILTER_LEVEL2] = FilterAdd(2, 0, "level2", UFOAI_CONTENTS_LEVEL_2);
20         filters[FILTER_LEVEL3] = FilterAdd(2, 0, "level3", UFOAI_CONTENTS_LEVEL_3);
21         filters[FILTER_LEVEL4] = FilterAdd(2, 0, "level4", UFOAI_CONTENTS_LEVEL_4);
22         filters[FILTER_LEVEL5] = FilterAdd(2, 0, "level5", UFOAI_CONTENTS_LEVEL_5);
23         filters[FILTER_LEVEL6] = FilterAdd(2, 0, "level6", UFOAI_CONTENTS_LEVEL_6);
24         filters[FILTER_LEVEL7] = FilterAdd(2, 0, "level7", UFOAI_CONTENTS_LEVEL_7);
25         filters[FILTER_LEVEL8] = FilterAdd(2, 0, "level8", UFOAI_CONTENTS_LEVEL_8);
26
27         Sys_Printf("UFO:AI Filters initialized\n");
28 }
29
30 void PerformFiltering (int type)
31 {
32         if (!filters[type]) {
33                 Sys_Printf("filters are not yet initialized\n");
34                 return;
35         }
36
37         if (filters[type]->active) {
38                 filters[type]->active = false;
39                 Sys_Printf("filter %i deactivated\n", type);
40         } else {
41                 filters[type]->active = true;
42                 Sys_Printf("filter %i activated\n", type);
43         }
44
45         FiltersActivate();
46 }
47
48 void DoSteponFiltering(void)
49 {
50         PerformFiltering(FILTER_STEPON);
51 }
52
53 void DoWeaponClipFiltering(void)
54 {
55         PerformFiltering(FILTER_WEAPONCLIP);
56 }
57
58 void DoActorClipFiltering(void)
59 {
60         PerformFiltering(FILTER_ACTORCLIP);
61 }
62
63 void DoNoDrawFiltering(void)
64 {
65         PerformFiltering(FILTER_NODRAW);
66 }
67
68 void DoLevel1Filtering(void)
69 {
70         PerformFiltering(FILTER_LEVEL1);
71 }
72
73 void DoLevel2Filtering(void)
74 {
75         PerformFiltering(FILTER_LEVEL2);
76 }
77
78 void DoLevel3Filtering(void)
79 {
80         PerformFiltering(FILTER_LEVEL3);
81 }
82
83 void DoLevel4Filtering(void)
84 {
85         PerformFiltering(FILTER_LEVEL4);
86 }
87
88 void DoLevel5Filtering(void)
89 {
90         PerformFiltering(FILTER_LEVEL5);
91 }
92
93 void DoLevel6Filtering(void)
94 {
95         PerformFiltering(FILTER_LEVEL6);
96 }
97
98 void DoLevel7Filtering(void)
99 {
100         PerformFiltering(FILTER_LEVEL7);
101 }
102
103 void DoLevel8Filtering(void)
104 {
105         PerformFiltering(FILTER_LEVEL8);
106 }