X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fmenu%2Fxonotic%2Fserverlist.c;h=8b3a9e9a0394caf9f443e27499ce37d46aea4556;hb=094f9682a7e8258a383ea9574dc7144eaf7ceecc;hp=89947b00eac47e2e5f71c29fdb52327a99fd1b76;hpb=5345531c2e74527f0a7d87f5aee427c5775b1c4e;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/menu/xonotic/serverlist.c b/qcsrc/menu/xonotic/serverlist.c index 89947b00e..8b3a9e9a0 100644 --- a/qcsrc/menu/xonotic/serverlist.c +++ b/qcsrc/menu/xonotic/serverlist.c @@ -49,7 +49,6 @@ CLASS(XonoticServerList) EXTENDS(XonoticListBox) ATTRIB(XonoticServerList, infoButton, entity, NULL) ATTRIB(XonoticServerList, currentSortOrder, float, 0) ATTRIB(XonoticServerList, currentSortField, float, -1) - ATTRIB(XonoticServerList, lastBumpSelectTime, float, 0) ATTRIB(XonoticServerList, lastClickedServer, float, -1) ATTRIB(XonoticServerList, lastClickedTime, float, 0) @@ -67,16 +66,15 @@ ENDCLASS(XonoticServerList) entity makeXonoticServerList(); #ifndef IMPLEMENTATION -var float autocvar_menu_slist_categories = TRUE; -var float autocvar_menu_slist_categories_onlyifmultiple = TRUE; -var float autocvar_menu_slist_purethreshold = 10; -var float autocvar_menu_slist_modimpurity = 10; -var float autocvar_menu_slist_recommendations = 2; -var float autocvar_menu_slist_recommendations_maxping = 150; -var float autocvar_menu_slist_recommendations_minfreeslots = 1; -var float autocvar_menu_slist_recommendations_minhumans = 1; -var float autocvar_menu_slist_recommendations_purethreshold = -1; -//var string autocvar_menu_slist_recommended = "76.124.107.5:26004"; +float autocvar_menu_slist_categories; +float autocvar_menu_slist_categories_onlyifmultiple; +float autocvar_menu_slist_purethreshold; +float autocvar_menu_slist_modimpurity; +float autocvar_menu_slist_recommendations; +float autocvar_menu_slist_recommendations_maxping; +float autocvar_menu_slist_recommendations_minfreeslots; +float autocvar_menu_slist_recommendations_minhumans; +float autocvar_menu_slist_recommendations_purethreshold; // server cache fields #define SLIST_FIELDS \ @@ -107,12 +105,13 @@ const float REFRESHSERVERLIST_ASK = 2; // ..., also suggest querying serve const float REFRESHSERVERLIST_RESET = 3; // ..., also clear the list first // function declarations -entity RetrieveCategoryEnt(float catnum); - float IsServerInList(string list, string srv); #define IsFavorite(srv) IsServerInList(cvar_string("net_slist_favorites"), srv) +#define IsPromoted(srv) IsServerInList(_Nex_ExtResponseSystem_PromotedServers, srv) #define IsRecommended(srv) IsServerInList(_Nex_ExtResponseSystem_RecommendedServers, srv) +entity RetrieveCategoryEnt(float catnum); + float CheckCategoryOverride(float cat); float CheckCategoryForEntry(float entry); float m_gethostcachecategory(float entry) { return CheckCategoryOverride(CheckCategoryForEntry(entry)); } @@ -147,13 +146,13 @@ float category_draw_count; #define SLIST_CATEGORIES \ SLIST_CATEGORY(CAT_FAVORITED, "", "", ZCTX(_("SLCAT^Favorites"))) \ - SLIST_CATEGORY(CAT_RECOMMENDED, "", "CAT_SERVERS", ZCTX(_("SLCAT^Recommended"))) \ + SLIST_CATEGORY(CAT_RECOMMENDED, "", "", 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_INSTAGIB, "", "CAT_SERVERS", ZCTX(_("SLCAT^InstaGib Mode"))) \ SLIST_CATEGORY(CAT_DEFRAG, "", "CAT_SERVERS", ZCTX(_("SLCAT^Defrag Mode"))) #define SLIST_CATEGORY_AUTOCVAR(name) autocvar_menu_slist_categories_##name##_override @@ -206,11 +205,11 @@ void RegisterSLCategories() } \ else \ { \ - print(sprintf( \ + printf( \ "RegisterSLCategories(): Improper override '%s' for category '%s'!\n", \ s, \ categories[i].cat_name \ - )); \ + ); \ } \ } \ strunzone(categories[i].override_string); \ @@ -308,42 +307,50 @@ float CheckCategoryForEntry(float entry) // now check if it's recommended if(autocvar_menu_slist_recommendations) { - float recommended = 0; - if(autocvar_menu_slist_recommendations & 1) - { - if(IsRecommended(gethostcachestring(SLIST_FIELD_CNAME, entry))) - { ++recommended; } - else - { --recommended; } - } - if(autocvar_menu_slist_recommendations & 2) + string cname = gethostcachestring(SLIST_FIELD_CNAME, entry); + + if(IsPromoted(cname)) { return CAT_RECOMMENDED; } + else { - if( - (freeslots >= autocvar_menu_slist_recommendations_minfreeslots) - && - ( - (autocvar_menu_slist_recommendations_purethreshold < 0) - || - (impure <= autocvar_menu_slist_recommendations_purethreshold) - ) - && - ( - gethostcachenumber(SLIST_FIELD_NUMHUMANS, entry) - >= - autocvar_menu_slist_recommendations_minhumans - ) - && - ( - gethostcachenumber(SLIST_FIELD_PING, entry) - <= - autocvar_menu_slist_recommendations_maxping + float recommended = 0; + if(autocvar_menu_slist_recommendations & 1) + { + if(IsRecommended(cname)) { ++recommended; } + else { --recommended; } + } + if(autocvar_menu_slist_recommendations & 2) + { + if( + ///// check for minimum free slots + (freeslots >= autocvar_menu_slist_recommendations_minfreeslots) + + && // check for purity requirement + ( + (autocvar_menu_slist_recommendations_purethreshold < 0) + || + (impure <= autocvar_menu_slist_recommendations_purethreshold) + ) + + && // check for minimum amount of humans + ( + gethostcachenumber(SLIST_FIELD_NUMHUMANS, entry) + >= + autocvar_menu_slist_recommendations_minhumans + ) + + && // check for maximum latency + ( + gethostcachenumber(SLIST_FIELD_PING, entry) + <= + autocvar_menu_slist_recommendations_maxping + ) ) - ) - { ++recommended; } - else - { --recommended; } + { ++recommended; } + else + { --recommended; } + } + if(recommended > 0) { return CAT_RECOMMENDED; } } - if(recommended > 0) { return CAT_RECOMMENDED; } } // if not favorited or recommended, check modname @@ -354,8 +361,9 @@ float CheckCategoryForEntry(float entry) // old servers which don't report their mod name are considered modified now case "": { return CAT_MODIFIED; } - case "xpm": { return CAT_XPM; } - case "minstagib": { return CAT_MINSTAGIB; } + case "xpm": { return CAT_XPM; } + case "minstagib": + case "instagib": { return CAT_INSTAGIB; } case "overkill": { return CAT_OVERKILL; } //case "nix": { return CAT_NIX; } //case "newtoys": { return CAT_NEWTOYS; } @@ -364,7 +372,7 @@ float CheckCategoryForEntry(float entry) case "cts": case "xdf": { return CAT_DEFRAG; } - default: { dprint(sprintf("Found strange mod type: %s\n", modtype)); return CAT_MODIFIED; } + default: { dprintf("Found strange mod type: %s\n", modtype); return CAT_MODIFIED; } } } @@ -407,7 +415,7 @@ void XonoticServerList_toggleFavorite(entity me, string srv) f = 1; --i; } - + if(!f) { s1 = ""; @@ -575,6 +583,13 @@ void XonoticServerList_draw(entity me) _Nex_ExtResponseSystem_BannedServersNeedsRefresh = 0; } + if(_Nex_ExtResponseSystem_PromotedServersNeedsRefresh) + { + if(!me.needsRefresh) + me.needsRefresh = 3; + _Nex_ExtResponseSystem_PromotedServersNeedsRefresh = 0; + } + if(_Nex_ExtResponseSystem_RecommendedServersNeedsRefresh) { if(!me.needsRefresh) @@ -942,7 +957,10 @@ void ServerList_Info_Click(entity btn, entity me) { if (me.nItems != 0) main.serverInfoDialog.loadServerInfo(main.serverInfoDialog, me.selectedItem); - DialogOpenButton_Click(me, main.serverInfoDialog); + + vector org = boxToGlobal(eY * (me.selectedItem * me.itemHeight - me.scrollPos), me.origin, me.size); + vector sz = boxToGlobalSize(eY * me.itemHeight + eX * (1 - me.controlWidth), me.size); + DialogOpenButton_Click_withCoords(me, main.serverInfoDialog, org, sz); } void XonoticServerList_clickListBoxItem(entity me, float i, vector where) { @@ -965,7 +983,7 @@ void XonoticServerList_drawListBoxItem(entity me, float i, vector absSize, float float m, pure, freeslots, j, sflags; string s, typestr, versionstr, k, v, modname; - //print(sprintf("time: %f, i: %d, item: %d, nitems: %d\n", time, i, item, me.nItems)); + //printf("time: %f, i: %d, item: %d, nitems: %d\n", time, i, item, me.nItems); vector oldscale = draw_scale; vector oldshift = draw_shift; @@ -999,8 +1017,8 @@ void XonoticServerList_drawListBoxItem(entity me, float i, vector absSize, float strcat(catent.cat_string, ":"), #endif me.realFontSize, - '1 1 1', - SKINALPHA_TEXT, + SKINCOLOR_SERVERLIST_CATEGORY, + SKINALPHA_SERVERLIST_CATEGORY, 0 ); SET_YRANGE(me.categoriesHeight / (me.categoriesHeight + 1), 1); @@ -1053,7 +1071,7 @@ void XonoticServerList_drawListBoxItem(entity me, float i, vector absSize, float // list the mods here on which the pure server check actually works if(modname != "Xonotic") - if(modname != "MinstaGib") + if(modname != "InstaGib" || modname != "MinstaGib") if(modname != "CTS") if(modname != "NIX") if(modname != "NewToys") @@ -1063,7 +1081,7 @@ void XonoticServerList_drawListBoxItem(entity me, float i, vector absSize, float theAlpha = SKINALPHA_SERVERLIST_FULL; else if(freeslots == 0) theAlpha = SKINALPHA_SERVERLIST_FULL; // g_maxplayers support - else if not(gethostcachenumber(SLIST_FIELD_NUMHUMANS, i)) + else if (!gethostcachenumber(SLIST_FIELD_NUMHUMANS, i)) theAlpha = SKINALPHA_SERVERLIST_EMPTY; else theAlpha = 1; @@ -1149,7 +1167,7 @@ void XonoticServerList_drawListBoxItem(entity me, float i, vector absSize, float string n; - if not(me.seenIPv4 && me.seenIPv6) + if (!(me.seenIPv4 && me.seenIPv6)) { iconPos_x += iconSize_x * 0.5; } @@ -1226,14 +1244,11 @@ void XonoticServerList_drawListBoxItem(entity me, float i, vector absSize, float float XonoticServerList_keyDown(entity me, float scan, float ascii, float shift) { - float i = me.selectedItem; vector org, sz; org = boxToGlobal(eY * (me.selectedItem * me.itemHeight - me.scrollPos), me.origin, me.size); sz = boxToGlobalSize(eY * me.itemHeight + eX * (1 - me.controlWidth), me.size); - me.lastBumpSelectTime = 0; - if(scan == K_ENTER || scan == K_KP_ENTER) { ServerList_Connect_Click(NULL, me); @@ -1243,7 +1258,7 @@ float XonoticServerList_keyDown(entity me, float scan, float ascii, float shift) { if(me.nItems != 0) { - main.serverInfoDialog.loadServerInfo(main.serverInfoDialog, i); + main.serverInfoDialog.loadServerInfo(main.serverInfoDialog, me.selectedItem); DialogOpenButton_Click_withCoords(me, main.serverInfoDialog, org, sz); return 1; }