mirror of
https://github.com/gamedig/node-gamedig.git
synced 2024-11-19 02:00:38 +01:00
Remove complex players
setter overload (3.0.8)
This commit is contained in:
parent
c46e8efb0d
commit
5c2d15df49
13 changed files with 23 additions and 32 deletions
|
@ -1,3 +1,7 @@
|
|||
### 3.0.8
|
||||
* Fixes player array corruption on some protocols which only report player counts without names (Thanks to a-sync)
|
||||
* Fixes minecraft protocol not using player list from bedrock protocol in some cases
|
||||
|
||||
### 3.0.7
|
||||
* Fixes corrupted dayzMods when packet overflow is present
|
||||
|
||||
|
|
|
@ -39,21 +39,6 @@ class Results {
|
|||
maxplayers = 0;
|
||||
players = new Players();
|
||||
bots = new Players();
|
||||
|
||||
set players(val) {
|
||||
if (typeof val === 'number') {
|
||||
this.players.setNum(val);
|
||||
} else if (Array.isArray(val)) {
|
||||
this.players = val;
|
||||
}
|
||||
}
|
||||
set bots(val) {
|
||||
if (typeof val === 'number') {
|
||||
this.bots.setNum(val);
|
||||
} else if (Array.isArray(val)) {
|
||||
this.bots = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Results;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
],
|
||||
"main": "lib/index.js",
|
||||
"author": "GameDig Contributors",
|
||||
"version": "3.0.7",
|
||||
"version": "3.0.8",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/gamedig/node-gamedig.git"
|
||||
|
|
|
@ -28,7 +28,7 @@ class GeneShift extends Core {
|
|||
state.raw.country = found[1];
|
||||
state.name = found[4];
|
||||
state.map = found[5];
|
||||
state.players = parseInt(found[6]);
|
||||
state.players.setNum(parseInt(found[6]));
|
||||
state.maxplayers = parseInt(found[7]);
|
||||
// fields[8] is unknown?
|
||||
state.raw.rules = found[9];
|
||||
|
|
|
@ -12,7 +12,7 @@ class Jc2mp extends Gamespy3 {
|
|||
async run(state) {
|
||||
await super.run(state);
|
||||
if(!state.players.length && parseInt(state.raw.numplayers)) {
|
||||
state.players = parseInt(state.raw.numplayers);
|
||||
state.players.setNum(parseInt(state.raw.numplayers));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
const Core = require('./core'),
|
||||
MinecraftVanilla = require('./minecraftvanilla'),
|
||||
MinecraftBedrock = require('./minecraftbedrock'),
|
||||
Gamespy3 = require('./gamespy3');
|
||||
const Core = require('./core');
|
||||
const MinecraftVanilla = require('./minecraftvanilla');
|
||||
const MinecraftBedrock = require('./minecraftbedrock');
|
||||
const Gamespy3 = require('./gamespy3');
|
||||
const Results = require('../lib/Results');
|
||||
|
||||
/*
|
||||
Vanilla servers respond to minecraftvanilla only
|
||||
|
@ -17,6 +18,7 @@ class Minecraft extends Core {
|
|||
this.srvRecord = "_minecraft._tcp";
|
||||
}
|
||||
async run(state) {
|
||||
/** @type {Promise<Results>[]} */
|
||||
const promises = [];
|
||||
|
||||
const vanillaResolver = new MinecraftVanilla();
|
||||
|
@ -57,7 +59,7 @@ class Minecraft extends Core {
|
|||
if (bedrockState) {
|
||||
if (bedrockState.name) state.name = bedrockState.name;
|
||||
if (bedrockState.maxplayers) state.maxplayers = bedrockState.maxplayers;
|
||||
if (bedrockState.players) state.players = bedrockState.players;
|
||||
if (bedrockState.players.length) state.players = bedrockState.players;
|
||||
if (bedrockState.map) state.map = bedrockState.map;
|
||||
}
|
||||
if (vanillaState) {
|
||||
|
@ -76,13 +78,13 @@ class Minecraft extends Core {
|
|||
state.name = name;
|
||||
} catch(e) {}
|
||||
if (vanillaState.maxplayers) state.maxplayers = vanillaState.maxplayers;
|
||||
if (vanillaState.players) state.players = vanillaState.players;
|
||||
if (vanillaState.players.length) state.players = vanillaState.players;
|
||||
}
|
||||
if (gamespyState) {
|
||||
if (gamespyState.name) state.name = gamespyState.name;
|
||||
if (gamespyState.maxplayers) state.maxplayers = gamespyState.maxplayers;
|
||||
if (gamespyState.players.length) state.players = gamespyState.players;
|
||||
else if (gamespyState.raw.numplayers) state.players = parseInt(gamespyState.raw.numplayers);
|
||||
else if (gamespyState.raw.numplayers) state.players.setNum(parseInt(gamespyState.raw.numplayers));
|
||||
}
|
||||
// remove dupe spaces from name
|
||||
state.name = state.name.replace(/\s+/g, ' ');
|
||||
|
|
|
@ -57,7 +57,7 @@ class MinecraftBedrock extends Core {
|
|||
state.name = split.shift();
|
||||
state.raw.protocolVersion = split.shift();
|
||||
state.raw.mcVersion = split.shift();
|
||||
state.players = parseInt(split.shift());
|
||||
state.players.setNum(parseInt(split.shift()));
|
||||
state.maxplayers = parseInt(split.shift());
|
||||
if (split.length) state.raw.serverId = split.shift();
|
||||
if (split.length) state.map = split.shift();
|
||||
|
|
|
@ -17,7 +17,7 @@ class MumblePing extends Core {
|
|||
state.raw.versionMinor = reader.uint(1);
|
||||
state.raw.versionPatch = reader.uint(1);
|
||||
reader.skip(8);
|
||||
state.players = reader.uint(4);
|
||||
state.players.setNum(reader.uint(4));
|
||||
state.maxplayers = reader.uint(4);
|
||||
state.raw.allowedbandwidth = reader.uint(4);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class OpenTtd extends Core {
|
|||
|
||||
state.password = !!reader.uint(1);
|
||||
state.maxplayers = reader.uint(1);
|
||||
state.players = reader.uint(1);
|
||||
state.players.setNum(reader.uint(1));
|
||||
state.raw.numspectators = reader.uint(1);
|
||||
state.map = reader.string();
|
||||
state.raw.map_width = reader.uint(2);
|
||||
|
|
|
@ -27,7 +27,7 @@ class Rfactor extends Core {
|
|||
state.raw.ping = reader.uint(2);
|
||||
state.raw.packedFlags = reader.uint(1);
|
||||
state.raw.rate = reader.uint(1);
|
||||
state.players = reader.uint(1);
|
||||
state.players.setNum(reader.uint(1));
|
||||
state.maxplayers = reader.uint(1);
|
||||
state.raw.bots = reader.uint(1);
|
||||
state.raw.packedSpecial = reader.uint(1);
|
||||
|
|
|
@ -69,7 +69,7 @@ class Samp extends Core {
|
|||
}
|
||||
}
|
||||
if (!gotPlayerData) {
|
||||
state.players = state.raw.numplayers;
|
||||
state.players.setNum(state.raw.numplayers);
|
||||
}
|
||||
}
|
||||
async sendPacket(type,allowTimeout) {
|
||||
|
|
|
@ -11,7 +11,7 @@ class Savage2 extends Core {
|
|||
|
||||
reader.skip(12);
|
||||
state.name = this.stripColorCodes(reader.string());
|
||||
state.players = reader.uint(1);
|
||||
state.players.setNum(reader.uint(1));
|
||||
state.maxplayers = reader.uint(1);
|
||||
state.raw.time = reader.string();
|
||||
state.map = reader.string();
|
||||
|
|
|
@ -61,7 +61,7 @@ class Starmade extends Core {
|
|||
if(typeof data[2] === 'string') state.name = data[2];
|
||||
if(typeof data[3] === 'string') state.raw.description = data[3];
|
||||
if(typeof data[4] === 'number') state.raw.startTime = data[4];
|
||||
if(typeof data[5] === 'number') state.players = data[5];
|
||||
if(typeof data[5] === 'number') state.players.setNum(data[5]);
|
||||
if(typeof data[6] === 'number') state.maxplayers = data[6];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue