4 CLASS(XonoticServerList, XonoticListBox)
5 METHOD(XonoticServerList, configureXonoticServerList, void(entity));
6 ATTRIB(XonoticServerList, rowsPerItem, float, 1)
7 METHOD(XonoticServerList, draw, void(entity));
8 METHOD(XonoticServerList, drawListBoxItem, void(entity, int, vector, bool, bool));
9 METHOD(XonoticServerList, doubleClickListBoxItem, void(entity, float, vector));
10 METHOD(XonoticServerList, resizeNotify, void(entity, vector, vector, vector, vector));
11 METHOD(XonoticServerList, keyDown, float(entity, float, float, float));
12 METHOD(XonoticServerList, toggleFavorite, void(entity, string));
14 ATTRIB(XonoticServerList, iconsSizeFactor, float, 0.85)
15 METHOD(XonoticServerList, mouseMove, float(entity, vector));
16 ATTRIB(XonoticServerList, mouseOverIcons, bool, false)
17 METHOD(XonoticServerList, focusedItemChangeNotify, void(entity));
19 ATTRIB(XonoticServerList, realFontSize, vector, '0 0 0')
20 ATTRIB(XonoticServerList, realUpperMargin, float, 0)
21 ATTRIB(XonoticServerList, columnIconsOrigin, float, 0)
22 ATTRIB(XonoticServerList, columnIconsSize, float, 0)
23 ATTRIB(XonoticServerList, columnPingOrigin, float, 0)
24 ATTRIB(XonoticServerList, columnPingSize, float, 0)
25 ATTRIB(XonoticServerList, columnNameOrigin, float, 0)
26 ATTRIB(XonoticServerList, columnNameSize, float, 0)
27 ATTRIB(XonoticServerList, columnMapOrigin, float, 0)
28 ATTRIB(XonoticServerList, columnMapSize, float, 0)
29 ATTRIB(XonoticServerList, columnTypeOrigin, float, 0)
30 ATTRIB(XonoticServerList, columnTypeSize, float, 0)
31 ATTRIB(XonoticServerList, columnPlayersOrigin, float, 0)
32 ATTRIB(XonoticServerList, columnPlayersSize, float, 0)
33 ATTRIB(XonoticServerList, lockedSelectedItem, bool, true) // initially keep selected the first item of the list, avoiding an unwanted scrolling
35 ATTRIB(XonoticServerList, selectedServer, string, string_null) // to restore selected server when needed
36 METHOD(XonoticServerList, setSelected, void(entity, float));
37 METHOD(XonoticServerList, setSortOrder, void(entity, float, float));
38 ATTRIB(XonoticServerList, filterShowEmpty, float, 1)
39 ATTRIB(XonoticServerList, filterShowFull, float, 1)
40 ATTRIB(XonoticServerList, filterString, string, string_null)
41 ATTRIB(XonoticServerList, controlledTextbox, entity, NULL)
42 ATTRIB(XonoticServerList, ipAddressBox, entity, NULL)
43 ATTRIB(XonoticServerList, favoriteButton, entity, NULL)
44 ATTRIB(XonoticServerList, nextRefreshTime, float, 0)
45 METHOD(XonoticServerList, refreshServerList, void(entity, float)); // refresh mode: REFRESHSERVERLIST_*
46 ATTRIB(XonoticServerList, needsRefresh, float, 1)
47 METHOD(XonoticServerList, focusEnter, void(entity));
48 METHOD(XonoticServerList, positionSortButton, void(entity, entity, float, float, string, void(entity, entity)));
49 ATTRIB(XonoticServerList, sortButton1, entity, NULL)
50 ATTRIB(XonoticServerList, sortButton2, entity, NULL)
51 ATTRIB(XonoticServerList, sortButton3, entity, NULL)
52 ATTRIB(XonoticServerList, sortButton4, entity, NULL)
53 ATTRIB(XonoticServerList, sortButton5, entity, NULL)
54 ATTRIB(XonoticServerList, connectButton, entity, NULL)
55 ATTRIB(XonoticServerList, infoButton, entity, NULL)
56 ATTRIB(XonoticServerList, currentSortOrder, float, 0)
57 ATTRIB(XonoticServerList, currentSortField, float, -1)
59 ATTRIB(XonoticServerList, ipAddressBoxFocused, float, -1)
61 ATTRIB(XonoticServerList, seenIPv4, float, 0)
62 ATTRIB(XonoticServerList, seenIPv6, float, 0)
63 ATTRIB(XonoticServerList, categoriesHeight, float, 1.25)
65 METHOD(XonoticServerList, getTotalHeight, float(entity));
66 METHOD(XonoticServerList, getItemAtPos, float(entity, float));
67 METHOD(XonoticServerList, getItemStart, float(entity, float));
68 METHOD(XonoticServerList, getItemHeight, float(entity, float));
69 ENDCLASS(XonoticServerList)
70 entity makeXonoticServerList();
72 #ifndef IMPLEMENTATION
73 float autocvar_menu_slist_categories;
74 float autocvar_menu_slist_categories_onlyifmultiple;
75 float autocvar_menu_slist_purethreshold;
76 float autocvar_menu_slist_modimpurity;
77 float autocvar_menu_slist_recommendations;
78 float autocvar_menu_slist_recommendations_maxping;
79 float autocvar_menu_slist_recommendations_minfreeslots;
80 float autocvar_menu_slist_recommendations_minhumans;
81 float autocvar_menu_slist_recommendations_purethreshold;
83 // server cache fields
84 #define SLIST_FIELDS \
85 SLIST_FIELD(CNAME, "cname") \
86 SLIST_FIELD(PING, "ping") \
87 SLIST_FIELD(GAME, "game") \
88 SLIST_FIELD(MOD, "mod") \
89 SLIST_FIELD(MAP, "map") \
90 SLIST_FIELD(NAME, "name") \
91 SLIST_FIELD(MAXPLAYERS, "maxplayers") \
92 SLIST_FIELD(NUMPLAYERS, "numplayers") \
93 SLIST_FIELD(NUMHUMANS, "numhumans") \
94 SLIST_FIELD(NUMBOTS, "numbots") \
95 SLIST_FIELD(PROTOCOL, "protocol") \
96 SLIST_FIELD(FREESLOTS, "freeslots") \
97 SLIST_FIELD(PLAYERS, "players") \
98 SLIST_FIELD(QCSTATUS, "qcstatus") \
99 SLIST_FIELD(CATEGORY, "category") \
100 SLIST_FIELD(ISFAVORITE, "isfavorite")
102 #define SLIST_FIELD(suffix,name) float SLIST_FIELD_##suffix;
106 const float REFRESHSERVERLIST_RESORT = 0; // sort the server list again to update for changes to e.g. favorite status, categories
107 const float REFRESHSERVERLIST_REFILTER = 1; // ..., also update filter and sort criteria
108 const float REFRESHSERVERLIST_ASK = 2; // ..., also suggest querying servers now
109 const float REFRESHSERVERLIST_RESET = 3; // ..., also clear the list first
111 // function declarations
112 float IsServerInList(string list, string srv);
113 #define IsFavorite(srv) IsServerInList(cvar_string("net_slist_favorites"), srv)
114 #define IsPromoted(srv) IsServerInList(_Nex_ExtResponseSystem_PromotedServers, srv)
115 #define IsRecommended(srv) IsServerInList(_Nex_ExtResponseSystem_RecommendedServers, srv)
117 entity RetrieveCategoryEnt(float catnum);
119 float CheckCategoryOverride(float cat);
120 float CheckCategoryForEntry(float entry);
121 float m_gethostcachecategory(float entry) { return CheckCategoryOverride(CheckCategoryForEntry(entry)); }
123 void RegisterSLCategories();
125 void ServerList_Connect_Click(entity btn, entity me);
126 void ServerList_Categories_Click(entity box, entity me);
127 void ServerList_ShowEmpty_Click(entity box, entity me);
128 void ServerList_ShowFull_Click(entity box, entity me);
129 void ServerList_Filter_Change(entity box, entity me);
130 void ServerList_Favorite_Click(entity btn, entity me);
131 void ServerList_Info_Click(entity btn, entity me);
132 void ServerList_Update_favoriteButton(entity btn, entity me);
134 // fields for category entities
135 const int MAX_CATEGORIES = 9;
136 const int CATEGORY_FIRST = 1;
137 entity categories[MAX_CATEGORIES];
138 int category_ent_count;
141 .string cat_enoverride_string;
142 .string cat_dioverride_string;
143 .float cat_enoverride;
144 .float cat_dioverride;
146 // fields for drawing categories
147 int category_name[MAX_CATEGORIES];
148 int category_item[MAX_CATEGORIES];
149 int category_draw_count;
151 #define SLIST_CATEGORIES \
152 SLIST_CATEGORY(CAT_FAVORITED, "", "", CTX(_("SLCAT^Favorites"))) \
153 SLIST_CATEGORY(CAT_RECOMMENDED, "", "", CTX(_("SLCAT^Recommended"))) \
154 SLIST_CATEGORY(CAT_NORMAL, "", "CAT_SERVERS", CTX(_("SLCAT^Normal Servers"))) \
155 SLIST_CATEGORY(CAT_SERVERS, "CAT_NORMAL", "CAT_SERVERS", CTX(_("SLCAT^Servers"))) \
156 SLIST_CATEGORY(CAT_XPM, "CAT_NORMAL", "CAT_SERVERS", CTX(_("SLCAT^Competitive Mode"))) \
157 SLIST_CATEGORY(CAT_MODIFIED, "", "CAT_SERVERS", CTX(_("SLCAT^Modified Servers"))) \
158 SLIST_CATEGORY(CAT_OVERKILL, "", "CAT_SERVERS", CTX(_("SLCAT^Overkill Mode"))) \
159 SLIST_CATEGORY(CAT_INSTAGIB, "", "CAT_SERVERS", CTX(_("SLCAT^InstaGib Mode"))) \
160 SLIST_CATEGORY(CAT_DEFRAG, "", "CAT_SERVERS", CTX(_("SLCAT^Defrag Mode")))
162 #define SLIST_CATEGORY_AUTOCVAR(name) autocvar_menu_slist_categories_##name##_override
163 #define SLIST_CATEGORY(name,enoverride,dioverride,str) \
165 string SLIST_CATEGORY_AUTOCVAR(name) = enoverride;
167 #undef SLIST_CATEGORY
171 #ifdef IMPLEMENTATION
173 void RegisterSLCategories()
176 #define SLIST_CATEGORY(name,enoverride,dioverride,str) \
177 SET_FIELD_COUNT(name, CATEGORY_FIRST, category_ent_count) \
178 CHECK_MAX_COUNT(name, MAX_CATEGORIES, category_ent_count, "SLIST_CATEGORY") \
179 cat = categories[name - 1] = new(slist_category); \
180 cat.cat_name = #name; \
181 cat.cat_enoverride_string = strzone(SLIST_CATEGORY_AUTOCVAR(name)); \
182 cat.cat_dioverride_string = strzone(dioverride); \
183 cat.cat_string = strzone(str);
185 #undef SLIST_CATEGORY
190 #define PROCESS_OVERRIDE(override_string,override_field) \
191 for(i = 0; i < category_ent_count; ++i) \
193 s = categories[i].override_string; \
194 if((s != "") && (s != categories[i].cat_name)) \
197 for(x = 0; x < category_ent_count; ++x) \
198 { if(categories[x].cat_name == s) { \
204 strunzone(categories[i].override_string); \
205 categories[i].override_string = string_null; \
206 categories[i].override_field = catnum; \
212 "RegisterSLCategories(): Improper override '%s' for category '%s'!\n", \
214 categories[i].cat_name \
218 strunzone(categories[i].override_string); \
219 categories[i].override_string = string_null; \
220 categories[i].override_field = 0; \
222 PROCESS_OVERRIDE(cat_enoverride_string, cat_enoverride)
223 PROCESS_OVERRIDE(cat_dioverride_string, cat_dioverride)
224 #undef PROCESS_OVERRIDE
227 // Supporting Functions
228 entity RetrieveCategoryEnt(int catnum)
230 if((catnum > 0) && (catnum <= category_ent_count))
232 return categories[catnum - 1];
236 error(sprintf("RetrieveCategoryEnt(%d): Improper category number!\n", catnum));
241 bool IsServerInList(string list, string srv)
247 srv = netaddress_resolve(srv, 26000);
250 p = crypto_getidfp(srv);
251 n = tokenize_console(list);
252 for(i = 0; i < n; ++i)
254 if(substring(argv(i), 0, 1) != "[" && strlen(argv(i)) == 44 && strstrofs(argv(i), ".", 0) < 0)
262 if(srv == netaddress_resolve(argv(i), 26000))
269 int CheckCategoryOverride(int cat)
271 entity catent = RetrieveCategoryEnt(cat);
274 int override = (autocvar_menu_slist_categories ? catent.cat_enoverride : catent.cat_dioverride);
275 if(override) { return override; }
280 error(sprintf("CheckCategoryOverride(%d): Improper category number!\n", cat));
285 int CheckCategoryForEntry(int entry)
287 string s, k, v, modtype = "";
288 int j, m, impure = 0, freeslots = 0, sflags = 0;
289 s = gethostcachestring(SLIST_FIELD_QCSTATUS, entry);
290 m = tokenizebyseparator(s, ":");
292 for(j = 2; j < m; ++j)
294 if(argv(j) == "") { break; }
295 k = substring(argv(j), 0, 1);
296 v = substring(argv(j), 1, -1);
299 case "P": { impure = stof(v); break; }
300 case "S": { freeslots = stof(v); break; }
301 case "F": { sflags = stof(v); break; }
302 case "M": { modtype = strtolower(v); break; }
306 if(modtype != "xonotic") { impure += autocvar_menu_slist_modimpurity; }
308 // check if this server is favorited
309 if(gethostcachenumber(SLIST_FIELD_ISFAVORITE, entry)) { return CAT_FAVORITED; }
311 // now check if it's recommended
312 if(autocvar_menu_slist_recommendations)
314 string cname = gethostcachestring(SLIST_FIELD_CNAME, entry);
316 if(IsPromoted(cname)) { return CAT_RECOMMENDED; }
319 float recommended = 0;
320 if(autocvar_menu_slist_recommendations & 1)
322 if(IsRecommended(cname)) { ++recommended; }
323 else { --recommended; }
325 if(autocvar_menu_slist_recommendations & 2)
328 ///// check for minimum free slots
329 (freeslots >= autocvar_menu_slist_recommendations_minfreeslots)
331 && // check for purity requirement
333 (autocvar_menu_slist_recommendations_purethreshold < 0)
335 (impure <= autocvar_menu_slist_recommendations_purethreshold)
338 && // check for minimum amount of humans
340 gethostcachenumber(SLIST_FIELD_NUMHUMANS, entry)
342 autocvar_menu_slist_recommendations_minhumans
345 && // check for maximum latency
347 gethostcachenumber(SLIST_FIELD_PING, entry)
349 autocvar_menu_slist_recommendations_maxping
356 if(recommended > 0) { return CAT_RECOMMENDED; }
360 // if not favorited or recommended, check modname
361 if(modtype != "xonotic")
365 // old servers which don't report their mod name are considered modified now
366 case "": { return CAT_MODIFIED; }
368 case "xpm": { return CAT_XPM; }
370 case "instagib": { return CAT_INSTAGIB; }
371 case "overkill": { return CAT_OVERKILL; }
372 //case "nix": { return CAT_NIX; }
373 //case "newtoys": { return CAT_NEWTOYS; }
375 // "cts" is allowed as compat, xdf is replacement
377 case "xdf": { return CAT_DEFRAG; }
379 default: { LOG_TRACEF("Found strange mod type: %s\n", modtype); return CAT_MODIFIED; }
383 // must be normal or impure server
384 return ((impure > autocvar_menu_slist_purethreshold) ? CAT_MODIFIED : CAT_NORMAL);
387 void XonoticServerList_toggleFavorite(entity me, string srv)
389 string s, s0, s1, s2, srv_resolved, p;
392 srv_resolved = netaddress_resolve(srv, 26000);
393 p = crypto_getidfp(srv_resolved);
394 s = cvar_string("net_slist_favorites");
395 n = tokenize_console(s);
396 for(i = 0; i < n; ++i)
398 if(substring(argv(i), 0, 1) != "[" && strlen(argv(i)) == 44 && strstrofs(argv(i), ".", 0) < 0)
406 if(srv_resolved != netaddress_resolve(argv(i), 26000))
411 s0 = substring(s, 0, argv_end_index(i - 1));
413 s2 = substring(s, argv_start_index(i + 1), -1);
414 if(s0 != "" && s2 != "")
416 cvar_set("net_slist_favorites", strcat(s0, s1, s2));
417 s = cvar_string("net_slist_favorites");
418 n = tokenize_console(s);
429 cvar_set("net_slist_favorites", strcat(s, s1, p));
431 cvar_set("net_slist_favorites", strcat(s, s1, srv));
434 me.refreshServerList(me, REFRESHSERVERLIST_RESORT);
437 void ServerList_Update_favoriteButton(entity btn, entity me)
439 entity e = me.favoriteButton;
440 if(IsFavorite(me.ipAddressBox.text))
442 e.setText(e, _("Remove"));
447 e.setText(e, _("Favorite"));
448 setZonedTooltip(e, _("Bookmark the currently highlighted server so that it's faster to find in the future"), string_null);
452 entity makeXonoticServerList()
455 me = NEW(XonoticServerList);
456 me.configureXonoticServerList(me);
459 void XonoticServerList_configureXonoticServerList(entity me)
461 me.configureXonoticListBox(me);
464 #define SLIST_FIELD(suffix,name) SLIST_FIELD_##suffix = gethostcacheindexforkey(name);
471 void XonoticServerList_setSelected(entity me, int i)
473 me.lockedSelectedItem = false;
474 //int save = me.selectedItem;
475 SUPER(XonoticServerList).setSelected(me, i);
477 if(me.selectedItem == save)
482 if(gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT) != me.nItems)
483 return; // sorry, it would be wrong
485 if(me.selectedServer)
486 strunzone(me.selectedServer);
487 me.selectedServer = strzone(gethostcachestring(SLIST_FIELD_CNAME, me.selectedItem));
489 me.ipAddressBox.setText(me.ipAddressBox, me.selectedServer);
490 me.ipAddressBox.cursorPos = strlen(me.selectedServer);
491 me.ipAddressBoxFocused = -1;
493 void XonoticServerList_refreshServerList(entity me, int mode)
495 //print("refresh of type ", ftos(mode), "\n");
497 if(mode >= REFRESHSERVERLIST_REFILTER)
502 string s, typestr, modstr;
506 m = strstrofs(s, ":", 0);
509 typestr = substring(s, 0, m);
510 s = substring(s, m + 1, strlen(s) - m - 1);
511 while(substring(s, 0, 1) == " ")
512 s = substring(s, 1, strlen(s) - 1);
517 modstr = cvar_string("menu_slist_modfilter");
519 m = SLIST_MASK_AND - 1;
520 resethostcachemasks();
522 // ping: reject negative ping (no idea why this happens in the first place, engine bug)
523 sethostcachemasknumber(++m, SLIST_FIELD_PING, 0, SLIST_TEST_GREATEREQUAL);
526 if(!me.filterShowFull)
528 sethostcachemasknumber(++m, SLIST_FIELD_FREESLOTS, 1, SLIST_TEST_GREATEREQUAL); // legacy
529 sethostcachemaskstring(++m, SLIST_FIELD_QCSTATUS, ":S0:", SLIST_TEST_NOTCONTAIN); // g_maxplayers support
533 if(!me.filterShowEmpty)
534 sethostcachemasknumber(++m, SLIST_FIELD_NUMHUMANS, 1, SLIST_TEST_GREATEREQUAL);
536 // gametype filtering
538 sethostcachemaskstring(++m, SLIST_FIELD_QCSTATUS, strcat(typestr, ":"), SLIST_TEST_STARTSWITH);
543 if(substring(modstr, 0, 1) == "!")
544 sethostcachemaskstring(++m, SLIST_FIELD_MOD, resolvemod(substring(modstr, 1, strlen(modstr) - 1)), SLIST_TEST_NOTEQUAL);
546 sethostcachemaskstring(++m, SLIST_FIELD_MOD, resolvemod(modstr), SLIST_TEST_EQUAL);
550 n = tokenizebyseparator(_Nex_ExtResponseSystem_BannedServers, " ");
551 for(i = 0; i < n; ++i)
553 sethostcachemaskstring(++m, SLIST_FIELD_CNAME, argv(i), SLIST_TEST_NOTSTARTSWITH);
555 m = SLIST_MASK_OR - 1;
558 sethostcachemaskstring(++m, SLIST_FIELD_NAME, s, SLIST_TEST_CONTAINS);
559 sethostcachemaskstring(++m, SLIST_FIELD_MAP, s, SLIST_TEST_CONTAINS);
560 sethostcachemaskstring(++m, SLIST_FIELD_PLAYERS, s, SLIST_TEST_CONTAINS);
561 sethostcachemaskstring(++m, SLIST_FIELD_QCSTATUS, strcat(s, ":"), SLIST_TEST_STARTSWITH);
565 //listflags |= SLSF_FAVORITES;
566 listflags |= SLSF_CATEGORIES;
567 if(me.currentSortOrder < 0) { listflags |= SLSF_DESCENDING; }
568 sethostcachesort(me.currentSortField, listflags);
572 if(mode >= REFRESHSERVERLIST_ASK)
573 refreshhostcache(mode >= REFRESHSERVERLIST_RESET);
575 void XonoticServerList_focusEnter(entity me)
577 SUPER(XonoticServerList).focusEnter(me);
578 if(time < me.nextRefreshTime)
580 //print("sorry, no refresh yet\n");
583 me.nextRefreshTime = time + 10;
584 me.refreshServerList(me, REFRESHSERVERLIST_ASK);
587 void XonoticServerList_draw(entity me)
590 bool found = false, owned;
592 if(_Nex_ExtResponseSystem_BannedServersNeedsRefresh)
596 _Nex_ExtResponseSystem_BannedServersNeedsRefresh = 0;
599 if(_Nex_ExtResponseSystem_PromotedServersNeedsRefresh)
603 _Nex_ExtResponseSystem_PromotedServersNeedsRefresh = 0;
606 if(_Nex_ExtResponseSystem_RecommendedServersNeedsRefresh)
610 _Nex_ExtResponseSystem_RecommendedServersNeedsRefresh = 0;
613 if(me.currentSortField == -1)
615 me.setSortOrder(me, SLIST_FIELD_PING, +1);
616 me.refreshServerList(me, REFRESHSERVERLIST_RESET);
618 else if(me.needsRefresh == 1)
620 me.needsRefresh = 2; // delay by one frame to make sure "slist" has been executed
622 else if(me.needsRefresh == 2)
625 me.refreshServerList(me, REFRESHSERVERLIST_REFILTER);
627 else if(me.needsRefresh == 3)
630 me.refreshServerList(me, REFRESHSERVERLIST_RESORT);
633 owned = ((me.selectedServer == me.ipAddressBox.text) && (me.ipAddressBox.text != ""));
635 for(i = 0; i < category_draw_count; ++i) { category_name[i] = -1; category_item[i] = -1; }
636 category_draw_count = 0;
638 if(autocvar_menu_slist_categories >= 0) // if less than 0, don't even draw a category heading for favorites
640 float itemcount = gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT);
641 me.nItems = itemcount;
643 //float visible = floor(me.scrollPos / me.itemHeight);
644 // ^ unfortunately no such optimization can be made-- we must process through the
645 // entire list, otherwise there is no way to know which item is first in its category.
647 // binary search method suggested by div
650 for(x = 1; x <= category_ent_count; ++x) {
652 float last = (itemcount - 1);
657 float catf = gethostcachenumber(SLIST_FIELD_CATEGORY, first);
658 float catl = gethostcachenumber(SLIST_FIELD_CATEGORY, last);
660 // The first one is already > x.
661 // Therefore, category x does not exist.
662 // Higher numbered categories do exist though.
663 } else if (catl < x) {
664 // The last one is < x.
665 // Thus this category - and any following -
668 } else if (catf == x) {
669 // Starts at first. This breaks the loop
670 // invariant in the binary search and thus has
671 // to be handled separately.
672 if(gethostcachenumber(SLIST_FIELD_CATEGORY, first) != x)
673 error("Category mismatch I");
675 if(gethostcachenumber(SLIST_FIELD_CATEGORY, first - 1) == x)
676 error("Category mismatch II");
677 category_name[category_draw_count] = x;
678 category_item[category_draw_count] = first;
679 ++category_draw_count;
682 // At this point, catf <= x < catl, thus
683 // catf < catl, thus first < last.
686 // catf == gethostcachenumber(SLIST_FIELD_CATEGORY(first)
687 // catl == gethostcachenumber(SLIST_FIELD_CATEGORY(last)
690 while (last - first > 1) {
691 float middle = floor((first + last) / 2);
692 // By loop condition, middle != first && middle != last.
693 float cat = gethostcachenumber(SLIST_FIELD_CATEGORY, middle);
703 if(gethostcachenumber(SLIST_FIELD_CATEGORY, last) != x)
704 error("Category mismatch III");
706 if(gethostcachenumber(SLIST_FIELD_CATEGORY, last - 1) == x)
707 error("Category mismatch IV");
708 category_name[category_draw_count] = x;
709 category_item[category_draw_count] = last;
710 ++category_draw_count;
711 begin = last + 1; // already scanned through these, skip 'em
714 begin = last; // already scanned through these, skip 'em
717 if(autocvar_menu_slist_categories_onlyifmultiple && (category_draw_count == 1))
719 category_name[0] = -1;
720 category_item[0] = -1;
721 category_draw_count = 0;
722 me.nItems = itemcount;
725 else { me.nItems = gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT); }
727 me.connectButton.disabled = ((me.nItems == 0) && (me.ipAddressBox.text == ""));
728 me.infoButton.disabled = ((me.nItems == 0) || !owned);
729 me.favoriteButton.disabled = ((me.nItems == 0) && (me.ipAddressBox.text == ""));
731 if(me.lockedSelectedItem)
735 if(gethostcachestring(SLIST_FIELD_CNAME, me.selectedItem) != me.selectedServer)
737 if(me.selectedServer)
738 strunzone(me.selectedServer);
739 me.selectedServer = strzone(gethostcachestring(SLIST_FIELD_CNAME, me.selectedItem));
744 else if(me.selectedServer)
746 for(i = 0; i < me.nItems; ++i)
748 if(gethostcachestring(SLIST_FIELD_CNAME, i) == me.selectedServer)
750 // don't follow the selected item with SUPER(XonoticServerList).setSelected(me, i);
761 // selected server disappeared, select the last server (scrolling to it)
762 if(me.selectedItem >= me.nItems)
763 SUPER(XonoticServerList).setSelected(me, me.nItems - 1);
764 if(me.selectedServer)
765 strunzone(me.selectedServer);
766 me.selectedServer = strzone(gethostcachestring(SLIST_FIELD_CNAME, me.selectedItem));
772 if(me.selectedServer != me.ipAddressBox.text)
774 me.ipAddressBox.setText(me.ipAddressBox, me.selectedServer);
775 me.ipAddressBox.cursorPos = strlen(me.selectedServer);
776 me.ipAddressBoxFocused = -1;
780 if(me.ipAddressBoxFocused != me.ipAddressBox.focused)
782 if(me.ipAddressBox.focused || me.ipAddressBoxFocused < 0)
783 ServerList_Update_favoriteButton(NULL, me);
784 me.ipAddressBoxFocused = me.ipAddressBox.focused;
787 SUPER(XonoticServerList).draw(me);
789 void ServerList_PingSort_Click(entity btn, entity me)
791 me.setSortOrder(me, SLIST_FIELD_PING, +1);
793 void ServerList_NameSort_Click(entity btn, entity me)
795 me.setSortOrder(me, SLIST_FIELD_NAME, -1); // why?
797 void ServerList_MapSort_Click(entity btn, entity me)
799 me.setSortOrder(me, SLIST_FIELD_MAP, -1); // why?
801 void ServerList_PlayerSort_Click(entity btn, entity me)
803 me.setSortOrder(me, SLIST_FIELD_NUMHUMANS, -1);
805 void ServerList_TypeSort_Click(entity btn, entity me)
810 m = strstrofs(s, ":", 0);
813 s = substring(s, 0, m);
814 while(substring(s, m+1, 1) == " ") // skip spaces
820 for(i = 1; ; i *= 2) // 20 modes ought to be enough for anyone
822 t = MapInfo_Type_ToString(i);
824 if(t == "") // it repeats (default case)
827 // choose the first one
828 s = MapInfo_Type_ToString(1);
833 // the type was found
834 // choose the next one
835 s = MapInfo_Type_ToString(i * 2);
837 s = MapInfo_Type_ToString(1);
844 s = strcat(s, substring(me.filterString, m+1, strlen(me.filterString) - m - 1));
846 me.controlledTextbox.setText(me.controlledTextbox, s);
847 me.controlledTextbox.keyDown(me.controlledTextbox, K_END, 0, 0);
848 me.controlledTextbox.keyUp(me.controlledTextbox, K_END, 0, 0);
849 //ServerList_Filter_Change(me.controlledTextbox, me);
851 void ServerList_Filter_Change(entity box, entity me)
854 strunzone(me.filterString);
856 me.filterString = strzone(box.text);
858 me.filterString = string_null;
859 me.refreshServerList(me, REFRESHSERVERLIST_REFILTER);
861 me.ipAddressBox.setText(me.ipAddressBox, "");
862 me.ipAddressBox.cursorPos = 0;
863 me.ipAddressBoxFocused = -1;
865 void ServerList_Categories_Click(entity box, entity me)
867 box.setChecked(box, autocvar_menu_slist_categories = !autocvar_menu_slist_categories);
868 me.refreshServerList(me, REFRESHSERVERLIST_RESORT);
870 me.ipAddressBox.setText(me.ipAddressBox, "");
871 me.ipAddressBox.cursorPos = 0;
872 me.ipAddressBoxFocused = -1;
874 void ServerList_ShowEmpty_Click(entity box, entity me)
876 box.setChecked(box, me.filterShowEmpty = !me.filterShowEmpty);
877 me.refreshServerList(me, REFRESHSERVERLIST_REFILTER);
879 me.ipAddressBox.setText(me.ipAddressBox, "");
880 me.ipAddressBox.cursorPos = 0;
881 me.ipAddressBoxFocused = -1;
883 void ServerList_ShowFull_Click(entity box, entity me)
885 box.setChecked(box, me.filterShowFull = !me.filterShowFull);
886 me.refreshServerList(me, REFRESHSERVERLIST_REFILTER);
888 me.ipAddressBox.setText(me.ipAddressBox, "");
889 me.ipAddressBox.cursorPos = 0;
890 me.ipAddressBoxFocused = -1;
892 void XonoticServerList_setSortOrder(entity me, int fld, int direction)
894 if(me.currentSortField == fld)
895 direction = -me.currentSortOrder;
896 me.currentSortOrder = direction;
897 me.currentSortField = fld;
898 me.sortButton1.forcePressed = (fld == SLIST_FIELD_PING);
899 me.sortButton2.forcePressed = (fld == SLIST_FIELD_NAME);
900 me.sortButton3.forcePressed = (fld == SLIST_FIELD_MAP);
901 me.sortButton4.forcePressed = 0;
902 me.sortButton5.forcePressed = (fld == SLIST_FIELD_NUMHUMANS);
904 if(me.selectedServer)
905 strunzone(me.selectedServer);
906 me.selectedServer = string_null;
907 me.refreshServerList(me, REFRESHSERVERLIST_REFILTER);
909 void XonoticServerList_positionSortButton(entity me, entity btn, float theOrigin, float theSize, string theTitle, void(entity, entity) theFunc)
911 vector originInLBSpace, sizeInLBSpace;
912 originInLBSpace = eY * (-me.itemHeight);
913 sizeInLBSpace = eY * me.itemHeight + eX * (1 - me.controlWidth);
915 vector originInDialogSpace, sizeInDialogSpace;
916 originInDialogSpace = boxToGlobal(originInLBSpace, me.Container_origin, me.Container_size);
917 sizeInDialogSpace = boxToGlobalSize(sizeInLBSpace, me.Container_size);
919 btn.Container_origin_x = originInDialogSpace.x + sizeInDialogSpace.x * theOrigin;
920 btn.Container_size_x = sizeInDialogSpace.x * theSize;
921 btn.setText(btn, theTitle);
922 btn.onClick = theFunc;
923 btn.onClickEntity = me;
926 void XonoticServerList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
928 SUPER(XonoticServerList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
930 me.realFontSize_y = me.fontSize / (absSize.y * me.itemHeight);
931 me.realFontSize_x = me.fontSize / (absSize.x * (1 - me.controlWidth));
932 me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
934 me.columnIconsOrigin = 0;
935 me.columnIconsSize = me.realFontSize.x * 4 * me.iconsSizeFactor;
936 me.columnPingSize = me.realFontSize.x * 3;
937 me.columnMapSize = me.realFontSize.x * 10;
938 me.columnTypeSize = me.realFontSize.x * 4;
939 me.columnPlayersSize = me.realFontSize.x * 5;
940 me.columnNameSize = 1 - me.columnPlayersSize - me.columnMapSize - me.columnPingSize - me.columnIconsSize - me.columnTypeSize - 5 * me.realFontSize.x;
941 me.columnPingOrigin = me.columnIconsOrigin + me.columnIconsSize + me.realFontSize.x;
942 me.columnNameOrigin = me.columnPingOrigin + me.columnPingSize + me.realFontSize.x;
943 me.columnMapOrigin = me.columnNameOrigin + me.columnNameSize + me.realFontSize.x;
944 me.columnTypeOrigin = me.columnMapOrigin + me.columnMapSize + me.realFontSize.x;
945 me.columnPlayersOrigin = me.columnTypeOrigin + me.columnTypeSize + me.realFontSize.x;
947 me.positionSortButton(me, me.sortButton1, me.columnPingOrigin, me.columnPingSize, _("Ping"), ServerList_PingSort_Click);
948 me.positionSortButton(me, me.sortButton2, me.columnNameOrigin, me.columnNameSize, _("Host name"), ServerList_NameSort_Click);
949 me.positionSortButton(me, me.sortButton3, me.columnMapOrigin, me.columnMapSize, _("Map"), ServerList_MapSort_Click);
950 me.positionSortButton(me, me.sortButton4, me.columnTypeOrigin, me.columnTypeSize, _("Type"), ServerList_TypeSort_Click);
951 me.positionSortButton(me, me.sortButton5, me.columnPlayersOrigin, me.columnPlayersSize, _("Players"), ServerList_PlayerSort_Click);
953 int f = me.currentSortField;
956 me.currentSortField = -1;
957 me.setSortOrder(me, f, me.currentSortOrder); // force resetting the sort order
960 void ServerList_Connect_Click(entity btn, entity me)
962 localcmd(sprintf("connect %s\n",
963 ((me.ipAddressBox.text != "") ?
964 me.ipAddressBox.text : me.selectedServer
968 void ServerList_Favorite_Click(entity btn, entity me)
971 ipstr = netaddress_resolve(me.ipAddressBox.text, 26000);
974 m_play_click_sound(MENU_SOUND_SELECT);
975 me.toggleFavorite(me, me.ipAddressBox.text);
976 me.ipAddressBoxFocused = -1;
979 void ServerList_Info_Click(entity btn, entity me)
982 main.serverInfoDialog.loadServerInfo(main.serverInfoDialog, me.selectedItem);
984 vector org = boxToGlobal(eY * (me.selectedItem * me.itemHeight - me.scrollPos), me.origin, me.size);
985 vector sz = boxToGlobalSize(eY * me.itemHeight + eX * (1 - me.controlWidth), me.size);
986 DialogOpenButton_Click_withCoords(me, main.serverInfoDialog, org, sz);
988 void XonoticServerList_doubleClickListBoxItem(entity me, int i, vector where)
990 ServerList_Connect_Click(NULL, me);
992 void XonoticServerList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
994 // layout: Ping, Server name, Map name, NP, TP, MP
1000 bool pure = false, pure_available = false;
1001 int freeslots = -1, sflags = -1, j, m;
1002 string s, typestr, versionstr, k, v, modname;
1004 //printf("time: %f, i: %d, item: %d, nitems: %d\n", time, i, item, me.nItems);
1006 vector oldscale = draw_scale;
1007 vector oldshift = draw_shift;
1008 #define SET_YRANGE(start,end) \
1009 draw_scale = boxToGlobalSize(eX * 1 + eY * (end - start), oldscale); \
1010 draw_shift = boxToGlobal(eY * start, oldshift, oldscale);
1012 for (j = 0; j < category_draw_count; ++j) {
1013 // Matches exactly the headings with increased height.
1014 if (i == category_item[j])
1018 if (j < category_draw_count)
1020 entity catent = RetrieveCategoryEnt(category_name[j]);
1024 (me.categoriesHeight - 1) / (me.categoriesHeight + 1),
1025 me.categoriesHeight / (me.categoriesHeight + 1)
1028 eY * me.realUpperMargin
1031 eX * (me.columnNameOrigin + (me.columnNameSize - draw_TextWidth(catent.cat_string, 0, me.realFontSize)) * 0.5),
1034 eX * (me.columnNameOrigin),
1035 strcat(catent.cat_string, ":"),
1038 SKINCOLOR_SERVERLIST_CATEGORY,
1039 SKINALPHA_SERVERLIST_CATEGORY,
1042 SET_YRANGE(me.categoriesHeight / (me.categoriesHeight + 1), 1);
1047 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
1050 me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
1051 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
1054 s = gethostcachestring(SLIST_FIELD_QCSTATUS, i);
1055 m = tokenizebyseparator(s, ":");
1060 versionstr = argv(1);
1064 for(j = 2; j < m; ++j)
1068 k = substring(argv(j), 0, 1);
1069 v = substring(argv(j), 1, -1);
1072 pure = (stof(v) == 0);
1073 pure_available = true;
1076 freeslots = stof(v);
1083 #ifdef COMPAT_NO_MOD_IS_XONOTIC
1085 modname = "Xonotic";
1088 string original_modname = modname;
1089 modname = strtolower(modname);
1092 SLIST_FIELD_MOD = gethostcacheindexforkey("mod");
1093 s = gethostcachestring(SLIST_FIELD_MOD, i);
1095 if(modname == "xonotic")
1099 // list the mods here on which the pure server check actually works
1100 if(modname != "xonotic")
1101 if(modname != "instagib" || modname != "minstagib")
1102 if(modname != "cts")
1103 if(modname != "nix")
1104 if(modname != "newtoys")
1105 pure_available = false;
1107 if(gethostcachenumber(SLIST_FIELD_FREESLOTS, i) <= 0)
1108 theAlpha = SKINALPHA_SERVERLIST_FULL;
1109 else if(freeslots == 0)
1110 theAlpha = SKINALPHA_SERVERLIST_FULL; // g_maxplayers support
1111 else if (!gethostcachenumber(SLIST_FIELD_NUMHUMANS, i))
1112 theAlpha = SKINALPHA_SERVERLIST_EMPTY;
1116 p = gethostcachenumber(SLIST_FIELD_PING, i);
1117 const int PING_LOW = 75;
1118 const int PING_MED = 200;
1119 const int PING_HIGH = 500;
1121 theColor = SKINCOLOR_SERVERLIST_LOWPING + (SKINCOLOR_SERVERLIST_MEDPING - SKINCOLOR_SERVERLIST_LOWPING) * (p / PING_LOW);
1122 else if(p < PING_MED)
1123 theColor = SKINCOLOR_SERVERLIST_MEDPING + (SKINCOLOR_SERVERLIST_HIGHPING - SKINCOLOR_SERVERLIST_MEDPING) * ((p - PING_LOW) / (PING_MED - PING_LOW));
1124 else if(p < PING_HIGH)
1126 theColor = SKINCOLOR_SERVERLIST_HIGHPING;
1127 theAlpha *= 1 + (SKINALPHA_SERVERLIST_HIGHPING - 1) * ((p - PING_MED) / (PING_HIGH - PING_MED));
1132 theAlpha *= SKINALPHA_SERVERLIST_HIGHPING;
1135 if(gethostcachenumber(SLIST_FIELD_ISFAVORITE, i))
1137 theColor = theColor * (1 - SKINALPHA_SERVERLIST_FAVORITE) + SKINCOLOR_SERVERLIST_FAVORITE * SKINALPHA_SERVERLIST_FAVORITE;
1138 theAlpha = theAlpha * (1 - SKINALPHA_SERVERLIST_FAVORITE) + SKINALPHA_SERVERLIST_FAVORITE;
1141 s = gethostcachestring(SLIST_FIELD_CNAME, i);
1143 isv4 = isv6 = false;
1144 if(substring(s, 0, 1) == "[")
1149 else if(strstrofs("0123456789", substring(s, 0, 1), 0) >= 0)
1155 q = stof(substring(crypto_getencryptlevel(s), 0, 1));
1156 if((q <= 0 && cvar("crypto_aeslevel") >= 3) || (q >= 3 && cvar("crypto_aeslevel") <= 0))
1158 theColor = SKINCOLOR_SERVERLIST_IMPOSSIBLE;
1159 theAlpha = SKINALPHA_SERVERLIST_IMPOSSIBLE;
1164 if(cvar("crypto_aeslevel") >= 2)
1169 if(cvar("crypto_aeslevel") >= 1)
1179 // 2: AES recommended but not available
1180 // 3: AES possible and will be used
1181 // 4: AES recommended and will be used
1187 vector iconSize = '0 0 0';
1188 iconSize_y = me.realFontSize.y * me.iconsSizeFactor;
1189 iconSize_x = me.realFontSize.x * me.iconsSizeFactor;
1191 vector iconPos = '0 0 0';
1192 iconPos_x = (me.columnIconsSize - 3 * iconSize.x) * 0.5;
1193 iconPos_y = (1 - iconSize.y) * 0.5;
1196 if(me.seenIPv4 && me.seenIPv6)
1199 draw_Picture(iconPos, "icon_ipv6", iconSize, '1 1 1', 1);
1201 draw_Picture(iconPos, "icon_ipv4", iconSize, '1 1 1', 1);
1204 iconPos.x += iconSize.x;
1208 draw_Picture(iconPos, strcat("icon_aeslevel", ftos(q)), iconSize, '1 1 1', 1);
1210 iconPos.x += iconSize.x;
1213 if(modname == "xonotic")
1215 // Here, pure_available should always be set. If not, consider
1217 if(pure_available && pure)
1218 draw_Picture(iconPos, "icon_pure1", iconSize, '1 1 1', 1);
1222 string icon = strcat("icon_mod_", modname);
1223 if(draw_PictureSize(icon) == '0 0 0')
1226 // In mods, pure_available not being present indicates
1227 // non-support of the feature. Just show the mod icon as is
1229 if(pure_available && !pure)
1230 draw_Picture(iconPos, icon, iconSize, '1 1 1', SKINALPHA_SERVERLIST_ICON_NONPURE);
1232 draw_Picture(iconPos, icon, iconSize, '1 1 1', 1);
1235 iconPos.x += iconSize.x;
1238 if(sflags >= 0 && (sflags & SERVERFLAG_PLAYERSTATS))
1239 draw_Picture(iconPos, "icon_stats1", iconSize, '1 1 1', 1);
1241 if(isFocused && me.mouseOverIcons && !me.tooltip)
1244 if(me.seenIPv4 && me.seenIPv6)
1245 t = strcat(t, (isv6) ? "IPv6, " : "IPv4, ");
1246 t = strcat(t, _("encryption:"), " ", (q ? sprintf(_("AES level %d"), q) : ZCTX(_("ENC^none"))), ", ");
1247 t = strcat(t, sprintf(_("mod: %s"), ((modname == "xonotic") ? ZCTX(_("MOD^Default")) : original_modname)));
1249 t = strcat(t, sprintf(_(" (%s)"), (pure) ? _("official settings") : _("modified settings")));
1250 t = strcat(t, ", ");
1251 t = strcat(t, ((sflags >= 0 && (sflags & SERVERFLAG_PLAYERSTATS)) ? _("stats enabled") : _("stats disabled")));
1252 setZonedTooltip(me, t, string_null);
1260 draw_Text(me.realUpperMargin * eY + (me.columnPingOrigin + me.columnPingSize - draw_TextWidth(s, 0, me.realFontSize)) * eX, s, me.realFontSize, theColor, theAlpha, 0);
1263 s = draw_TextShortenToWidth(gethostcachestring(SLIST_FIELD_NAME, i), me.columnNameSize, 0, me.realFontSize);
1264 draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s, me.realFontSize, theColor, theAlpha, 0);
1267 s = draw_TextShortenToWidth(gethostcachestring(SLIST_FIELD_MAP, i), me.columnMapSize, 0, me.realFontSize);
1268 draw_Text(me.realUpperMargin * eY + (me.columnMapOrigin + (me.columnMapSize - draw_TextWidth(s, 0, me.realFontSize)) * 0.5) * eX, s, me.realFontSize, theColor, theAlpha, 0);
1271 s = draw_TextShortenToWidth(typestr, me.columnTypeSize, 0, me.realFontSize);
1272 draw_Text(me.realUpperMargin * eY + (me.columnTypeOrigin + (me.columnTypeSize - draw_TextWidth(s, 0, me.realFontSize)) * 0.5) * eX, s, me.realFontSize, theColor, theAlpha, 0);
1274 // server playercount
1275 s = strcat(ftos(gethostcachenumber(SLIST_FIELD_NUMHUMANS, i)), "/", ftos(gethostcachenumber(SLIST_FIELD_MAXPLAYERS, i)));
1276 draw_Text(me.realUpperMargin * eY + (me.columnPlayersOrigin + (me.columnPlayersSize - draw_TextWidth(s, 0, me.realFontSize)) * 0.5) * eX, s, me.realFontSize, theColor, theAlpha, 0);
1279 void XonoticServerList_focusedItemChangeNotify(entity me)
1284 float XonoticServerList_mouseMove(entity me, vector pos)
1286 if(!SUPER(XonoticServerList).mouseMove(me, pos))
1288 me.mouseOverIcons = false;
1293 me.mouseOverIcons = (pos_x <= me.columnIconsSize);
1294 if(!me.mouseOverIcons)
1299 bool XonoticServerList_keyDown(entity me, int scan, bool ascii, bool shift)
1303 org = boxToGlobal(eY * (me.selectedItem * me.itemHeight - me.scrollPos), me.origin, me.size);
1304 sz = boxToGlobalSize(eY * me.itemHeight + eX * (1 - me.controlWidth), me.size);
1306 if(scan == K_ENTER || scan == K_KP_ENTER)
1308 ServerList_Connect_Click(NULL, me);
1311 else if(scan == K_MOUSE2 || scan == K_SPACE)
1315 m_play_click_sound(MENU_SOUND_OPEN);
1316 main.serverInfoDialog.loadServerInfo(main.serverInfoDialog, me.selectedItem);
1317 DialogOpenButton_Click_withCoords(me, main.serverInfoDialog, org, sz);
1322 else if(scan == K_INS || scan == K_MOUSE3 || scan == K_KP_INS)
1326 me.toggleFavorite(me, me.selectedServer);
1327 me.ipAddressBoxFocused = -1;
1332 else if(SUPER(XonoticServerList).keyDown(me, scan, ascii, shift))
1334 else if(!me.controlledTextbox)
1337 return me.controlledTextbox.keyDown(me.controlledTextbox, scan, ascii, shift);
1340 float XonoticServerList_getTotalHeight(entity me)
1342 float num_normal_rows = me.nItems;
1343 int num_headers = category_draw_count;
1344 return me.itemHeight * (num_normal_rows + me.categoriesHeight * num_headers);
1346 int XonoticServerList_getItemAtPos(entity me, float pos)
1348 pos = pos / me.itemHeight;
1350 for (i = category_draw_count - 1; i >= 0; --i) {
1351 int itemidx = category_item[i];
1352 float itempos = i * me.categoriesHeight + category_item[i];
1353 if (pos >= itempos + me.categoriesHeight + 1)
1354 return itemidx + 1 + floor(pos - (itempos + me.categoriesHeight + 1));
1358 // No category matches? Note that category 0 is... 0. Therefore no headings exist at all.
1361 float XonoticServerList_getItemStart(entity me, int item)
1364 for (i = category_draw_count - 1; i >= 0; --i) {
1365 int itemidx = category_item[i];
1366 float itempos = i * me.categoriesHeight + category_item[i];
1367 if (item >= itemidx + 1)
1368 return (itempos + me.categoriesHeight + 1 + item - (itemidx + 1)) * me.itemHeight;
1369 if (item >= itemidx)
1370 return itempos * me.itemHeight;
1372 // No category matches? Note that category 0 is... 0. Therefore no headings exist at all.
1373 return item * me.itemHeight;
1375 float XonoticServerList_getItemHeight(entity me, int item)
1378 for (i = 0; i < category_draw_count; ++i) {
1379 // Matches exactly the headings with increased height.
1380 if (item == category_item[i])
1381 return me.itemHeight * (me.categoriesHeight + 1);
1383 return me.itemHeight;