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 = strzone(#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_field = catnum; \
211 "RegisterSLCategories(): Improper override '%s' for category '%s'!\n", \
213 categories[i].cat_name \
217 strunzone(categories[i].override_string); \
218 categories[i].override_field = 0; \
220 PROCESS_OVERRIDE(cat_enoverride_string, cat_enoverride)
221 PROCESS_OVERRIDE(cat_dioverride_string, cat_dioverride)
222 #undef PROCESS_OVERRIDE
225 // Supporting Functions
226 entity RetrieveCategoryEnt(int catnum)
228 if((catnum > 0) && (catnum <= category_ent_count))
230 return categories[catnum - 1];
234 error(sprintf("RetrieveCategoryEnt(%d): Improper category number!\n", catnum));
239 bool IsServerInList(string list, string srv)
245 srv = netaddress_resolve(srv, 26000);
248 p = crypto_getidfp(srv);
249 n = tokenize_console(list);
250 for(i = 0; i < n; ++i)
252 if(substring(argv(i), 0, 1) != "[" && strlen(argv(i)) == 44 && strstrofs(argv(i), ".", 0) < 0)
260 if(srv == netaddress_resolve(argv(i), 26000))
267 int CheckCategoryOverride(int cat)
269 entity catent = RetrieveCategoryEnt(cat);
272 int override = (autocvar_menu_slist_categories ? catent.cat_enoverride : catent.cat_dioverride);
273 if(override) { return override; }
278 error(sprintf("CheckCategoryOverride(%d): Improper category number!\n", cat));
283 int CheckCategoryForEntry(int entry)
285 string s, k, v, modtype = "";
286 int j, m, impure = 0, freeslots = 0, sflags = 0;
287 s = gethostcachestring(SLIST_FIELD_QCSTATUS, entry);
288 m = tokenizebyseparator(s, ":");
290 for(j = 2; j < m; ++j)
292 if(argv(j) == "") { break; }
293 k = substring(argv(j), 0, 1);
294 v = substring(argv(j), 1, -1);
297 case "P": { impure = stof(v); break; }
298 case "S": { freeslots = stof(v); break; }
299 case "F": { sflags = stof(v); break; }
300 case "M": { modtype = strtolower(v); break; }
304 if(modtype != "xonotic") { impure += autocvar_menu_slist_modimpurity; }
306 // check if this server is favorited
307 if(gethostcachenumber(SLIST_FIELD_ISFAVORITE, entry)) { return CAT_FAVORITED; }
309 // now check if it's recommended
310 if(autocvar_menu_slist_recommendations)
312 string cname = gethostcachestring(SLIST_FIELD_CNAME, entry);
314 if(IsPromoted(cname)) { return CAT_RECOMMENDED; }
317 float recommended = 0;
318 if(autocvar_menu_slist_recommendations & 1)
320 if(IsRecommended(cname)) { ++recommended; }
321 else { --recommended; }
323 if(autocvar_menu_slist_recommendations & 2)
326 ///// check for minimum free slots
327 (freeslots >= autocvar_menu_slist_recommendations_minfreeslots)
329 && // check for purity requirement
331 (autocvar_menu_slist_recommendations_purethreshold < 0)
333 (impure <= autocvar_menu_slist_recommendations_purethreshold)
336 && // check for minimum amount of humans
338 gethostcachenumber(SLIST_FIELD_NUMHUMANS, entry)
340 autocvar_menu_slist_recommendations_minhumans
343 && // check for maximum latency
345 gethostcachenumber(SLIST_FIELD_PING, entry)
347 autocvar_menu_slist_recommendations_maxping
354 if(recommended > 0) { return CAT_RECOMMENDED; }
358 // if not favorited or recommended, check modname
359 if(modtype != "xonotic")
363 // old servers which don't report their mod name are considered modified now
364 case "": { return CAT_MODIFIED; }
366 case "xpm": { return CAT_XPM; }
368 case "instagib": { return CAT_INSTAGIB; }
369 case "overkill": { return CAT_OVERKILL; }
370 //case "nix": { return CAT_NIX; }
371 //case "newtoys": { return CAT_NEWTOYS; }
373 // "cts" is allowed as compat, xdf is replacement
375 case "xdf": { return CAT_DEFRAG; }
377 default: { LOG_TRACEF("Found strange mod type: %s\n", modtype); return CAT_MODIFIED; }
381 // must be normal or impure server
382 return ((impure > autocvar_menu_slist_purethreshold) ? CAT_MODIFIED : CAT_NORMAL);
385 void XonoticServerList_toggleFavorite(entity me, string srv)
387 string s, s0, s1, s2, srv_resolved, p;
390 srv_resolved = netaddress_resolve(srv, 26000);
391 p = crypto_getidfp(srv_resolved);
392 s = cvar_string("net_slist_favorites");
393 n = tokenize_console(s);
394 for(i = 0; i < n; ++i)
396 if(substring(argv(i), 0, 1) != "[" && strlen(argv(i)) == 44 && strstrofs(argv(i), ".", 0) < 0)
404 if(srv_resolved != netaddress_resolve(argv(i), 26000))
409 s0 = substring(s, 0, argv_end_index(i - 1));
411 s2 = substring(s, argv_start_index(i + 1), -1);
412 if(s0 != "" && s2 != "")
414 cvar_set("net_slist_favorites", strcat(s0, s1, s2));
415 s = cvar_string("net_slist_favorites");
416 n = tokenize_console(s);
427 cvar_set("net_slist_favorites", strcat(s, s1, p));
429 cvar_set("net_slist_favorites", strcat(s, s1, srv));
432 me.refreshServerList(me, REFRESHSERVERLIST_RESORT);
435 void ServerList_Update_favoriteButton(entity btn, entity me)
437 entity e = me.favoriteButton;
438 if(IsFavorite(me.ipAddressBox.text))
440 e.setText(e, _("Remove"));
445 e.setText(e, _("Favorite"));
446 setZonedTooltip(e, _("Bookmark the currently highlighted server so that it's faster to find in the future"), string_null);
450 entity makeXonoticServerList()
453 me = NEW(XonoticServerList);
454 me.configureXonoticServerList(me);
457 void XonoticServerList_configureXonoticServerList(entity me)
459 me.configureXonoticListBox(me);
462 #define SLIST_FIELD(suffix,name) SLIST_FIELD_##suffix = gethostcacheindexforkey(name);
469 void XonoticServerList_setSelected(entity me, int i)
471 me.lockedSelectedItem = false;
472 //int save = me.selectedItem;
473 SUPER(XonoticServerList).setSelected(me, i);
475 if(me.selectedItem == save)
480 if(gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT) != me.nItems)
481 return; // sorry, it would be wrong
483 if(me.selectedServer)
484 strunzone(me.selectedServer);
485 me.selectedServer = strzone(gethostcachestring(SLIST_FIELD_CNAME, me.selectedItem));
487 me.ipAddressBox.setText(me.ipAddressBox, me.selectedServer);
488 me.ipAddressBox.cursorPos = strlen(me.selectedServer);
489 me.ipAddressBoxFocused = -1;
491 void XonoticServerList_refreshServerList(entity me, int mode)
493 //print("refresh of type ", ftos(mode), "\n");
495 if(mode >= REFRESHSERVERLIST_REFILTER)
500 string s, typestr, modstr;
504 m = strstrofs(s, ":", 0);
507 typestr = substring(s, 0, m);
508 s = substring(s, m + 1, strlen(s) - m - 1);
509 while(substring(s, 0, 1) == " ")
510 s = substring(s, 1, strlen(s) - 1);
515 modstr = cvar_string("menu_slist_modfilter");
517 m = SLIST_MASK_AND - 1;
518 resethostcachemasks();
520 // ping: reject negative ping (no idea why this happens in the first place, engine bug)
521 sethostcachemasknumber(++m, SLIST_FIELD_PING, 0, SLIST_TEST_GREATEREQUAL);
524 if(!me.filterShowFull)
526 sethostcachemasknumber(++m, SLIST_FIELD_FREESLOTS, 1, SLIST_TEST_GREATEREQUAL); // legacy
527 sethostcachemaskstring(++m, SLIST_FIELD_QCSTATUS, ":S0:", SLIST_TEST_NOTCONTAIN); // g_maxplayers support
531 if(!me.filterShowEmpty)
532 sethostcachemasknumber(++m, SLIST_FIELD_NUMHUMANS, 1, SLIST_TEST_GREATEREQUAL);
534 // gametype filtering
536 sethostcachemaskstring(++m, SLIST_FIELD_QCSTATUS, strcat(typestr, ":"), SLIST_TEST_STARTSWITH);
541 if(substring(modstr, 0, 1) == "!")
542 sethostcachemaskstring(++m, SLIST_FIELD_MOD, resolvemod(substring(modstr, 1, strlen(modstr) - 1)), SLIST_TEST_NOTEQUAL);
544 sethostcachemaskstring(++m, SLIST_FIELD_MOD, resolvemod(modstr), SLIST_TEST_EQUAL);
548 n = tokenizebyseparator(_Nex_ExtResponseSystem_BannedServers, " ");
549 for(i = 0; i < n; ++i)
551 sethostcachemaskstring(++m, SLIST_FIELD_CNAME, argv(i), SLIST_TEST_NOTSTARTSWITH);
553 m = SLIST_MASK_OR - 1;
556 sethostcachemaskstring(++m, SLIST_FIELD_NAME, s, SLIST_TEST_CONTAINS);
557 sethostcachemaskstring(++m, SLIST_FIELD_MAP, s, SLIST_TEST_CONTAINS);
558 sethostcachemaskstring(++m, SLIST_FIELD_PLAYERS, s, SLIST_TEST_CONTAINS);
559 sethostcachemaskstring(++m, SLIST_FIELD_QCSTATUS, strcat(s, ":"), SLIST_TEST_STARTSWITH);
563 //listflags |= SLSF_FAVORITES;
564 listflags |= SLSF_CATEGORIES;
565 if(me.currentSortOrder < 0) { listflags |= SLSF_DESCENDING; }
566 sethostcachesort(me.currentSortField, listflags);
570 if(mode >= REFRESHSERVERLIST_ASK)
571 refreshhostcache(mode >= REFRESHSERVERLIST_RESET);
573 void XonoticServerList_focusEnter(entity me)
575 SUPER(XonoticServerList).focusEnter(me);
576 if(time < me.nextRefreshTime)
578 //print("sorry, no refresh yet\n");
581 me.nextRefreshTime = time + 10;
582 me.refreshServerList(me, REFRESHSERVERLIST_ASK);
585 void XonoticServerList_draw(entity me)
588 bool found = false, owned;
590 if(_Nex_ExtResponseSystem_BannedServersNeedsRefresh)
594 _Nex_ExtResponseSystem_BannedServersNeedsRefresh = 0;
597 if(_Nex_ExtResponseSystem_PromotedServersNeedsRefresh)
601 _Nex_ExtResponseSystem_PromotedServersNeedsRefresh = 0;
604 if(_Nex_ExtResponseSystem_RecommendedServersNeedsRefresh)
608 _Nex_ExtResponseSystem_RecommendedServersNeedsRefresh = 0;
611 if(me.currentSortField == -1)
613 me.setSortOrder(me, SLIST_FIELD_PING, +1);
614 me.refreshServerList(me, REFRESHSERVERLIST_RESET);
616 else if(me.needsRefresh == 1)
618 me.needsRefresh = 2; // delay by one frame to make sure "slist" has been executed
620 else if(me.needsRefresh == 2)
623 me.refreshServerList(me, REFRESHSERVERLIST_REFILTER);
625 else if(me.needsRefresh == 3)
628 me.refreshServerList(me, REFRESHSERVERLIST_RESORT);
631 owned = ((me.selectedServer == me.ipAddressBox.text) && (me.ipAddressBox.text != ""));
633 for(i = 0; i < category_draw_count; ++i) { category_name[i] = -1; category_item[i] = -1; }
634 category_draw_count = 0;
636 if(autocvar_menu_slist_categories >= 0) // if less than 0, don't even draw a category heading for favorites
638 float itemcount = gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT);
639 me.nItems = itemcount;
641 //float visible = floor(me.scrollPos / me.itemHeight);
642 // ^ unfortunately no such optimization can be made-- we must process through the
643 // entire list, otherwise there is no way to know which item is first in its category.
645 // binary search method suggested by div
648 for(x = 1; x <= category_ent_count; ++x) {
650 float last = (itemcount - 1);
655 float catf = gethostcachenumber(SLIST_FIELD_CATEGORY, first);
656 float catl = gethostcachenumber(SLIST_FIELD_CATEGORY, last);
658 // The first one is already > x.
659 // Therefore, category x does not exist.
660 // Higher numbered categories do exist though.
661 } else if (catl < x) {
662 // The last one is < x.
663 // Thus this category - and any following -
666 } else if (catf == x) {
667 // Starts at first. This breaks the loop
668 // invariant in the binary search and thus has
669 // to be handled separately.
670 if(gethostcachenumber(SLIST_FIELD_CATEGORY, first) != x)
671 error("Category mismatch I");
673 if(gethostcachenumber(SLIST_FIELD_CATEGORY, first - 1) == x)
674 error("Category mismatch II");
675 category_name[category_draw_count] = x;
676 category_item[category_draw_count] = first;
677 ++category_draw_count;
680 // At this point, catf <= x < catl, thus
681 // catf < catl, thus first < last.
684 // catf == gethostcachenumber(SLIST_FIELD_CATEGORY(first)
685 // catl == gethostcachenumber(SLIST_FIELD_CATEGORY(last)
688 while (last - first > 1) {
689 float middle = floor((first + last) / 2);
690 // By loop condition, middle != first && middle != last.
691 float cat = gethostcachenumber(SLIST_FIELD_CATEGORY, middle);
701 if(gethostcachenumber(SLIST_FIELD_CATEGORY, last) != x)
702 error("Category mismatch III");
704 if(gethostcachenumber(SLIST_FIELD_CATEGORY, last - 1) == x)
705 error("Category mismatch IV");
706 category_name[category_draw_count] = x;
707 category_item[category_draw_count] = last;
708 ++category_draw_count;
709 begin = last + 1; // already scanned through these, skip 'em
712 begin = last; // already scanned through these, skip 'em
715 if(autocvar_menu_slist_categories_onlyifmultiple && (category_draw_count == 1))
717 category_name[0] = -1;
718 category_item[0] = -1;
719 category_draw_count = 0;
720 me.nItems = itemcount;
723 else { me.nItems = gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT); }
725 me.connectButton.disabled = ((me.nItems == 0) && (me.ipAddressBox.text == ""));
726 me.infoButton.disabled = ((me.nItems == 0) || !owned);
727 me.favoriteButton.disabled = ((me.nItems == 0) && (me.ipAddressBox.text == ""));
729 if(me.lockedSelectedItem)
733 if(gethostcachestring(SLIST_FIELD_CNAME, me.selectedItem) != me.selectedServer)
735 if(me.selectedServer)
736 strunzone(me.selectedServer);
737 me.selectedServer = strzone(gethostcachestring(SLIST_FIELD_CNAME, me.selectedItem));
742 else if(me.selectedServer)
744 for(i = 0; i < me.nItems; ++i)
746 if(gethostcachestring(SLIST_FIELD_CNAME, i) == me.selectedServer)
748 // don't follow the selected item with SUPER(XonoticServerList).setSelected(me, i);
759 // selected server disappeared, select the last server (scrolling to it)
760 if(me.selectedItem >= me.nItems)
761 SUPER(XonoticServerList).setSelected(me, me.nItems - 1);
762 if(me.selectedServer)
763 strunzone(me.selectedServer);
764 me.selectedServer = strzone(gethostcachestring(SLIST_FIELD_CNAME, me.selectedItem));
770 if(me.selectedServer != me.ipAddressBox.text)
772 me.ipAddressBox.setText(me.ipAddressBox, me.selectedServer);
773 me.ipAddressBox.cursorPos = strlen(me.selectedServer);
774 me.ipAddressBoxFocused = -1;
778 if(me.ipAddressBoxFocused != me.ipAddressBox.focused)
780 if(me.ipAddressBox.focused || me.ipAddressBoxFocused < 0)
781 ServerList_Update_favoriteButton(NULL, me);
782 me.ipAddressBoxFocused = me.ipAddressBox.focused;
785 SUPER(XonoticServerList).draw(me);
787 void ServerList_PingSort_Click(entity btn, entity me)
789 me.setSortOrder(me, SLIST_FIELD_PING, +1);
791 void ServerList_NameSort_Click(entity btn, entity me)
793 me.setSortOrder(me, SLIST_FIELD_NAME, -1); // why?
795 void ServerList_MapSort_Click(entity btn, entity me)
797 me.setSortOrder(me, SLIST_FIELD_MAP, -1); // why?
799 void ServerList_PlayerSort_Click(entity btn, entity me)
801 me.setSortOrder(me, SLIST_FIELD_NUMHUMANS, -1);
803 void ServerList_TypeSort_Click(entity btn, entity me)
808 m = strstrofs(s, ":", 0);
811 s = substring(s, 0, m);
812 while(substring(s, m+1, 1) == " ") // skip spaces
818 for(i = 1; ; i *= 2) // 20 modes ought to be enough for anyone
820 t = MapInfo_Type_ToString(i);
822 if(t == "") // it repeats (default case)
825 // choose the first one
826 s = MapInfo_Type_ToString(1);
831 // the type was found
832 // choose the next one
833 s = MapInfo_Type_ToString(i * 2);
835 s = MapInfo_Type_ToString(1);
842 s = strcat(s, substring(me.filterString, m+1, strlen(me.filterString) - m - 1));
844 me.controlledTextbox.setText(me.controlledTextbox, s);
845 me.controlledTextbox.keyDown(me.controlledTextbox, K_END, 0, 0);
846 me.controlledTextbox.keyUp(me.controlledTextbox, K_END, 0, 0);
847 //ServerList_Filter_Change(me.controlledTextbox, me);
849 void ServerList_Filter_Change(entity box, entity me)
852 strunzone(me.filterString);
854 me.filterString = strzone(box.text);
856 me.filterString = string_null;
857 me.refreshServerList(me, REFRESHSERVERLIST_REFILTER);
859 me.ipAddressBox.setText(me.ipAddressBox, "");
860 me.ipAddressBox.cursorPos = 0;
861 me.ipAddressBoxFocused = -1;
863 void ServerList_Categories_Click(entity box, entity me)
865 box.setChecked(box, autocvar_menu_slist_categories = !autocvar_menu_slist_categories);
866 me.refreshServerList(me, REFRESHSERVERLIST_RESORT);
868 me.ipAddressBox.setText(me.ipAddressBox, "");
869 me.ipAddressBox.cursorPos = 0;
870 me.ipAddressBoxFocused = -1;
872 void ServerList_ShowEmpty_Click(entity box, entity me)
874 box.setChecked(box, me.filterShowEmpty = !me.filterShowEmpty);
875 me.refreshServerList(me, REFRESHSERVERLIST_REFILTER);
877 me.ipAddressBox.setText(me.ipAddressBox, "");
878 me.ipAddressBox.cursorPos = 0;
879 me.ipAddressBoxFocused = -1;
881 void ServerList_ShowFull_Click(entity box, entity me)
883 box.setChecked(box, me.filterShowFull = !me.filterShowFull);
884 me.refreshServerList(me, REFRESHSERVERLIST_REFILTER);
886 me.ipAddressBox.setText(me.ipAddressBox, "");
887 me.ipAddressBox.cursorPos = 0;
888 me.ipAddressBoxFocused = -1;
890 void XonoticServerList_setSortOrder(entity me, int fld, int direction)
892 if(me.currentSortField == fld)
893 direction = -me.currentSortOrder;
894 me.currentSortOrder = direction;
895 me.currentSortField = fld;
896 me.sortButton1.forcePressed = (fld == SLIST_FIELD_PING);
897 me.sortButton2.forcePressed = (fld == SLIST_FIELD_NAME);
898 me.sortButton3.forcePressed = (fld == SLIST_FIELD_MAP);
899 me.sortButton4.forcePressed = 0;
900 me.sortButton5.forcePressed = (fld == SLIST_FIELD_NUMHUMANS);
902 if(me.selectedServer)
903 strunzone(me.selectedServer);
904 me.selectedServer = string_null;
905 me.refreshServerList(me, REFRESHSERVERLIST_REFILTER);
907 void XonoticServerList_positionSortButton(entity me, entity btn, float theOrigin, float theSize, string theTitle, void(entity, entity) theFunc)
909 vector originInLBSpace, sizeInLBSpace;
910 originInLBSpace = eY * (-me.itemHeight);
911 sizeInLBSpace = eY * me.itemHeight + eX * (1 - me.controlWidth);
913 vector originInDialogSpace, sizeInDialogSpace;
914 originInDialogSpace = boxToGlobal(originInLBSpace, me.Container_origin, me.Container_size);
915 sizeInDialogSpace = boxToGlobalSize(sizeInLBSpace, me.Container_size);
917 btn.Container_origin_x = originInDialogSpace.x + sizeInDialogSpace.x * theOrigin;
918 btn.Container_size_x = sizeInDialogSpace.x * theSize;
919 btn.setText(btn, theTitle);
920 btn.onClick = theFunc;
921 btn.onClickEntity = me;
924 void XonoticServerList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
926 SUPER(XonoticServerList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
928 me.realFontSize_y = me.fontSize / (absSize.y * me.itemHeight);
929 me.realFontSize_x = me.fontSize / (absSize.x * (1 - me.controlWidth));
930 me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
932 me.columnIconsOrigin = 0;
933 me.columnIconsSize = me.realFontSize.x * 4 * me.iconsSizeFactor;
934 me.columnPingSize = me.realFontSize.x * 3;
935 me.columnMapSize = me.realFontSize.x * 10;
936 me.columnTypeSize = me.realFontSize.x * 4;
937 me.columnPlayersSize = me.realFontSize.x * 5;
938 me.columnNameSize = 1 - me.columnPlayersSize - me.columnMapSize - me.columnPingSize - me.columnIconsSize - me.columnTypeSize - 5 * me.realFontSize.x;
939 me.columnPingOrigin = me.columnIconsOrigin + me.columnIconsSize + me.realFontSize.x;
940 me.columnNameOrigin = me.columnPingOrigin + me.columnPingSize + me.realFontSize.x;
941 me.columnMapOrigin = me.columnNameOrigin + me.columnNameSize + me.realFontSize.x;
942 me.columnTypeOrigin = me.columnMapOrigin + me.columnMapSize + me.realFontSize.x;
943 me.columnPlayersOrigin = me.columnTypeOrigin + me.columnTypeSize + me.realFontSize.x;
945 me.positionSortButton(me, me.sortButton1, me.columnPingOrigin, me.columnPingSize, _("Ping"), ServerList_PingSort_Click);
946 me.positionSortButton(me, me.sortButton2, me.columnNameOrigin, me.columnNameSize, _("Host name"), ServerList_NameSort_Click);
947 me.positionSortButton(me, me.sortButton3, me.columnMapOrigin, me.columnMapSize, _("Map"), ServerList_MapSort_Click);
948 me.positionSortButton(me, me.sortButton4, me.columnTypeOrigin, me.columnTypeSize, _("Type"), ServerList_TypeSort_Click);
949 me.positionSortButton(me, me.sortButton5, me.columnPlayersOrigin, me.columnPlayersSize, _("Players"), ServerList_PlayerSort_Click);
951 int f = me.currentSortField;
954 me.currentSortField = -1;
955 me.setSortOrder(me, f, me.currentSortOrder); // force resetting the sort order
958 void ServerList_Connect_Click(entity btn, entity me)
960 localcmd(sprintf("connect %s\n",
961 ((me.ipAddressBox.text != "") ?
962 me.ipAddressBox.text : me.selectedServer
966 void ServerList_Favorite_Click(entity btn, entity me)
969 ipstr = netaddress_resolve(me.ipAddressBox.text, 26000);
972 m_play_click_sound(MENU_SOUND_SELECT);
973 me.toggleFavorite(me, me.ipAddressBox.text);
974 me.ipAddressBoxFocused = -1;
977 void ServerList_Info_Click(entity btn, entity me)
980 main.serverInfoDialog.loadServerInfo(main.serverInfoDialog, me.selectedItem);
982 vector org = boxToGlobal(eY * (me.selectedItem * me.itemHeight - me.scrollPos), me.origin, me.size);
983 vector sz = boxToGlobalSize(eY * me.itemHeight + eX * (1 - me.controlWidth), me.size);
984 DialogOpenButton_Click_withCoords(me, main.serverInfoDialog, org, sz);
986 void XonoticServerList_doubleClickListBoxItem(entity me, int i, vector where)
988 ServerList_Connect_Click(NULL, me);
990 void XonoticServerList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
992 // layout: Ping, Server name, Map name, NP, TP, MP
998 bool pure = false, pure_available = false;
999 int freeslots = -1, sflags = -1, j, m;
1000 string s, typestr, versionstr, k, v, modname;
1002 //printf("time: %f, i: %d, item: %d, nitems: %d\n", time, i, item, me.nItems);
1004 vector oldscale = draw_scale;
1005 vector oldshift = draw_shift;
1006 #define SET_YRANGE(start,end) \
1007 draw_scale = boxToGlobalSize(eX * 1 + eY * (end - start), oldscale); \
1008 draw_shift = boxToGlobal(eY * start, oldshift, oldscale);
1010 for (j = 0; j < category_draw_count; ++j) {
1011 // Matches exactly the headings with increased height.
1012 if (i == category_item[j])
1016 if (j < category_draw_count)
1018 entity catent = RetrieveCategoryEnt(category_name[j]);
1022 (me.categoriesHeight - 1) / (me.categoriesHeight + 1),
1023 me.categoriesHeight / (me.categoriesHeight + 1)
1026 eY * me.realUpperMargin
1029 eX * (me.columnNameOrigin + (me.columnNameSize - draw_TextWidth(catent.cat_string, 0, me.realFontSize)) * 0.5),
1032 eX * (me.columnNameOrigin),
1033 strcat(catent.cat_string, ":"),
1036 SKINCOLOR_SERVERLIST_CATEGORY,
1037 SKINALPHA_SERVERLIST_CATEGORY,
1040 SET_YRANGE(me.categoriesHeight / (me.categoriesHeight + 1), 1);
1045 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
1048 me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
1049 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
1052 s = gethostcachestring(SLIST_FIELD_QCSTATUS, i);
1053 m = tokenizebyseparator(s, ":");
1058 versionstr = argv(1);
1062 for(j = 2; j < m; ++j)
1066 k = substring(argv(j), 0, 1);
1067 v = substring(argv(j), 1, -1);
1070 pure = (stof(v) == 0);
1071 pure_available = true;
1074 freeslots = stof(v);
1081 #ifdef COMPAT_NO_MOD_IS_XONOTIC
1083 modname = "Xonotic";
1086 string original_modname = modname;
1087 modname = strtolower(modname);
1090 SLIST_FIELD_MOD = gethostcacheindexforkey("mod");
1091 s = gethostcachestring(SLIST_FIELD_MOD, i);
1093 if(modname == "xonotic")
1097 // list the mods here on which the pure server check actually works
1098 if(modname != "xonotic")
1099 if(modname != "instagib" || modname != "minstagib")
1100 if(modname != "cts")
1101 if(modname != "nix")
1102 if(modname != "newtoys")
1103 pure_available = false;
1105 if(gethostcachenumber(SLIST_FIELD_FREESLOTS, i) <= 0)
1106 theAlpha = SKINALPHA_SERVERLIST_FULL;
1107 else if(freeslots == 0)
1108 theAlpha = SKINALPHA_SERVERLIST_FULL; // g_maxplayers support
1109 else if (!gethostcachenumber(SLIST_FIELD_NUMHUMANS, i))
1110 theAlpha = SKINALPHA_SERVERLIST_EMPTY;
1114 p = gethostcachenumber(SLIST_FIELD_PING, i);
1115 const int PING_LOW = 75;
1116 const int PING_MED = 200;
1117 const int PING_HIGH = 500;
1119 theColor = SKINCOLOR_SERVERLIST_LOWPING + (SKINCOLOR_SERVERLIST_MEDPING - SKINCOLOR_SERVERLIST_LOWPING) * (p / PING_LOW);
1120 else if(p < PING_MED)
1121 theColor = SKINCOLOR_SERVERLIST_MEDPING + (SKINCOLOR_SERVERLIST_HIGHPING - SKINCOLOR_SERVERLIST_MEDPING) * ((p - PING_LOW) / (PING_MED - PING_LOW));
1122 else if(p < PING_HIGH)
1124 theColor = SKINCOLOR_SERVERLIST_HIGHPING;
1125 theAlpha *= 1 + (SKINALPHA_SERVERLIST_HIGHPING - 1) * ((p - PING_MED) / (PING_HIGH - PING_MED));
1130 theAlpha *= SKINALPHA_SERVERLIST_HIGHPING;
1133 if(gethostcachenumber(SLIST_FIELD_ISFAVORITE, i))
1135 theColor = theColor * (1 - SKINALPHA_SERVERLIST_FAVORITE) + SKINCOLOR_SERVERLIST_FAVORITE * SKINALPHA_SERVERLIST_FAVORITE;
1136 theAlpha = theAlpha * (1 - SKINALPHA_SERVERLIST_FAVORITE) + SKINALPHA_SERVERLIST_FAVORITE;
1139 s = gethostcachestring(SLIST_FIELD_CNAME, i);
1141 isv4 = isv6 = false;
1142 if(substring(s, 0, 1) == "[")
1147 else if(strstrofs("0123456789", substring(s, 0, 1), 0) >= 0)
1153 q = stof(substring(crypto_getencryptlevel(s), 0, 1));
1154 if((q <= 0 && cvar("crypto_aeslevel") >= 3) || (q >= 3 && cvar("crypto_aeslevel") <= 0))
1156 theColor = SKINCOLOR_SERVERLIST_IMPOSSIBLE;
1157 theAlpha = SKINALPHA_SERVERLIST_IMPOSSIBLE;
1162 if(cvar("crypto_aeslevel") >= 2)
1167 if(cvar("crypto_aeslevel") >= 1)
1177 // 2: AES recommended but not available
1178 // 3: AES possible and will be used
1179 // 4: AES recommended and will be used
1185 vector iconSize = '0 0 0';
1186 iconSize_y = me.realFontSize.y * me.iconsSizeFactor;
1187 iconSize_x = me.realFontSize.x * me.iconsSizeFactor;
1189 vector iconPos = '0 0 0';
1190 iconPos_x = (me.columnIconsSize - 3 * iconSize.x) * 0.5;
1191 iconPos_y = (1 - iconSize.y) * 0.5;
1194 if(me.seenIPv4 && me.seenIPv6)
1197 draw_Picture(iconPos, "icon_ipv6", iconSize, '1 1 1', 1);
1199 draw_Picture(iconPos, "icon_ipv4", iconSize, '1 1 1', 1);
1202 iconPos.x += iconSize.x;
1206 draw_Picture(iconPos, strcat("icon_aeslevel", ftos(q)), iconSize, '1 1 1', 1);
1208 iconPos.x += iconSize.x;
1211 if(modname == "xonotic")
1213 // Here, pure_available should always be set. If not, consider
1215 if(pure_available && pure)
1216 draw_Picture(iconPos, "icon_pure1", iconSize, '1 1 1', 1);
1220 string icon = strcat("icon_mod_", modname);
1221 if(draw_PictureSize(icon) == '0 0 0')
1224 // In mods, pure_available not being present indicates
1225 // non-support of the feature. Just show the mod icon as is
1227 if(pure_available && !pure)
1228 draw_Picture(iconPos, icon, iconSize, '1 1 1', SKINALPHA_SERVERLIST_ICON_NONPURE);
1230 draw_Picture(iconPos, icon, iconSize, '1 1 1', 1);
1233 iconPos.x += iconSize.x;
1236 if(sflags >= 0 && (sflags & SERVERFLAG_PLAYERSTATS))
1237 draw_Picture(iconPos, "icon_stats1", iconSize, '1 1 1', 1);
1239 if(isFocused && me.mouseOverIcons && !me.tooltip)
1242 if(me.seenIPv4 && me.seenIPv6)
1243 t = strcat(t, (isv6) ? "IPv6, " : "IPv4, ");
1244 t = strcat(t, _("encryption:"), " ", (q ? sprintf(_("AES level %d"), q) : ZCTX(_("ENC^none"))), ", ");
1245 t = strcat(t, sprintf(_("mod: %s"), ((modname == "xonotic") ? ZCTX(_("MOD^Default")) : original_modname)));
1247 t = strcat(t, sprintf(_(" (%s)"), (pure) ? _("official settings") : _("modified settings")));
1248 t = strcat(t, ", ");
1249 t = strcat(t, ((sflags >= 0 && (sflags & SERVERFLAG_PLAYERSTATS)) ? _("stats enabled") : _("stats disabled")));
1250 setZonedTooltip(me, t, string_null);
1258 draw_Text(me.realUpperMargin * eY + (me.columnPingOrigin + me.columnPingSize - draw_TextWidth(s, 0, me.realFontSize)) * eX, s, me.realFontSize, theColor, theAlpha, 0);
1261 s = draw_TextShortenToWidth(gethostcachestring(SLIST_FIELD_NAME, i), me.columnNameSize, 0, me.realFontSize);
1262 draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s, me.realFontSize, theColor, theAlpha, 0);
1265 s = draw_TextShortenToWidth(gethostcachestring(SLIST_FIELD_MAP, i), me.columnMapSize, 0, me.realFontSize);
1266 draw_Text(me.realUpperMargin * eY + (me.columnMapOrigin + (me.columnMapSize - draw_TextWidth(s, 0, me.realFontSize)) * 0.5) * eX, s, me.realFontSize, theColor, theAlpha, 0);
1269 s = draw_TextShortenToWidth(typestr, me.columnTypeSize, 0, me.realFontSize);
1270 draw_Text(me.realUpperMargin * eY + (me.columnTypeOrigin + (me.columnTypeSize - draw_TextWidth(s, 0, me.realFontSize)) * 0.5) * eX, s, me.realFontSize, theColor, theAlpha, 0);
1272 // server playercount
1273 s = strcat(ftos(gethostcachenumber(SLIST_FIELD_NUMHUMANS, i)), "/", ftos(gethostcachenumber(SLIST_FIELD_MAXPLAYERS, i)));
1274 draw_Text(me.realUpperMargin * eY + (me.columnPlayersOrigin + (me.columnPlayersSize - draw_TextWidth(s, 0, me.realFontSize)) * 0.5) * eX, s, me.realFontSize, theColor, theAlpha, 0);
1277 void XonoticServerList_focusedItemChangeNotify(entity me)
1282 float XonoticServerList_mouseMove(entity me, vector pos)
1284 if(!SUPER(XonoticServerList).mouseMove(me, pos))
1286 me.mouseOverIcons = false;
1291 me.mouseOverIcons = (pos_x <= me.columnIconsSize);
1292 if(!me.mouseOverIcons)
1297 bool XonoticServerList_keyDown(entity me, int scan, bool ascii, bool shift)
1301 org = boxToGlobal(eY * (me.selectedItem * me.itemHeight - me.scrollPos), me.origin, me.size);
1302 sz = boxToGlobalSize(eY * me.itemHeight + eX * (1 - me.controlWidth), me.size);
1304 if(scan == K_ENTER || scan == K_KP_ENTER)
1306 ServerList_Connect_Click(NULL, me);
1309 else if(scan == K_MOUSE2 || scan == K_SPACE)
1313 m_play_click_sound(MENU_SOUND_OPEN);
1314 main.serverInfoDialog.loadServerInfo(main.serverInfoDialog, me.selectedItem);
1315 DialogOpenButton_Click_withCoords(me, main.serverInfoDialog, org, sz);
1320 else if(scan == K_INS || scan == K_MOUSE3 || scan == K_KP_INS)
1324 me.toggleFavorite(me, me.selectedServer);
1325 me.ipAddressBoxFocused = -1;
1330 else if(SUPER(XonoticServerList).keyDown(me, scan, ascii, shift))
1332 else if(!me.controlledTextbox)
1335 return me.controlledTextbox.keyDown(me.controlledTextbox, scan, ascii, shift);
1338 float XonoticServerList_getTotalHeight(entity me)
1340 float num_normal_rows = me.nItems;
1341 int num_headers = category_draw_count;
1342 return me.itemHeight * (num_normal_rows + me.categoriesHeight * num_headers);
1344 int XonoticServerList_getItemAtPos(entity me, float pos)
1346 pos = pos / me.itemHeight;
1348 for (i = category_draw_count - 1; i >= 0; --i) {
1349 int itemidx = category_item[i];
1350 float itempos = i * me.categoriesHeight + category_item[i];
1351 if (pos >= itempos + me.categoriesHeight + 1)
1352 return itemidx + 1 + floor(pos - (itempos + me.categoriesHeight + 1));
1356 // No category matches? Note that category 0 is... 0. Therefore no headings exist at all.
1359 float XonoticServerList_getItemStart(entity me, int item)
1362 for (i = category_draw_count - 1; i >= 0; --i) {
1363 int itemidx = category_item[i];
1364 float itempos = i * me.categoriesHeight + category_item[i];
1365 if (item >= itemidx + 1)
1366 return (itempos + me.categoriesHeight + 1 + item - (itemidx + 1)) * me.itemHeight;
1367 if (item >= itemidx)
1368 return itempos * me.itemHeight;
1370 // No category matches? Note that category 0 is... 0. Therefore no headings exist at all.
1371 return item * me.itemHeight;
1373 float XonoticServerList_getItemHeight(entity me, int item)
1376 for (i = 0; i < category_draw_count; ++i) {
1377 // Matches exactly the headings with increased height.
1378 if (item == category_item[i])
1379 return me.itemHeight * (me.categoriesHeight + 1);
1381 return me.itemHeight;