diff --git a/readme.md b/readme.md index 8b46ff6..69b3f07 100644 --- a/readme.md +++ b/readme.md @@ -14,6 +14,10 @@ c:\program files (x86)\Steam\SteamApps\workshop\content\282440\539252269 Changelog ========= +Version 2.18 +--- +- fixed /whois when console dump includes timestamps (also using the less spammy /players command now to get player info) + Version 2.17 --- - show warning when the offical UI in web.pak is newer than the currently selected alternative UI diff --git a/source/MainForm.cs b/source/MainForm.cs index df717b3..4e6ae12 100644 --- a/source/MainForm.cs +++ b/source/MainForm.cs @@ -13,7 +13,7 @@ namespace ExtraQL { public partial class MainForm : Form { - public const string Version = "2.17"; + public const string Version = "2.18"; private readonly Config config; private readonly HttpServer server; diff --git a/source/Servlets.cs b/source/Servlets.cs index 6bb4720..acc0e5e 100644 --- a/source/Servlets.cs +++ b/source/Servlets.cs @@ -582,9 +582,15 @@ private static Dictionary ExtractConfigstrings(int i, string[] line int index = -1; string value = ""; var info = new Dictionary(); + var regexTimestamp = new Regex(@"^\[\d+:\d\d.\d+\] (.*)"); for (; i < lines.Length; i++) { string line = lines[i]; + + var match = regexTimestamp.Match(line); + if (match.Success) + line = match.Groups[1].Value; + if (line.Length >= 4 && line[0] == ' ' && line[4] == ':') { if (index == 0 || index >= 529 && index < 529 + 32) diff --git a/source/scripts/_elo.js b/source/scripts/_elo.js index eb94b67..5c288d5 100644 --- a/source/scripts/_elo.js +++ b/source/scripts/_elo.js @@ -1,6 +1,6 @@ // ==UserScript== // @name QLStats: Adds an /elo command to show rating information from qlstats.net -// @version 0.1 +// @version 1.1 // @author PredatH0r // @description Use "/elo help" in the console to get a list of available commands. // @description /elo score: display rating for all players on the server @@ -12,6 +12,9 @@ /* +Version 1.1 +- fixed help text + Version 1.0 - rewrite to work with Steam exclusive version of Quake Live @@ -99,7 +102,6 @@ Version 1.0 function showHelp() { qz_instance.SendGameCommand("echo Usage: ^5/" + CVAR_elo + "^7 <^3command^7>"); qz_instance.SendGameCommand("echo \"^3say^7 shows the QLRanks score to all players\""); - /* qz_instance.SendGameCommand("echo \"^3table^7|^3list^7|^3simple^7 ^^^7... formatted in your console\""); qz_instance.SendGameCommand("echo \"^3method^7=x show/set output method\""); qz_instance.SendGameCommand("echo \"^3format^7=x show/set output format used by method=echo\""); @@ -109,13 +111,12 @@ Version 1.0 qz_instance.SendGameCommand("echo \"^3games^7 shows the number of completed games for each player\""); qz_instance.SendGameCommand("echo \"^3shuffle^7! suggest/arrange teams based on QLRanks score\""); qz_instance.SendGameCommand("echo \" append ^3,+all,+player1,-player2^7 to add/remove players\""); - qz_instance.SendGameCommand("echo \"^3profile=^7x opens QLranks.com player profile in your browser\""); + //qz_instance.SendGameCommand("echo \"^3profile=^7x opens QLranks.com player profile in your browser\""); qz_instance.SendGameCommand("echo \" ^3x^7 is a comma separated list of game types and players\""); - */ qz_instance.SendGameCommand("echo \"^3update^7 clears cached Elo scores\""); - qz_instance.SendGameCommand("echo \"\""); - qz_instance.SendGameCommand("echo \"Badge letters after Elo score indicate number of games completed\""); - qz_instance.SendGameCommand("echo ^3A-J^7: <100...<1000, ^3K-Y^7: <2000...<16000, ^3Z^7: >=16000"); + //qz_instance.SendGameCommand("echo \"\""); + //qz_instance.SendGameCommand("echo \"Badge letters after Elo score indicate number of games completed\""); + //qz_instance.SendGameCommand("echo ^3A-J^7: <100...<1000, ^3K-Y^7: <2000...<16000, ^3Z^7: >=16000"); } function clearEloCache() { diff --git a/source/scripts/whois.js b/source/scripts/whois.js index ccc6b3d..38ff646 100644 --- a/source/scripts/whois.js +++ b/source/scripts/whois.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Whois: Adds a /whois command to show alias nicknames stored on qlstats.net -// @version 1.0 +// @version 1.1 // @author PredatH0r // @description Use "/whois nickname -or- client-id (from /players)" // @enabled 1 @@ -8,6 +8,9 @@ /* +Version 1.1 +- using /players instead of /configstrings to get list of players + Version 1.0 - first release @@ -21,7 +24,7 @@ Version 1.0 // constants var CVAR_whois = "whois"; var HelpText = "a user script command. Use ^3" + CVAR_whois +" help^7 to get some help."; - var ConfigstringsMarker = "]\\configstrings"; + var CondumpMarker = "]\\players"; // state variables var pendingAjaxRequest = null; @@ -36,6 +39,7 @@ Version 1.0 var postal = window.req("postal"); var channel = postal.channel(); channel.subscribe("cvar." + CVAR_whois, onCommand); + channel.subscribe("cvar.ui_mainmenu", function() { playerCache.timestamp = 0; }); // happens on connect and map change echo("^2whois.js installed"); } @@ -57,8 +61,10 @@ Version 1.0 if (val == "help") showHelp(); - else if (val == "update") + else if (val == "update") { playerCache.timestamp = 0; + showAliases("*"); + } else showAliases(val); } @@ -125,51 +131,61 @@ Version 1.0 return; } - qz_instance.SendGameCommand("echo " + ConfigstringsMarker); // text marker required by extraQL servlet - qz_instance.SendGameCommand("configstrings"); + qz_instance.SendGameCommand("echo " + CondumpMarker); // text marker required by extraQL servlet + qz_instance.SendGameCommand("players"); setTimeout(function () { qz_instance.SendGameCommand("condump extraql_condump.txt"); setTimeout(function () { var xhttp = new XMLHttpRequest(); xhttp.timeout = 1000; - xhttp.onload = function () { onExtraQLServerInfo(arg, xhttp, callback); } + xhttp.onload = function () { onExtraQLCondump(arg, xhttp, callback); } xhttp.onerror = function () { echo("^3extraQL.exe not running:^7"); pendingAjaxRequest = null; } - xhttp.open("GET", "http://localhost:27963/serverinfo", true); + xhttp.open("GET", "http://localhost:27963/condump", true); xhttp.send(); }, 100); }, 1000); - function onExtraQLServerInfo(arg, xhttp, callback) { + function onExtraQLCondump(arg, xhttp, callback) { if (xhttp.status != 200) { pendingAjaxRequest = null; return; } - var json = null; - try { - json = JSON.parse(xhttp.responseText); - } catch (err) { - } - if (!json || !json.players) { + var players = getPlayersFromCondump(xhttp.responseText); + if (!players || players.length == 0) { pendingAjaxRequest = null; return; } - playerCache.players = json.players; + playerCache.players = players; playerCache.timestamp = Date.now(); - requestAliasInformation(arg, json.players, callback); + requestAliasInformation(arg, players, callback); + } + + function getPlayersFromCondump(condump) { + var idx = condump.lastIndexOf(CondumpMarker); + if (idx < 0) { + return null; + } + var players = []; + var lines = condump.substring(idx).split('\n'); + lines.forEach(function (line) { + var match = /^(?:\[\d+:\d\d\.\d+\] )?([ \d]\d) (.) (.+) steam:(\d+)$/.exec(line); + if (match) + players.push({ clientid: parseInt(match[1].trim()), opflag: match[2], name: match[3], steamid: match[4] }); + }); + return players; } function requestAliasInformation(arg, players, callback) { var steamIds = []; pendingAjaxRequest = {}; for (var i = 0; i < players.length; i++) { - var obj = players[i]; - var player = { "steamid": obj.st, "name": obj.n, "clientid": obj.clientid }; + var player = players[i]; if (arg == "*" || player.name.indexOf(arg) >= 0 || player.clientid.toString() == arg) { steamIds.push(player.steamid); pendingAjaxRequest[player.steamid] = player; diff --git a/workshop/extraQL.vdf b/workshop/extraQL.vdf index f26cedf..57da3e1 100644 --- a/workshop/extraQL.vdf +++ b/workshop/extraQL.vdf @@ -6,5 +6,5 @@ "previewfile" "d:\sources\extraQL\workshop\extraQL1.png" "visibility" "0" "title" "extraQL userscripts" - "changenote" "https://github.com/PredatH0r/extraQL/releases/tag/v2.16" + "changenote" "https://github.com/PredatH0r/extraQL/releases/tag/v2.17" }