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

@@ -17,7 +17,7 @@ export class AvatarNotesUpdateMessage implements MessageBase
};
Data: {
TargetID: UUID;
Notes: string;
Notes: Buffer;
};
getSize(): number
@@ -36,7 +36,7 @@ export class AvatarNotesUpdateMessage implements MessageBase
pos += 16;
buf.writeUInt16LE(this.Data['Notes'].length, pos);
pos += 2;
buf.write(this.Data['Notes'], pos);
this.Data['Notes'].copy(buf, pos);
pos += this.Data['Notes'].length;
return pos - startPos;
}
@@ -59,16 +59,16 @@ export class AvatarNotesUpdateMessage implements MessageBase
this.AgentData = newObjAgentData;
const newObjData: {
TargetID: UUID,
Notes: string
Notes: Buffer
} = {
TargetID: UUID.zero(),
Notes: ''
Notes: Buffer.allocUnsafe(0)
};
newObjData['TargetID'] = new UUID(buf, pos);
pos += 16;
varLength = buf.readUInt16LE(pos);
pos += 2;
newObjData['Notes'] = buf.toString('utf8', pos, pos + (varLength - 1));
newObjData['Notes'] = buf.slice(pos, pos + (varLength - 1));
pos += varLength;
this.Data = newObjData;
return pos - startPos;