fix: xonotic player names being reported as numbers (#580)

* fix: xonotic player names being reported as numbers

* changelog
This commit is contained in:
CosminPerRam 2024-06-29 21:25:58 +03:00 committed by GitHub
parent cfd5614353
commit 5210f523b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 20 additions and 2 deletions

16
protocols/xonotic.js Normal file
View file

@ -0,0 +1,16 @@
import quake3 from './quake3.js'
export default class xonotic extends quake3 {
async run (state) {
await super.run(state)
// Sometimes, the server returns a player's name as a number (which seems to be the team?) and the name in
// an extra field called "address", we are not sure of this behaviour nor if this is a good enough solution
for (const player of state.players) {
if (!isNaN(player.name) && player.raw.address) {
player.raw.team = player.name
player.name = player.raw.address
}
}
}
}