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

@@ -21,7 +21,7 @@ export class AgentGroupDataUpdateMessage implements MessageBase
AcceptNotices: boolean;
GroupInsigniaID: UUID;
Contribution: number;
GroupName: string;
GroupName: Buffer;
}[];
getSize(): number
@@ -60,7 +60,7 @@ export class AgentGroupDataUpdateMessage implements MessageBase
buf.writeInt32LE(this.GroupData[i]['Contribution'], pos);
pos += 4;
buf.writeUInt8(this.GroupData[i]['GroupName'].length, pos++);
buf.write(this.GroupData[i]['GroupName'], pos);
this.GroupData[i]['GroupName'].copy(buf, pos);
pos += this.GroupData[i]['GroupName'].length;
}
return pos - startPos;
@@ -88,14 +88,14 @@ export class AgentGroupDataUpdateMessage implements MessageBase
AcceptNotices: boolean,
GroupInsigniaID: UUID,
Contribution: number,
GroupName: string
GroupName: Buffer
} = {
GroupID: UUID.zero(),
GroupPowers: Long.ZERO,
AcceptNotices: false,
GroupInsigniaID: UUID.zero(),
Contribution: 0,
GroupName: ''
GroupName: Buffer.allocUnsafe(0)
};
newObjGroupData['GroupID'] = new UUID(buf, pos);
pos += 16;
@@ -107,7 +107,7 @@ export class AgentGroupDataUpdateMessage implements MessageBase
newObjGroupData['Contribution'] = buf.readInt32LE(pos);
pos += 4;
varLength = buf.readUInt8(pos++);
newObjGroupData['GroupName'] = buf.toString('utf8', pos, pos + (varLength - 1));
newObjGroupData['GroupName'] = buf.slice(pos, pos + (varLength - 1));
pos += varLength;
this.GroupData.push(newObjGroupData);
}