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

@@ -18,7 +18,7 @@ export class AvatarTextureUpdateMessage implements MessageBase
WearableData: {
CacheID: UUID;
TextureIndex: number;
HostName: string;
HostName: Buffer;
}[];
TextureData: {
TextureID: UUID;
@@ -53,7 +53,7 @@ export class AvatarTextureUpdateMessage implements MessageBase
pos += 16;
buf.writeUInt8(this.WearableData[i]['TextureIndex'], pos++);
buf.writeUInt8(this.WearableData[i]['HostName'].length, pos++);
buf.write(this.WearableData[i]['HostName'], pos);
this.WearableData[i]['HostName'].copy(buf, pos);
pos += this.WearableData[i]['HostName'].length;
}
count = this.TextureData.length;
@@ -88,17 +88,17 @@ export class AvatarTextureUpdateMessage implements MessageBase
const newObjWearableData: {
CacheID: UUID,
TextureIndex: number,
HostName: string
HostName: Buffer
} = {
CacheID: UUID.zero(),
TextureIndex: 0,
HostName: ''
HostName: Buffer.allocUnsafe(0)
};
newObjWearableData['CacheID'] = new UUID(buf, pos);
pos += 16;
newObjWearableData['TextureIndex'] = buf.readUInt8(pos++);
varLength = buf.readUInt8(pos++);
newObjWearableData['HostName'] = buf.toString('utf8', pos, pos + (varLength - 1));
newObjWearableData['HostName'] = buf.slice(pos, pos + (varLength - 1));
pos += varLength;
this.WearableData.push(newObjWearableData);
}