void XonoticPlayerList_setPlayerList(entity me, string plist) { float buf,i,n; string s; buf = buf_create(); me.nItems = tokenizebyseparator(plist, "\n"); for(i = 0; i < me.nItems; ++i) { bufstr_set(buf, i * PLAYERPARM_COUNT + PLAYERPARM_NAME, argv(i)); // -666 100 "^4Nex ^2Player" } for(i = 0; i < me.nItems; ++i) { s = bufstr_get(buf, i * PLAYERPARM_COUNT + PLAYERPARM_NAME); n = tokenize_console(s); if(n == 4) { bufstr_set(buf, i * PLAYERPARM_COUNT + PLAYERPARM_SCORE, argv(0)); // -666 bufstr_set(buf, i * PLAYERPARM_COUNT + PLAYERPARM_PING, argv(1)); // 100 bufstr_set(buf, i * PLAYERPARM_COUNT + PLAYERPARM_TEAM, argv(2)); // 0 for spec, else 1, 2, 3, 4 bufstr_set(buf, i * PLAYERPARM_COUNT + PLAYERPARM_NAME, argv(3)); // ^4Nex ^2Player } else { bufstr_set(buf, i * PLAYERPARM_COUNT + PLAYERPARM_SCORE, argv(0)); // -666 bufstr_set(buf, i * PLAYERPARM_COUNT + PLAYERPARM_PING, argv(1)); // 100 bufstr_set(buf, i * PLAYERPARM_COUNT + PLAYERPARM_TEAM, "-1"); bufstr_set(buf, i * PLAYERPARM_COUNT + PLAYERPARM_NAME, argv(2)); // ^4Nex ^2Player } } me.playerList = buf; }
void XonoticPlayerModelSelector_draw(entity me) { float i, n; vector o; if (me.numModels <= 0) { draw_CenterText('0.5 0.5 0', _("<no model found>"), me.realFontSize, '1 1 1', 0.6, FALSE); return; } SUPER(XonoticPlayerModelSelector).draw(me); // draw text on the image, handle \n in the description draw_beginBoldFont(); draw_CenterText('0.5 0 0', me.currentModelTitle, me.realFontSize * (me.titleFontSize / me.fontSize), SKINCOLOR_MODELTITLE, SKINALPHA_MODELTITLE, FALSE); draw_endBoldFont(); o = '0.5 1 0' - eY * me.realFontSize_y * ((n = tokenizebyseparator(me.currentModelDescription, "\n")) + 0.5); for(i = 0; i < n; ++i) { draw_CenterText(o, argv(i), me.realFontSize, '1 1 1', 1, FALSE); o += eY * me.realFontSize_y; } }
void saveCvarsNexuizResolutionSlider(entity me) { if(me.value >= 0 || me.value < me.nValues) { tokenizebyseparator(me.getIdentifier(me), "x"); cvar_set("menu_vid_width", argv(0)); cvar_set("menu_vid_height", argv(1)); } }
void rewrapCampaign(float w, float l0, float emptyheight) { float i, j; float n, l; string r, s; for(i = 0; i < campaign_entries; ++i) { l = l0; if(campaign_longdesc_wrapped[i]) strunzone(campaign_longdesc_wrapped[i]); n = tokenizebyseparator(campaign_longdesc[i], "\n"); r = ""; for(j = 0; j < n; ++j) { s = argv(j); if(s == "") { l -= emptyheight; r = strcat(r, "\n"); continue; } getWrappedLine_remaining = s; while(getWrappedLine_remaining) { s = getWrappedLine(w, draw_TextWidth_WithoutColors); if(--l < 0) goto toolong; r = strcat(r, s, "\n"); } } goto nottoolong; :toolong while(substring(r, strlen(r) - 1, 1) == "\n") r = substring(r, 0, strlen(r) - 1); r = strcat(r, "...\n"); :nottoolong
void loadServerInfoNexuizServerInfoDialog(entity me, float i, entity slist) { float m; string s, typestr, versionstr, rmversion, numh, maxp; var ip = gethostcachestring(SLIST_FIELD_CNAME, i); SLIST_FIELD_CNAME = gethostcacheindexforkey("cname"); me.currentServerCName = strzone(ip); me.cnameLabel.setText(me.cnameLabel, me.currentServerCName); SLIST_FIELD_NAME = gethostcacheindexforkey("name"); var clrname = db_get(slist.alt_hostnames_db, ip); if(clrname == "") { me.currentServerName = strzone(gethostcachestring(SLIST_FIELD_NAME, i)); me.nameLabel.allowColors = FALSE; } else { me.currentServerName = strzone(clrname); me.nameLabel.allowColors = TRUE; } me.nameLabel.setText(me.nameLabel, me.currentServerName); SLIST_FIELD_QCSTATUS = gethostcacheindexforkey("qcstatus"); s = gethostcachestring(SLIST_FIELD_QCSTATUS, i); m = tokenizebyseparator(s, ":"); if(m > 1) { typestr = argv (0); versionstr = argv(1); } else { typestr = "N/A"; versionstr = "N/A"; } m = tokenizebyseparator(versionstr, "_rm-"); rmversion = argv(1); me.currentServerType = gametype_Name_to_LongName(typestr); //strzone(typestr); me.typeLabel.setText(me.typeLabel, me.currentServerType); SLIST_FIELD_MAP = gethostcacheindexforkey("map"); me.currentServerMap = strzone(gethostcachestring(SLIST_FIELD_MAP, i)); me.mapLabel.setText(me.mapLabel, me.currentServerMap); SLIST_FIELD_PLAYERS = gethostcacheindexforkey("players"); me.currentServerPlayers = strzone(gethostcachestring(SLIST_FIELD_PLAYERS, i)); me.rawPlayerList.setPlayerList(me.rawPlayerList, me.currentServerPlayers); SLIST_FIELD_NUMHUMANS = gethostcacheindexforkey("numhumans"); numh = ftos(gethostcachenumber(SLIST_FIELD_NUMHUMANS, i)); SLIST_FIELD_MAXPLAYERS = gethostcacheindexforkey("maxplayers"); maxp = ftos(gethostcachenumber(SLIST_FIELD_MAXPLAYERS, i)); me.currentServerNumPlayers = strzone(strcat(numh,"/",maxp)); me.numPlayersLabel.setText(me.numPlayersLabel, me.currentServerNumPlayers); SLIST_FIELD_NUMBOTS = gethostcacheindexforkey("numbots"); s = ftos(gethostcachenumber(SLIST_FIELD_NUMBOTS, i)); me.currentServerNumBots = strzone(s); me.numBotsLabel.setText(me.numBotsLabel, me.currentServerNumBots); SLIST_FIELD_MOD = gethostcacheindexforkey("mod"); me.currentServerMod = strzone(gethostcachestring(SLIST_FIELD_MOD, i)); me.modLabel.setText(me.modLabel, me.currentServerMod); me.currentServerVersion = strzone(versionstr); me.versionLabel.setText(me.versionLabel, me.currentServerVersion); me.currentServerRMLabel = strzone(if(rmversion && rmversion != "") strcat("This server is running RocketMinsta ", rmversion) else strcat("This server is running Nexuiz ", versionstr)); me.rmLabel.setText(me.rmLabel, me.currentServerRMLabel); SLIST_FIELD_PING = gethostcacheindexforkey("ping"); s = ftos(gethostcachenumber(SLIST_FIELD_PING, i)); me.currentServerPing = strzone(s); me.pingLabel.setText(me.pingLabel, me.currentServerPing); }
void XonoticServerInfoDialog_loadServerInfo(entity me, float i) { float m, pure, freeslots, j, numh, maxp, numb; string s, typestr, versionstr, k, v; if(me.currentServerName) strunzone(me.currentServerName); me.currentServerName = string_null; if(me.currentServerCName) strunzone(me.currentServerCName); me.currentServerCName = string_null; if(me.currentServerType) strunzone(me.currentServerType); me.currentServerType = string_null; if(me.currentServerMap) strunzone(me.currentServerMap); me.currentServerMap = string_null; if(me.currentServerPlayers) strunzone(me.currentServerPlayers); me.currentServerPlayers = string_null; if(me.currentServerNumPlayers) strunzone(me.currentServerNumPlayers); me.currentServerNumPlayers = string_null; if(me.currentServerNumBots) strunzone(me.currentServerNumBots); me.currentServerNumBots = string_null; if(me.currentServerMod) strunzone(me.currentServerMod); me.currentServerMod = string_null; if(me.currentServerVersion) strunzone(me.currentServerVersion); me.currentServerVersion = string_null; if(me.currentServerPing) strunzone(me.currentServerPing); me.currentServerPing = string_null; if(me.currentServerKey) strunzone(me.currentServerKey); me.currentServerKey = string_null; if(me.currentServerID) strunzone(me.currentServerID); me.currentServerID = string_null; // not zoned! //if(me.currentServerEncrypt) // strunzone(me.currentServerEncrypt); //me.currentServerEncrypt = string_null; if(me.currentServerPure) strunzone(me.currentServerPure); me.currentServerPure = string_null; SLIST_FIELD_NAME = gethostcacheindexforkey("name"); me.currentServerName = strzone(gethostcachestring(SLIST_FIELD_NAME, i)); me.nameLabel.setText(me.nameLabel, me.currentServerName); SLIST_FIELD_CNAME = gethostcacheindexforkey("cname"); me.currentServerCName = strzone(gethostcachestring(SLIST_FIELD_CNAME, i)); me.cnameLabel.setText(me.cnameLabel, me.currentServerCName); pure = -1; typestr = _("N/A"); versionstr = _("N/A"); SLIST_FIELD_QCSTATUS = gethostcacheindexforkey("qcstatus"); s = gethostcachestring(SLIST_FIELD_QCSTATUS, i); m = tokenizebyseparator(s, ":"); if(m >= 2) { typestr = argv(0); versionstr = argv(1); } freeslots = -1; for(j = 2; j < m; ++j) { if(argv(j) == "") break; k = substring(argv(j), 0, 1); v = substring(argv(j), 1, -1); if(k == "P") pure = stof(v); else if(k == "S") freeslots = stof(v); } me.currentServerType = strzone(typestr); me.typeLabel.setText(me.typeLabel, me.currentServerType); SLIST_FIELD_MAP = gethostcacheindexforkey("map"); me.currentServerMap = strzone(gethostcachestring(SLIST_FIELD_MAP, i)); me.mapLabel.setText(me.mapLabel, me.currentServerMap); SLIST_FIELD_PLAYERS = gethostcacheindexforkey("players"); me.currentServerPlayers = strzone(gethostcachestring(SLIST_FIELD_PLAYERS, i)); me.rawPlayerList.setPlayerList(me.rawPlayerList, me.currentServerPlayers); SLIST_FIELD_NUMHUMANS = gethostcacheindexforkey("numhumans"); numh = gethostcachenumber(SLIST_FIELD_NUMHUMANS, i); SLIST_FIELD_MAXPLAYERS = gethostcacheindexforkey("maxplayers"); maxp = gethostcachenumber(SLIST_FIELD_MAXPLAYERS, i); SLIST_FIELD_NUMBOTS = gethostcacheindexforkey("numbots"); numb = gethostcachenumber(SLIST_FIELD_NUMBOTS, i); if(freeslots < 0) freeslots = maxp - numh - numb; me.currentServerNumPlayers = strzone(sprintf(_("%d/%d, %d free player slots"), numh, maxp, freeslots)); me.numPlayersLabel.setText(me.numPlayersLabel, me.currentServerNumPlayers); s = ftos(numb); me.currentServerNumBots = strzone(s); me.numBotsLabel.setText(me.numBotsLabel, me.currentServerNumBots); SLIST_FIELD_MOD = gethostcacheindexforkey("mod"); me.currentServerMod = strzone(gethostcachestring(SLIST_FIELD_MOD, i)); me.modLabel.setText(me.modLabel, me.currentServerMod); me.currentServerVersion = strzone(versionstr); me.versionLabel.setText(me.versionLabel, me.currentServerVersion); me.currentServerPure = ((pure < 0) ? "N/A" : (pure == 0) ? _("Official settings") : sprintf(_("%d modified settings"), pure)); me.currentServerPure = strzone(me.currentServerPure); me.pureLabel.setText(me.pureLabel, me.currentServerPure); SLIST_FIELD_PING = gethostcacheindexforkey("ping"); s = ftos(gethostcachenumber(SLIST_FIELD_PING, i)); me.currentServerPing = strzone(s); me.pingLabel.setText(me.pingLabel, me.currentServerPing); s = crypto_getidfp(me.currentServerCName); if not(s) s = _("N/A"); me.currentServerID = strzone(s); me.idLabel.setText(me.idLabel, me.currentServerID); s = crypto_getkeyfp(me.currentServerCName); if not(s) s = _("N/A"); me.currentServerKey = strzone(s); me.keyLabel.setText(me.keyLabel, me.currentServerKey); s = crypto_getencryptlevel(me.currentServerCName); if(s == "") { if(cvar("crypto_aeslevel") >= 3) me.currentServerEncrypt = _("N/A (can't connect)"); else me.currentServerEncrypt = _("N/A"); } else switch(stof(substring(s, 0, 1))) { case 0: if(cvar("crypto_aeslevel") >= 3) me.currentServerEncrypt = _("not supported (can't connect)"); else me.currentServerEncrypt = _("not supported (won't encrypt)"); break; case 1: if(cvar("crypto_aeslevel") >= 2) me.currentServerEncrypt = _("supported (will encrypt)"); else me.currentServerEncrypt = _("supported (won't encrypt)"); break; case 2: if(cvar("crypto_aeslevel") >= 1) me.currentServerEncrypt = _("requested (will encrypt)"); else me.currentServerEncrypt = _("requested (won't encrypt)"); break; case 3: if(cvar("crypto_aeslevel") <= 0) me.currentServerEncrypt = _("required (can't connect)"); else me.currentServerEncrypt = _("required (will encrypt)"); break; } me.encryptLabel.setText(me.encryptLabel, me.currentServerEncrypt); }
void loadServerInfoNexuizServerInfoDialog(entity me, float i) { float m; string s, typestr, versionstr, numh, maxp; SLIST_FIELD_NAME = gethostcacheindexforkey("name"); me.currentServerName = strzone(gethostcachestring(SLIST_FIELD_NAME, i)); me.nameLabel.setText(me.nameLabel, me.currentServerName); SLIST_FIELD_CNAME = gethostcacheindexforkey("cname"); me.currentServerCName = strzone(gethostcachestring(SLIST_FIELD_CNAME, i)); me.cnameLabel.setText(me.cnameLabel, me.currentServerCName); SLIST_FIELD_QCSTATUS = gethostcacheindexforkey("qcstatus"); s = gethostcachestring(SLIST_FIELD_QCSTATUS, i); m = tokenizebyseparator(s, ":"); if(m > 1) { typestr = argv (0); versionstr = argv(1); } else { typestr = "N/A"; versionstr = "N/A"; } me.currentServerType = strzone(typestr); me.typeLabel.setText(me.typeLabel, me.currentServerType); SLIST_FIELD_MAP = gethostcacheindexforkey("map"); me.currentServerMap = strzone(gethostcachestring(SLIST_FIELD_MAP, i)); me.mapLabel.setText(me.mapLabel, me.currentServerMap); SLIST_FIELD_PLAYERS = gethostcacheindexforkey("players"); me.currentServerPlayers = strzone(gethostcachestring(SLIST_FIELD_PLAYERS, i)); me.rawPlayerList.setPlayerList(me.rawPlayerList, me.currentServerPlayers); SLIST_FIELD_NUMHUMANS = gethostcacheindexforkey("numhumans"); numh = ftos(gethostcachenumber(SLIST_FIELD_NUMHUMANS, i)); SLIST_FIELD_MAXPLAYERS = gethostcacheindexforkey("maxplayers"); maxp = ftos(gethostcachenumber(SLIST_FIELD_MAXPLAYERS, i)); me.currentServerNumPlayers = strzone(strcat(numh,"/",maxp)); me.numPlayersLabel.setText(me.numPlayersLabel, me.currentServerNumPlayers); SLIST_FIELD_NUMBOTS = gethostcacheindexforkey("numbots"); s = ftos(gethostcachenumber(SLIST_FIELD_NUMBOTS, i)); me.currentServerNumBots = strzone(s); me.numBotsLabel.setText(me.numBotsLabel, me.currentServerNumBots); SLIST_FIELD_MOD = gethostcacheindexforkey("mod"); me.currentServerMod = strzone(gethostcachestring(SLIST_FIELD_MOD, i)); me.modLabel.setText(me.modLabel, me.currentServerMod); me.currentServerVersion = strzone(versionstr); me.versionLabel.setText(me.versionLabel, me.currentServerVersion); SLIST_FIELD_PING = gethostcacheindexforkey("ping"); s = ftos(gethostcachenumber(SLIST_FIELD_PING, i)); me.currentServerPing = strzone(s); me.pingLabel.setText(me.pingLabel, me.currentServerPing); }
void XonoticServerList_refreshServerList(entity me, float mode) { // 0: just reparametrize // 1: also ask for new servers // 2: clear //print("refresh of type ", ftos(mode), "\n"); /* if(mode == 2) // borken { // clear list localcmd("net_slist\n"); me.needsRefresh = 1; // net_slist kills sort order, so we need to restore it later } else */ { float m, o, i, n; // moin moin string s, typestr, modstr; s = me.filterString; m = strstrofs(s, ":", 0); if(m >= 0) { typestr = substring(s, 0, m); s = substring(s, m + 1, strlen(s) - m - 1); while(substring(s, 0, 1) == " ") s = substring(s, 1, strlen(s) - 1); } else typestr = ""; modstr = cvar_string("menu_slist_modfilter"); m = SLIST_MASK_AND - 1; resethostcachemasks(); // ping: reject negative ping (no idea why this happens in the first place, engine bug) sethostcachemasknumber(++m, SLIST_FIELD_PING, 0, SLIST_TEST_GREATEREQUAL); // show full button if(!me.filterShowFull) { sethostcachemasknumber(++m, SLIST_FIELD_FREESLOTS, 1, SLIST_TEST_GREATEREQUAL); // legacy sethostcachemaskstring(++m, SLIST_FIELD_QCSTATUS, ":S0:", SLIST_TEST_NOTCONTAIN); // g_maxplayers support } // show empty button if(!me.filterShowEmpty) sethostcachemasknumber(++m, SLIST_FIELD_NUMHUMANS, 1, SLIST_TEST_GREATEREQUAL); // gametype filtering if(typestr != "") sethostcachemaskstring(++m, SLIST_FIELD_QCSTATUS, strcat(typestr, ":"), SLIST_TEST_STARTSWITH); // mod filtering if(modstr != "") { if(substring(modstr, 0, 1) == "!") sethostcachemaskstring(++m, SLIST_FIELD_MOD, resolvemod(substring(modstr, 1, strlen(modstr) - 1)), SLIST_TEST_NOTEQUAL); else sethostcachemaskstring(++m, SLIST_FIELD_MOD, resolvemod(modstr), SLIST_TEST_EQUAL); } // server banning n = tokenizebyseparator(_Nex_ExtResponseSystem_BannedServers, " "); for(i = 0; i < n; ++i) if(argv(i) != "") sethostcachemaskstring(++m, SLIST_FIELD_CNAME, argv(i), SLIST_TEST_NOTSTARTSWITH); m = SLIST_MASK_OR - 1; if(s != "") { sethostcachemaskstring(++m, SLIST_FIELD_NAME, s, SLIST_TEST_CONTAINS); sethostcachemaskstring(++m, SLIST_FIELD_MAP, s, SLIST_TEST_CONTAINS); sethostcachemaskstring(++m, SLIST_FIELD_PLAYERS, s, SLIST_TEST_CONTAINS); sethostcachemaskstring(++m, SLIST_FIELD_QCSTATUS, strcat(s, ":"), SLIST_TEST_STARTSWITH); } o = 2; // favorites first if(me.currentSortOrder < 0) o |= 1; // descending sethostcachesort(me.currentSortField, o); resorthostcache(); if(mode >= 1) refreshhostcache(); } }