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 =
37 cmd( "connect \"", gethostcachestring( SLIST_FIELD_CNAME, self.stepValue ), "\"\n" );
42 void() Nex_Action_RefreshSlist =
44 HostCache_RefreshHostCache();
47 void() Nex_Action_JumpToJoinGame =
51 resethostcachemasks();
52 sethostcachesort( SLIST_FIELD_PING, false );
53 HostCache_RefreshHostCache();
55 lItem = Menu_GetItem( "Normal::Panel" );
56 String_EntitySet( lItem, link, "JoinGame" );
58 Raise_Update( lItem );
59 Menu_UpdateRunFlags();
60 Menu_JumpToWindow( lItem._link, false, false );
64 /* query string format:
66 1) Prefix "mask" Advanced query
67 Format: ( and|or TYPE OP MASK [...] )*
68 TYPE : one of the slist fields
70 <;<=;>=;==;!= normal arithmetic comparison operators (default <=) (= instead of == also supported)
71 $$ 'does contain' (default string op)
75 On every occurence of AND or OR a new mask of the spec type is created.
76 E.g. or name: "WWClan" ping: 200 and protocol == 3 maxplayers > 5
77 will create an or and an and mask
82 compatible (same net protocol version)
83 goodping (ping <= 150)
84 mediumping (ping <= 250)
86 #define GetNextToken if( ++lTokenNum > lTokenCount ) goto finish; else lToken = argv( lTokenNum )
87 void() Nex_Action_ExecuteQuery =
89 local float lAndPos, lOrPos;
90 local float lTokenNum, lTokenCount;
92 resethostcachemasks();
93 lAndPos = SLIST_MASK_AND;
94 lOrPos = SLIST_MASK_OR;
96 lTokenCount = tokenize( self._target.value );
98 for( lTokenNum = 0 ; lTokenNum < lTokenCount ; ++lTokenNum ) {
100 lToken = argv( lTokenNum );
102 if( lToken == "notempty" ) {
103 sethostcachemasknumber( lAndPos, SLIST_FIELD_NUMPLAYERS, 0, SLIST_TEST_NOTEQUAL );
105 } else if( lToken == "compatible" ) {
106 sethostcachemasknumber( lAndPos, SLIST_FIELD_PROTOCOL, NET_CURRENTPROTOCOL, SLIST_TEST_EQUAL );
108 } else if( lToken == "goodping" ) {
109 sethostcachemasknumber( lAndPos, SLIST_FIELD_PING, 150, SLIST_TEST_LESSEQUAL );
111 } else if( lToken == "mediumping" ) {
112 sethostcachemasknumber( lAndPos, SLIST_FIELD_PING, 250, SLIST_TEST_LESSEQUAL );
114 } else if( lToken == "mask" ) {
115 // start the query loop
122 else if( lToken == "and" )
125 goto finish; // abort the parsing
126 // now parse all condition fields
129 local float lOperator;
130 local bool lIsStringArg;
133 // now get the field number
134 if( lToken == "cname" ) {
135 lField = SLIST_FIELD_CNAME;
138 else if( lToken == "ping" ) {
139 lField = SLIST_FIELD_PING;
140 lIsStringArg = false;
142 else if( lToken == "game" ) {
143 lField = SLIST_FIELD_GAME;
146 else if( lToken == "mod" ) {
147 lField = SLIST_FIELD_MOD;
150 else if( lToken == "map" ) {
151 lField = SLIST_FIELD_MAP;
154 else if( lToken == "name" ) {
155 lField = SLIST_FIELD_NAME;
158 else if( lToken == "maxplayers" ) {
159 lField = SLIST_FIELD_MAXPLAYERS;
160 lIsStringArg = false;
162 else if( lToken == "numplayers" ) {
163 lField = SLIST_FIELD_NUMPLAYERS;
164 lIsStringArg = false;
166 else if( lToken == "protocol" ) {
167 lField = SLIST_FIELD_PROTOCOL;
168 lIsStringArg = false;
171 { // increment the mask pos and let upper check for or or and
178 // now lets determine the comparison operator
181 lOperator = SLIST_TEST_CONTAINS;
182 else if( lToken == "!$" )
183 lOperator = SLIST_TEST_NOTCONTAIN;
184 else if( lToken == "<" )
185 lOperator = SLIST_TEST_LESS;
186 else if( lToken == "<=" )
187 lOperator = SLIST_TEST_LESSEQUAL;
188 else if( lToken == "==" || lToken == "=" )
189 lOperator = SLIST_TEST_EQUAL;
190 else if( lToken == ">" )
191 lOperator = SLIST_TEST_GREATER;
192 else if( lToken == ">=" )
193 lOperator = SLIST_TEST_GREATEREQUAL;
194 else if( lToken == "!=" )
195 lOperator = SLIST_TEST_NOTEQUAL;
196 else if( lToken == ":" )
198 lOperator = SLIST_TEST_CONTAINS;
200 lOperator = SLIST_TEST_LESSEQUAL;
202 goto finish; // abort the parsing
207 sethostcachemaskstring( lAndPos, lField, lToken, lOperator );
209 sethostcachemaskstring( lOrPos, lField, lToken, lOperator );
212 sethostcachemasknumber( lAndPos, lField, stof( lToken ), lOperator );
214 sethostcachemasknumber( lOrPos, lField, stof( lToken ), lOperator );
217 } else { // lets have a try it with or and string contain
218 sethostcachemaskstring( lOrPos, SLIST_FIELD_MAP, lToken, SLIST_TEST_CONTAINS );
220 sethostcachemaskstring( lOrPos, SLIST_FIELD_NAME, lToken, SLIST_TEST_CONTAINS );
222 //sethostcachemasknumber( lOrPos, SLIST_FIELD_MOD, lToken, SLIST_TEST_CONTAINS );
223 //lOrPos = lOrPos + 1;
227 HostCache_ResortViewSet();
228 #undef GetNextToken()