mirror of
https://github.com/gamedig/node-gamedig.git
synced 2024-11-16 00:38:31 +01:00
Improve null splitting on rfactor
This commit is contained in:
parent
81750805f6
commit
82084ad38e
2 changed files with 4 additions and 4 deletions
|
@ -68,7 +68,8 @@ class Rfactor extends Core {
|
||||||
|
|
||||||
// Consumes bytesToConsume, but only returns string up to the first null
|
// Consumes bytesToConsume, but only returns string up to the first null
|
||||||
readString(reader, bytesToConsume) {
|
readString(reader, bytesToConsume) {
|
||||||
return reader.string(bytesToConsume).replace(/\0.*$/g,'');
|
const consumed = reader.part(bytesToConsume);
|
||||||
|
return this.reader(consumed).string();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,8 @@ class Samp extends Core {
|
||||||
{
|
{
|
||||||
const reader = await this.sendPacket('i');
|
const reader = await this.sendPacket('i');
|
||||||
if (this.isVcmp) {
|
if (this.isVcmp) {
|
||||||
let version = reader.string(12);
|
const consumed = reader.part(12);
|
||||||
version = version.replace(/\0.*$/g,'');
|
state.raw.version = this.reader(consumed).string();
|
||||||
state.raw.version = version;
|
|
||||||
}
|
}
|
||||||
state.password = !!reader.uint(1);
|
state.password = !!reader.uint(1);
|
||||||
state.raw.numplayers = reader.uint(2);
|
state.raw.numplayers = reader.uint(2);
|
||||||
|
|
Loading…
Reference in a new issue