1 #include "dialog_multiplayer_join_serverinfo.qh"
2 #include <common/mapinfo.qh>
4 #include "tabcontroller.qh"
5 #include "serverlist.qh"
6 #include "playerlist.qh"
8 #include "textlabel.qh"
10 #include "dialog_multiplayer_join_serverinfotab.qh"
11 #include "dialog_multiplayer_join_termsofservice.qh"
14 void XonoticServerInfoDialog_loadServerInfo(entity me, float i)
17 float m, pure_violations, freeslots, numh, maxp, numb, sflags;
18 string s, typestr, versionstr, k, v, modname;
20 // ====================================
21 // First clear and unzone the strings
22 // ====================================
23 strfree(me.currentServerName);
24 strfree(me.currentServerCName);
25 strfree(me.currentServerType);
26 strfree(me.currentServerMap);
27 strfree(me.currentServerPlayers);
28 strfree(me.currentServerNumPlayers);
29 strfree(me.currentServerNumBots);
30 strfree(me.currentServerNumFreeSlots);
31 strfree(me.currentServerMod);
32 strfree(me.currentServerVersion);
34 // strfree(me.currentServerEncrypt);
35 strfree(me.currentServerPure);
36 strfree(me.currentServerKey);
37 strfree(me.currentServerID);
39 // ==========================
40 // Now, fill in the strings
41 // ==========================
42 me.currentServerName = strzone(gethostcachestring(SLIST_FIELD_NAME, i));
43 me.infoTab.nameLabel.setText(me.infoTab.nameLabel, me.currentServerName);
45 me.currentServerCName = strzone(gethostcachestring(SLIST_FIELD_CNAME, i));
46 me.infoTab.cnameLabel.setText(me.infoTab.cnameLabel, me.currentServerCName);
48 pure_available = false;
51 versionstr = _("N/A");
53 s = gethostcachestring(SLIST_FIELD_QCSTATUS, i);
54 m = tokenizebyseparator(s, ":");
63 bool ToSSpecified = false;
64 for(int j = 2; j < m; ++j)
68 k = substring(argv(j), 0, 1);
69 v = substring(argv(j), 1, -1);
72 pure_available = true;
73 pure_violations = stof(v);
90 string downloadurl = v;
91 LOG_INFOF("SERVERTOS DOWNLOADURL: %s", downloadurl);
92 if (downloadurl == "INVALID")
94 me.ToSTab.textBox.setText(me.ToSTab.textBox, _("No Terms of Service specified"));
98 downloadurl = strreplace("|", ":", downloadurl);
99 me.ToSTab.loadToS(me.ToSTab, downloadurl);
106 me.ToSTab.textBox.setText(me.ToSTab.textBox, _("No Terms of Service specified"));
109 #ifdef COMPAT_NO_MOD_IS_XONOTIC
114 s = gethostcachestring(SLIST_FIELD_MOD, i);
116 modname = sprintf("%s (%s)", modname, s);
118 Gametype j = MapInfo_Type_FromString(typestr, false); // try and get the real name of the game type
119 if(j) { typestr = MapInfo_Type_ToText(j); } // only set it if we actually found it
121 me.currentServerType = strzone(typestr);
122 me.infoTab.typeLabel.setText(me.infoTab.typeLabel, me.currentServerType);
124 me.currentServerMap = strzone(gethostcachestring(SLIST_FIELD_MAP, i));
125 me.infoTab.mapLabel.setText(me.infoTab.mapLabel, me.currentServerMap);
127 me.currentServerPlayers = strzone(gethostcachestring(SLIST_FIELD_PLAYERS, i));
128 me.infoTab.rawPlayerList.setPlayerList(me.infoTab.rawPlayerList, me.currentServerPlayers);
130 numh = gethostcachenumber(SLIST_FIELD_NUMHUMANS, i);
131 maxp = gethostcachenumber(SLIST_FIELD_MAXPLAYERS, i);
132 numb = gethostcachenumber(SLIST_FIELD_NUMBOTS, i);
133 me.currentServerNumPlayers = strzone(sprintf("%d/%d", numh, maxp));
134 me.infoTab.numPlayersLabel.setText(me.infoTab.numPlayersLabel, me.currentServerNumPlayers);
137 me.currentServerNumBots = strzone(s);
138 me.infoTab.numBotsLabel.setText(me.infoTab.numBotsLabel, me.currentServerNumBots);
140 if(freeslots < 0) { freeslots = maxp - numh - numb; }
142 me.currentServerNumFreeSlots = strzone(s);
143 me.infoTab.numFreeSlotsLabel.setText(me.infoTab.numFreeSlotsLabel, me.currentServerNumFreeSlots);
145 me.currentServerMod = ((modname == "Xonotic") ? ZCTX(_("MOD^Default")) : modname);
146 me.currentServerMod = strzone(me.currentServerMod);
147 me.infoTab.modLabel.setText(me.infoTab.modLabel, me.currentServerMod);
149 me.currentServerVersion = strzone(versionstr);
150 me.infoTab.versionLabel.setText(me.infoTab.versionLabel, me.currentServerVersion);
152 me.currentServerPure = ((!pure_available) ? _("N/A") : (pure_violations == 0) ? _("Official") : sprintf(_("%d modified"), pure_violations));
153 me.currentServerPure = strzone(me.currentServerPure);
154 me.infoTab.pureLabel.setText(me.infoTab.pureLabel, me.currentServerPure);
156 s = crypto_getencryptlevel(me.currentServerCName);
159 if(cvar("crypto_aeslevel") >= 3)
160 me.currentServerEncrypt = _("N/A (auth library missing, can't connect)");
162 me.currentServerEncrypt = _("N/A (auth library missing)");
164 else switch(stof(substring(s, 0, 1)))
167 if(cvar("crypto_aeslevel") >= 3)
168 me.currentServerEncrypt = _("Not supported (can't connect)");
170 me.currentServerEncrypt = _("Not supported (won't encrypt)");
173 if(cvar("crypto_aeslevel") >= 2)
174 me.currentServerEncrypt = _("Supported (will encrypt)");
176 me.currentServerEncrypt = _("Supported (won't encrypt)");
179 if(cvar("crypto_aeslevel") >= 1)
180 me.currentServerEncrypt = _("Requested (will encrypt)");
182 me.currentServerEncrypt = _("Requested (won't encrypt)");
185 if(cvar("crypto_aeslevel") <= 0)
186 me.currentServerEncrypt = _("Required (can't connect)");
188 me.currentServerEncrypt = _("Required (will encrypt)");
191 me.infoTab.encryptLabel.setText(me.infoTab.encryptLabel, me.currentServerEncrypt);
192 setZonedTooltip(me.infoTab.encryptLabel, _("Use the `crypto_aeslevel` cvar to change your preferences"), string_null);
194 s = crypto_getidfp(me.currentServerCName);
195 if (!s) { s = _("N/A"); }
196 me.currentServerID = strzone(s);
197 me.infoTab.idLabel.setText(me.infoTab.idLabel, me.currentServerID);
199 s = crypto_getkeyfp(me.currentServerCName);
200 if (!s) { s = _("N/A"); }
201 me.currentServerKey = strzone(s);
202 me.infoTab.keyLabel.setText(me.infoTab.keyLabel, me.currentServerKey);
204 me.currentServerStatsStatus = ((sflags >= 0 && (sflags & SERVERFLAG_PLAYERSTATS)) ? ((sflags & SERVERFLAG_PLAYERSTATS_CUSTOM) ? _("custom stats server") : _("stats enabled")) : _("stats disabled"));
205 me.currentServerStatsStatus = strzone(me.currentServerStatsStatus);
206 me.infoTab.statsLabel.setText(me.infoTab.statsLabel, me.currentServerStatsStatus);
209 void XonoticServerInfoDialog_fill(entity me)
212 mc = makeXonoticTabController(me.rows - 2);
214 me.TD(me, 1, 1, e = mc.makeTabButton(mc, _("Status"), me.infoTab = makeXonoticServerInfoTab()));
215 me.TD(me, 1, 1, e = mc.makeTabButton(mc, _("Terms of Service"), me.ToSTab = makeXonoticServerToSTab()));
218 me.TD(me, me.rows - 2, me.columns, mc);
220 me.gotoRC(me, me.rows - 1, 0);
221 me.TD(me, 1, me.columns/2, e = makeXonoticButton(_("Close"), '0 0 0'));
222 e.onClick = Dialog_Close;
223 e.onClickEntity = me;
224 //me.TD(me, 1, me.columns/3, e = makeXonoticButton("", '0 0 0')); // TODO: Add bookmark button here
225 // e.onClick = ServerList_Favorite_Click;
226 // e.onClickEntity = slist;
227 // slist.favoriteButton = e;
228 me.TD(me, 1, me.columns/2, e = makeXonoticButton(_("Join!"), '0 0 0'));
229 e.onClick = Join_Click;
230 e.onClickEntity = me;
233 void Join_Click(entity btn, entity me)
235 localcmd("connect ", me.currentServerCName, "\n");