1 // Property of Alientrap
4 // stepValue should contain the field name
5 void() Nex_Action_JoinGame_SortBy_Action =
7 if( HostCache_SortField == self._realValue )
8 sethostcachesort( self._realValue, !HostCache_SortDescending );
10 sethostcachesort( self._realValue, true );
11 HostCache_ResortViewSet();
14 void() Nex_Action_JoinGame_SortBy =
16 self._realValue = gethostcacheindexforkey( self.target );
17 self.action = Nex_Action_JoinGame_SortBy_Action;
20 void() Nex_Automation_CreateEntries =
22 local entity lTemplate;
25 lTemplate = Menu_GetItem( "Entry" );
26 for( lCounter = 0 ; lCounter < 64 ; ++lCounter ) {
29 lEntry = Menu_DeriveItem( lTemplate, strcat( "Entry", ftos( lCounter) ), self.parent, true );
30 lEntry.stepValue = lCounter;
32 Menu_LinkItem( self._parent );
35 void() Nex_Action_EntryConnect =
38 cmd( gethostcachestring( SLIST_FIELD_CNAME, self.stepValue ) );
44 void() Nex_Action_RefreshSlist =
46 HostCache_RefreshHostCache();
49 void() Nex_Action_JumpToJoinGame =
53 resethostcachemasks();
54 sethostcachesort( SLIST_FIELD_PING, false );
55 HostCache_RefreshHostCache();
57 lItem = Menu_GetItem( "Normal::Panel" );
58 String_EntitySet( lItem, link, "JoinGame" );
60 Raise_Update( lItem );
61 Menu_UpdateRunFlags();
62 Menu_JumpToWindow( lItem._link, false, false );
66 /* query string format:
68 1) Prefix "mask" Advanced query
69 Format: ( and|or TYPE OP MASK [...] )*
70 TYPE : one of the slist fields
72 <;<=;>=;==;!= normal arithmetic comparison operators (default <=) (= instead of == also supported)
73 $$ 'does contain' (default string op)
77 On every occurence of AND or OR a new mask of the spec type is created.
78 E.g. or name: "WWClan" ping: 200 and protocol == 3 maxplayers > 5
79 will create an or and an and mask
84 compatible (same net protocol version)
85 goodping (ping <= 150)
86 mediumping (ping <= 250)
88 #define GetNextToken if( ++lTokenNum > lTokenCount ) goto finish; else lToken = argv( lTokenNum )
89 void() Nex_Action_ExecuteQuery =
91 local float lAndPos, lOrPos;
92 local float lTokenNum, lTokenCount;
94 resethostcachemasks();
95 lAndPos = SLIST_MASK_AND;
96 lOrPos = SLIST_MASK_OR;
98 lTokenCount = tokenize( self._target.value );
100 for( lTokenNum = 0 ; lTokenNum < lTokenCount ; ++lTokenNum ) {
102 lToken = argv( lTokenNum );
104 if( lToken == "notempty" ) {
105 sethostcachemasknumber( lAndPos, SLIST_FIELD_NUMPLAYERS, 0, SLIST_TEST_NOTEQUAL );
107 } else if( lToken == "compatible" ) {
108 sethostcachemasknumber( lAndPos, SLIST_FIELD_PROTOCOL, NET_CURRENTPROTOCOL, SLIST_TEST_EQUAL );
110 } else if( lToken == "goodping" ) {
111 sethostcachemasknumber( lAndPos, SLIST_FIELD_PING, 150, SLIST_TEST_LESSEQUAL );
113 } else if( lToken == "mediumping" ) {
114 sethostcachemasknumber( lAndPos, SLIST_FIELD_PROTOCOL, 250, SLIST_TEST_LESSEQUAL );
116 } else if( lToken == "mask" ) {
117 // start the query loop
124 else if( lToken == "and" )
127 goto finish; // abort the parsing
128 // now parse all condition fields
131 local float lOperator;
132 local bool lIsStringArg;
135 // now get the field number
136 if( lToken == "cname" ) {
137 lField = SLIST_FIELD_CNAME;
140 else if( lToken == "ping" ) {
141 lField = SLIST_FIELD_PING;
142 lIsStringArg = false;
144 else if( lToken == "game" ) {
145 lField = SLIST_FIELD_GAME;
148 else if( lToken == "mod" ) {
149 lField = SLIST_FIELD_MOD;
152 else if( lToken == "map" ) {
153 lField = SLIST_FIELD_MAP;
156 else if( lToken == "name" ) {
157 lField = SLIST_FIELD_NAME;
160 else if( lToken == "maxplayers" ) {
161 lField = SLIST_FIELD_MAXPLAYERS;
162 lIsStringArg = false;
164 else if( lToken == "numplayers" ) {
165 lField = SLIST_FIELD_NUMPLAYERS;
166 lIsStringArg = false;
168 else if( lToken == "protocol" ) {
169 lField = SLIST_FIELD_PROTOCOL;
170 lIsStringArg = false;
173 { // increment the mask pos and let upper check for or or and
180 // now lets determine the comparison operator
183 lOperator = SLIST_TEST_CONTAINS;
184 else if( lToken == "!$" )
185 lOperator = SLIST_TEST_NOTCONTAIN;
186 else if( lToken == "<" )
187 lOperator = SLIST_TEST_LESS;
188 else if( lToken == "<=" )
189 lOperator = SLIST_TEST_LESSEQUAL;
190 else if( lToken == "==" || lToken == "=" )
191 lOperator = SLIST_TEST_EQUAL;
192 else if( lToken == ">" )
193 lOperator = SLIST_TEST_GREATER;
194 else if( lToken == ">=" )
195 lOperator = SLIST_TEST_GREATEREQUAL;
196 else if( lToken == "!=" )
197 lOperator = SLIST_TEST_NOTEQUAL;
198 else if( lToken == ":" )
200 lOperator = SLIST_TEST_CONTAINS;
202 lOperator = SLIST_TEST_LESSEQUAL;
204 goto finish; // abort the parsing
209 sethostcachemaskstring( lAndPos, lField, lToken, lOperator );
211 sethostcachemaskstring( lOrPos, lField, lToken, lOperator );
214 sethostcachemasknumber( lAndPos, lField, stof( lToken ), lOperator );
216 sethostcachemasknumber( lOrPos, lField, stof( lToken ), lOperator );
219 } else { // lets have a try it with or and string contain
220 sethostcachemaskstring( lOrPos, SLIST_FIELD_MAP, lToken, SLIST_TEST_CONTAINS );
222 sethostcachemaskstring( lOrPos, SLIST_FIELD_NAME, lToken, SLIST_TEST_CONTAINS );
224 //sethostcachemasknumber( lOrPos, SLIST_FIELD_MOD, lToken, SLIST_TEST_CONTAINS );
225 //lOrPos = lOrPos + 1;
229 HostCache_ResortViewSet();
230 #undef GetNextToken()