diff --git a/protocols/rfactor.js b/protocols/rfactor.js index 7d4b58c..1716a12 100644 --- a/protocols/rfactor.js +++ b/protocols/rfactor.js @@ -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(); } } diff --git a/protocols/samp.js b/protocols/samp.js index 8af3c99..34a8b77 100644 --- a/protocols/samp.js +++ b/protocols/samp.js @@ -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);