Xonotic
serverlist.qh File Reference
#include "listbox.qh"
+ Include dependency graph for serverlist.qh:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  XonoticServerList
 

Macros

#define SLIST_CATEGORIES
 
#define SLIST_CATEGORY(name, enoverride, dioverride, str)
 
#define SLIST_CATEGORY_AUTOCVAR(name)   autocvar_menu_slist_categories_##name##_override
 
#define SLIST_FIELD(suffix, name)   float SLIST_FIELD_##suffix;
 
#define SLIST_FIELDS
 

Functions

float CategoryForEntry (float entry)
 
float CategoryOverride (float cat)
 
float IsServerInList (string list, string srv)
 
float m_gethostcachecategory (float entry)
 
entity makeXonoticServerList ()
 
void RegisterSLCategories ()
 
entity RetrieveCategoryEnt (float catnum)
 
void ServerList_Categories_Click (entity box, entity me)
 
void ServerList_Connect_Click (entity btn, entity me)
 
void ServerList_Favorite_Click (entity btn, entity me)
 
void ServerList_Filter_Change (entity box, entity me)
 
void ServerList_Info_Click (entity btn, entity me)
 
void ServerList_ShowEmpty_Click (entity box, entity me)
 
void ServerList_ShowFull_Click (entity box, entity me)
 
void ServerList_ShowLaggy_Click (entity box, entity me)
 
void ServerList_Update_favoriteButton (entity btn, entity me)
 

Variables

SLIST_FIELDS float autocvar_menu_slist_categories
 
float autocvar_menu_slist_categories_onlyifmultiple
 
float autocvar_menu_slist_maxping = 300
 
float autocvar_menu_slist_modimpurity
 
float autocvar_menu_slist_purethreshold
 
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
 
float cat_dioverride
 
string cat_dioverride_string
 
float cat_enoverride
 
string cat_enoverride_string
 
string cat_name
 
string cat_string
 
entity categories [MAX_CATEGORIES]
 
int category_draw_count
 
int category_ent_count
 
const int CATEGORY_FIRST = 1
 
int category_item [MAX_CATEGORIES]
 
int category_name [MAX_CATEGORIES]
 
const int MAX_CATEGORIES = 9
 
const float REFRESHSERVERLIST_ASK = 2
 
const float REFRESHSERVERLIST_REFILTER = 1
 
const float REFRESHSERVERLIST_RESET = 3
 
const float REFRESHSERVERLIST_RESORT = 0
 

Macro Definition Documentation

◆ SLIST_CATEGORIES

#define SLIST_CATEGORIES
Value:
SLIST_CATEGORY(CAT_FAVORITED, "", "", CTX(_("SLCAT^Favorites"))) \
SLIST_CATEGORY(CAT_RECOMMENDED, "", "", CTX(_("SLCAT^Recommended"))) \
SLIST_CATEGORY(CAT_NORMAL, "", "CAT_SERVERS", CTX(_("SLCAT^Normal Servers"))) \
SLIST_CATEGORY(CAT_SERVERS, "CAT_NORMAL", "CAT_SERVERS", CTX(_("SLCAT^Servers"))) \
SLIST_CATEGORY(CAT_XPM, "CAT_NORMAL", "CAT_SERVERS", CTX(_("SLCAT^Competitive Mode"))) \
SLIST_CATEGORY(CAT_MODIFIED, "", "CAT_SERVERS", CTX(_("SLCAT^Modified Servers"))) \
SLIST_CATEGORY(CAT_OVERKILL, "", "CAT_SERVERS", CTX(_("SLCAT^Overkill"))) \
SLIST_CATEGORY(CAT_INSTAGIB, "", "CAT_SERVERS", CTX(_("SLCAT^InstaGib"))) \
SLIST_CATEGORY(CAT_DEFRAG, "", "CAT_SERVERS", CTX(_("SLCAT^Defrag Mode")))
#define SLIST_CATEGORY(name, enoverride, dioverride, str)
Definition: serverlist.qh:164
ERASEABLE string CTX(string s)
Definition: i18n.qh:45

Definition at line 152 of file serverlist.qh.

Referenced by RegisterSLCategories().

◆ SLIST_CATEGORY

#define SLIST_CATEGORY (   name,
  enoverride,
  dioverride,
  str 
)
Value:
int name; \
string SLIST_CATEGORY_AUTOCVAR(name) = enoverride;
#define SLIST_CATEGORY_AUTOCVAR(name)
Definition: serverlist.qh:163

Definition at line 164 of file serverlist.qh.

◆ SLIST_CATEGORY_AUTOCVAR

#define SLIST_CATEGORY_AUTOCVAR (   name)    autocvar_menu_slist_categories_##name##_override

Definition at line 163 of file serverlist.qh.

◆ SLIST_FIELD

#define SLIST_FIELD (   suffix,
  name 
)    float SLIST_FIELD_##suffix;

Definition at line 106 of file serverlist.qh.

◆ SLIST_FIELDS

#define SLIST_FIELDS
Value:
SLIST_FIELD(CNAME, "cname") \
SLIST_FIELD(PING, "ping") \
SLIST_FIELD(GAME, "game") \
SLIST_FIELD(MOD, "mod") \
SLIST_FIELD(MAP, "map") \
SLIST_FIELD(NAME, "name") \
SLIST_FIELD(MAXPLAYERS, "maxplayers") \
SLIST_FIELD(NUMPLAYERS, "numplayers") \
SLIST_FIELD(NUMHUMANS, "numhumans") \
SLIST_FIELD(NUMBOTS, "numbots") \
SLIST_FIELD(PROTOCOL, "protocol") \
SLIST_FIELD(FREESLOTS, "freeslots") \
SLIST_FIELD(PLAYERS, "players") \
SLIST_FIELD(QCSTATUS, "qcstatus") \
SLIST_FIELD(CATEGORY, "category") \
SLIST_FIELD(ISFAVORITE, "isfavorite")
#define MAP(f,...)
Definition: functional.qh:3
#define SLIST_FIELD(suffix, name)
Definition: serverlist.qh:106

Definition at line 88 of file serverlist.qh.

Referenced by XonoticServerList_configureXonoticServerList().

Function Documentation

◆ CategoryForEntry()

float CategoryForEntry ( float  entry)

◆ CategoryOverride()

float CategoryOverride ( float  cat)

◆ IsServerInList()

float IsServerInList ( string  list,
string  srv 
)

Definition at line 76 of file serverlist.qc.

References argv(), strlen(), strstrofs, substring(), and tokenize_console.

77 {
78  if(srv == "")
79  return false;
80  srv = netaddress_resolve(srv, 26000);
81  if(srv == "")
82  return false;
83  string p = crypto_getidfp(srv);
84  int n = tokenize_console(list);
85  for(int i = 0; i < n; ++i)
86  {
87  if(substring(argv(i), 0, 1) != "[" && strlen(argv(i)) == 44 && strstrofs(argv(i), ".", 0) < 0)
88  {
89  if(p && argv(i) == p)
90  return true;
91  }
92  else
93  {
94  if(srv == netaddress_resolve(argv(i), 26000))
95  return true;
96  }
97  }
98  return false;
99 }
#define strstrofs
Definition: dpextensions.qh:42
#define tokenize_console
Definition: dpextensions.qh:24
+ Here is the call graph for this function:

◆ m_gethostcachecategory()

float m_gethostcachecategory ( float  entry)

Definition at line 13 of file serverlist.qc.

References CategoryForEntry(), and CategoryOverride().

13 { return CategoryOverride(CategoryForEntry(entry)); }
int CategoryForEntry(int entry)
Definition: serverlist.qc:117
int CategoryOverride(int cat)
Definition: serverlist.qc:101
+ Here is the call graph for this function:

◆ makeXonoticServerList()

entity makeXonoticServerList ( )

Definition at line 272 of file serverlist.qc.

References entity(), and NEW.

Referenced by XonoticServerListTab_fill().

273 {
274  entity me;
275  me = NEW(XonoticServerList);
276  me.configureXonoticServerList(me);
277  return me;
278 }
#define NEW(cname,...)
Definition: oo.qh:105
entity() spawn
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RegisterSLCategories()

void RegisterSLCategories ( )

Definition at line 44 of file serverlist.qc.

References cat_dioverride, cat_dioverride_string, cat_enoverride, cat_enoverride_string, entity(), SL_ProcessCategoryOverrides(), and SLIST_CATEGORIES.

Referenced by m_init().

45 {
46  entity cat;
47  #define SLIST_CATEGORY(name,enoverride,dioverride,str) \
48  SET_FIELD_COUNT(name, CATEGORY_FIRST, category_ent_count) \
49  CHECK_MAX_COUNT(name, MAX_CATEGORIES, category_ent_count, "SLIST_CATEGORY") \
50  cat = categories[name - 1] = new(slist_category); \
51  cat.cat_name = #name; \
52  cat.cat_enoverride_string = strzone(SLIST_CATEGORY_AUTOCVAR(name)); \
53  cat.cat_dioverride_string = strzone(dioverride); \
54  cat.cat_string = strzone(str);
56  #undef SLIST_CATEGORY
57 
60 }
#define SLIST_CATEGORIES
Definition: serverlist.qh:152
void SL_ProcessCategoryOverrides(.string override_field_string,.float override_field)
Definition: serverlist.qc:15
entity() spawn
string cat_enoverride_string
Definition: serverlist.qh:142
string cat_dioverride_string
Definition: serverlist.qh:143
float cat_enoverride
Definition: serverlist.qh:144
float cat_dioverride
Definition: serverlist.qh:145
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RetrieveCategoryEnt()

entity RetrieveCategoryEnt ( float  catnum)

◆ ServerList_Categories_Click()

void ServerList_Categories_Click ( entity  box,
entity  me 
)

Definition at line 667 of file serverlist.qc.

References autocvar_menu_slist_categories, and REFRESHSERVERLIST_RESORT.

668 {
670  me.refreshServerList(me, REFRESHSERVERLIST_RESORT);
671 
672  me.ipAddressBox.setText(me.ipAddressBox, "");
673  me.ipAddressBox.cursorPos = 0;
674  me.ipAddressBoxFocused = -1;
675 }
SLIST_FIELDS float autocvar_menu_slist_categories
Definition: serverlist.qh:110
const float REFRESHSERVERLIST_RESORT
Definition: serverlist.qh:121

◆ ServerList_Connect_Click()

void ServerList_Connect_Click ( entity  btn,
entity  me 
)

Definition at line 767 of file serverlist.qc.

References localcmd.

Referenced by XonoticServerList_doubleClickListBoxItem(), and XonoticServerList_keyDown().

768 {
769  if (me.ipAddressBox.text != "")
770  localcmd(sprintf("connect %s\n", me.ipAddressBox.text));
771 }
+ Here is the caller graph for this function:

◆ ServerList_Favorite_Click()

void ServerList_Favorite_Click ( entity  btn,
entity  me 
)

Definition at line 772 of file serverlist.qc.

References m_play_click_sound(), and MENU_SOUND_SELECT.

773 {
774  string addr = this.ipAddressBox.text;
775  string ipstr = netaddress_resolve(addr, 26000);
776  if (ipstr == "") return;
778  this.toggleFavorite(this, addr);
779  this.ipAddressBoxFocused = -1;
780 }
+ Here is the call graph for this function:

◆ ServerList_Filter_Change()

void ServerList_Filter_Change ( entity  box,
entity  me 
)

Definition at line 656 of file serverlist.qc.

References REFRESHSERVERLIST_REFILTER, strfree, and strzone().

657 {
658  strfree(me.filterString);
659  if(box.text != "")
660  me.filterString = strzone(box.text);
661  me.refreshServerList(me, REFRESHSERVERLIST_REFILTER);
662 
663  me.ipAddressBox.setText(me.ipAddressBox, "");
664  me.ipAddressBox.cursorPos = 0;
665  me.ipAddressBoxFocused = -1;
666 }
const float REFRESHSERVERLIST_REFILTER
Definition: serverlist.qh:122
#define strfree(this)
Definition: string.qh:56
+ Here is the call graph for this function:

◆ ServerList_Info_Click()

void ServerList_Info_Click ( entity  btn,
entity  me 
)

Definition at line 781 of file serverlist.qc.

References boxToGlobal(), boxToGlobalSize(), DialogOpenButton_Click_withCoords(), eX, eY, main, and vector().

782 {
783  if (me.nItems != 0)
784  main.serverInfoDialog.loadServerInfo(main.serverInfoDialog, me.selectedItem);
785 
786  float thisPos = me.getItemStart(me, me.selectedItem);
787  float thisHeight = me.getItemHeight(me, me.selectedItem);
788  vector org = boxToGlobal(eY * (thisPos - me.scrollPos), me.origin, me.size);
789  vector sz = boxToGlobalSize(eY * thisHeight + eX * (1 - me.controlWidth), me.size);
790  DialogOpenButton_Click_withCoords(me, main.serverInfoDialog, org, sz);
791 }
const vector eY
Definition: vector.qh:45
void DialogOpenButton_Click_withCoords(entity button, entity tab, vector theOrigin, vector theSize)
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const vector eX
Definition: vector.qh:44
+ Here is the call graph for this function:

◆ ServerList_ShowEmpty_Click()

void ServerList_ShowEmpty_Click ( entity  box,
entity  me 
)

Definition at line 676 of file serverlist.qc.

References REFRESHSERVERLIST_REFILTER.

677 {
678  box.setChecked(box, me.filterShowEmpty = !me.filterShowEmpty);
679  me.refreshServerList(me, REFRESHSERVERLIST_REFILTER);
680 
681  me.ipAddressBox.setText(me.ipAddressBox, "");
682  me.ipAddressBox.cursorPos = 0;
683  me.ipAddressBoxFocused = -1;
684 }
const float REFRESHSERVERLIST_REFILTER
Definition: serverlist.qh:122

◆ ServerList_ShowFull_Click()

void ServerList_ShowFull_Click ( entity  box,
entity  me 
)

Definition at line 685 of file serverlist.qc.

References REFRESHSERVERLIST_REFILTER.

686 {
687  box.setChecked(box, me.filterShowFull = !me.filterShowFull);
688  me.refreshServerList(me, REFRESHSERVERLIST_REFILTER);
689 
690  me.ipAddressBox.setText(me.ipAddressBox, "");
691  me.ipAddressBox.cursorPos = 0;
692  me.ipAddressBoxFocused = -1;
693 }
const float REFRESHSERVERLIST_REFILTER
Definition: serverlist.qh:122

◆ ServerList_ShowLaggy_Click()

void ServerList_ShowLaggy_Click ( entity  box,
entity  me 
)

Definition at line 694 of file serverlist.qc.

References REFRESHSERVERLIST_REFILTER.

695 {
696  box.setChecked(box, me.filterShowLaggy = !me.filterShowLaggy);
697  me.refreshServerList(me, REFRESHSERVERLIST_REFILTER);
698 
699  me.ipAddressBox.setText(me.ipAddressBox, "");
700  me.ipAddressBox.cursorPos = 0;
701  me.ipAddressBoxFocused = -1;
702 }
const float REFRESHSERVERLIST_REFILTER
Definition: serverlist.qh:122

◆ ServerList_Update_favoriteButton()

void ServerList_Update_favoriteButton ( entity  btn,
entity  me 
)

Definition at line 257 of file serverlist.qc.

References entity(), IsFavorite, and ZCTX.

Referenced by XonoticServerList_draw().

258 {
259  entity e = me.favoriteButton;
260  if(IsFavorite(me.ipAddressBox.text))
261  {
262  e.setText(e, ZCTX(_("SERVER^Remove favorite")));
263  setZonedTooltip(e, _("Remove the currently highlighted server from bookmarks"), string_null);
264  }
265  else
266  {
267  e.setText(e, ZCTX(_("SERVER^Favorite")));
268  setZonedTooltip(e, _("Bookmark the currently highlighted server so that it's faster to find in the future"), string_null);
269  }
270 }
string string_null
Definition: nil.qh:9
entity() spawn
#define IsFavorite(srv)
Definition: serverlist.qc:9
#define ZCTX(s)
Definition: i18n.qh:68
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ autocvar_menu_slist_categories

SLIST_FIELDS float autocvar_menu_slist_categories

◆ autocvar_menu_slist_categories_onlyifmultiple

float autocvar_menu_slist_categories_onlyifmultiple

Definition at line 111 of file serverlist.qh.

Referenced by XonoticServerList_draw().

◆ autocvar_menu_slist_maxping

float autocvar_menu_slist_maxping = 300

Definition at line 114 of file serverlist.qh.

Referenced by XonoticServerList_refreshServerList().

◆ autocvar_menu_slist_modimpurity

float autocvar_menu_slist_modimpurity

Definition at line 113 of file serverlist.qh.

Referenced by CategoryForEntry().

◆ autocvar_menu_slist_purethreshold

float autocvar_menu_slist_purethreshold

Definition at line 112 of file serverlist.qh.

Referenced by CategoryForEntry().

◆ autocvar_menu_slist_recommendations

float autocvar_menu_slist_recommendations

Definition at line 115 of file serverlist.qh.

Referenced by CategoryForEntry().

◆ autocvar_menu_slist_recommendations_maxping

float autocvar_menu_slist_recommendations_maxping

Definition at line 116 of file serverlist.qh.

Referenced by CategoryForEntry().

◆ autocvar_menu_slist_recommendations_minfreeslots

float autocvar_menu_slist_recommendations_minfreeslots

Definition at line 117 of file serverlist.qh.

Referenced by CategoryForEntry().

◆ autocvar_menu_slist_recommendations_minhumans

float autocvar_menu_slist_recommendations_minhumans

Definition at line 118 of file serverlist.qh.

Referenced by CategoryForEntry().

◆ autocvar_menu_slist_recommendations_purethreshold

float autocvar_menu_slist_recommendations_purethreshold

Definition at line 119 of file serverlist.qh.

Referenced by CategoryForEntry().

◆ cat_dioverride

float cat_dioverride

Definition at line 145 of file serverlist.qh.

Referenced by RegisterSLCategories().

◆ cat_dioverride_string

string cat_dioverride_string

Definition at line 143 of file serverlist.qh.

Referenced by RegisterSLCategories().

◆ cat_enoverride

float cat_enoverride

Definition at line 144 of file serverlist.qh.

Referenced by RegisterSLCategories().

◆ cat_enoverride_string

string cat_enoverride_string

Definition at line 142 of file serverlist.qh.

Referenced by RegisterSLCategories().

◆ cat_name

string cat_name

Definition at line 140 of file serverlist.qh.

Referenced by SL_ProcessCategoryOverrides().

◆ cat_string

string cat_string

Definition at line 141 of file serverlist.qh.

◆ categories

entity categories[MAX_CATEGORIES]

Definition at line 138 of file serverlist.qh.

Referenced by RetrieveCategoryEnt(), and SL_ProcessCategoryOverrides().

◆ category_draw_count

◆ category_ent_count

int category_ent_count

◆ CATEGORY_FIRST

const int CATEGORY_FIRST = 1

Definition at line 137 of file serverlist.qh.

◆ category_item

◆ category_name

int category_name[MAX_CATEGORIES]

Definition at line 148 of file serverlist.qh.

Referenced by XonoticServerList_draw(), and XonoticServerList_drawListBoxItem().

◆ MAX_CATEGORIES

const int MAX_CATEGORIES = 9

Definition at line 136 of file serverlist.qh.

◆ REFRESHSERVERLIST_ASK

const float REFRESHSERVERLIST_ASK = 2

◆ REFRESHSERVERLIST_REFILTER

◆ REFRESHSERVERLIST_RESET

const float REFRESHSERVERLIST_RESET = 3

Definition at line 124 of file serverlist.qh.

Referenced by XonoticServerList_draw(), and XonoticServerList_refreshServerList().

◆ REFRESHSERVERLIST_RESORT

const float REFRESHSERVERLIST_RESORT = 0