mirror of
https://github.com/tribufu/node-gamedig
synced 2026-06-01 09:42:41 +00: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
|
### 3.0.7
|
||||||
* Fixes corrupted dayzMods when packet overflow is present
|
* Fixes corrupted dayzMods when packet overflow is present
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,21 +39,6 @@ class Results {
|
||||||
maxplayers = 0;
|
maxplayers = 0;
|
||||||
players = new Players();
|
players = new Players();
|
||||||
bots = 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;
|
module.exports = Results;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
],
|
],
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"author": "GameDig Contributors",
|
"author": "GameDig Contributors",
|
||||||
"version": "3.0.7",
|
"version": "3.0.8",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/gamedig/node-gamedig.git"
|
"url": "https://github.com/gamedig/node-gamedig.git"
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class GeneShift extends Core {
|
||||||
state.raw.country = found[1];
|
state.raw.country = found[1];
|
||||||
state.name = found[4];
|
state.name = found[4];
|
||||||
state.map = found[5];
|
state.map = found[5];
|
||||||
state.players = parseInt(found[6]);
|
state.players.setNum(parseInt(found[6]));
|
||||||
state.maxplayers = parseInt(found[7]);
|
state.maxplayers = parseInt(found[7]);
|
||||||
// fields[8] is unknown?
|
// fields[8] is unknown?
|
||||||
state.raw.rules = found[9];
|
state.raw.rules = found[9];
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ class Jc2mp extends Gamespy3 {
|
||||||
async run(state) {
|
async run(state) {
|
||||||
await super.run(state);
|
await super.run(state);
|
||||||
if(!state.players.length && parseInt(state.raw.numplayers)) {
|
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'),
|
const Core = require('./core');
|
||||||
MinecraftVanilla = require('./minecraftvanilla'),
|
const MinecraftVanilla = require('./minecraftvanilla');
|
||||||
MinecraftBedrock = require('./minecraftbedrock'),
|
const MinecraftBedrock = require('./minecraftbedrock');
|
||||||
Gamespy3 = require('./gamespy3');
|
const Gamespy3 = require('./gamespy3');
|
||||||
|
const Results = require('../lib/Results');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Vanilla servers respond to minecraftvanilla only
|
Vanilla servers respond to minecraftvanilla only
|
||||||
|
|
@ -17,6 +18,7 @@ class Minecraft extends Core {
|
||||||
this.srvRecord = "_minecraft._tcp";
|
this.srvRecord = "_minecraft._tcp";
|
||||||
}
|
}
|
||||||
async run(state) {
|
async run(state) {
|
||||||
|
/** @type {Promise<Results>[]} */
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
|
||||||
const vanillaResolver = new MinecraftVanilla();
|
const vanillaResolver = new MinecraftVanilla();
|
||||||
|
|
@ -57,7 +59,7 @@ class Minecraft extends Core {
|
||||||
if (bedrockState) {
|
if (bedrockState) {
|
||||||
if (bedrockState.name) state.name = bedrockState.name;
|
if (bedrockState.name) state.name = bedrockState.name;
|
||||||
if (bedrockState.maxplayers) state.maxplayers = bedrockState.maxplayers;
|
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 (bedrockState.map) state.map = bedrockState.map;
|
||||||
}
|
}
|
||||||
if (vanillaState) {
|
if (vanillaState) {
|
||||||
|
|
@ -76,13 +78,13 @@ class Minecraft extends Core {
|
||||||
state.name = name;
|
state.name = name;
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
if (vanillaState.maxplayers) state.maxplayers = vanillaState.maxplayers;
|
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) {
|
||||||
if (gamespyState.name) state.name = gamespyState.name;
|
if (gamespyState.name) state.name = gamespyState.name;
|
||||||
if (gamespyState.maxplayers) state.maxplayers = gamespyState.maxplayers;
|
if (gamespyState.maxplayers) state.maxplayers = gamespyState.maxplayers;
|
||||||
if (gamespyState.players.length) state.players = gamespyState.players;
|
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
|
// remove dupe spaces from name
|
||||||
state.name = state.name.replace(/\s+/g, ' ');
|
state.name = state.name.replace(/\s+/g, ' ');
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ class MinecraftBedrock extends Core {
|
||||||
state.name = split.shift();
|
state.name = split.shift();
|
||||||
state.raw.protocolVersion = split.shift();
|
state.raw.protocolVersion = split.shift();
|
||||||
state.raw.mcVersion = split.shift();
|
state.raw.mcVersion = split.shift();
|
||||||
state.players = parseInt(split.shift());
|
state.players.setNum(parseInt(split.shift()));
|
||||||
state.maxplayers = parseInt(split.shift());
|
state.maxplayers = parseInt(split.shift());
|
||||||
if (split.length) state.raw.serverId = split.shift();
|
if (split.length) state.raw.serverId = split.shift();
|
||||||
if (split.length) state.map = 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.versionMinor = reader.uint(1);
|
||||||
state.raw.versionPatch = reader.uint(1);
|
state.raw.versionPatch = reader.uint(1);
|
||||||
reader.skip(8);
|
reader.skip(8);
|
||||||
state.players = reader.uint(4);
|
state.players.setNum(reader.uint(4));
|
||||||
state.maxplayers = reader.uint(4);
|
state.maxplayers = reader.uint(4);
|
||||||
state.raw.allowedbandwidth = reader.uint(4);
|
state.raw.allowedbandwidth = reader.uint(4);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class OpenTtd extends Core {
|
||||||
|
|
||||||
state.password = !!reader.uint(1);
|
state.password = !!reader.uint(1);
|
||||||
state.maxplayers = 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.raw.numspectators = reader.uint(1);
|
||||||
state.map = reader.string();
|
state.map = reader.string();
|
||||||
state.raw.map_width = reader.uint(2);
|
state.raw.map_width = reader.uint(2);
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class Rfactor extends Core {
|
||||||
state.raw.ping = reader.uint(2);
|
state.raw.ping = reader.uint(2);
|
||||||
state.raw.packedFlags = reader.uint(1);
|
state.raw.packedFlags = reader.uint(1);
|
||||||
state.raw.rate = 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.maxplayers = reader.uint(1);
|
||||||
state.raw.bots = reader.uint(1);
|
state.raw.bots = reader.uint(1);
|
||||||
state.raw.packedSpecial = reader.uint(1);
|
state.raw.packedSpecial = reader.uint(1);
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ class Samp extends Core {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!gotPlayerData) {
|
if (!gotPlayerData) {
|
||||||
state.players = state.raw.numplayers;
|
state.players.setNum(state.raw.numplayers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async sendPacket(type,allowTimeout) {
|
async sendPacket(type,allowTimeout) {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ class Savage2 extends Core {
|
||||||
|
|
||||||
reader.skip(12);
|
reader.skip(12);
|
||||||
state.name = this.stripColorCodes(reader.string());
|
state.name = this.stripColorCodes(reader.string());
|
||||||
state.players = reader.uint(1);
|
state.players.setNum(reader.uint(1));
|
||||||
state.maxplayers = reader.uint(1);
|
state.maxplayers = reader.uint(1);
|
||||||
state.raw.time = reader.string();
|
state.raw.time = reader.string();
|
||||||
state.map = 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[2] === 'string') state.name = data[2];
|
||||||
if(typeof data[3] === 'string') state.raw.description = data[3];
|
if(typeof data[3] === 'string') state.raw.description = data[3];
|
||||||
if(typeof data[4] === 'number') state.raw.startTime = data[4];
|
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];
|
if(typeof data[6] === 'number') state.maxplayers = data[6];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue