]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Working on recommendation logic
authorSamual Lenks <samual@xonotic.org>
Thu, 10 Oct 2013 18:57:34 +0000 (14:57 -0400)
committerSamual Lenks <samual@xonotic.org>
Thu, 10 Oct 2013 18:57:34 +0000 (14:57 -0400)
qcsrc/menu/xonotic/serverlist.c

index 24694d5f48fe5cd6eea23046ffef8a11b0b3b352..749ea8d6f8c2bacbc551747342e9126994709aca 100644 (file)
@@ -64,6 +64,7 @@ entity makeXonoticServerList();
 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_recommendations = 2; 
 //var string autocvar_menu_slist_recommended = "76.124.107.5:26004";
 
 // server cache fields
@@ -287,9 +288,35 @@ float CheckCategoryForEntry(float entry)
        if(impure > autocvar_menu_slist_purethreshold) { impure = TRUE; }
        else { impure = FALSE; }
 
+       // check if this server is favorited
        if(gethostcachenumber(SLIST_FIELD_ISFAVORITE, entry)) { return CAT_FAVORITED; }
-       if(IsRecommended(gethostcachestring(SLIST_FIELD_CNAME, entry))) { return CAT_RECOMMENDED; }
-       else if(modtype != "xonotic")
+
+       // now check if it's recommended
+       switch(autocvar_menu_slist_recommendations)
+       {
+               case 1:
+               {
+                       if(IsRecommended(gethostcachestring(SLIST_FIELD_CNAME, entry)))
+                               { return CAT_RECOMMENDED; }
+                               
+                       break;
+               }
+               
+               case 2:
+               {
+                       if(
+                               gethostcachenumber(SLIST_FIELD_NUMHUMANS, entry)
+                               &&
+                               (gethostcachenumber(SLIST_FIELD_PING, entry) < 200)
+                       )
+                               { return CAT_RECOMMENDED; }
+                               
+                       break;
+               }
+       }
+
+       // if not favorited or recommended, check modname
+       if(modtype != "xonotic")
        {
                switch(modtype)
                {
@@ -309,11 +336,9 @@ float CheckCategoryForEntry(float entry)
                        default: { dprint(sprintf("Found strange mod type: %s\n", modtype)); return CAT_MODIFIED; }
                }
        }
-       else { return (impure ? CAT_MODIFIED : CAT_NORMAL); }
 
-       // should never hit this point
-       error(sprintf("CheckCategoryForEntry(%d): Function fell through without normal return!\n", entry));
-       return FALSE;
+       // must be normal or impure server
+       return (impure ? CAT_MODIFIED : CAT_NORMAL);
 }
 
 float CheckItemNumber(float num)