Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
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)
#define SLIST_FIELD(suffix, name)
#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_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")))
ERASEABLE string CTX(string s)
Definition i18n.qh:45
#define SLIST_CATEGORY(name, enoverride, dioverride, str)

Definition at line 150 of file serverlist.qh.

150#define SLIST_CATEGORIES \
151 SLIST_CATEGORY(CAT_FAVORITED, "", "", CTX(_("SLCAT^Favorites"))) \
152 SLIST_CATEGORY(CAT_RECOMMENDED, "", "", CTX(_("SLCAT^Recommended"))) \
153 SLIST_CATEGORY(CAT_NORMAL, "", "CAT_SERVERS", CTX(_("SLCAT^Normal Servers"))) \
154 SLIST_CATEGORY(CAT_SERVERS, "CAT_NORMAL", "CAT_SERVERS", CTX(_("SLCAT^Servers"))) \
155 SLIST_CATEGORY(CAT_XPM, "CAT_NORMAL", "CAT_SERVERS", CTX(_("SLCAT^Competitive Mode"))) \
156 SLIST_CATEGORY(CAT_MODIFIED, "", "CAT_SERVERS", CTX(_("SLCAT^Modified Servers"))) \
157 SLIST_CATEGORY(CAT_OVERKILL, "", "CAT_SERVERS", CTX(_("SLCAT^Overkill"))) \
158 SLIST_CATEGORY(CAT_INSTAGIB, "", "CAT_SERVERS", CTX(_("SLCAT^InstaGib"))) \
159 SLIST_CATEGORY(CAT_DEFRAG, "", "CAT_SERVERS", CTX(_("SLCAT^Defrag Mode")))

Referenced by RegisterSLCategories().

◆ SLIST_CATEGORY

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

Definition at line 162 of file serverlist.qh.

162#define SLIST_CATEGORY(name,enoverride,dioverride,str) \
163 int name; \
164 string SLIST_CATEGORY_AUTOCVAR(name) = enoverride;

◆ SLIST_CATEGORY_AUTOCVAR

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

Definition at line 161 of file serverlist.qh.

◆ SLIST_FIELD

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

Definition at line 105 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 at line 87 of file serverlist.qh.

87#define SLIST_FIELDS \
88 SLIST_FIELD(CNAME, "cname") \
89 SLIST_FIELD(PING, "ping") \
90 SLIST_FIELD(GAME, "game") \
91 SLIST_FIELD(MOD, "mod") \
92 SLIST_FIELD(MAP, "map") \
93 SLIST_FIELD(NAME, "name") \
94 SLIST_FIELD(MAXPLAYERS, "maxplayers") \
95 SLIST_FIELD(NUMPLAYERS, "numplayers") \
96 SLIST_FIELD(NUMHUMANS, "numhumans") \
97 SLIST_FIELD(NUMBOTS, "numbots") \
98 SLIST_FIELD(PROTOCOL, "protocol") \
99 SLIST_FIELD(FREESLOTS, "freeslots") \
100 SLIST_FIELD(PLAYERS, "players") \
101 SLIST_FIELD(QCSTATUS, "qcstatus") \
102 SLIST_FIELD(CATEGORY, "category") \
103 SLIST_FIELD(ISFAVORITE, "isfavorite")

Referenced by XonoticServerList_configureXonoticServerList().

Function Documentation

◆ CategoryForEntry()

◆ CategoryOverride()

float CategoryOverride ( float cat)

◆ IsServerInList()

float IsServerInList ( string list,
string srv )

Definition at line 76 of file serverlist.qc.

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
#define strlen
#define tokenize_console
string substring(string s, float start, float length)
string argv(float n)

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

◆ m_gethostcachecategory()

float m_gethostcachecategory ( float entry)

Definition at line 13 of file serverlist.qc.

13{ return CategoryOverride(CategoryForEntry(entry)); }
int CategoryForEntry(int entry)
int CategoryOverride(int cat)

References CategoryForEntry(), and CategoryOverride().

◆ makeXonoticServerList()

entity makeXonoticServerList ( )

Definition at line 273 of file serverlist.qc.

274{
275 entity me;
277 me.configureXonoticServerList(me);
278 return me;
279}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define NEW(cname,...)
Definition oo.qh:117

References entity(), and NEW.

Referenced by XonoticServerList::getItemHeight(), and XonoticServerListTab_fill().

◆ RegisterSLCategories()

void RegisterSLCategories ( )

Definition at line 44 of file serverlist.qc.

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}
void SL_ProcessCategoryOverrides(.string override_field_string,.float override_field)
Definition serverlist.qc:15
float cat_enoverride
#define SLIST_CATEGORIES
string cat_enoverride_string
string cat_dioverride_string
float cat_dioverride

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

Referenced by XonoticServerList::getItemHeight(), and m_init().

◆ RetrieveCategoryEnt()

entity RetrieveCategoryEnt ( float catnum)

References entity().

◆ ServerList_Categories_Click()

void ServerList_Categories_Click ( entity box,
entity me )

Definition at line 666 of file serverlist.qc.

667{
669 me.refreshServerList(me, REFRESHSERVERLIST_RESORT);
670
671 me.ipAddressBox.setText(me.ipAddressBox, "");
672 me.ipAddressBox.cursorPos = 0;
673 me.ipAddressBoxFocused = -1;
674}
const float REFRESHSERVERLIST_RESORT
SLIST_FIELDS float autocvar_menu_slist_categories

References autocvar_menu_slist_categories, entity(), and REFRESHSERVERLIST_RESORT.

Referenced by CategoryForEntry(), and XonoticServerListTab_fill().

◆ ServerList_Connect_Click()

void ServerList_Connect_Click ( entity btn,
entity me )

Definition at line 767 of file serverlist.qc.

768{
769 if (me.ipAddressBox.text != "")
770 localcmd(sprintf("connect %s\n", me.ipAddressBox.text));
771}
void localcmd(string command,...)

References entity(), and localcmd().

Referenced by CategoryForEntry(), XonoticServerList_doubleClickListBoxItem(), XonoticServerList_keyDown(), and XonoticServerListTab_fill().

◆ ServerList_Favorite_Click()

void ServerList_Favorite_Click ( entity btn,
entity me )

Definition at line 772 of file serverlist.qc.

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}
void m_play_click_sound(string soundfile)
Definition menu.qc:1106
const string MENU_SOUND_SELECT
Definition menu.qh:54

References entity(), m_play_click_sound(), and MENU_SOUND_SELECT.

Referenced by CategoryForEntry(), and XonoticServerListTab_fill().

◆ ServerList_Filter_Change()

void ServerList_Filter_Change ( entity box,
entity me )

Definition at line 655 of file serverlist.qc.

656{
657 strfree(me.filterString);
658 if(box.text != "")
659 me.filterString = strzone(box.text);
660 me.refreshServerList(me, REFRESHSERVERLIST_REFILTER);
661
662 me.ipAddressBox.setText(me.ipAddressBox, "");
663 me.ipAddressBox.cursorPos = 0;
664 me.ipAddressBoxFocused = -1;
665}
string strzone(string s)
const float REFRESHSERVERLIST_REFILTER
#define strfree(this)
Definition string.qh:59

References entity(), REFRESHSERVERLIST_REFILTER, strfree, and strzone().

Referenced by CategoryForEntry(), and XonoticServerListTab_fill().

◆ ServerList_Info_Click()

void ServerList_Info_Click ( entity btn,
entity me )

Definition at line 781 of file serverlist.qc.

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}
#define main
Definition _all.inc:202
vector boxToGlobalSize(vector v, vector theScale)
Definition draw.qc:53
vector boxToGlobal(vector v, vector theOrigin, vector theScale)
Definition draw.qc:45
void DialogOpenButton_Click_withCoords(entity button, entity tab, vector theOrigin, vector theSize)
vector
Definition self.qh:92
vector org
Definition self.qh:92
const vector eY
Definition vector.qh:45
const vector eX
Definition vector.qh:44

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

Referenced by CategoryForEntry(), and XonoticServerListTab_fill().

◆ ServerList_ShowEmpty_Click()

void ServerList_ShowEmpty_Click ( entity box,
entity me )

Definition at line 675 of file serverlist.qc.

676{
677 box.setChecked(box, me.filterShowEmpty = !me.filterShowEmpty);
678 me.refreshServerList(me, REFRESHSERVERLIST_REFILTER);
679
680 me.ipAddressBox.setText(me.ipAddressBox, "");
681 me.ipAddressBox.cursorPos = 0;
682 me.ipAddressBoxFocused = -1;
683}

References entity(), and REFRESHSERVERLIST_REFILTER.

Referenced by CategoryForEntry(), and XonoticServerListTab_fill().

◆ ServerList_ShowFull_Click()

void ServerList_ShowFull_Click ( entity box,
entity me )

Definition at line 684 of file serverlist.qc.

685{
686 box.setChecked(box, me.filterShowFull = !me.filterShowFull);
687 me.refreshServerList(me, REFRESHSERVERLIST_REFILTER);
688
689 me.ipAddressBox.setText(me.ipAddressBox, "");
690 me.ipAddressBox.cursorPos = 0;
691 me.ipAddressBoxFocused = -1;
692}

References entity(), and REFRESHSERVERLIST_REFILTER.

Referenced by CategoryForEntry(), and XonoticServerListTab_fill().

◆ ServerList_ShowLaggy_Click()

void ServerList_ShowLaggy_Click ( entity box,
entity me )

Definition at line 693 of file serverlist.qc.

694{
695 box.setChecked(box, me.filterShowLaggy = !me.filterShowLaggy);
696 me.refreshServerList(me, REFRESHSERVERLIST_REFILTER);
697
698 me.ipAddressBox.setText(me.ipAddressBox, "");
699 me.ipAddressBox.cursorPos = 0;
700 me.ipAddressBoxFocused = -1;
701}

References entity(), and REFRESHSERVERLIST_REFILTER.

Referenced by CategoryForEntry(), and XonoticServerListTab_fill().

◆ ServerList_Update_favoriteButton()

void ServerList_Update_favoriteButton ( entity btn,
entity me )

Definition at line 258 of file serverlist.qc.

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

References entity(), IsFavorite, setZonedTooltip(), string_null, and ZCTX.

Referenced by CategoryForEntry(), XonoticServerList_draw(), and XonoticServerListTab_fill().

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 110 of file serverlist.qh.

Referenced by XonoticServerList_draw().

◆ autocvar_menu_slist_maxping

float autocvar_menu_slist_maxping = 300

Definition at line 112 of file serverlist.qh.

Referenced by XonoticServerList_refreshServerList().

◆ autocvar_menu_slist_modimpurity

float autocvar_menu_slist_modimpurity

Definition at line 111 of file serverlist.qh.

Referenced by CategoryForEntry().

◆ autocvar_menu_slist_recommendations

float autocvar_menu_slist_recommendations

Definition at line 113 of file serverlist.qh.

Referenced by CategoryForEntry().

◆ autocvar_menu_slist_recommendations_maxping

float autocvar_menu_slist_recommendations_maxping

Definition at line 114 of file serverlist.qh.

Referenced by CategoryForEntry().

◆ autocvar_menu_slist_recommendations_minfreeslots

float autocvar_menu_slist_recommendations_minfreeslots

Definition at line 115 of file serverlist.qh.

Referenced by CategoryForEntry().

◆ autocvar_menu_slist_recommendations_minhumans

float autocvar_menu_slist_recommendations_minhumans

Definition at line 116 of file serverlist.qh.

Referenced by CategoryForEntry().

◆ autocvar_menu_slist_recommendations_purethreshold

float autocvar_menu_slist_recommendations_purethreshold

Definition at line 117 of file serverlist.qh.

Referenced by CategoryForEntry().

◆ cat_dioverride

float cat_dioverride

Definition at line 143 of file serverlist.qh.

Referenced by RegisterSLCategories().

◆ cat_dioverride_string

string cat_dioverride_string

Definition at line 141 of file serverlist.qh.

Referenced by RegisterSLCategories().

◆ cat_enoverride

float cat_enoverride

Definition at line 142 of file serverlist.qh.

Referenced by RegisterSLCategories().

◆ cat_enoverride_string

string cat_enoverride_string

Definition at line 140 of file serverlist.qh.

Referenced by RegisterSLCategories().

◆ cat_name

string cat_name

Definition at line 138 of file serverlist.qh.

Referenced by SL_ProcessCategoryOverrides().

◆ cat_string

string cat_string

Definition at line 139 of file serverlist.qh.

◆ categories

entity categories[MAX_CATEGORIES]

Definition at line 136 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 135 of file serverlist.qh.

◆ category_item

◆ category_name

int category_name[MAX_CATEGORIES]

Definition at line 146 of file serverlist.qh.

Referenced by XonoticServerList_draw(), and XonoticServerList_drawListBoxItem().

◆ MAX_CATEGORIES

const int MAX_CATEGORIES = 9

Definition at line 134 of file serverlist.qh.

◆ REFRESHSERVERLIST_ASK

const float REFRESHSERVERLIST_ASK = 2

◆ REFRESHSERVERLIST_REFILTER

◆ REFRESHSERVERLIST_RESET

const float REFRESHSERVERLIST_RESET = 3

Definition at line 122 of file serverlist.qh.

Referenced by XonoticServerList_draw(), and XonoticServerList_refreshServerList().

◆ REFRESHSERVERLIST_RESORT

const float REFRESHSERVERLIST_RESORT = 0