Improve null splitting on rfactor

This commit is contained in:
mmorrison 2019-02-04 01:16:30 -06:00
parent 81750805f6
commit 82084ad38e
2 changed files with 4 additions and 4 deletions

View File

@ -68,7 +68,8 @@ class Rfactor extends Core {
// Consumes bytesToConsume, but only returns string up to the first null
readString(reader, bytesToConsume) {
return reader.string(bytesToConsume).replace(/\0.*$/g,'');
const consumed = reader.part(bytesToConsume);
return this.reader(consumed).string();
}
}

View File

@ -14,9 +14,8 @@ class Samp extends Core {
{
const reader = await this.sendPacket('i');
if (this.isVcmp) {
let version = reader.string(12);
version = version.replace(/\0.*$/g,'');
state.raw.version = version;
const consumed = reader.part(12);
state.raw.version = this.reader(consumed).string();
}
state.password = !!reader.uint(1);
state.raw.numplayers = reader.uint(2);