var float autocvar_menu_slist_categories = TRUE;
var float autocvar_menu_slist_categories_onlyifmultiple = TRUE;
var float autocvar_menu_slist_purethreshold = 10;
-var string autocvar_menu_slist_recommended = "76.124.107.5:26004";
+//var string autocvar_menu_slist_recommended = "76.124.107.5:26004";
// server cache fields
#define SLIST_FIELDS \
SLIST_FIELDS
#undef SLIST_FIELD
-// sort flags
-const float SLSF_DESCENDING = 1;
-const float SLSF_FAVORITES = 2;
-const float SLSF_CATEGORIES = 4;
-
const float REFRESHSERVERLIST_RESORT = 0; // sort the server list again to update for changes to e.g. favorite status, categories
const float REFRESHSERVERLIST_REFILTER = 1; // ..., also update filter and sort criteria
const float REFRESHSERVERLIST_ASK = 2; // ..., also suggest querying servers now
const float REFRESHSERVERLIST_RESET = 3; // ..., also clear the list first
// function declarations
-float Get_Cat_Num_FromString(string input);
-entity Get_Cat_Ent(float catnum);
+entity RetrieveCategoryEnt(float catnum);
float IsServerInList(string list, string srv);
#define IsFavorite(srv) IsServerInList(cvar_string("net_slist_favorites"), srv)
-#define IsRecommended(srv) IsServerInList(cvar_string("menu_slist_recommended"), srv) // todo: use update notification instead of cvar
+#define IsRecommended(srv) IsServerInList(_Nex_ExtResponseSystem_RecommendedServers, srv)
float CheckCategoryOverride(float cat);
float CheckCategoryForEntry(float entry);
-float m_getserverlistentrycategory(float entry) { return CheckCategoryOverride(CheckCategoryForEntry(entry)); }
+float m_gethostcachecategory(float entry) { return CheckCategoryOverride(CheckCategoryForEntry(entry)); }
void RegisterSLCategories();
float category_draw_count;
#define SLIST_CATEGORIES \
- SLIST_CATEGORY(CAT_FAVORITED, "", "", _("Favorites")) \
- SLIST_CATEGORY(CAT_RECOMMENDED, "", "CAT_SERVERS", _("Recommended")) \
- SLIST_CATEGORY(CAT_NORMAL, "", "CAT_SERVERS", _("Normal Servers")) \
- SLIST_CATEGORY(CAT_SERVERS, "CAT_NORMAL", "CAT_SERVERS", _("Servers")) \
- SLIST_CATEGORY(CAT_XPM, "CAT_NORMAL", "CAT_SERVERS", _("Competitive Mode")) \
- SLIST_CATEGORY(CAT_MODIFIED, "", "CAT_SERVERS", _("Modified Servers")) \
- SLIST_CATEGORY(CAT_OVERKILL, "", "CAT_SERVERS", _("Overkill Mode")) \
- SLIST_CATEGORY(CAT_MINSTAGIB, "", "CAT_SERVERS", _("MinstaGib Mode")) \
- SLIST_CATEGORY(CAT_DEFRAG, "", "CAT_SERVERS", _("Defrag Mode"))
+ SLIST_CATEGORY(CAT_FAVORITED, "", "", ZCTX(_("SLCAT^Favorites"))) \
+ SLIST_CATEGORY(CAT_RECOMMENDED, "", "CAT_SERVERS", ZCTX(_("SLCAT^Recommended"))) \
+ SLIST_CATEGORY(CAT_NORMAL, "", "CAT_SERVERS", ZCTX(_("SLCAT^Normal Servers"))) \
+ SLIST_CATEGORY(CAT_SERVERS, "CAT_NORMAL", "CAT_SERVERS", ZCTX(_("SLCAT^Servers"))) \
+ SLIST_CATEGORY(CAT_XPM, "CAT_NORMAL", "CAT_SERVERS", ZCTX(_("SLCAT^Competitive Mode"))) \
+ SLIST_CATEGORY(CAT_MODIFIED, "", "CAT_SERVERS", ZCTX(_("SLCAT^Modified Servers"))) \
+ SLIST_CATEGORY(CAT_OVERKILL, "", "CAT_SERVERS", ZCTX(_("SLCAT^Overkill Mode"))) \
+ SLIST_CATEGORY(CAT_MINSTAGIB, "", "CAT_SERVERS", ZCTX(_("SLCAT^MinstaGib Mode"))) \
+ SLIST_CATEGORY(CAT_DEFRAG, "", "CAT_SERVERS", ZCTX(_("SLCAT^Defrag Mode")))
#define SLIST_CATEGORY_AUTOCVAR(name) autocvar_menu_slist_categories_##name##_override
#define SLIST_CATEGORY(name,enoverride,dioverride,str) \
SLIST_CATEGORIES
#undef SLIST_CATEGORY
- float i, catnum;
+ float i, x, catnum;
string s;
#define PROCESS_OVERRIDE(override_string,override_field) \
s = categories[i].override_string; \
if((s != "") && (s != categories[i].cat_name)) \
{ \
- catnum = Get_Cat_Num_FromString(s); \
+ catnum = 0; \
+ for(x = 0; x < category_ent_count; ++x) \
+ { if(categories[x].cat_name == s) { \
+ catnum = (x+1); \
+ break; \
+ } } \
if(catnum) \
{ \
strunzone(categories[i].override_string); \
categories[i].override_field = catnum; \
continue; \
} \
+ else \
+ { \
+ print(sprintf( \
+ "RegisterSLCategories(): Improper override '%s' for category '%s'!\n", \
+ s, \
+ categories[i].cat_name \
+ )); \
+ } \
} \
strunzone(categories[i].override_string); \
categories[i].override_field = 0; \
}
// Supporting Functions
-float Get_Cat_Num_FromString(string input)
-{
- float i;
- for(i = 0; i < category_ent_count; ++i) { if(categories[i].cat_name == input) { return (i + 1); } }
- print(sprintf("Get_Cat_Num_FromString('%s'): Improper category name!\n", input));
- return 0;
-}
-entity Get_Cat_Ent(float catnum)
+entity RetrieveCategoryEnt(float catnum)
{
if((catnum > 0) && (catnum <= category_ent_count))
{
}
else
{
- error(sprintf("Get_Cat_Ent(%d): Improper category number!\n", catnum));
+ error(sprintf("RetrieveCategoryEnt(%d): Improper category number!\n", catnum));
return world;
}
}
-
float IsServerInList(string list, string srv)
{
string p;
float CheckCategoryOverride(float cat)
{
- entity catent = Get_Cat_Ent(cat);
+ entity catent = RetrieveCategoryEnt(cat);
if(catent)
{
float override = (autocvar_menu_slist_categories ? catent.cat_enoverride : catent.cat_dioverride);
else if(k == "M") { modtype = strtolower(v); }
}
- //print(sprintf("modtype = %s\n", modtype));
-
if(impure > autocvar_menu_slist_purethreshold) { impure = TRUE; }
else { impure = FALSE; }
case "xpm": { return CAT_XPM; }
case "minstagib": { return CAT_MINSTAGIB; }
case "overkill": { return CAT_OVERKILL; }
+ //case "nix": { return CAT_NIX; }
+ //case "newtoys": { return CAT_NEWTOYS; }
// "cts" is allowed as compat, xdf is replacement
case "cts":
case "xdf": { return CAT_DEFRAG; }
- //if(modname != "CTS")
- //if(modname != "NIX")
- //if(modname != "NewToys")
-
default: { dprint(sprintf("Found strange mod type: %s\n", modtype)); return CAT_MODIFIED; }
}
}
_Nex_ExtResponseSystem_BannedServersNeedsRefresh = 0;
}
+ if(_Nex_ExtResponseSystem_RecommendedServersNeedsRefresh)
+ {
+ if(!me.needsRefresh)
+ me.needsRefresh = 3;
+ _Nex_ExtResponseSystem_RecommendedServersNeedsRefresh = 0;
+ }
+
if(me.currentSortField == -1)
{
me.setSortOrder(me, SLIST_FIELD_PING, +1);
me.needsRefresh = 0;
me.refreshServerList(me, REFRESHSERVERLIST_REFILTER);
}
+ else if(me.needsRefresh == 3)
+ {
+ me.needsRefresh = 0;
+ me.refreshServerList(me, REFRESHSERVERLIST_RESORT);
+ }
owned = ((me.selectedServer == me.ipAddressBox.text) && (me.ipAddressBox.text != ""));
// entire list, otherwise there is no way to know which item is first in its category.
float cat, x;
- for(i = 0; i < itemcount; ++i)
+ for(i = 0; i < itemcount; ++i) // FIXME this loop is TOTALLY unacceptable (O(servers)). Make it O(categories * log(servers)). Yes, that is possible.
{
cat = gethostcachenumber(SLIST_FIELD_CATEGORY, i);
if(cat)
}
if(autocvar_menu_slist_categories_onlyifmultiple && (category_draw_count == 1))
{
- category_name[0] = category_name[1] = -1;
- category_item[0] = category_item[1] = -1;
+ category_name[0] = -1;
+ category_item[0] = -1;
category_draw_count = 0;
me.nItems = itemcount;
}
if(item < 0)
{
- entity catent = Get_Cat_Ent(-item);
+ entity catent = RetrieveCategoryEnt(-item);
if(catent)
{
draw_Text(