Fix zerocoder, use buffers instead of strings for vardata, add util for null-terminated string<->buffer conversion
This commit is contained in:
@@ -16,7 +16,7 @@ export class DirClassifiedQueryBackendMessage implements MessageBase
|
||||
};
|
||||
QueryData: {
|
||||
QueryID: UUID;
|
||||
QueryText: string;
|
||||
QueryText: Buffer;
|
||||
QueryFlags: number;
|
||||
Category: number;
|
||||
EstateID: number;
|
||||
@@ -37,7 +37,7 @@ export class DirClassifiedQueryBackendMessage implements MessageBase
|
||||
this.QueryData['QueryID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeUInt8(this.QueryData['QueryText'].length, pos++);
|
||||
buf.write(this.QueryData['QueryText'], pos);
|
||||
this.QueryData['QueryText'].copy(buf, pos);
|
||||
pos += this.QueryData['QueryText'].length;
|
||||
buf.writeUInt32LE(this.QueryData['QueryFlags'], pos);
|
||||
pos += 4;
|
||||
@@ -65,7 +65,7 @@ export class DirClassifiedQueryBackendMessage implements MessageBase
|
||||
this.AgentData = newObjAgentData;
|
||||
const newObjQueryData: {
|
||||
QueryID: UUID,
|
||||
QueryText: string,
|
||||
QueryText: Buffer,
|
||||
QueryFlags: number,
|
||||
Category: number,
|
||||
EstateID: number,
|
||||
@@ -73,7 +73,7 @@ export class DirClassifiedQueryBackendMessage implements MessageBase
|
||||
QueryStart: number
|
||||
} = {
|
||||
QueryID: UUID.zero(),
|
||||
QueryText: '',
|
||||
QueryText: Buffer.allocUnsafe(0),
|
||||
QueryFlags: 0,
|
||||
Category: 0,
|
||||
EstateID: 0,
|
||||
@@ -83,7 +83,7 @@ export class DirClassifiedQueryBackendMessage implements MessageBase
|
||||
newObjQueryData['QueryID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
varLength = buf.readUInt8(pos++);
|
||||
newObjQueryData['QueryText'] = buf.toString('utf8', pos, pos + (varLength - 1));
|
||||
newObjQueryData['QueryText'] = buf.slice(pos, pos + (varLength - 1));
|
||||
pos += varLength;
|
||||
newObjQueryData['QueryFlags'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
|
||||
Reference in New Issue
Block a user