Fix zerocoder, use buffers instead of strings for vardata, add util for null-terminated string<->buffer conversion
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user