From: Samual Lenks Date: Thu, 10 Oct 2013 18:57:34 +0000 (-0400) Subject: Working on recommendation logic X-Git-Tag: xonotic-v0.8.0~256^2~30 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a649c66c59208c0222701717981109060947faf2;p=xonotic%2Fxonotic-data.pk3dir.git Working on recommendation logic --- diff --git a/qcsrc/menu/xonotic/serverlist.c b/qcsrc/menu/xonotic/serverlist.c index 24694d5f4..749ea8d6f 100644 --- a/qcsrc/menu/xonotic/serverlist.c +++ b/qcsrc/menu/xonotic/serverlist.c @@ -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)