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

@@ -38,8 +38,8 @@ export class RezScriptMessage implements MessageBase
Flags: number;
SaleType: number;
SalePrice: number;
Name: string;
Description: string;
Name: Buffer;
Description: Buffer;
CreationDate: number;
CRC: number;
};
@@ -92,10 +92,10 @@ export class RezScriptMessage implements MessageBase
buf.writeInt32LE(this.InventoryBlock['SalePrice'], pos);
pos += 4;
buf.writeUInt8(this.InventoryBlock['Name'].length, pos++);
buf.write(this.InventoryBlock['Name'], pos);
this.InventoryBlock['Name'].copy(buf, pos);
pos += this.InventoryBlock['Name'].length;
buf.writeUInt8(this.InventoryBlock['Description'].length, pos++);
buf.write(this.InventoryBlock['Description'], pos);
this.InventoryBlock['Description'].copy(buf, pos);
pos += this.InventoryBlock['Description'].length;
buf.writeInt32LE(this.InventoryBlock['CreationDate'], pos);
pos += 4;
@@ -153,8 +153,8 @@ export class RezScriptMessage implements MessageBase
Flags: number,
SaleType: number,
SalePrice: number,
Name: string,
Description: string,
Name: Buffer,
Description: Buffer,
CreationDate: number,
CRC: number
} = {
@@ -175,8 +175,8 @@ export class RezScriptMessage implements MessageBase
Flags: 0,
SaleType: 0,
SalePrice: 0,
Name: '',
Description: '',
Name: Buffer.allocUnsafe(0),
Description: Buffer.allocUnsafe(0),
CreationDate: 0,
CRC: 0
};
@@ -211,10 +211,10 @@ export class RezScriptMessage implements MessageBase
newObjInventoryBlock['SalePrice'] = buf.readInt32LE(pos);
pos += 4;
varLength = buf.readUInt8(pos++);
newObjInventoryBlock['Name'] = buf.toString('utf8', pos, pos + (varLength - 1));
newObjInventoryBlock['Name'] = buf.slice(pos, pos + (varLength - 1));
pos += varLength;
varLength = buf.readUInt8(pos++);
newObjInventoryBlock['Description'] = buf.toString('utf8', pos, pos + (varLength - 1));
newObjInventoryBlock['Description'] = buf.slice(pos, pos + (varLength - 1));
pos += varLength;
newObjInventoryBlock['CreationDate'] = buf.readInt32LE(pos);
pos += 4;