]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Support promoted servers in the recommendations
authorSamual Lenks <samual@xonotic.org>
Sat, 12 Oct 2013 22:54:31 +0000 (18:54 -0400)
committerSamual Lenks <samual@xonotic.org>
Sat, 12 Oct 2013 22:54:31 +0000 (18:54 -0400)
qcsrc/menu/xonotic/serverlist.c

index 8d09155ac93ab9ccd4f6515eec9ccc3c30e8742e..795e68a4bdfa2c7c8eaaa8b05663d13e6be91ad6 100644 (file)
@@ -111,6 +111,7 @@ 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)
 
 float CheckCategoryOverride(float cat);
@@ -308,42 +309,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
@@ -575,6 +584,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)