Fix zerocoder, use buffers instead of strings for vardata, add util for null-terminated string<->buffer conversion

This commit is contained in:
Casper Warden
2017-11-26 19:47:41 +00:00
parent 3f25aa0f1b
commit fc6d77a893
195 changed files with 2005 additions and 1881 deletions

View File

@@ -37,8 +37,8 @@ export class UpdateTaskInventoryMessage implements MessageBase
Flags: number;
SaleType: number;
SalePrice: number;
Name: string;
Description: string;
Name: Buffer;
Description: Buffer;
CreationDate: number;
CRC: number;
};
@@ -89,10 +89,10 @@ export class UpdateTaskInventoryMessage implements MessageBase
buf.writeInt32LE(this.InventoryData['SalePrice'], pos);
pos += 4;
buf.writeUInt8(this.InventoryData['Name'].length, pos++);
buf.write(this.InventoryData['Name'], pos);
this.InventoryData['Name'].copy(buf, pos);
pos += this.InventoryData['Name'].length;
buf.writeUInt8(this.InventoryData['Description'].length, pos++);
buf.write(this.InventoryData['Description'], pos);
this.InventoryData['Description'].copy(buf, pos);
pos += this.InventoryData['Description'].length;
buf.writeInt32LE(this.InventoryData['CreationDate'], pos);
pos += 4;
@@ -146,8 +146,8 @@ export class UpdateTaskInventoryMessage implements MessageBase
Flags: number,
SaleType: number,
SalePrice: number,
Name: string,
Description: string,
Name: Buffer,
Description: Buffer,
CreationDate: number,
CRC: number
} = {
@@ -168,8 +168,8 @@ export class UpdateTaskInventoryMessage implements MessageBase
Flags: 0,
SaleType: 0,
SalePrice: 0,
Name: '',
Description: '',
Name: Buffer.allocUnsafe(0),
Description: Buffer.allocUnsafe(0),
CreationDate: 0,
CRC: 0
};
@@ -204,10 +204,10 @@ export class UpdateTaskInventoryMessage implements MessageBase
newObjInventoryData['SalePrice'] = buf.readInt32LE(pos);
pos += 4;
varLength = buf.readUInt8(pos++);
newObjInventoryData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1));
newObjInventoryData['Name'] = buf.slice(pos, pos + (varLength - 1));
pos += varLength;
varLength = buf.readUInt8(pos++);
newObjInventoryData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1));
newObjInventoryData['Description'] = buf.slice(pos, pos + (varLength - 1));
pos += varLength;
newObjInventoryData['CreationDate'] = buf.readInt32LE(pos);
pos += 4;