]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'samual/serverlist' of http://nl.git.xonotic.org/xonotic/xonotic-data...
authorSamual Lenks <samual@xonotic.org>
Thu, 10 Oct 2013 17:25:17 +0000 (13:25 -0400)
committerSamual Lenks <samual@xonotic.org>
Thu, 10 Oct 2013 17:25:17 +0000 (13:25 -0400)
1  2 
qcsrc/menu/xonotic/serverlist.c

index 992e7f17a4083890c993b0dd720a5e8c2c56fe17,181cd696dee478bc1ded8ef8f8e072256b055635..3fa4e4b774fe8efd5fb02debe3067e35c327a2a4
@@@ -89,18 -89,14 +89,13 @@@ var string autocvar_menu_slist_recommen
  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)
@@@ -176,7 -172,7 +171,7 @@@ void RegisterSLCategories(
        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;
        }
  }
@@@ -258,7 -248,7 +253,7 @@@ float IsServerInList(string list, strin
  
  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); 
@@@ -941,7 -931,7 +936,7 @@@ void XonoticServerList_drawListBoxItem(
        
        if(item < 0)
        {
 -              entity catent = Get_Cat_Ent(-item);
 +              entity catent = RetrieveCategoryEnt(-item);
                if(catent)
                {
                        draw_Text(