mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-18 09:35:50 +00:00
Additional async rewrite
This commit is contained in:
parent
efe12a00aa
commit
29ce0b82d0
24 changed files with 654 additions and 470 deletions
|
|
@ -37,6 +37,30 @@ class Gamespy2 extends Core {
|
|||
const reader = this.reader(body);
|
||||
state.raw.teams = this.readFieldData(reader);
|
||||
}
|
||||
|
||||
// Special case for america's army 1 and 2
|
||||
// both use gamename = "armygame"
|
||||
if (state.raw.gamename === 'armygame') {
|
||||
const stripColor = (str) => {
|
||||
// uses unreal 2 color codes
|
||||
return str.replace(/\x1b...|[\x00-\x1a]/g,'');
|
||||
};
|
||||
state.name = stripColor(state.name);
|
||||
state.map = stripColor(state.map);
|
||||
for(const key of Object.keys(state.raw)) {
|
||||
if(typeof state.raw[key] === 'string') {
|
||||
state.raw[key] = stripColor(state.raw[key]);
|
||||
}
|
||||
}
|
||||
for(const player of state.players) {
|
||||
if(!('name' in player)) continue;
|
||||
player.name = stripColor(player.name);
|
||||
}
|
||||
}
|
||||
|
||||
if (state.raw.hostport) {
|
||||
state.gamePort = parseInt(state.raw.hostport);
|
||||
}
|
||||
}
|
||||
|
||||
async sendPacket(type) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue