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_JumpToPlayerSetup;
48 void() Nex_Action_JumpToJoinGame =
52 if(cvar_string("_cl_name") == "Player")
54 Nex_Action_JumpToPlayerSetup();
58 resethostcachemasks();
59 sethostcachesort( SLIST_FIELD_PING, false );
60 HostCache_RefreshHostCache();
62 lItem = Menu_GetItem( "Normal::Panel" );
63 String_EntitySet( lItem, link, "JoinGame" );
65 Raise_Update( lItem );
66 Menu_UpdateRunFlags();
67 Menu_JumpToWindow( lItem._link, false, false );
71 /* query string format:
73 1) Prefix "mask" Advanced query
74 Format: ( and|or TYPE OP MASK [...] )*
75 TYPE : one of the slist fields
77 <;<=;>=;==;!= normal arithmetic comparison operators (default <=) (= instead of == also supported)
78 $$ 'does contain' (default string op)
82 On every occurence of AND or OR a new mask of the spec type is created.
83 E.g. or name: "WWClan" ping: 200 and protocol == 3 maxplayers > 5
84 will create an or and an and mask
89 compatible (same net protocol version)
90 goodping (ping <= 150)
91 mediumping (ping <= 250)
93 #define GetNextToken if( ++lTokenNum > lTokenCount ) goto finish; else lToken = argv( lTokenNum )
94 void() Nex_Action_ExecuteQuery =
96 local float lAndPos, lOrPos;
97 local float lTokenNum, lTokenCount;
99 resethostcachemasks();
100 lAndPos = SLIST_MASK_AND;
101 lOrPos = SLIST_MASK_OR;
103 lTokenCount = tokenize( self._target.value );
105 for( lTokenNum = 0 ; lTokenNum < lTokenCount ; ++lTokenNum ) {
107 lToken = argv( lTokenNum );
109 if( lToken == "notempty" ) {
110 sethostcachemasknumber( lAndPos, SLIST_FIELD_NUMPLAYERS, 0, SLIST_TEST_NOTEQUAL );
112 } else if( lToken == "compatible" ) {
113 sethostcachemasknumber( lAndPos, SLIST_FIELD_PROTOCOL, NET_CURRENTPROTOCOL, SLIST_TEST_EQUAL );
115 } else if( lToken == "goodping" ) {
116 sethostcachemasknumber( lAndPos, SLIST_FIELD_PING, 150, SLIST_TEST_LESSEQUAL );
118 } else if( lToken == "mediumping" ) {
119 sethostcachemasknumber( lAndPos, SLIST_FIELD_PING, 250, SLIST_TEST_LESSEQUAL );
121 } else if( lToken == "mask" ) {
122 // start the query loop
129 else if( lToken == "and" )
132 goto finish; // abort the parsing
133 // now parse all condition fields
136 local float lOperator;
137 local bool lIsStringArg;
140 // now get the field number
141 if( lToken == "cname" ) {
142 lField = SLIST_FIELD_CNAME;
145 else if( lToken == "ping" ) {
146 lField = SLIST_FIELD_PING;
147 lIsStringArg = false;
149 else if( lToken == "game" ) {
150 lField = SLIST_FIELD_GAME;
153 else if( lToken == "mod" ) {
154 lField = SLIST_FIELD_MOD;
157 else if( lToken == "map" ) {
158 lField = SLIST_FIELD_MAP;
161 else if( lToken == "name" ) {
162 lField = SLIST_FIELD_NAME;
165 else if( lToken == "maxplayers" ) {
166 lField = SLIST_FIELD_MAXPLAYERS;
167 lIsStringArg = false;
169 else if( lToken == "numplayers" ) {
170 lField = SLIST_FIELD_NUMPLAYERS;
171 lIsStringArg = false;
173 else if( lToken == "numbots" ) {
174 lField = SLIST_FIELD_NUMBOTS;
175 lIsStringArg = false;
177 else if( lToken == "numhumans" ) {
178 lField = SLIST_FIELD_NUMHUMANS;
179 lIsStringArg = false;
181 else if( lToken == "protocol" ) {
182 lField = SLIST_FIELD_PROTOCOL;
183 lIsStringArg = false;
186 { // increment the mask pos and let upper check for or or and
193 // now lets determine the comparison operator
196 lOperator = SLIST_TEST_CONTAINS;
197 else if( lToken == "!$" )
198 lOperator = SLIST_TEST_NOTCONTAIN;
199 else if( lToken == "<" )
200 lOperator = SLIST_TEST_LESS;
201 else if( lToken == "<=" )
202 lOperator = SLIST_TEST_LESSEQUAL;
203 else if( lToken == "==" || lToken == "=" )
204 lOperator = SLIST_TEST_EQUAL;
205 else if( lToken == ">" )
206 lOperator = SLIST_TEST_GREATER;
207 else if( lToken == ">=" )
208 lOperator = SLIST_TEST_GREATEREQUAL;
209 else if( lToken == "!=" )
210 lOperator = SLIST_TEST_NOTEQUAL;
211 else if( lToken == ":" )
213 lOperator = SLIST_TEST_CONTAINS;
215 lOperator = SLIST_TEST_LESSEQUAL;
217 goto finish; // abort the parsing
222 sethostcachemaskstring( lAndPos, lField, lToken, lOperator );
224 sethostcachemaskstring( lOrPos, lField, lToken, lOperator );
227 sethostcachemasknumber( lAndPos, lField, stof( lToken ), lOperator );
229 sethostcachemasknumber( lOrPos, lField, stof( lToken ), lOperator );
232 } else { // lets have a try it with or and string contain
233 sethostcachemaskstring( lOrPos, SLIST_FIELD_MAP, lToken, SLIST_TEST_CONTAINS );
235 sethostcachemaskstring( lOrPos, SLIST_FIELD_NAME, lToken, SLIST_TEST_CONTAINS );
237 //sethostcachemasknumber( lOrPos, SLIST_FIELD_MOD, lToken, SLIST_TEST_CONTAINS );
238 //lOrPos = lOrPos + 1;
242 HostCache_ResortViewSet();
243 #undef GetNextToken()