QW-Group / mvdsv

MVDSV: a QuakeWorld server
GNU General Public License v2.0
58 stars 56 forks source link

BUG: laststats connectionless command responds with invalid json #119

Closed vikpe closed 1 year ago

vikpe commented 1 year ago

Example

❯ echo -e "\xff\xff\xff\xfflaststats 3" | nc -u -vvv -w 1 quake.se 28505
Connection to quake.se 28505 port [udp/*] succeeded!
����nlaststats 3
[
,
{"version": 3,"date": "2023-02-23 20:21:24 +0100","map": "dm2","hostname": "QUAKE.SE KTX:28501"},
]

Related code https://github.com/QW-Group/mvdsv/blob/971e7de49255fb41d56ae8e9332825bbf15617a8/src/sv_demo_misc.c#L1035-L1107


In the example above , is printed as the first entry. Could it be because we are reading the stats file for the demo of current game (which is empty)? Also there is an invalid trailing comma at the second entry.

We should iterate a Sys_listdir() call with the stats files, instead of using the demo files (sv_demoRegexp).

Example

// STATS_FILE_REGEX = "\\.mvd\\.txt$"
dir = Sys_listdir(va("%s/%s", fs_gamedir, sv_demoDir.string), STATS_FILE_REGEX, SORT_BY_DATE); 
vikpe commented 1 year ago

i've prepared the qw hub api with endpoints for lastscores/laststats (e.g. https://hubapi.quakeworld.nu/v2/servers/quake.se:28501/lastscores) but it will return empty result as long as the connectionless cmd returns invalid json. once it works I can add lastscores to QW HUB, streambot etc.

I don't have c or mvdsv setup on my laptop and I'm traveling next two weeks.

Should be pretty easy to fix.