From fc6d77a8934386ba8d612763db2425d182751c22 Mon Sep 17 00:00:00 2001 From: Casper Warden <216465704+casperwardensl@users.noreply.github.com> Date: Sun, 26 Nov 2017 19:47:41 +0000 Subject: [PATCH] Fix zerocoder, use buffers instead of strings for vardata, add util for null-terminated string<->buffer conversion --- example/testBot.js | 22 +- lib/Bot.ts | 110 +++++++++- lib/classes/Circuit.ts | 197 +++++++++--------- lib/classes/LoginResponse.ts | 1 + lib/classes/Packet.ts | 2 +- lib/classes/Utils.ts | 7 + lib/classes/Zerocoder.ts | 5 +- lib/classes/messages/AgentAlertMessage.ts | 10 +- lib/classes/messages/AgentAnimation.ts | 10 +- .../messages/AgentCachedTextureResponse.ts | 10 +- lib/classes/messages/AgentDataUpdate.ts | 40 ++-- lib/classes/messages/AgentGroupDataUpdate.ts | 10 +- lib/classes/messages/AgentMovementComplete.ts | 10 +- lib/classes/messages/AgentSetAppearance.ts | 10 +- lib/classes/messages/AgentThrottle.ts | 10 +- lib/classes/messages/AlertMessage.ts | 30 +-- lib/classes/messages/AssetUploadRequest.ts | 10 +- lib/classes/messages/AvatarAnimation.ts | 10 +- lib/classes/messages/AvatarAppearance.ts | 10 +- lib/classes/messages/AvatarClassifiedReply.ts | 10 +- lib/classes/messages/AvatarGroupsReply.ts | 20 +- lib/classes/messages/AvatarInterestsReply.ts | 30 +-- lib/classes/messages/AvatarInterestsUpdate.ts | 30 +-- lib/classes/messages/AvatarNotesReply.ts | 10 +- lib/classes/messages/AvatarNotesUpdate.ts | 10 +- lib/classes/messages/AvatarPickerReply.ts | 20 +- lib/classes/messages/AvatarPickerRequest.ts | 10 +- .../messages/AvatarPickerRequestBackend.ts | 10 +- lib/classes/messages/AvatarPicksReply.ts | 10 +- lib/classes/messages/AvatarPropertiesReply.ts | 50 ++--- .../messages/AvatarPropertiesUpdate.ts | 30 +-- lib/classes/messages/AvatarTextureUpdate.ts | 10 +- lib/classes/messages/BulkUpdateInventory.ts | 30 +-- lib/classes/messages/ChatFromSimulator.ts | 20 +- lib/classes/messages/ChatFromViewer.ts | 10 +- lib/classes/messages/ChatPass.ts | 20 +- lib/classes/messages/ChildAgentUpdate.ts | 40 ++-- lib/classes/messages/ClassifiedInfoReply.ts | 40 ++-- lib/classes/messages/ClassifiedInfoUpdate.ts | 20 +- lib/classes/messages/CopyInventoryItem.ts | 10 +- lib/classes/messages/CreateGroupReply.ts | 10 +- lib/classes/messages/CreateGroupRequest.ts | 20 +- .../messages/CreateGroupRequestExtended.ts | 20 +- lib/classes/messages/CreateInventoryFolder.ts | 10 +- lib/classes/messages/CreateInventoryItem.ts | 20 +- .../messages/CreateLandmarkForEvent.ts | 10 +- lib/classes/messages/CrossedRegion.ts | 10 +- lib/classes/messages/DirClassifiedQuery.ts | 10 +- .../messages/DirClassifiedQueryBackend.ts | 10 +- lib/classes/messages/DirClassifiedReply.ts | 10 +- lib/classes/messages/DirEventsReply.ts | 20 +- lib/classes/messages/DirFindQuery.ts | 10 +- lib/classes/messages/DirFindQueryBackend.ts | 10 +- lib/classes/messages/DirGroupsReply.ts | 10 +- lib/classes/messages/DirLandReply.ts | 10 +- lib/classes/messages/DirPeopleReply.ts | 30 +-- lib/classes/messages/DirPlacesQuery.ts | 20 +- lib/classes/messages/DirPlacesQueryBackend.ts | 20 +- lib/classes/messages/DirPlacesReply.ts | 10 +- lib/classes/messages/DirPopularReply.ts | 10 +- lib/classes/messages/EdgeDataPacket.ts | 10 +- lib/classes/messages/EmailMessageReply.ts | 40 ++-- lib/classes/messages/EmailMessageRequest.ts | 20 +- lib/classes/messages/Error.ts | 40 ++-- lib/classes/messages/EstateCovenantReply.ts | 10 +- lib/classes/messages/EstateOwnerMessage.ts | 20 +- lib/classes/messages/EventGodDelete.ts | 10 +- lib/classes/messages/EventInfoReply.ts | 60 +++--- lib/classes/messages/FeatureDisabled.ts | 10 +- lib/classes/messages/FetchInventoryReply.ts | 20 +- lib/classes/messages/GenericMessage.ts | 20 +- lib/classes/messages/GodKickUser.ts | 10 +- lib/classes/messages/GodUpdateRegionInfo.ts | 10 +- lib/classes/messages/GodlikeMessage.ts | 20 +- .../messages/GroupAccountDetailsReply.ts | 20 +- .../messages/GroupAccountSummaryReply.ts | 30 +-- .../messages/GroupAccountTransactionsReply.ts | 40 ++-- .../messages/GroupActiveProposalItemReply.ts | 50 ++--- lib/classes/messages/GroupDataUpdate.ts | 10 +- lib/classes/messages/GroupMembersReply.ts | 20 +- lib/classes/messages/GroupNoticeAdd.ts | 30 +-- lib/classes/messages/GroupNoticesListReply.ts | 20 +- lib/classes/messages/GroupProfileReply.ts | 30 +-- lib/classes/messages/GroupProposalBallot.ts | 10 +- lib/classes/messages/GroupRoleDataReply.ts | 30 +-- lib/classes/messages/GroupRoleUpdate.ts | 30 +-- lib/classes/messages/GroupTitlesReply.ts | 10 +- .../messages/GroupVoteHistoryItemReply.ts | 70 +++---- lib/classes/messages/ImageData.ts | 10 +- lib/classes/messages/ImagePacket.ts | 10 +- .../messages/ImprovedInstantMessage.ts | 30 +-- .../messages/ImprovedTerseObjectUpdate.ts | 20 +- lib/classes/messages/InitiateDownload.ts | 20 +- lib/classes/messages/InternalScriptMail.ts | 30 +-- lib/classes/messages/InventoryDescendents.ts | 30 +-- lib/classes/messages/KickUser.ts | 10 +- lib/classes/messages/LandStatReply.ts | 20 +- lib/classes/messages/LandStatRequest.ts | 10 +- lib/classes/messages/LayerData.ts | 10 +- lib/classes/messages/LinkInventoryItem.ts | 20 +- lib/classes/messages/LiveHelpGroupReply.ts | 10 +- lib/classes/messages/LoadURL.ts | 30 +-- lib/classes/messages/LogDwellTime.ts | 10 +- lib/classes/messages/LogTextMessage.ts | 10 +- lib/classes/messages/MapBlockReply.ts | 10 +- lib/classes/messages/MapItemReply.ts | 10 +- lib/classes/messages/MapNameRequest.ts | 10 +- lib/classes/messages/MoneyBalanceReply.ts | 20 +- lib/classes/messages/MoneyTransferBackend.ts | 10 +- lib/classes/messages/MoneyTransferRequest.ts | 10 +- lib/classes/messages/MoveInventoryItem.ts | 10 +- lib/classes/messages/MultipleObjectUpdate.ts | 10 +- lib/classes/messages/MuteListUpdate.ts | 10 +- lib/classes/messages/NameValuePair.ts | 10 +- lib/classes/messages/NeighborList.ts | 10 +- lib/classes/messages/ObjectDescription.ts | 10 +- lib/classes/messages/ObjectExtraParams.ts | 10 +- lib/classes/messages/ObjectImage.ts | 20 +- lib/classes/messages/ObjectName.ts | 10 +- lib/classes/messages/ObjectProperties.ts | 50 ++--- .../messages/ObjectPropertiesFamily.ts | 20 +- lib/classes/messages/ObjectUpdate.ts | 90 ++++---- .../messages/ObjectUpdateCompressed.ts | 10 +- lib/classes/messages/ParcelInfoReply.ts | 30 +-- lib/classes/messages/ParcelMediaUpdate.ts | 30 +-- lib/classes/messages/ParcelOverlay.ts | 10 +- lib/classes/messages/ParcelProperties.ts | 50 ++--- .../messages/ParcelPropertiesUpdate.ts | 40 ++-- lib/classes/messages/ParcelRename.ts | 10 +- lib/classes/messages/PickInfoReply.ts | 50 ++--- lib/classes/messages/PickInfoUpdate.ts | 20 +- lib/classes/messages/PlacesQuery.ts | 20 +- lib/classes/messages/PlacesReply.ts | 30 +-- lib/classes/messages/RegionHandshake.ts | 40 ++-- lib/classes/messages/RegionInfo.ts | 30 +-- .../messages/RegionPresenceResponse.ts | 10 +- lib/classes/messages/RemoveMuteListEntry.ts | 10 +- lib/classes/messages/RemoveNameValuePair.ts | 10 +- lib/classes/messages/ReplyTaskInventory.ts | 10 +- lib/classes/messages/RequestXfer.ts | 10 +- .../messages/RezMultipleAttachmentsFromInv.ts | 20 +- lib/classes/messages/RezObject.ts | 20 +- lib/classes/messages/RezRestoreToWorld.ts | 20 +- lib/classes/messages/RezScript.ts | 20 +- .../messages/RezSingleAttachmentFromInv.ts | 20 +- .../messages/RoutedMoneyBalanceReply.ts | 20 +- lib/classes/messages/RpcScriptReplyInbound.ts | 10 +- .../messages/RpcScriptRequestInbound.ts | 10 +- .../RpcScriptRequestInboundForward.ts | 10 +- lib/classes/messages/ScriptDataReply.ts | 10 +- lib/classes/messages/ScriptDataRequest.ts | 10 +- lib/classes/messages/ScriptDialog.ts | 50 ++--- lib/classes/messages/ScriptDialogReply.ts | 10 +- .../messages/ScriptMailRegistration.ts | 10 +- lib/classes/messages/ScriptQuestion.ts | 20 +- lib/classes/messages/ScriptSensorReply.ts | 10 +- lib/classes/messages/ScriptSensorRequest.ts | 10 +- lib/classes/messages/ScriptTeleportRequest.ts | 20 +- lib/classes/messages/SendPostcard.ts | 50 ++--- lib/classes/messages/SendXferPacket.ts | 10 +- .../messages/SetSimPresenceInDatabase.ts | 20 +- .../messages/SetSimStatusInDatabase.ts | 20 +- .../messages/SetStartLocationRequest.ts | 10 +- .../messages/SimulatorPresentAtLocation.ts | 10 +- lib/classes/messages/SimulatorReady.ts | 10 +- lib/classes/messages/StartAuction.ts | 10 +- lib/classes/messages/StartGroupProposal.ts | 10 +- lib/classes/messages/StartLure.ts | 10 +- lib/classes/messages/StateSave.ts | 10 +- lib/classes/messages/SystemMessage.ts | 20 +- lib/classes/messages/TelehubInfo.ts | 10 +- lib/classes/messages/TeleportFailed.ts | 30 +-- lib/classes/messages/TeleportFinish.ts | 10 +- lib/classes/messages/TeleportProgress.ts | 10 +- lib/classes/messages/TransferInfo.ts | 10 +- lib/classes/messages/TransferPacket.ts | 10 +- lib/classes/messages/TransferRequest.ts | 10 +- lib/classes/messages/UUIDGroupNameReply.ts | 10 +- lib/classes/messages/UUIDNameReply.ts | 20 +- lib/classes/messages/UpdateAttachment.ts | 20 +- .../messages/UpdateCreateInventoryItem.ts | 20 +- lib/classes/messages/UpdateGroupInfo.ts | 10 +- lib/classes/messages/UpdateInventoryFolder.ts | 10 +- lib/classes/messages/UpdateInventoryItem.ts | 20 +- lib/classes/messages/UpdateMuteListEntry.ts | 10 +- lib/classes/messages/UpdateParcel.ts | 30 +-- lib/classes/messages/UpdateSimulator.ts | 10 +- lib/classes/messages/UpdateTaskInventory.ts | 20 +- lib/classes/messages/UpdateUserInfo.ts | 10 +- lib/classes/messages/UserInfoReply.ts | 20 +- lib/classes/messages/UserReport.ts | 40 ++-- lib/classes/messages/UserReportInternal.ts | 40 ++-- lib/classes/messages/ViewerEffect.ts | 10 +- lib/classes/messages/ViewerStats.ts | 30 +-- tools/writePacketClasses.js | 12 +- 195 files changed, 2005 insertions(+), 1881 deletions(-) create mode 100644 lib/classes/Utils.ts diff --git a/example/testBot.js b/example/testBot.js index 0ab983d..60a61dc 100644 --- a/example/testBot.js +++ b/example/testBot.js @@ -12,14 +12,30 @@ const bot = new nmv.Bot(loginParameters); let resp = null; -bot.Login().then((response) => +bot.login().then((response) => { //Establish circuit wit region resp = response; - return response.region.circuit.establish(response.agent.agentID); + return bot.connectToSim(); }).then(() => { - resp.region.circuit.sendInstantMessage(resp.agent.agentID, "dbcd7dfe-a5db-4736-91bc-2af1e69902e6", "FUCK YOU"); + let it = 0; + setInterval(() => + { + it++; + if (it < 11) + { + bot.sendInstantMessage("dbcd7dfe-a5db-4736-91bc-2af1e69902e6", "Test " + it); + bot.sendInstantMessage("d1cd5b71-6209-4595-9bf0-771bf689ce00", "Test " + it); + } + }, 1000); +}).then(() => +{ + console.log("IM 1 Sent"); +}).then(() => +{ + //console.log("Logging off"); + //return bot.close(); }).catch((error) => { console.log("Error:"); diff --git a/lib/Bot.ts b/lib/Bot.ts index 77e92c4..63bd847 100644 --- a/lib/Bot.ts +++ b/lib/Bot.ts @@ -1,23 +1,74 @@ import {LoginHandler} from './LoginHandler'; import {LoginResponse} from './classes/LoginResponse'; import {LoginParameters} from './classes/LoginParameters'; +import {Agent} from './classes/Agent'; +import {UUID} from './classes/UUID'; +import {Vector3} from './classes/Vector3'; +import {ImprovedInstantMessageMessage} from './classes/messages/ImprovedInstantMessage'; +import {PacketFlags} from './enums/PacketFlags'; +import {UseCircuitCodeMessage} from './classes/messages/UseCircuitCode'; +import {CompleteAgentMovementMessage} from './classes/messages/CompleteAgentMovement'; +import {Message} from './enums/Message'; +import {Packet} from './classes/Packet'; +import {Region} from './classes/Region'; +import {LogoutRequestMessage} from './classes/messages/LogoutRequest'; +import {Utils} from './classes/Utils'; export class Bot { loginParams: LoginParameters; + currentRegion: Region; + agent: Agent; constructor(login: LoginParameters) { this.loginParams = login; } - Login() + sendInstantMessage(to: UUID | string, message: string): Promise + { + const circuit = this.currentRegion.circuit; + if (typeof to === 'string') + { + to = new UUID(to); + } + message += '\0'; + const agentName = this.agent.firstName + ' ' + this.agent.lastName; + const im: ImprovedInstantMessageMessage = new ImprovedInstantMessageMessage(); + im.AgentData = { + AgentID: this.agent.agentID, + SessionID: circuit.sessionID + }; + im.MessageBlock = { + FromGroup: false, + ToAgentID: to, + ParentEstateID: 0, + RegionID: UUID.zero(), + Position: Vector3.getZero(), + Offline: 0, + Dialog: 0, + ID: UUID.zero(), + Timestamp: 0, + FromAgentName: Utils.StringToBuffer(agentName), + Message: Utils.StringToBuffer(message), + BinaryBucket: Buffer.allocUnsafe(0) + }; + im.EstateBlock = { + EstateID: 0 + }; + const sequenceNo = circuit.sendMessage(im, PacketFlags.Reliable); + return circuit.waitForAck(sequenceNo, 10000); + } + + login() { return new Promise((resolve, reject) => { const loginHandler = new LoginHandler(); loginHandler.Login(this.loginParams).then((response: LoginResponse) => { + this.currentRegion = response.region; + this.agent = response.agent; resolve(response); }).catch((error: Error) => { @@ -25,4 +76,61 @@ export class Bot }); }); } + + close() + { + return new Promise((resolve, reject) => + { + const circuit = this.currentRegion.circuit; + const msg: LogoutRequestMessage = new LogoutRequestMessage(); + msg.AgentData = { + AgentID: this.agent.agentID, + SessionID: circuit.sessionID + }; + circuit.sendMessage(msg, PacketFlags.Reliable); + circuit.waitForMessage(Message.LogoutReply, 5000).then((packet: Packet) => + { + + }).catch((error) => + { + console.error('Timeout waiting for logout reply') + }).then(() => + { + circuit.shutdown(); + resolve(); + }); + }); + } + + connectToSim() + { + return new Promise((resolve, reject) => + { + const circuit = this.currentRegion.circuit; + circuit.init(); + const msg: UseCircuitCodeMessage = new UseCircuitCodeMessage(); + msg.CircuitCode = { + SessionID: circuit.sessionID, + ID: this.agent.agentID, + Code: circuit.circuitCode + }; + circuit.waitForAck(circuit.sendMessage(msg, PacketFlags.Reliable), 1000).then(() => + { + const agentMovement: CompleteAgentMovementMessage = new CompleteAgentMovementMessage(); + agentMovement.AgentData = { + AgentID: this.agent.agentID, + SessionID: circuit.sessionID, + CircuitCode: circuit.circuitCode + }; + circuit.sendMessage(agentMovement, PacketFlags.Reliable); + return circuit.waitForMessage(Message.RegionHandshake, 10000); + }).then((packet: Packet) => + { + resolve(); + }).catch((error) => + { + reject(error); + }); + }); + } } diff --git a/lib/classes/Circuit.ts b/lib/classes/Circuit.ts index 23b3cbc..7489c78 100644 --- a/lib/classes/Circuit.ts +++ b/lib/classes/Circuit.ts @@ -3,21 +3,18 @@ import {AddressInfo, Socket} from 'dgram'; import * as dgram from 'dgram'; import {PacketFlags} from '../enums/PacketFlags'; import {Packet} from './Packet'; -import {UseCircuitCodeMessage} from './messages/UseCircuitCode'; import {MessageBase} from './MessageBase'; import {PacketAckMessage} from './messages/PacketAck'; import {Message} from '../enums/Message'; import {StartPingCheckMessage} from './messages/StartPingCheck'; import {CompletePingCheckMessage} from './messages/CompletePingCheck'; -import {CompleteAgentMovementMessage} from './messages/CompleteAgentMovement'; import {Subscription} from 'rxjs/Subscription'; import {Subject} from 'rxjs/Subject'; import Timer = NodeJS.Timer; -import {ImprovedInstantMessageMessage} from './messages/ImprovedInstantMessage'; -import {Vector3} from './Vector3'; export class Circuit { + agentID: UUID; secureSessionID: UUID; sessionID: UUID; circuitCode: number; @@ -37,19 +34,22 @@ export class Circuit } = {}; onPacketReceived: Subject; + onAckReceived: Subject; constructor() { this.onPacketReceived = new Subject(); + this.onAckReceived = new Subject(); } - sendMessage(message: MessageBase, flags: PacketFlags) + sendMessage(message: MessageBase, flags: PacketFlags): number { const packet: Packet = new Packet(); packet.message = message; packet.sequenceNumber = this.sequenceNumber++; packet.packetFlags = flags; this.sendPacket(packet); + return packet.sequenceNumber; } resend(sequenceNumber: number) @@ -62,7 +62,87 @@ export class Circuit } } - waitForMessage(id: Message, timeout: number) + waitForAck(ack: number, timeout: number): Promise + { + return new Promise((resolve, reject) => + { + const handleObj: { + timeout: Timer | null, + subscription: Subscription | null + } = { + timeout: null, + subscription: null + }; + handleObj.timeout = setTimeout(() => + { + if (handleObj.subscription !== null) + { + handleObj.subscription.unsubscribe(); + reject(new Error('Timeout')); + } + }, timeout); + + handleObj.subscription = this.onAckReceived.subscribe((sequenceNumber: number) => + { + if (sequenceNumber === ack) + { + if (handleObj.timeout !== null) + { + clearTimeout(handleObj.timeout); + handleObj.timeout = null; + } + if (handleObj.subscription !== null) + { + handleObj.subscription.unsubscribe(); + handleObj.subscription = null; + } + resolve(); + } + }); + }); + } + + init() + { + if (this.client !== null) + { + this.client.close(); + } + this.client = dgram.createSocket('udp4'); + this.client.on('listening', () => + { + + }); + + this.client.on('message', (message, remote) => + { + if (remote.address === this.ipAddress) + { + this.receivedPacket(message); + } + }); + + this.client.on('error', (error) => + { + + }); + } + + shutdown() + { + if (this.client !== null) + { + Object.keys(this.awaitingAck).forEach((sequenceNumber: string) => + { + clearTimeout(this.awaitingAck[parseInt(sequenceNumber, 10)].timeout); + delete this.awaitingAck[parseInt(sequenceNumber, 10)]; + }); + this.client.close(); + this.client = null; + } + } + + waitForMessage(id: Message, timeout: number): Promise { return new Promise((resolve, reject) => { @@ -98,13 +178,6 @@ export class Circuit } resolve(packet); } - }, - (err) => - { - console.error(err); - }, () => - { - console.log('Subscription complete'); }); }); } @@ -124,6 +197,7 @@ export class Circuit dataToSend = packet.writeToBuffer(dataToSend, 0); if (this.client !== null) { + console.log("Writing to "+this.ipAddress+":"+this.port); this.client.send(dataToSend, 0, dataToSend.length, this.port, this.ipAddress, (err, bytes) => { let resend = ''; @@ -140,57 +214,22 @@ export class Circuit } } - ackReceived(sequenceID: number) + ackReceived(sequenceNumber: number) { - if (this.awaitingAck[sequenceID]) + if (this.awaitingAck[sequenceNumber]) { - clearTimeout(this.awaitingAck[sequenceID].timeout); - delete this.awaitingAck[sequenceID]; + clearTimeout(this.awaitingAck[sequenceNumber].timeout); + delete this.awaitingAck[sequenceNumber]; } + this.onAckReceived.next(sequenceNumber); } - sendInstantMessage(from: UUID | string, to: UUID | string, message: string) - { - if (typeof from === 'string') - { - from = new UUID(from); - } - if (typeof to === 'string') - { - to = new UUID(to); - } - message += '\0'; - const im: ImprovedInstantMessageMessage = new ImprovedInstantMessageMessage(); - im.AgentData = { - AgentID: from, - SessionID: this.sessionID - }; - im.MessageBlock = { - FromGroup: false, - ToAgentID: to, - ParentEstateID: 0, - RegionID: UUID.zero(), - Position: Vector3.getZero(), - Offline: 0, - Dialog: 0, - ID: UUID.zero(), - Timestamp: 0, - FromAgentName: 'Yo Momma', - Message: message, - BinaryBucket: '' - }; - im.EstateBlock = { - EstateID: 0 - }; - this.sendMessage(im, PacketFlags.Reliable); - } - - sendAck(sequenceID: number) + sendAck(sequenceNumber: number) { const msg: PacketAckMessage = new PacketAckMessage(); msg.Packets = [ { - ID: sequenceID + ID: sequenceNumber } ]; this.sendMessage(msg, 0); @@ -221,52 +260,4 @@ export class Circuit } this.onPacketReceived.next(packet); } - - establish(agentID: UUID) - { - return new Promise((resolve, reject) => - { - if (this.client !== null) - { - this.client.close(); - } - this.client = dgram.createSocket('udp4'); - this.client.on('listening', () => - { - - }); - - this.client.on('message', (message, remote) => - { - if (remote.address === this.ipAddress) - { - this.receivedPacket(message); - } - }); - - const msg: UseCircuitCodeMessage = new UseCircuitCodeMessage(); - msg.CircuitCode = { - SessionID: this.sessionID, - ID: agentID, - Code: this.circuitCode - }; - this.sendMessage(msg, PacketFlags.Reliable); - - const agentMovement: CompleteAgentMovementMessage = new CompleteAgentMovementMessage(); - agentMovement.AgentData = { - AgentID: agentID, - SessionID: this.sessionID, - CircuitCode: this.circuitCode - }; - this.sendMessage(agentMovement, PacketFlags.Reliable); - - this.waitForMessage(Message.RegionHandshake, 10000).then((packet: Packet) => - { - resolve(); - }).catch((error) => - { - reject(error); - }); - }); - } } diff --git a/lib/classes/LoginResponse.ts b/lib/classes/LoginResponse.ts index 66520a0..df3e6b4 100644 --- a/lib/classes/LoginResponse.ts +++ b/lib/classes/LoginResponse.ts @@ -309,6 +309,7 @@ export class LoginResponse break; case 'agent_id': this.agent.agentID = new UUID(val); + this.region.circuit.agentID = new UUID(val); break; case 'seconds_since_epoch': this.region.circuit.timestamp = parseInt(val, 10); diff --git a/lib/classes/Packet.ts b/lib/classes/Packet.ts index 1eb2f85..9434ad3 100644 --- a/lib/classes/Packet.ts +++ b/lib/classes/Packet.ts @@ -38,7 +38,7 @@ export class Packet buf.writeUInt8(this.extraHeader.length, pos++); if (this.extraHeader.length > 0) { - this.extraHeader.copy(buf, pos, 0, this.extraHeader.length - 1); + this.extraHeader.copy(buf, pos); pos += this.extraHeader.length; } const bodyStart = pos; diff --git a/lib/classes/Utils.ts b/lib/classes/Utils.ts new file mode 100644 index 0000000..dcd2b89 --- /dev/null +++ b/lib/classes/Utils.ts @@ -0,0 +1,7 @@ +export class Utils +{ + static StringToBuffer(str: string): Buffer + { + return Buffer.from(str + '\0', 'utf8'); + } +} \ No newline at end of file diff --git a/lib/classes/Zerocoder.ts b/lib/classes/Zerocoder.ts index c0dc6b1..8f9ad26 100644 --- a/lib/classes/Zerocoder.ts +++ b/lib/classes/Zerocoder.ts @@ -25,8 +25,9 @@ export class Zerocoder bytes += (zero - 2); } - const newBuf = Buffer.allocUnsafe((end + 1) - bytes); - buf.copy(newBuf, 0, 0, start - 1); + const newBuf = Buffer.allocUnsafe(end - bytes); + buf.copy(newBuf, 0, 0, start); + let newBufIndex = start; zero = 0; for (let i = start; i <= end; i++) diff --git a/lib/classes/messages/AgentAlertMessage.ts b/lib/classes/messages/AgentAlertMessage.ts index a468f3e..defb532 100644 --- a/lib/classes/messages/AgentAlertMessage.ts +++ b/lib/classes/messages/AgentAlertMessage.ts @@ -16,7 +16,7 @@ export class AgentAlertMessageMessage implements MessageBase }; AlertData: { Modal: boolean; - Message: string; + Message: Buffer; }; getSize(): number @@ -31,7 +31,7 @@ export class AgentAlertMessageMessage implements MessageBase pos += 16; buf.writeUInt8((this.AlertData['Modal']) ? 1 : 0, pos++); buf.writeUInt8(this.AlertData['Message'].length, pos++); - buf.write(this.AlertData['Message'], pos); + this.AlertData['Message'].copy(buf, pos); pos += this.AlertData['Message'].length; return pos - startPos; } @@ -50,14 +50,14 @@ export class AgentAlertMessageMessage implements MessageBase this.AgentData = newObjAgentData; const newObjAlertData: { Modal: boolean, - Message: string + Message: Buffer } = { Modal: false, - Message: '' + Message: Buffer.allocUnsafe(0) }; newObjAlertData['Modal'] = (buf.readUInt8(pos++) === 1); varLength = buf.readUInt8(pos++); - newObjAlertData['Message'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAlertData['Message'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.AlertData = newObjAlertData; return pos - startPos; diff --git a/lib/classes/messages/AgentAnimation.ts b/lib/classes/messages/AgentAnimation.ts index e23d666..9a43162 100644 --- a/lib/classes/messages/AgentAnimation.ts +++ b/lib/classes/messages/AgentAnimation.ts @@ -20,7 +20,7 @@ export class AgentAnimationMessage implements MessageBase StartAnim: boolean; }[]; PhysicalAvatarEventList: { - TypeData: string; + TypeData: Buffer; }[]; getSize(): number @@ -58,7 +58,7 @@ export class AgentAnimationMessage implements MessageBase for (let i = 0; i < count; i++) { buf.writeUInt8(this.PhysicalAvatarEventList[i]['TypeData'].length, pos++); - buf.write(this.PhysicalAvatarEventList[i]['TypeData'], pos); + this.PhysicalAvatarEventList[i]['TypeData'].copy(buf, pos); pos += this.PhysicalAvatarEventList[i]['TypeData'].length; } return pos - startPos; @@ -101,12 +101,12 @@ export class AgentAnimationMessage implements MessageBase for (let i = 0; i < count; i++) { const newObjPhysicalAvatarEventList: { - TypeData: string + TypeData: Buffer } = { - TypeData: '' + TypeData: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjPhysicalAvatarEventList['TypeData'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjPhysicalAvatarEventList['TypeData'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.PhysicalAvatarEventList.push(newObjPhysicalAvatarEventList); } diff --git a/lib/classes/messages/AgentCachedTextureResponse.ts b/lib/classes/messages/AgentCachedTextureResponse.ts index a16612a..b625762 100644 --- a/lib/classes/messages/AgentCachedTextureResponse.ts +++ b/lib/classes/messages/AgentCachedTextureResponse.ts @@ -19,7 +19,7 @@ export class AgentCachedTextureResponseMessage implements MessageBase WearableData: { TextureID: UUID; TextureIndex: number; - HostName: string; + HostName: Buffer; }[]; getSize(): number @@ -54,7 +54,7 @@ export class AgentCachedTextureResponseMessage 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; } return pos - startPos; @@ -87,17 +87,17 @@ export class AgentCachedTextureResponseMessage implements MessageBase const newObjWearableData: { TextureID: UUID, TextureIndex: number, - HostName: string + HostName: Buffer } = { TextureID: UUID.zero(), TextureIndex: 0, - HostName: '' + HostName: Buffer.allocUnsafe(0) }; newObjWearableData['TextureID'] = 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); } diff --git a/lib/classes/messages/AgentDataUpdate.ts b/lib/classes/messages/AgentDataUpdate.ts index cf8b69d..acc740b 100644 --- a/lib/classes/messages/AgentDataUpdate.ts +++ b/lib/classes/messages/AgentDataUpdate.ts @@ -14,12 +14,12 @@ export class AgentDataUpdateMessage implements MessageBase AgentData: { AgentID: UUID; - FirstName: string; - LastName: string; - GroupTitle: string; + FirstName: Buffer; + LastName: Buffer; + GroupTitle: Buffer; ActiveGroupID: UUID; GroupPowers: Long; - GroupName: string; + GroupName: Buffer; }; getSize(): number @@ -33,13 +33,13 @@ export class AgentDataUpdateMessage implements MessageBase this.AgentData['AgentID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.AgentData['FirstName'].length, pos++); - buf.write(this.AgentData['FirstName'], pos); + this.AgentData['FirstName'].copy(buf, pos); pos += this.AgentData['FirstName'].length; buf.writeUInt8(this.AgentData['LastName'].length, pos++); - buf.write(this.AgentData['LastName'], pos); + this.AgentData['LastName'].copy(buf, pos); pos += this.AgentData['LastName'].length; buf.writeUInt8(this.AgentData['GroupTitle'].length, pos++); - buf.write(this.AgentData['GroupTitle'], pos); + this.AgentData['GroupTitle'].copy(buf, pos); pos += this.AgentData['GroupTitle'].length; this.AgentData['ActiveGroupID'].writeToBuffer(buf, pos); pos += 16; @@ -48,7 +48,7 @@ export class AgentDataUpdateMessage implements MessageBase buf.writeInt32LE(this.AgentData['GroupPowers'].high, pos); pos += 4; buf.writeUInt8(this.AgentData['GroupName'].length, pos++); - buf.write(this.AgentData['GroupName'], pos); + this.AgentData['GroupName'].copy(buf, pos); pos += this.AgentData['GroupName'].length; return pos - startPos; } @@ -59,38 +59,38 @@ export class AgentDataUpdateMessage implements MessageBase let varLength = 0; const newObjAgentData: { AgentID: UUID, - FirstName: string, - LastName: string, - GroupTitle: string, + FirstName: Buffer, + LastName: Buffer, + GroupTitle: Buffer, ActiveGroupID: UUID, GroupPowers: Long, - GroupName: string + GroupName: Buffer } = { AgentID: UUID.zero(), - FirstName: '', - LastName: '', - GroupTitle: '', + FirstName: Buffer.allocUnsafe(0), + LastName: Buffer.allocUnsafe(0), + GroupTitle: Buffer.allocUnsafe(0), ActiveGroupID: UUID.zero(), GroupPowers: Long.ZERO, - GroupName: '' + GroupName: Buffer.allocUnsafe(0) }; newObjAgentData['AgentID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjAgentData['FirstName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAgentData['FirstName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjAgentData['LastName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAgentData['LastName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjAgentData['GroupTitle'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAgentData['GroupTitle'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjAgentData['ActiveGroupID'] = new UUID(buf, pos); pos += 16; newObjAgentData['GroupPowers'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4)); pos += 8; varLength = buf.readUInt8(pos++); - newObjAgentData['GroupName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAgentData['GroupName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.AgentData = newObjAgentData; return pos - startPos; diff --git a/lib/classes/messages/AgentGroupDataUpdate.ts b/lib/classes/messages/AgentGroupDataUpdate.ts index 5be01f8..6f62ec7 100644 --- a/lib/classes/messages/AgentGroupDataUpdate.ts +++ b/lib/classes/messages/AgentGroupDataUpdate.ts @@ -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); } diff --git a/lib/classes/messages/AgentMovementComplete.ts b/lib/classes/messages/AgentMovementComplete.ts index 0c8165b..5aab136 100644 --- a/lib/classes/messages/AgentMovementComplete.ts +++ b/lib/classes/messages/AgentMovementComplete.ts @@ -24,7 +24,7 @@ export class AgentMovementCompleteMessage implements MessageBase Timestamp: number; }; SimData: { - ChannelVersion: string; + ChannelVersion: Buffer; }; getSize(): number @@ -51,7 +51,7 @@ export class AgentMovementCompleteMessage implements MessageBase pos += 4; buf.writeUInt16LE(this.SimData['ChannelVersion'].length, pos); pos += 2; - buf.write(this.SimData['ChannelVersion'], pos); + this.SimData['ChannelVersion'].copy(buf, pos); pos += this.SimData['ChannelVersion'].length; return pos - startPos; } @@ -93,13 +93,13 @@ export class AgentMovementCompleteMessage implements MessageBase pos += 4; this.Data = newObjData; const newObjSimData: { - ChannelVersion: string + ChannelVersion: Buffer } = { - ChannelVersion: '' + ChannelVersion: Buffer.allocUnsafe(0) }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjSimData['ChannelVersion'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjSimData['ChannelVersion'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.SimData = newObjSimData; return pos - startPos; diff --git a/lib/classes/messages/AgentSetAppearance.ts b/lib/classes/messages/AgentSetAppearance.ts index 6293075..46e1b93 100644 --- a/lib/classes/messages/AgentSetAppearance.ts +++ b/lib/classes/messages/AgentSetAppearance.ts @@ -23,7 +23,7 @@ export class AgentSetAppearanceMessage implements MessageBase TextureIndex: number; }[]; ObjectData: { - TextureEntry: string; + TextureEntry: Buffer; }; VisualParam: { ParamValue: number; @@ -55,7 +55,7 @@ export class AgentSetAppearanceMessage implements MessageBase } buf.writeUInt16LE(this.ObjectData['TextureEntry'].length, pos); pos += 2; - buf.write(this.ObjectData['TextureEntry'], pos); + this.ObjectData['TextureEntry'].copy(buf, pos); pos += this.ObjectData['TextureEntry'].length; count = this.VisualParam.length; buf.writeUInt8(this.VisualParam.length, pos++); @@ -107,13 +107,13 @@ export class AgentSetAppearanceMessage implements MessageBase this.WearableData.push(newObjWearableData); } const newObjObjectData: { - TextureEntry: string + TextureEntry: Buffer } = { - TextureEntry: '' + TextureEntry: Buffer.allocUnsafe(0) }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjObjectData['TextureEntry'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['TextureEntry'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ObjectData = newObjObjectData; count = buf.readUInt8(pos++); diff --git a/lib/classes/messages/AgentThrottle.ts b/lib/classes/messages/AgentThrottle.ts index d449d11..6b12463 100644 --- a/lib/classes/messages/AgentThrottle.ts +++ b/lib/classes/messages/AgentThrottle.ts @@ -18,7 +18,7 @@ export class AgentThrottleMessage implements MessageBase }; Throttle: { GenCounter: number; - Throttles: string; + Throttles: Buffer; }; getSize(): number @@ -38,7 +38,7 @@ export class AgentThrottleMessage implements MessageBase buf.writeUInt32LE(this.Throttle['GenCounter'], pos); pos += 4; buf.writeUInt8(this.Throttle['Throttles'].length, pos++); - buf.write(this.Throttle['Throttles'], pos); + this.Throttle['Throttles'].copy(buf, pos); pos += this.Throttle['Throttles'].length; return pos - startPos; } @@ -65,15 +65,15 @@ export class AgentThrottleMessage implements MessageBase this.AgentData = newObjAgentData; const newObjThrottle: { GenCounter: number, - Throttles: string + Throttles: Buffer } = { GenCounter: 0, - Throttles: '' + Throttles: Buffer.allocUnsafe(0) }; newObjThrottle['GenCounter'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjThrottle['Throttles'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjThrottle['Throttles'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.Throttle = newObjThrottle; return pos - startPos; diff --git a/lib/classes/messages/AlertMessage.ts b/lib/classes/messages/AlertMessage.ts index ea9cb7e..e2b51b5 100644 --- a/lib/classes/messages/AlertMessage.ts +++ b/lib/classes/messages/AlertMessage.ts @@ -12,11 +12,11 @@ export class AlertMessageMessage implements MessageBase id = Message.AlertMessage; AlertData: { - Message: string; + Message: Buffer; }; AlertInfo: { - Message: string; - ExtraParams: string; + Message: Buffer; + ExtraParams: Buffer; }[]; AgentInfo: { AgentID: UUID; @@ -41,17 +41,17 @@ export class AlertMessageMessage implements MessageBase { const startPos = pos; buf.writeUInt8(this.AlertData['Message'].length, pos++); - buf.write(this.AlertData['Message'], pos); + this.AlertData['Message'].copy(buf, pos); pos += this.AlertData['Message'].length; let count = this.AlertInfo.length; buf.writeUInt8(this.AlertInfo.length, pos++); for (let i = 0; i < count; i++) { buf.writeUInt8(this.AlertInfo[i]['Message'].length, pos++); - buf.write(this.AlertInfo[i]['Message'], pos); + this.AlertInfo[i]['Message'].copy(buf, pos); pos += this.AlertInfo[i]['Message'].length; buf.writeUInt8(this.AlertInfo[i]['ExtraParams'].length, pos++); - buf.write(this.AlertInfo[i]['ExtraParams'], pos); + this.AlertInfo[i]['ExtraParams'].copy(buf, pos); pos += this.AlertInfo[i]['ExtraParams'].length; } count = this.AgentInfo.length; @@ -69,12 +69,12 @@ export class AlertMessageMessage implements MessageBase const startPos = pos; let varLength = 0; const newObjAlertData: { - Message: string + Message: Buffer } = { - Message: '' + Message: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjAlertData['Message'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAlertData['Message'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.AlertData = newObjAlertData; let count = buf.readUInt8(pos++); @@ -82,17 +82,17 @@ export class AlertMessageMessage implements MessageBase for (let i = 0; i < count; i++) { const newObjAlertInfo: { - Message: string, - ExtraParams: string + Message: Buffer, + ExtraParams: Buffer } = { - Message: '', - ExtraParams: '' + Message: Buffer.allocUnsafe(0), + ExtraParams: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjAlertInfo['Message'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAlertInfo['Message'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjAlertInfo['ExtraParams'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAlertInfo['ExtraParams'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.AlertInfo.push(newObjAlertInfo); } diff --git a/lib/classes/messages/AssetUploadRequest.ts b/lib/classes/messages/AssetUploadRequest.ts index df59b49..9e63bbb 100644 --- a/lib/classes/messages/AssetUploadRequest.ts +++ b/lib/classes/messages/AssetUploadRequest.ts @@ -16,7 +16,7 @@ export class AssetUploadRequestMessage implements MessageBase Type: number; Tempfile: boolean; StoreLocal: boolean; - AssetData: string; + AssetData: Buffer; }; getSize(): number @@ -34,7 +34,7 @@ export class AssetUploadRequestMessage implements MessageBase buf.writeUInt8((this.AssetBlock['StoreLocal']) ? 1 : 0, pos++); buf.writeUInt16LE(this.AssetBlock['AssetData'].length, pos); pos += 2; - buf.write(this.AssetBlock['AssetData'], pos); + this.AssetBlock['AssetData'].copy(buf, pos); pos += this.AssetBlock['AssetData'].length; return pos - startPos; } @@ -48,13 +48,13 @@ export class AssetUploadRequestMessage implements MessageBase Type: number, Tempfile: boolean, StoreLocal: boolean, - AssetData: string + AssetData: Buffer } = { TransactionID: UUID.zero(), Type: 0, Tempfile: false, StoreLocal: false, - AssetData: '' + AssetData: Buffer.allocUnsafe(0) }; newObjAssetBlock['TransactionID'] = new UUID(buf, pos); pos += 16; @@ -63,7 +63,7 @@ export class AssetUploadRequestMessage implements MessageBase newObjAssetBlock['StoreLocal'] = (buf.readUInt8(pos++) === 1); varLength = buf.readUInt16LE(pos); pos += 2; - newObjAssetBlock['AssetData'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAssetBlock['AssetData'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.AssetBlock = newObjAssetBlock; return pos - startPos; diff --git a/lib/classes/messages/AvatarAnimation.ts b/lib/classes/messages/AvatarAnimation.ts index 88e3813..a714063 100644 --- a/lib/classes/messages/AvatarAnimation.ts +++ b/lib/classes/messages/AvatarAnimation.ts @@ -22,7 +22,7 @@ export class AvatarAnimationMessage implements MessageBase ObjectID: UUID; }[]; PhysicalAvatarEventList: { - TypeData: string; + TypeData: Buffer; }[]; getSize(): number @@ -66,7 +66,7 @@ export class AvatarAnimationMessage implements MessageBase for (let i = 0; i < count; i++) { buf.writeUInt8(this.PhysicalAvatarEventList[i]['TypeData'].length, pos++); - buf.write(this.PhysicalAvatarEventList[i]['TypeData'], pos); + this.PhysicalAvatarEventList[i]['TypeData'].copy(buf, pos); pos += this.PhysicalAvatarEventList[i]['TypeData'].length; } return pos - startPos; @@ -119,12 +119,12 @@ export class AvatarAnimationMessage implements MessageBase for (let i = 0; i < count; i++) { const newObjPhysicalAvatarEventList: { - TypeData: string + TypeData: Buffer } = { - TypeData: '' + TypeData: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjPhysicalAvatarEventList['TypeData'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjPhysicalAvatarEventList['TypeData'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.PhysicalAvatarEventList.push(newObjPhysicalAvatarEventList); } diff --git a/lib/classes/messages/AvatarAppearance.ts b/lib/classes/messages/AvatarAppearance.ts index e535864..0efbe56 100644 --- a/lib/classes/messages/AvatarAppearance.ts +++ b/lib/classes/messages/AvatarAppearance.ts @@ -17,7 +17,7 @@ export class AvatarAppearanceMessage implements MessageBase IsTrial: boolean; }; ObjectData: { - TextureEntry: string; + TextureEntry: Buffer; }; VisualParam: { ParamValue: number; @@ -44,7 +44,7 @@ export class AvatarAppearanceMessage implements MessageBase buf.writeUInt8((this.Sender['IsTrial']) ? 1 : 0, pos++); buf.writeUInt16LE(this.ObjectData['TextureEntry'].length, pos); pos += 2; - buf.write(this.ObjectData['TextureEntry'], pos); + this.ObjectData['TextureEntry'].copy(buf, pos); pos += this.ObjectData['TextureEntry'].length; let count = this.VisualParam.length; buf.writeUInt8(this.VisualParam.length, pos++); @@ -88,13 +88,13 @@ export class AvatarAppearanceMessage implements MessageBase newObjSender['IsTrial'] = (buf.readUInt8(pos++) === 1); this.Sender = newObjSender; const newObjObjectData: { - TextureEntry: string + TextureEntry: Buffer } = { - TextureEntry: '' + TextureEntry: Buffer.allocUnsafe(0) }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjObjectData['TextureEntry'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['TextureEntry'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ObjectData = newObjObjectData; let count = buf.readUInt8(pos++); diff --git a/lib/classes/messages/AvatarClassifiedReply.ts b/lib/classes/messages/AvatarClassifiedReply.ts index dc47031..8c5f5d4 100644 --- a/lib/classes/messages/AvatarClassifiedReply.ts +++ b/lib/classes/messages/AvatarClassifiedReply.ts @@ -17,7 +17,7 @@ export class AvatarClassifiedReplyMessage implements MessageBase }; Data: { ClassifiedID: UUID; - Name: string; + Name: Buffer; }[]; getSize(): number @@ -49,7 +49,7 @@ export class AvatarClassifiedReplyMessage implements MessageBase this.Data[i]['ClassifiedID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.Data[i]['Name'].length, pos++); - buf.write(this.Data[i]['Name'], pos); + this.Data[i]['Name'].copy(buf, pos); pos += this.Data[i]['Name'].length; } return pos - startPos; @@ -77,15 +77,15 @@ export class AvatarClassifiedReplyMessage implements MessageBase { const newObjData: { ClassifiedID: UUID, - Name: string + Name: Buffer } = { ClassifiedID: UUID.zero(), - Name: '' + Name: Buffer.allocUnsafe(0) }; newObjData['ClassifiedID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.Data.push(newObjData); } diff --git a/lib/classes/messages/AvatarGroupsReply.ts b/lib/classes/messages/AvatarGroupsReply.ts index 24a6160..cdb8cbe 100644 --- a/lib/classes/messages/AvatarGroupsReply.ts +++ b/lib/classes/messages/AvatarGroupsReply.ts @@ -19,9 +19,9 @@ export class AvatarGroupsReplyMessage implements MessageBase GroupData: { GroupPowers: Long; AcceptNotices: boolean; - GroupTitle: string; + GroupTitle: Buffer; GroupID: UUID; - GroupName: string; + GroupName: Buffer; GroupInsigniaID: UUID; }[]; NewGroupData: { @@ -60,12 +60,12 @@ export class AvatarGroupsReplyMessage implements MessageBase pos += 4; buf.writeUInt8((this.GroupData[i]['AcceptNotices']) ? 1 : 0, pos++); buf.writeUInt8(this.GroupData[i]['GroupTitle'].length, pos++); - buf.write(this.GroupData[i]['GroupTitle'], pos); + this.GroupData[i]['GroupTitle'].copy(buf, pos); pos += this.GroupData[i]['GroupTitle'].length; this.GroupData[i]['GroupID'].writeToBuffer(buf, pos); pos += 16; 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; this.GroupData[i]['GroupInsigniaID'].writeToBuffer(buf, pos); pos += 16; @@ -97,28 +97,28 @@ export class AvatarGroupsReplyMessage implements MessageBase const newObjGroupData: { GroupPowers: Long, AcceptNotices: boolean, - GroupTitle: string, + GroupTitle: Buffer, GroupID: UUID, - GroupName: string, + GroupName: Buffer, GroupInsigniaID: UUID } = { GroupPowers: Long.ZERO, AcceptNotices: false, - GroupTitle: '', + GroupTitle: Buffer.allocUnsafe(0), GroupID: UUID.zero(), - GroupName: '', + GroupName: Buffer.allocUnsafe(0), GroupInsigniaID: UUID.zero() }; newObjGroupData['GroupPowers'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4)); pos += 8; newObjGroupData['AcceptNotices'] = (buf.readUInt8(pos++) === 1); varLength = buf.readUInt8(pos++); - newObjGroupData['GroupTitle'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjGroupData['GroupTitle'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjGroupData['GroupID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjGroupData['GroupName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjGroupData['GroupName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjGroupData['GroupInsigniaID'] = new UUID(buf, pos); pos += 16; diff --git a/lib/classes/messages/AvatarInterestsReply.ts b/lib/classes/messages/AvatarInterestsReply.ts index 14b2265..0239dae 100644 --- a/lib/classes/messages/AvatarInterestsReply.ts +++ b/lib/classes/messages/AvatarInterestsReply.ts @@ -17,10 +17,10 @@ export class AvatarInterestsReplyMessage implements MessageBase }; PropertiesData: { WantToMask: number; - WantToText: string; + WantToText: Buffer; SkillsMask: number; - SkillsText: string; - LanguagesText: string; + SkillsText: Buffer; + LanguagesText: Buffer; }; getSize(): number @@ -38,15 +38,15 @@ export class AvatarInterestsReplyMessage implements MessageBase buf.writeUInt32LE(this.PropertiesData['WantToMask'], pos); pos += 4; buf.writeUInt8(this.PropertiesData['WantToText'].length, pos++); - buf.write(this.PropertiesData['WantToText'], pos); + this.PropertiesData['WantToText'].copy(buf, pos); pos += this.PropertiesData['WantToText'].length; buf.writeUInt32LE(this.PropertiesData['SkillsMask'], pos); pos += 4; buf.writeUInt8(this.PropertiesData['SkillsText'].length, pos++); - buf.write(this.PropertiesData['SkillsText'], pos); + this.PropertiesData['SkillsText'].copy(buf, pos); pos += this.PropertiesData['SkillsText'].length; buf.writeUInt8(this.PropertiesData['LanguagesText'].length, pos++); - buf.write(this.PropertiesData['LanguagesText'], pos); + this.PropertiesData['LanguagesText'].copy(buf, pos); pos += this.PropertiesData['LanguagesText'].length; return pos - startPos; } @@ -69,29 +69,29 @@ export class AvatarInterestsReplyMessage implements MessageBase this.AgentData = newObjAgentData; const newObjPropertiesData: { WantToMask: number, - WantToText: string, + WantToText: Buffer, SkillsMask: number, - SkillsText: string, - LanguagesText: string + SkillsText: Buffer, + LanguagesText: Buffer } = { WantToMask: 0, - WantToText: '', + WantToText: Buffer.allocUnsafe(0), SkillsMask: 0, - SkillsText: '', - LanguagesText: '' + SkillsText: Buffer.allocUnsafe(0), + LanguagesText: Buffer.allocUnsafe(0) }; newObjPropertiesData['WantToMask'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjPropertiesData['WantToText'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjPropertiesData['WantToText'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjPropertiesData['SkillsMask'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjPropertiesData['SkillsText'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjPropertiesData['SkillsText'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjPropertiesData['LanguagesText'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjPropertiesData['LanguagesText'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.PropertiesData = newObjPropertiesData; return pos - startPos; diff --git a/lib/classes/messages/AvatarInterestsUpdate.ts b/lib/classes/messages/AvatarInterestsUpdate.ts index 7c7dc08..26d12e7 100644 --- a/lib/classes/messages/AvatarInterestsUpdate.ts +++ b/lib/classes/messages/AvatarInterestsUpdate.ts @@ -17,10 +17,10 @@ export class AvatarInterestsUpdateMessage implements MessageBase }; PropertiesData: { WantToMask: number; - WantToText: string; + WantToText: Buffer; SkillsMask: number; - SkillsText: string; - LanguagesText: string; + SkillsText: Buffer; + LanguagesText: Buffer; }; getSize(): number @@ -38,15 +38,15 @@ export class AvatarInterestsUpdateMessage implements MessageBase buf.writeUInt32LE(this.PropertiesData['WantToMask'], pos); pos += 4; buf.writeUInt8(this.PropertiesData['WantToText'].length, pos++); - buf.write(this.PropertiesData['WantToText'], pos); + this.PropertiesData['WantToText'].copy(buf, pos); pos += this.PropertiesData['WantToText'].length; buf.writeUInt32LE(this.PropertiesData['SkillsMask'], pos); pos += 4; buf.writeUInt8(this.PropertiesData['SkillsText'].length, pos++); - buf.write(this.PropertiesData['SkillsText'], pos); + this.PropertiesData['SkillsText'].copy(buf, pos); pos += this.PropertiesData['SkillsText'].length; buf.writeUInt8(this.PropertiesData['LanguagesText'].length, pos++); - buf.write(this.PropertiesData['LanguagesText'], pos); + this.PropertiesData['LanguagesText'].copy(buf, pos); pos += this.PropertiesData['LanguagesText'].length; return pos - startPos; } @@ -69,29 +69,29 @@ export class AvatarInterestsUpdateMessage implements MessageBase this.AgentData = newObjAgentData; const newObjPropertiesData: { WantToMask: number, - WantToText: string, + WantToText: Buffer, SkillsMask: number, - SkillsText: string, - LanguagesText: string + SkillsText: Buffer, + LanguagesText: Buffer } = { WantToMask: 0, - WantToText: '', + WantToText: Buffer.allocUnsafe(0), SkillsMask: 0, - SkillsText: '', - LanguagesText: '' + SkillsText: Buffer.allocUnsafe(0), + LanguagesText: Buffer.allocUnsafe(0) }; newObjPropertiesData['WantToMask'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjPropertiesData['WantToText'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjPropertiesData['WantToText'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjPropertiesData['SkillsMask'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjPropertiesData['SkillsText'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjPropertiesData['SkillsText'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjPropertiesData['LanguagesText'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjPropertiesData['LanguagesText'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.PropertiesData = newObjPropertiesData; return pos - startPos; diff --git a/lib/classes/messages/AvatarNotesReply.ts b/lib/classes/messages/AvatarNotesReply.ts index 788c204..8510390 100644 --- a/lib/classes/messages/AvatarNotesReply.ts +++ b/lib/classes/messages/AvatarNotesReply.ts @@ -16,7 +16,7 @@ export class AvatarNotesReplyMessage implements MessageBase }; Data: { TargetID: UUID; - Notes: string; + Notes: Buffer; }; getSize(): number @@ -33,7 +33,7 @@ export class AvatarNotesReplyMessage 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; } @@ -52,16 +52,16 @@ export class AvatarNotesReplyMessage 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; diff --git a/lib/classes/messages/AvatarNotesUpdate.ts b/lib/classes/messages/AvatarNotesUpdate.ts index a6ee4fc..0cee208 100644 --- a/lib/classes/messages/AvatarNotesUpdate.ts +++ b/lib/classes/messages/AvatarNotesUpdate.ts @@ -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; diff --git a/lib/classes/messages/AvatarPickerReply.ts b/lib/classes/messages/AvatarPickerReply.ts index a96d22b..18d2ceb 100644 --- a/lib/classes/messages/AvatarPickerReply.ts +++ b/lib/classes/messages/AvatarPickerReply.ts @@ -17,8 +17,8 @@ export class AvatarPickerReplyMessage implements MessageBase }; Data: { AvatarID: UUID; - FirstName: string; - LastName: string; + FirstName: Buffer; + LastName: Buffer; }[]; getSize(): number @@ -50,10 +50,10 @@ export class AvatarPickerReplyMessage implements MessageBase this.Data[i]['AvatarID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.Data[i]['FirstName'].length, pos++); - buf.write(this.Data[i]['FirstName'], pos); + this.Data[i]['FirstName'].copy(buf, pos); pos += this.Data[i]['FirstName'].length; buf.writeUInt8(this.Data[i]['LastName'].length, pos++); - buf.write(this.Data[i]['LastName'], pos); + this.Data[i]['LastName'].copy(buf, pos); pos += this.Data[i]['LastName'].length; } return pos - startPos; @@ -81,20 +81,20 @@ export class AvatarPickerReplyMessage implements MessageBase { const newObjData: { AvatarID: UUID, - FirstName: string, - LastName: string + FirstName: Buffer, + LastName: Buffer } = { AvatarID: UUID.zero(), - FirstName: '', - LastName: '' + FirstName: Buffer.allocUnsafe(0), + LastName: Buffer.allocUnsafe(0) }; newObjData['AvatarID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['FirstName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['FirstName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjData['LastName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['LastName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.Data.push(newObjData); } diff --git a/lib/classes/messages/AvatarPickerRequest.ts b/lib/classes/messages/AvatarPickerRequest.ts index 61d9a0d..5ab1f86 100644 --- a/lib/classes/messages/AvatarPickerRequest.ts +++ b/lib/classes/messages/AvatarPickerRequest.ts @@ -17,7 +17,7 @@ export class AvatarPickerRequestMessage implements MessageBase QueryID: UUID; }; Data: { - Name: string; + Name: Buffer; }; getSize(): number @@ -35,7 +35,7 @@ export class AvatarPickerRequestMessage implements MessageBase this.AgentData['QueryID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.Data['Name'].length, pos++); - buf.write(this.Data['Name'], pos); + this.Data['Name'].copy(buf, pos); pos += this.Data['Name'].length; return pos - startPos; } @@ -61,12 +61,12 @@ export class AvatarPickerRequestMessage implements MessageBase pos += 16; this.AgentData = newObjAgentData; const newObjData: { - Name: string + Name: Buffer } = { - Name: '' + Name: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.Data = newObjData; return pos - startPos; diff --git a/lib/classes/messages/AvatarPickerRequestBackend.ts b/lib/classes/messages/AvatarPickerRequestBackend.ts index c1568f9..65bcee1 100644 --- a/lib/classes/messages/AvatarPickerRequestBackend.ts +++ b/lib/classes/messages/AvatarPickerRequestBackend.ts @@ -18,7 +18,7 @@ export class AvatarPickerRequestBackendMessage implements MessageBase GodLevel: number; }; Data: { - Name: string; + Name: Buffer; }; getSize(): number @@ -37,7 +37,7 @@ export class AvatarPickerRequestBackendMessage implements MessageBase pos += 16; buf.writeUInt8(this.AgentData['GodLevel'], pos++); buf.writeUInt8(this.Data['Name'].length, pos++); - buf.write(this.Data['Name'], pos); + this.Data['Name'].copy(buf, pos); pos += this.Data['Name'].length; return pos - startPos; } @@ -66,12 +66,12 @@ export class AvatarPickerRequestBackendMessage implements MessageBase newObjAgentData['GodLevel'] = buf.readUInt8(pos++); this.AgentData = newObjAgentData; const newObjData: { - Name: string + Name: Buffer } = { - Name: '' + Name: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.Data = newObjData; return pos - startPos; diff --git a/lib/classes/messages/AvatarPicksReply.ts b/lib/classes/messages/AvatarPicksReply.ts index e37fac2..9dd580f 100644 --- a/lib/classes/messages/AvatarPicksReply.ts +++ b/lib/classes/messages/AvatarPicksReply.ts @@ -17,7 +17,7 @@ export class AvatarPicksReplyMessage implements MessageBase }; Data: { PickID: UUID; - PickName: string; + PickName: Buffer; }[]; getSize(): number @@ -49,7 +49,7 @@ export class AvatarPicksReplyMessage implements MessageBase this.Data[i]['PickID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.Data[i]['PickName'].length, pos++); - buf.write(this.Data[i]['PickName'], pos); + this.Data[i]['PickName'].copy(buf, pos); pos += this.Data[i]['PickName'].length; } return pos - startPos; @@ -77,15 +77,15 @@ export class AvatarPicksReplyMessage implements MessageBase { const newObjData: { PickID: UUID, - PickName: string + PickName: Buffer } = { PickID: UUID.zero(), - PickName: '' + PickName: Buffer.allocUnsafe(0) }; newObjData['PickID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['PickName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['PickName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.Data.push(newObjData); } diff --git a/lib/classes/messages/AvatarPropertiesReply.ts b/lib/classes/messages/AvatarPropertiesReply.ts index 7a83c8a..ed323e7 100644 --- a/lib/classes/messages/AvatarPropertiesReply.ts +++ b/lib/classes/messages/AvatarPropertiesReply.ts @@ -19,11 +19,11 @@ export class AvatarPropertiesReplyMessage implements MessageBase ImageID: UUID; FLImageID: UUID; PartnerID: UUID; - AboutText: string; - FLAboutText: string; - BornOn: string; - ProfileURL: string; - CharterMember: string; + AboutText: Buffer; + FLAboutText: Buffer; + BornOn: Buffer; + ProfileURL: Buffer; + CharterMember: Buffer; Flags: number; }; @@ -47,19 +47,19 @@ export class AvatarPropertiesReplyMessage implements MessageBase pos += 16; buf.writeUInt16LE(this.PropertiesData['AboutText'].length, pos); pos += 2; - buf.write(this.PropertiesData['AboutText'], pos); + this.PropertiesData['AboutText'].copy(buf, pos); pos += this.PropertiesData['AboutText'].length; buf.writeUInt8(this.PropertiesData['FLAboutText'].length, pos++); - buf.write(this.PropertiesData['FLAboutText'], pos); + this.PropertiesData['FLAboutText'].copy(buf, pos); pos += this.PropertiesData['FLAboutText'].length; buf.writeUInt8(this.PropertiesData['BornOn'].length, pos++); - buf.write(this.PropertiesData['BornOn'], pos); + this.PropertiesData['BornOn'].copy(buf, pos); pos += this.PropertiesData['BornOn'].length; buf.writeUInt8(this.PropertiesData['ProfileURL'].length, pos++); - buf.write(this.PropertiesData['ProfileURL'], pos); + this.PropertiesData['ProfileURL'].copy(buf, pos); pos += this.PropertiesData['ProfileURL'].length; buf.writeUInt8(this.PropertiesData['CharterMember'].length, pos++); - buf.write(this.PropertiesData['CharterMember'], pos); + this.PropertiesData['CharterMember'].copy(buf, pos); pos += this.PropertiesData['CharterMember'].length; buf.writeUInt32LE(this.PropertiesData['Flags'], pos); pos += 4; @@ -86,21 +86,21 @@ export class AvatarPropertiesReplyMessage implements MessageBase ImageID: UUID, FLImageID: UUID, PartnerID: UUID, - AboutText: string, - FLAboutText: string, - BornOn: string, - ProfileURL: string, - CharterMember: string, + AboutText: Buffer, + FLAboutText: Buffer, + BornOn: Buffer, + ProfileURL: Buffer, + CharterMember: Buffer, Flags: number } = { ImageID: UUID.zero(), FLImageID: UUID.zero(), PartnerID: UUID.zero(), - AboutText: '', - FLAboutText: '', - BornOn: '', - ProfileURL: '', - CharterMember: '', + AboutText: Buffer.allocUnsafe(0), + FLAboutText: Buffer.allocUnsafe(0), + BornOn: Buffer.allocUnsafe(0), + ProfileURL: Buffer.allocUnsafe(0), + CharterMember: Buffer.allocUnsafe(0), Flags: 0 }; newObjPropertiesData['ImageID'] = new UUID(buf, pos); @@ -111,19 +111,19 @@ export class AvatarPropertiesReplyMessage implements MessageBase pos += 16; varLength = buf.readUInt16LE(pos); pos += 2; - newObjPropertiesData['AboutText'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjPropertiesData['AboutText'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjPropertiesData['FLAboutText'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjPropertiesData['FLAboutText'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjPropertiesData['BornOn'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjPropertiesData['BornOn'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjPropertiesData['ProfileURL'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjPropertiesData['ProfileURL'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjPropertiesData['CharterMember'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjPropertiesData['CharterMember'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjPropertiesData['Flags'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/AvatarPropertiesUpdate.ts b/lib/classes/messages/AvatarPropertiesUpdate.ts index 520d1d1..a1184ad 100644 --- a/lib/classes/messages/AvatarPropertiesUpdate.ts +++ b/lib/classes/messages/AvatarPropertiesUpdate.ts @@ -18,11 +18,11 @@ export class AvatarPropertiesUpdateMessage implements MessageBase PropertiesData: { ImageID: UUID; FLImageID: UUID; - AboutText: string; - FLAboutText: string; + AboutText: Buffer; + FLAboutText: Buffer; AllowPublish: boolean; MaturePublish: boolean; - ProfileURL: string; + ProfileURL: Buffer; }; getSize(): number @@ -43,15 +43,15 @@ export class AvatarPropertiesUpdateMessage implements MessageBase pos += 16; buf.writeUInt16LE(this.PropertiesData['AboutText'].length, pos); pos += 2; - buf.write(this.PropertiesData['AboutText'], pos); + this.PropertiesData['AboutText'].copy(buf, pos); pos += this.PropertiesData['AboutText'].length; buf.writeUInt8(this.PropertiesData['FLAboutText'].length, pos++); - buf.write(this.PropertiesData['FLAboutText'], pos); + this.PropertiesData['FLAboutText'].copy(buf, pos); pos += this.PropertiesData['FLAboutText'].length; buf.writeUInt8((this.PropertiesData['AllowPublish']) ? 1 : 0, pos++); buf.writeUInt8((this.PropertiesData['MaturePublish']) ? 1 : 0, pos++); buf.writeUInt8(this.PropertiesData['ProfileURL'].length, pos++); - buf.write(this.PropertiesData['ProfileURL'], pos); + this.PropertiesData['ProfileURL'].copy(buf, pos); pos += this.PropertiesData['ProfileURL'].length; return pos - startPos; } @@ -75,19 +75,19 @@ export class AvatarPropertiesUpdateMessage implements MessageBase const newObjPropertiesData: { ImageID: UUID, FLImageID: UUID, - AboutText: string, - FLAboutText: string, + AboutText: Buffer, + FLAboutText: Buffer, AllowPublish: boolean, MaturePublish: boolean, - ProfileURL: string + ProfileURL: Buffer } = { ImageID: UUID.zero(), FLImageID: UUID.zero(), - AboutText: '', - FLAboutText: '', + AboutText: Buffer.allocUnsafe(0), + FLAboutText: Buffer.allocUnsafe(0), AllowPublish: false, MaturePublish: false, - ProfileURL: '' + ProfileURL: Buffer.allocUnsafe(0) }; newObjPropertiesData['ImageID'] = new UUID(buf, pos); pos += 16; @@ -95,15 +95,15 @@ export class AvatarPropertiesUpdateMessage implements MessageBase pos += 16; varLength = buf.readUInt16LE(pos); pos += 2; - newObjPropertiesData['AboutText'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjPropertiesData['AboutText'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjPropertiesData['FLAboutText'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjPropertiesData['FLAboutText'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjPropertiesData['AllowPublish'] = (buf.readUInt8(pos++) === 1); newObjPropertiesData['MaturePublish'] = (buf.readUInt8(pos++) === 1); varLength = buf.readUInt8(pos++); - newObjPropertiesData['ProfileURL'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjPropertiesData['ProfileURL'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.PropertiesData = newObjPropertiesData; return pos - startPos; diff --git a/lib/classes/messages/AvatarTextureUpdate.ts b/lib/classes/messages/AvatarTextureUpdate.ts index 6512aae..2a7d0b3 100644 --- a/lib/classes/messages/AvatarTextureUpdate.ts +++ b/lib/classes/messages/AvatarTextureUpdate.ts @@ -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); } diff --git a/lib/classes/messages/BulkUpdateInventory.ts b/lib/classes/messages/BulkUpdateInventory.ts index 2428887..e3ad664 100644 --- a/lib/classes/messages/BulkUpdateInventory.ts +++ b/lib/classes/messages/BulkUpdateInventory.ts @@ -19,7 +19,7 @@ export class BulkUpdateInventoryMessage implements MessageBase FolderID: UUID; ParentID: UUID; Type: number; - Name: string; + Name: Buffer; }[]; ItemData: { ItemID: UUID; @@ -40,8 +40,8 @@ export class BulkUpdateInventoryMessage implements MessageBase Flags: number; SaleType: number; SalePrice: number; - Name: string; - Description: string; + Name: Buffer; + Description: Buffer; CreationDate: number; CRC: number; }[]; @@ -78,7 +78,7 @@ export class BulkUpdateInventoryMessage implements MessageBase pos += 16; buf.writeInt8(this.FolderData[i]['Type'], pos++); buf.writeUInt8(this.FolderData[i]['Name'].length, pos++); - buf.write(this.FolderData[i]['Name'], pos); + this.FolderData[i]['Name'].copy(buf, pos); pos += this.FolderData[i]['Name'].length; } count = this.ItemData.length; @@ -118,10 +118,10 @@ export class BulkUpdateInventoryMessage implements MessageBase buf.writeInt32LE(this.ItemData[i]['SalePrice'], pos); pos += 4; buf.writeUInt8(this.ItemData[i]['Name'].length, pos++); - buf.write(this.ItemData[i]['Name'], pos); + this.ItemData[i]['Name'].copy(buf, pos); pos += this.ItemData[i]['Name'].length; buf.writeUInt8(this.ItemData[i]['Description'].length, pos++); - buf.write(this.ItemData[i]['Description'], pos); + this.ItemData[i]['Description'].copy(buf, pos); pos += this.ItemData[i]['Description'].length; buf.writeInt32LE(this.ItemData[i]['CreationDate'], pos); pos += 4; @@ -155,12 +155,12 @@ export class BulkUpdateInventoryMessage implements MessageBase FolderID: UUID, ParentID: UUID, Type: number, - Name: string + Name: Buffer } = { FolderID: UUID.zero(), ParentID: UUID.zero(), Type: 0, - Name: '' + Name: Buffer.allocUnsafe(0) }; newObjFolderData['FolderID'] = new UUID(buf, pos); pos += 16; @@ -168,7 +168,7 @@ export class BulkUpdateInventoryMessage implements MessageBase pos += 16; newObjFolderData['Type'] = buf.readInt8(pos++); varLength = buf.readUInt8(pos++); - newObjFolderData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjFolderData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.FolderData.push(newObjFolderData); } @@ -195,8 +195,8 @@ export class BulkUpdateInventoryMessage implements MessageBase Flags: number, SaleType: number, SalePrice: number, - Name: string, - Description: string, + Name: Buffer, + Description: Buffer, CreationDate: number, CRC: number } = { @@ -218,8 +218,8 @@ export class BulkUpdateInventoryMessage implements MessageBase Flags: 0, SaleType: 0, SalePrice: 0, - Name: '', - Description: '', + Name: Buffer.allocUnsafe(0), + Description: Buffer.allocUnsafe(0), CreationDate: 0, CRC: 0 }; @@ -256,10 +256,10 @@ export class BulkUpdateInventoryMessage implements MessageBase newObjItemData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjItemData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjItemData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjItemData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjItemData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjItemData['CreationDate'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/ChatFromSimulator.ts b/lib/classes/messages/ChatFromSimulator.ts index 7d92616..82bcfd4 100644 --- a/lib/classes/messages/ChatFromSimulator.ts +++ b/lib/classes/messages/ChatFromSimulator.ts @@ -13,14 +13,14 @@ export class ChatFromSimulatorMessage implements MessageBase id = Message.ChatFromSimulator; ChatData: { - FromName: string; + FromName: Buffer; SourceID: UUID; OwnerID: UUID; SourceType: number; ChatType: number; Audible: number; Position: Vector3; - Message: string; + Message: Buffer; }; getSize(): number @@ -32,7 +32,7 @@ export class ChatFromSimulatorMessage implements MessageBase { const startPos = pos; buf.writeUInt8(this.ChatData['FromName'].length, pos++); - buf.write(this.ChatData['FromName'], pos); + this.ChatData['FromName'].copy(buf, pos); pos += this.ChatData['FromName'].length; this.ChatData['SourceID'].writeToBuffer(buf, pos); pos += 16; @@ -45,7 +45,7 @@ export class ChatFromSimulatorMessage implements MessageBase pos += 12; buf.writeUInt16LE(this.ChatData['Message'].length, pos); pos += 2; - buf.write(this.ChatData['Message'], pos); + this.ChatData['Message'].copy(buf, pos); pos += this.ChatData['Message'].length; return pos - startPos; } @@ -55,26 +55,26 @@ export class ChatFromSimulatorMessage implements MessageBase const startPos = pos; let varLength = 0; const newObjChatData: { - FromName: string, + FromName: Buffer, SourceID: UUID, OwnerID: UUID, SourceType: number, ChatType: number, Audible: number, Position: Vector3, - Message: string + Message: Buffer } = { - FromName: '', + FromName: Buffer.allocUnsafe(0), SourceID: UUID.zero(), OwnerID: UUID.zero(), SourceType: 0, ChatType: 0, Audible: 0, Position: Vector3.getZero(), - Message: '' + Message: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjChatData['FromName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjChatData['FromName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjChatData['SourceID'] = new UUID(buf, pos); pos += 16; @@ -87,7 +87,7 @@ export class ChatFromSimulatorMessage implements MessageBase pos += 12; varLength = buf.readUInt16LE(pos); pos += 2; - newObjChatData['Message'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjChatData['Message'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ChatData = newObjChatData; return pos - startPos; diff --git a/lib/classes/messages/ChatFromViewer.ts b/lib/classes/messages/ChatFromViewer.ts index d2b1ca0..e73bd35 100644 --- a/lib/classes/messages/ChatFromViewer.ts +++ b/lib/classes/messages/ChatFromViewer.ts @@ -16,7 +16,7 @@ export class ChatFromViewerMessage implements MessageBase SessionID: UUID; }; ChatData: { - Message: string; + Message: Buffer; Type: number; Channel: number; }; @@ -35,7 +35,7 @@ export class ChatFromViewerMessage implements MessageBase pos += 16; buf.writeUInt16LE(this.ChatData['Message'].length, pos); pos += 2; - buf.write(this.ChatData['Message'], pos); + this.ChatData['Message'].copy(buf, pos); pos += this.ChatData['Message'].length; buf.writeUInt8(this.ChatData['Type'], pos++); buf.writeInt32LE(this.ChatData['Channel'], pos); @@ -60,17 +60,17 @@ export class ChatFromViewerMessage implements MessageBase pos += 16; this.AgentData = newObjAgentData; const newObjChatData: { - Message: string, + Message: Buffer, Type: number, Channel: number } = { - Message: '', + Message: Buffer.allocUnsafe(0), Type: 0, Channel: 0 }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjChatData['Message'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjChatData['Message'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjChatData['Type'] = buf.readUInt8(pos++); newObjChatData['Channel'] = buf.readInt32LE(pos); diff --git a/lib/classes/messages/ChatPass.ts b/lib/classes/messages/ChatPass.ts index 8366b01..22f958e 100644 --- a/lib/classes/messages/ChatPass.ts +++ b/lib/classes/messages/ChatPass.ts @@ -17,12 +17,12 @@ export class ChatPassMessage implements MessageBase Position: Vector3; ID: UUID; OwnerID: UUID; - Name: string; + Name: Buffer; SourceType: number; Type: number; Radius: number; SimAccess: number; - Message: string; + Message: Buffer; }; getSize(): number @@ -42,7 +42,7 @@ export class ChatPassMessage implements MessageBase this.ChatData['OwnerID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.ChatData['Name'].length, pos++); - buf.write(this.ChatData['Name'], pos); + this.ChatData['Name'].copy(buf, pos); pos += this.ChatData['Name'].length; buf.writeUInt8(this.ChatData['SourceType'], pos++); buf.writeUInt8(this.ChatData['Type'], pos++); @@ -51,7 +51,7 @@ export class ChatPassMessage implements MessageBase buf.writeUInt8(this.ChatData['SimAccess'], pos++); buf.writeUInt16LE(this.ChatData['Message'].length, pos); pos += 2; - buf.write(this.ChatData['Message'], pos); + this.ChatData['Message'].copy(buf, pos); pos += this.ChatData['Message'].length; return pos - startPos; } @@ -65,23 +65,23 @@ export class ChatPassMessage implements MessageBase Position: Vector3, ID: UUID, OwnerID: UUID, - Name: string, + Name: Buffer, SourceType: number, Type: number, Radius: number, SimAccess: number, - Message: string + Message: Buffer } = { Channel: 0, Position: Vector3.getZero(), ID: UUID.zero(), OwnerID: UUID.zero(), - Name: '', + Name: Buffer.allocUnsafe(0), SourceType: 0, Type: 0, Radius: 0, SimAccess: 0, - Message: '' + Message: Buffer.allocUnsafe(0) }; newObjChatData['Channel'] = buf.readInt32LE(pos); pos += 4; @@ -92,7 +92,7 @@ export class ChatPassMessage implements MessageBase newObjChatData['OwnerID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjChatData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjChatData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjChatData['SourceType'] = buf.readUInt8(pos++); newObjChatData['Type'] = buf.readUInt8(pos++); @@ -101,7 +101,7 @@ export class ChatPassMessage implements MessageBase newObjChatData['SimAccess'] = buf.readUInt8(pos++); varLength = buf.readUInt16LE(pos); pos += 2; - newObjChatData['Message'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjChatData['Message'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ChatData = newObjChatData; return pos - startPos; diff --git a/lib/classes/messages/ChildAgentUpdate.ts b/lib/classes/messages/ChildAgentUpdate.ts index c1ad23b..be534c7 100644 --- a/lib/classes/messages/ChildAgentUpdate.ts +++ b/lib/classes/messages/ChildAgentUpdate.ts @@ -29,7 +29,7 @@ export class ChildAgentUpdateMessage implements MessageBase ChangedGrid: boolean; Far: number; Aspect: number; - Throttles: string; + Throttles: Buffer; LocomotionState: number; HeadRotation: Quaternion; BodyRotation: Quaternion; @@ -39,7 +39,7 @@ export class ChildAgentUpdateMessage implements MessageBase AlwaysRun: boolean; PreyAgent: UUID; AgentAccess: number; - AgentTextures: string; + AgentTextures: Buffer; ActiveGroupID: UUID; }; GroupData: { @@ -55,7 +55,7 @@ export class ChildAgentUpdateMessage implements MessageBase GranterID: UUID; }[]; NVPairData: { - NVPairs: string; + NVPairs: Buffer; }[]; VisualParam: { ParamValue: number; @@ -68,7 +68,7 @@ export class ChildAgentUpdateMessage implements MessageBase Flags: number; }[]; AgentInventoryHost: { - InventoryHost: string; + InventoryHost: Buffer; }[]; getSize(): number @@ -119,7 +119,7 @@ export class ChildAgentUpdateMessage implements MessageBase buf.writeFloatLE(this.AgentData['Aspect'], pos); pos += 4; buf.writeUInt8(this.AgentData['Throttles'].length, pos++); - buf.write(this.AgentData['Throttles'], pos); + this.AgentData['Throttles'].copy(buf, pos); pos += this.AgentData['Throttles'].length; buf.writeUInt32LE(this.AgentData['LocomotionState'], pos); pos += 4; @@ -138,7 +138,7 @@ export class ChildAgentUpdateMessage implements MessageBase buf.writeUInt8(this.AgentData['AgentAccess'], pos++); buf.writeUInt16LE(this.AgentData['AgentTextures'].length, pos); pos += 2; - buf.write(this.AgentData['AgentTextures'], pos); + this.AgentData['AgentTextures'].copy(buf, pos); pos += this.AgentData['AgentTextures'].length; this.AgentData['ActiveGroupID'].writeToBuffer(buf, pos); pos += 16; @@ -176,7 +176,7 @@ export class ChildAgentUpdateMessage implements MessageBase { buf.writeUInt16LE(this.NVPairData[i]['NVPairs'].length, pos); pos += 2; - buf.write(this.NVPairData[i]['NVPairs'], pos); + this.NVPairData[i]['NVPairs'].copy(buf, pos); pos += this.NVPairData[i]['NVPairs'].length; } count = this.VisualParam.length; @@ -204,7 +204,7 @@ export class ChildAgentUpdateMessage implements MessageBase for (let i = 0; i < count; i++) { buf.writeUInt8(this.AgentInventoryHost[i]['InventoryHost'].length, pos++); - buf.write(this.AgentInventoryHost[i]['InventoryHost'], pos); + this.AgentInventoryHost[i]['InventoryHost'].copy(buf, pos); pos += this.AgentInventoryHost[i]['InventoryHost'].length; } return pos - startPos; @@ -229,7 +229,7 @@ export class ChildAgentUpdateMessage implements MessageBase ChangedGrid: boolean, Far: number, Aspect: number, - Throttles: string, + Throttles: Buffer, LocomotionState: number, HeadRotation: Quaternion, BodyRotation: Quaternion, @@ -239,7 +239,7 @@ export class ChildAgentUpdateMessage implements MessageBase AlwaysRun: boolean, PreyAgent: UUID, AgentAccess: number, - AgentTextures: string, + AgentTextures: Buffer, ActiveGroupID: UUID } = { RegionHandle: Long.ZERO, @@ -256,7 +256,7 @@ export class ChildAgentUpdateMessage implements MessageBase ChangedGrid: false, Far: 0, Aspect: 0, - Throttles: '', + Throttles: Buffer.allocUnsafe(0), LocomotionState: 0, HeadRotation: Quaternion.getIdentity(), BodyRotation: Quaternion.getIdentity(), @@ -266,7 +266,7 @@ export class ChildAgentUpdateMessage implements MessageBase AlwaysRun: false, PreyAgent: UUID.zero(), AgentAccess: 0, - AgentTextures: '', + AgentTextures: Buffer.allocUnsafe(0), ActiveGroupID: UUID.zero() }; newObjAgentData['RegionHandle'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4)); @@ -297,7 +297,7 @@ export class ChildAgentUpdateMessage implements MessageBase newObjAgentData['Aspect'] = buf.readFloatLE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjAgentData['Throttles'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAgentData['Throttles'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjAgentData['LocomotionState'] = buf.readUInt32LE(pos); pos += 4; @@ -316,7 +316,7 @@ export class ChildAgentUpdateMessage implements MessageBase newObjAgentData['AgentAccess'] = buf.readUInt8(pos++); varLength = buf.readUInt16LE(pos); pos += 2; - newObjAgentData['AgentTextures'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAgentData['AgentTextures'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjAgentData['ActiveGroupID'] = new UUID(buf, pos); pos += 16; @@ -376,13 +376,13 @@ export class ChildAgentUpdateMessage implements MessageBase for (let i = 0; i < count; i++) { const newObjNVPairData: { - NVPairs: string + NVPairs: Buffer } = { - NVPairs: '' + NVPairs: Buffer.allocUnsafe(0) }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjNVPairData['NVPairs'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjNVPairData['NVPairs'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.NVPairData.push(newObjNVPairData); } @@ -431,12 +431,12 @@ export class ChildAgentUpdateMessage implements MessageBase for (let i = 0; i < count; i++) { const newObjAgentInventoryHost: { - InventoryHost: string + InventoryHost: Buffer } = { - InventoryHost: '' + InventoryHost: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjAgentInventoryHost['InventoryHost'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAgentInventoryHost['InventoryHost'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.AgentInventoryHost.push(newObjAgentInventoryHost); } diff --git a/lib/classes/messages/ClassifiedInfoReply.ts b/lib/classes/messages/ClassifiedInfoReply.ts index 8aa9ddd..464c378 100644 --- a/lib/classes/messages/ClassifiedInfoReply.ts +++ b/lib/classes/messages/ClassifiedInfoReply.ts @@ -21,14 +21,14 @@ export class ClassifiedInfoReplyMessage implements MessageBase CreationDate: number; ExpirationDate: number; Category: number; - Name: string; - Desc: string; + Name: Buffer; + Desc: Buffer; ParcelID: UUID; ParentEstate: number; SnapshotID: UUID; - SimName: string; + SimName: Buffer; PosGlobal: Vector3; - ParcelName: string; + ParcelName: Buffer; ClassifiedFlags: number; PriceForListing: number; }; @@ -54,11 +54,11 @@ export class ClassifiedInfoReplyMessage implements MessageBase buf.writeUInt32LE(this.Data['Category'], pos); pos += 4; buf.writeUInt8(this.Data['Name'].length, pos++); - buf.write(this.Data['Name'], pos); + this.Data['Name'].copy(buf, pos); pos += this.Data['Name'].length; buf.writeUInt16LE(this.Data['Desc'].length, pos); pos += 2; - buf.write(this.Data['Desc'], pos); + this.Data['Desc'].copy(buf, pos); pos += this.Data['Desc'].length; this.Data['ParcelID'].writeToBuffer(buf, pos); pos += 16; @@ -67,12 +67,12 @@ export class ClassifiedInfoReplyMessage implements MessageBase this.Data['SnapshotID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.Data['SimName'].length, pos++); - buf.write(this.Data['SimName'], pos); + this.Data['SimName'].copy(buf, pos); pos += this.Data['SimName'].length; this.Data['PosGlobal'].writeToBuffer(buf, pos, true); pos += 24; buf.writeUInt8(this.Data['ParcelName'].length, pos++); - buf.write(this.Data['ParcelName'], pos); + this.Data['ParcelName'].copy(buf, pos); pos += this.Data['ParcelName'].length; buf.writeUInt8(this.Data['ClassifiedFlags'], pos++); buf.writeInt32LE(this.Data['PriceForListing'], pos); @@ -98,14 +98,14 @@ export class ClassifiedInfoReplyMessage implements MessageBase CreationDate: number, ExpirationDate: number, Category: number, - Name: string, - Desc: string, + Name: Buffer, + Desc: Buffer, ParcelID: UUID, ParentEstate: number, SnapshotID: UUID, - SimName: string, + SimName: Buffer, PosGlobal: Vector3, - ParcelName: string, + ParcelName: Buffer, ClassifiedFlags: number, PriceForListing: number } = { @@ -114,14 +114,14 @@ export class ClassifiedInfoReplyMessage implements MessageBase CreationDate: 0, ExpirationDate: 0, Category: 0, - Name: '', - Desc: '', + Name: Buffer.allocUnsafe(0), + Desc: Buffer.allocUnsafe(0), ParcelID: UUID.zero(), ParentEstate: 0, SnapshotID: UUID.zero(), - SimName: '', + SimName: Buffer.allocUnsafe(0), PosGlobal: Vector3.getZero(), - ParcelName: '', + ParcelName: Buffer.allocUnsafe(0), ClassifiedFlags: 0, PriceForListing: 0 }; @@ -136,11 +136,11 @@ export class ClassifiedInfoReplyMessage implements MessageBase newObjData['Category'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjData['Desc'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Desc'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjData['ParcelID'] = new UUID(buf, pos); pos += 16; @@ -149,12 +149,12 @@ export class ClassifiedInfoReplyMessage implements MessageBase newObjData['SnapshotID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['SimName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['SimName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjData['PosGlobal'] = new Vector3(buf, pos, true); pos += 24; varLength = buf.readUInt8(pos++); - newObjData['ParcelName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['ParcelName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjData['ClassifiedFlags'] = buf.readUInt8(pos++); newObjData['PriceForListing'] = buf.readInt32LE(pos); diff --git a/lib/classes/messages/ClassifiedInfoUpdate.ts b/lib/classes/messages/ClassifiedInfoUpdate.ts index e40624d..2738dd7 100644 --- a/lib/classes/messages/ClassifiedInfoUpdate.ts +++ b/lib/classes/messages/ClassifiedInfoUpdate.ts @@ -19,8 +19,8 @@ export class ClassifiedInfoUpdateMessage implements MessageBase Data: { ClassifiedID: UUID; Category: number; - Name: string; - Desc: string; + Name: Buffer; + Desc: Buffer; ParcelID: UUID; ParentEstate: number; SnapshotID: UUID; @@ -46,11 +46,11 @@ export class ClassifiedInfoUpdateMessage implements MessageBase buf.writeUInt32LE(this.Data['Category'], pos); pos += 4; buf.writeUInt8(this.Data['Name'].length, pos++); - buf.write(this.Data['Name'], pos); + this.Data['Name'].copy(buf, pos); pos += this.Data['Name'].length; buf.writeUInt16LE(this.Data['Desc'].length, pos); pos += 2; - buf.write(this.Data['Desc'], pos); + this.Data['Desc'].copy(buf, pos); pos += this.Data['Desc'].length; this.Data['ParcelID'].writeToBuffer(buf, pos); pos += 16; @@ -85,8 +85,8 @@ export class ClassifiedInfoUpdateMessage implements MessageBase const newObjData: { ClassifiedID: UUID, Category: number, - Name: string, - Desc: string, + Name: Buffer, + Desc: Buffer, ParcelID: UUID, ParentEstate: number, SnapshotID: UUID, @@ -96,8 +96,8 @@ export class ClassifiedInfoUpdateMessage implements MessageBase } = { ClassifiedID: UUID.zero(), Category: 0, - Name: '', - Desc: '', + Name: Buffer.allocUnsafe(0), + Desc: Buffer.allocUnsafe(0), ParcelID: UUID.zero(), ParentEstate: 0, SnapshotID: UUID.zero(), @@ -110,11 +110,11 @@ export class ClassifiedInfoUpdateMessage implements MessageBase newObjData['Category'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjData['Desc'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Desc'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjData['ParcelID'] = new UUID(buf, pos); pos += 16; diff --git a/lib/classes/messages/CopyInventoryItem.ts b/lib/classes/messages/CopyInventoryItem.ts index 371bdfc..7ee8973 100644 --- a/lib/classes/messages/CopyInventoryItem.ts +++ b/lib/classes/messages/CopyInventoryItem.ts @@ -20,7 +20,7 @@ export class CopyInventoryItemMessage implements MessageBase OldAgentID: UUID; OldItemID: UUID; NewFolderID: UUID; - NewName: string; + NewName: Buffer; }[]; getSize(): number @@ -58,7 +58,7 @@ export class CopyInventoryItemMessage implements MessageBase this.InventoryData[i]['NewFolderID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.InventoryData[i]['NewName'].length, pos++); - buf.write(this.InventoryData[i]['NewName'], pos); + this.InventoryData[i]['NewName'].copy(buf, pos); pos += this.InventoryData[i]['NewName'].length; } return pos - startPos; @@ -89,13 +89,13 @@ export class CopyInventoryItemMessage implements MessageBase OldAgentID: UUID, OldItemID: UUID, NewFolderID: UUID, - NewName: string + NewName: Buffer } = { CallbackID: 0, OldAgentID: UUID.zero(), OldItemID: UUID.zero(), NewFolderID: UUID.zero(), - NewName: '' + NewName: Buffer.allocUnsafe(0) }; newObjInventoryData['CallbackID'] = buf.readUInt32LE(pos); pos += 4; @@ -106,7 +106,7 @@ export class CopyInventoryItemMessage implements MessageBase newObjInventoryData['NewFolderID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjInventoryData['NewName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInventoryData['NewName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.InventoryData.push(newObjInventoryData); } diff --git a/lib/classes/messages/CreateGroupReply.ts b/lib/classes/messages/CreateGroupReply.ts index 106a36b..1b823de 100644 --- a/lib/classes/messages/CreateGroupReply.ts +++ b/lib/classes/messages/CreateGroupReply.ts @@ -17,7 +17,7 @@ export class CreateGroupReplyMessage implements MessageBase ReplyData: { GroupID: UUID; Success: boolean; - Message: string; + Message: Buffer; }; getSize(): number @@ -34,7 +34,7 @@ export class CreateGroupReplyMessage implements MessageBase pos += 16; buf.writeUInt8((this.ReplyData['Success']) ? 1 : 0, pos++); buf.writeUInt8(this.ReplyData['Message'].length, pos++); - buf.write(this.ReplyData['Message'], pos); + this.ReplyData['Message'].copy(buf, pos); pos += this.ReplyData['Message'].length; return pos - startPos; } @@ -54,17 +54,17 @@ export class CreateGroupReplyMessage implements MessageBase const newObjReplyData: { GroupID: UUID, Success: boolean, - Message: string + Message: Buffer } = { GroupID: UUID.zero(), Success: false, - Message: '' + Message: Buffer.allocUnsafe(0) }; newObjReplyData['GroupID'] = new UUID(buf, pos); pos += 16; newObjReplyData['Success'] = (buf.readUInt8(pos++) === 1); varLength = buf.readUInt8(pos++); - newObjReplyData['Message'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjReplyData['Message'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ReplyData = newObjReplyData; return pos - startPos; diff --git a/lib/classes/messages/CreateGroupRequest.ts b/lib/classes/messages/CreateGroupRequest.ts index aaf7358..6c68345 100644 --- a/lib/classes/messages/CreateGroupRequest.ts +++ b/lib/classes/messages/CreateGroupRequest.ts @@ -16,8 +16,8 @@ export class CreateGroupRequestMessage implements MessageBase SessionID: UUID; }; GroupData: { - Name: string; - Charter: string; + Name: Buffer; + Charter: Buffer; ShowInList: boolean; InsigniaID: UUID; MembershipFee: number; @@ -39,11 +39,11 @@ export class CreateGroupRequestMessage implements MessageBase this.AgentData['SessionID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.GroupData['Name'].length, pos++); - buf.write(this.GroupData['Name'], pos); + this.GroupData['Name'].copy(buf, pos); pos += this.GroupData['Name'].length; buf.writeUInt16LE(this.GroupData['Charter'].length, pos); pos += 2; - buf.write(this.GroupData['Charter'], pos); + this.GroupData['Charter'].copy(buf, pos); pos += this.GroupData['Charter'].length; buf.writeUInt8((this.GroupData['ShowInList']) ? 1 : 0, pos++); this.GroupData['InsigniaID'].writeToBuffer(buf, pos); @@ -73,8 +73,8 @@ export class CreateGroupRequestMessage implements MessageBase pos += 16; this.AgentData = newObjAgentData; const newObjGroupData: { - Name: string, - Charter: string, + Name: Buffer, + Charter: Buffer, ShowInList: boolean, InsigniaID: UUID, MembershipFee: number, @@ -82,8 +82,8 @@ export class CreateGroupRequestMessage implements MessageBase AllowPublish: boolean, MaturePublish: boolean } = { - Name: '', - Charter: '', + Name: Buffer.allocUnsafe(0), + Charter: Buffer.allocUnsafe(0), ShowInList: false, InsigniaID: UUID.zero(), MembershipFee: 0, @@ -92,11 +92,11 @@ export class CreateGroupRequestMessage implements MessageBase MaturePublish: false }; varLength = buf.readUInt8(pos++); - newObjGroupData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjGroupData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjGroupData['Charter'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjGroupData['Charter'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjGroupData['ShowInList'] = (buf.readUInt8(pos++) === 1); newObjGroupData['InsigniaID'] = new UUID(buf, pos); diff --git a/lib/classes/messages/CreateGroupRequestExtended.ts b/lib/classes/messages/CreateGroupRequestExtended.ts index 77734ac..fe25fa8 100644 --- a/lib/classes/messages/CreateGroupRequestExtended.ts +++ b/lib/classes/messages/CreateGroupRequestExtended.ts @@ -17,8 +17,8 @@ export class CreateGroupRequestExtendedMessage implements MessageBase GroupLimit: number; }; GroupData: { - Name: string; - Charter: string; + Name: Buffer; + Charter: Buffer; ShowInList: boolean; InsigniaID: UUID; MembershipFee: number; @@ -42,11 +42,11 @@ export class CreateGroupRequestExtendedMessage implements MessageBase buf.writeInt32LE(this.AgentData['GroupLimit'], pos); pos += 4; buf.writeUInt8(this.GroupData['Name'].length, pos++); - buf.write(this.GroupData['Name'], pos); + this.GroupData['Name'].copy(buf, pos); pos += this.GroupData['Name'].length; buf.writeUInt16LE(this.GroupData['Charter'].length, pos); pos += 2; - buf.write(this.GroupData['Charter'], pos); + this.GroupData['Charter'].copy(buf, pos); pos += this.GroupData['Charter'].length; buf.writeUInt8((this.GroupData['ShowInList']) ? 1 : 0, pos++); this.GroupData['InsigniaID'].writeToBuffer(buf, pos); @@ -80,8 +80,8 @@ export class CreateGroupRequestExtendedMessage implements MessageBase pos += 4; this.AgentData = newObjAgentData; const newObjGroupData: { - Name: string, - Charter: string, + Name: Buffer, + Charter: Buffer, ShowInList: boolean, InsigniaID: UUID, MembershipFee: number, @@ -89,8 +89,8 @@ export class CreateGroupRequestExtendedMessage implements MessageBase AllowPublish: boolean, MaturePublish: boolean } = { - Name: '', - Charter: '', + Name: Buffer.allocUnsafe(0), + Charter: Buffer.allocUnsafe(0), ShowInList: false, InsigniaID: UUID.zero(), MembershipFee: 0, @@ -99,11 +99,11 @@ export class CreateGroupRequestExtendedMessage implements MessageBase MaturePublish: false }; varLength = buf.readUInt8(pos++); - newObjGroupData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjGroupData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjGroupData['Charter'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjGroupData['Charter'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjGroupData['ShowInList'] = (buf.readUInt8(pos++) === 1); newObjGroupData['InsigniaID'] = new UUID(buf, pos); diff --git a/lib/classes/messages/CreateInventoryFolder.ts b/lib/classes/messages/CreateInventoryFolder.ts index bf3cbc3..fd70b4d 100644 --- a/lib/classes/messages/CreateInventoryFolder.ts +++ b/lib/classes/messages/CreateInventoryFolder.ts @@ -19,7 +19,7 @@ export class CreateInventoryFolderMessage implements MessageBase FolderID: UUID; ParentID: UUID; Type: number; - Name: string; + Name: Buffer; }; getSize(): number @@ -40,7 +40,7 @@ export class CreateInventoryFolderMessage implements MessageBase pos += 16; buf.writeInt8(this.FolderData['Type'], pos++); buf.writeUInt8(this.FolderData['Name'].length, pos++); - buf.write(this.FolderData['Name'], pos); + this.FolderData['Name'].copy(buf, pos); pos += this.FolderData['Name'].length; return pos - startPos; } @@ -65,12 +65,12 @@ export class CreateInventoryFolderMessage implements MessageBase FolderID: UUID, ParentID: UUID, Type: number, - Name: string + Name: Buffer } = { FolderID: UUID.zero(), ParentID: UUID.zero(), Type: 0, - Name: '' + Name: Buffer.allocUnsafe(0) }; newObjFolderData['FolderID'] = new UUID(buf, pos); pos += 16; @@ -78,7 +78,7 @@ export class CreateInventoryFolderMessage implements MessageBase pos += 16; newObjFolderData['Type'] = buf.readInt8(pos++); varLength = buf.readUInt8(pos++); - newObjFolderData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjFolderData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.FolderData = newObjFolderData; return pos - startPos; diff --git a/lib/classes/messages/CreateInventoryItem.ts b/lib/classes/messages/CreateInventoryItem.ts index 94b7706..d29c717 100644 --- a/lib/classes/messages/CreateInventoryItem.ts +++ b/lib/classes/messages/CreateInventoryItem.ts @@ -23,8 +23,8 @@ export class CreateInventoryItemMessage implements MessageBase Type: number; InvType: number; WearableType: number; - Name: string; - Description: string; + Name: Buffer; + Description: Buffer; }; getSize(): number @@ -51,10 +51,10 @@ export class CreateInventoryItemMessage implements MessageBase buf.writeInt8(this.InventoryBlock['InvType'], pos++); buf.writeUInt8(this.InventoryBlock['WearableType'], pos++); 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; return pos - startPos; } @@ -83,8 +83,8 @@ export class CreateInventoryItemMessage implements MessageBase Type: number, InvType: number, WearableType: number, - Name: string, - Description: string + Name: Buffer, + Description: Buffer } = { CallbackID: 0, FolderID: UUID.zero(), @@ -93,8 +93,8 @@ export class CreateInventoryItemMessage implements MessageBase Type: 0, InvType: 0, WearableType: 0, - Name: '', - Description: '' + Name: Buffer.allocUnsafe(0), + Description: Buffer.allocUnsafe(0) }; newObjInventoryBlock['CallbackID'] = buf.readUInt32LE(pos); pos += 4; @@ -108,10 +108,10 @@ export class CreateInventoryItemMessage implements MessageBase newObjInventoryBlock['InvType'] = buf.readInt8(pos++); newObjInventoryBlock['WearableType'] = buf.readUInt8(pos++); 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; this.InventoryBlock = newObjInventoryBlock; return pos - startPos; diff --git a/lib/classes/messages/CreateLandmarkForEvent.ts b/lib/classes/messages/CreateLandmarkForEvent.ts index c244ce9..efc85a2 100644 --- a/lib/classes/messages/CreateLandmarkForEvent.ts +++ b/lib/classes/messages/CreateLandmarkForEvent.ts @@ -20,7 +20,7 @@ export class CreateLandmarkForEventMessage implements MessageBase }; InventoryBlock: { FolderID: UUID; - Name: string; + Name: Buffer; }; getSize(): number @@ -40,7 +40,7 @@ export class CreateLandmarkForEventMessage implements MessageBase this.InventoryBlock['FolderID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.InventoryBlock['Name'].length, pos++); - buf.write(this.InventoryBlock['Name'], pos); + this.InventoryBlock['Name'].copy(buf, pos); pos += this.InventoryBlock['Name'].length; return pos - startPos; } @@ -71,15 +71,15 @@ export class CreateLandmarkForEventMessage implements MessageBase this.EventData = newObjEventData; const newObjInventoryBlock: { FolderID: UUID, - Name: string + Name: Buffer } = { FolderID: UUID.zero(), - Name: '' + Name: Buffer.allocUnsafe(0) }; newObjInventoryBlock['FolderID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjInventoryBlock['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInventoryBlock['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.InventoryBlock = newObjInventoryBlock; return pos - startPos; diff --git a/lib/classes/messages/CrossedRegion.ts b/lib/classes/messages/CrossedRegion.ts index 2c9a3de..7603dbb 100644 --- a/lib/classes/messages/CrossedRegion.ts +++ b/lib/classes/messages/CrossedRegion.ts @@ -22,7 +22,7 @@ export class CrossedRegionMessage implements MessageBase SimIP: IPAddress; SimPort: number; RegionHandle: Long; - SeedCapability: string; + SeedCapability: Buffer; }; Info: { Position: Vector3; @@ -51,7 +51,7 @@ export class CrossedRegionMessage implements MessageBase pos += 4; buf.writeUInt16LE(this.RegionData['SeedCapability'].length, pos); pos += 2; - buf.write(this.RegionData['SeedCapability'], pos); + this.RegionData['SeedCapability'].copy(buf, pos); pos += this.RegionData['SeedCapability'].length; this.Info['Position'].writeToBuffer(buf, pos, false); pos += 12; @@ -80,12 +80,12 @@ export class CrossedRegionMessage implements MessageBase SimIP: IPAddress, SimPort: number, RegionHandle: Long, - SeedCapability: string + SeedCapability: Buffer } = { SimIP: IPAddress.zero(), SimPort: 0, RegionHandle: Long.ZERO, - SeedCapability: '' + SeedCapability: Buffer.allocUnsafe(0) }; newObjRegionData['SimIP'] = new IPAddress(buf, pos); pos += 4; @@ -95,7 +95,7 @@ export class CrossedRegionMessage implements MessageBase pos += 8; varLength = buf.readUInt16LE(pos); pos += 2; - newObjRegionData['SeedCapability'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjRegionData['SeedCapability'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.RegionData = newObjRegionData; const newObjInfo: { diff --git a/lib/classes/messages/DirClassifiedQuery.ts b/lib/classes/messages/DirClassifiedQuery.ts index 801c4b8..434a270 100644 --- a/lib/classes/messages/DirClassifiedQuery.ts +++ b/lib/classes/messages/DirClassifiedQuery.ts @@ -17,7 +17,7 @@ export class DirClassifiedQueryMessage implements MessageBase }; QueryData: { QueryID: UUID; - QueryText: string; + QueryText: Buffer; QueryFlags: number; Category: number; QueryStart: number; @@ -38,7 +38,7 @@ export class DirClassifiedQueryMessage 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; @@ -67,13 +67,13 @@ export class DirClassifiedQueryMessage implements MessageBase this.AgentData = newObjAgentData; const newObjQueryData: { QueryID: UUID, - QueryText: string, + QueryText: Buffer, QueryFlags: number, Category: number, QueryStart: number } = { QueryID: UUID.zero(), - QueryText: '', + QueryText: Buffer.allocUnsafe(0), QueryFlags: 0, Category: 0, QueryStart: 0 @@ -81,7 +81,7 @@ export class DirClassifiedQueryMessage 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; diff --git a/lib/classes/messages/DirClassifiedQueryBackend.ts b/lib/classes/messages/DirClassifiedQueryBackend.ts index 4caa746..a6f5fba 100644 --- a/lib/classes/messages/DirClassifiedQueryBackend.ts +++ b/lib/classes/messages/DirClassifiedQueryBackend.ts @@ -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; diff --git a/lib/classes/messages/DirClassifiedReply.ts b/lib/classes/messages/DirClassifiedReply.ts index 7d23fa2..27e66a9 100644 --- a/lib/classes/messages/DirClassifiedReply.ts +++ b/lib/classes/messages/DirClassifiedReply.ts @@ -19,7 +19,7 @@ export class DirClassifiedReplyMessage implements MessageBase }; QueryReplies: { ClassifiedID: UUID; - Name: string; + Name: Buffer; ClassifiedFlags: number; CreationDate: number; ExpirationDate: number; @@ -58,7 +58,7 @@ export class DirClassifiedReplyMessage implements MessageBase this.QueryReplies[i]['ClassifiedID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.QueryReplies[i]['Name'].length, pos++); - buf.write(this.QueryReplies[i]['Name'], pos); + this.QueryReplies[i]['Name'].copy(buf, pos); pos += this.QueryReplies[i]['Name'].length; buf.writeUInt8(this.QueryReplies[i]['ClassifiedFlags'], pos++); buf.writeUInt32LE(this.QueryReplies[i]['CreationDate'], pos); @@ -104,14 +104,14 @@ export class DirClassifiedReplyMessage implements MessageBase { const newObjQueryReplies: { ClassifiedID: UUID, - Name: string, + Name: Buffer, ClassifiedFlags: number, CreationDate: number, ExpirationDate: number, PriceForListing: number } = { ClassifiedID: UUID.zero(), - Name: '', + Name: Buffer.allocUnsafe(0), ClassifiedFlags: 0, CreationDate: 0, ExpirationDate: 0, @@ -120,7 +120,7 @@ export class DirClassifiedReplyMessage implements MessageBase newObjQueryReplies['ClassifiedID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryReplies['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjQueryReplies['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjQueryReplies['ClassifiedFlags'] = buf.readUInt8(pos++); newObjQueryReplies['CreationDate'] = buf.readUInt32LE(pos); diff --git a/lib/classes/messages/DirEventsReply.ts b/lib/classes/messages/DirEventsReply.ts index 9324893..8b36528 100644 --- a/lib/classes/messages/DirEventsReply.ts +++ b/lib/classes/messages/DirEventsReply.ts @@ -19,9 +19,9 @@ export class DirEventsReplyMessage implements MessageBase }; QueryReplies: { OwnerID: UUID; - Name: string; + Name: Buffer; EventID: number; - Date: string; + Date: Buffer; UnixTime: number; EventFlags: number; }[]; @@ -58,12 +58,12 @@ export class DirEventsReplyMessage implements MessageBase this.QueryReplies[i]['OwnerID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.QueryReplies[i]['Name'].length, pos++); - buf.write(this.QueryReplies[i]['Name'], pos); + this.QueryReplies[i]['Name'].copy(buf, pos); pos += this.QueryReplies[i]['Name'].length; buf.writeUInt32LE(this.QueryReplies[i]['EventID'], pos); pos += 4; buf.writeUInt8(this.QueryReplies[i]['Date'].length, pos++); - buf.write(this.QueryReplies[i]['Date'], pos); + this.QueryReplies[i]['Date'].copy(buf, pos); pos += this.QueryReplies[i]['Date'].length; buf.writeUInt32LE(this.QueryReplies[i]['UnixTime'], pos); pos += 4; @@ -106,28 +106,28 @@ export class DirEventsReplyMessage implements MessageBase { const newObjQueryReplies: { OwnerID: UUID, - Name: string, + Name: Buffer, EventID: number, - Date: string, + Date: Buffer, UnixTime: number, EventFlags: number } = { OwnerID: UUID.zero(), - Name: '', + Name: Buffer.allocUnsafe(0), EventID: 0, - Date: '', + Date: Buffer.allocUnsafe(0), UnixTime: 0, EventFlags: 0 }; newObjQueryReplies['OwnerID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryReplies['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjQueryReplies['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjQueryReplies['EventID'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjQueryReplies['Date'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjQueryReplies['Date'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjQueryReplies['UnixTime'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/DirFindQuery.ts b/lib/classes/messages/DirFindQuery.ts index 405bb0b..19976dc 100644 --- a/lib/classes/messages/DirFindQuery.ts +++ b/lib/classes/messages/DirFindQuery.ts @@ -17,7 +17,7 @@ export class DirFindQueryMessage implements MessageBase }; QueryData: { QueryID: UUID; - QueryText: string; + QueryText: Buffer; QueryFlags: number; QueryStart: number; }; @@ -37,7 +37,7 @@ export class DirFindQueryMessage 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; @@ -64,19 +64,19 @@ export class DirFindQueryMessage implements MessageBase this.AgentData = newObjAgentData; const newObjQueryData: { QueryID: UUID, - QueryText: string, + QueryText: Buffer, QueryFlags: number, QueryStart: number } = { QueryID: UUID.zero(), - QueryText: '', + QueryText: Buffer.allocUnsafe(0), QueryFlags: 0, QueryStart: 0 }; 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; diff --git a/lib/classes/messages/DirFindQueryBackend.ts b/lib/classes/messages/DirFindQueryBackend.ts index 4e0bd2d..2e59967 100644 --- a/lib/classes/messages/DirFindQueryBackend.ts +++ b/lib/classes/messages/DirFindQueryBackend.ts @@ -16,7 +16,7 @@ export class DirFindQueryBackendMessage implements MessageBase }; QueryData: { QueryID: UUID; - QueryText: string; + QueryText: Buffer; QueryFlags: number; QueryStart: number; EstateID: number; @@ -36,7 +36,7 @@ export class DirFindQueryBackendMessage 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; @@ -62,14 +62,14 @@ export class DirFindQueryBackendMessage implements MessageBase this.AgentData = newObjAgentData; const newObjQueryData: { QueryID: UUID, - QueryText: string, + QueryText: Buffer, QueryFlags: number, QueryStart: number, EstateID: number, Godlike: boolean } = { QueryID: UUID.zero(), - QueryText: '', + QueryText: Buffer.allocUnsafe(0), QueryFlags: 0, QueryStart: 0, EstateID: 0, @@ -78,7 +78,7 @@ export class DirFindQueryBackendMessage 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; diff --git a/lib/classes/messages/DirGroupsReply.ts b/lib/classes/messages/DirGroupsReply.ts index fa6cdd3..91e69a3 100644 --- a/lib/classes/messages/DirGroupsReply.ts +++ b/lib/classes/messages/DirGroupsReply.ts @@ -19,7 +19,7 @@ export class DirGroupsReplyMessage implements MessageBase }; QueryReplies: { GroupID: UUID; - GroupName: string; + GroupName: Buffer; Members: number; SearchOrder: number; }[]; @@ -53,7 +53,7 @@ export class DirGroupsReplyMessage implements MessageBase this.QueryReplies[i]['GroupID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.QueryReplies[i]['GroupName'].length, pos++); - buf.write(this.QueryReplies[i]['GroupName'], pos); + this.QueryReplies[i]['GroupName'].copy(buf, pos); pos += this.QueryReplies[i]['GroupName'].length; buf.writeInt32LE(this.QueryReplies[i]['Members'], pos); pos += 4; @@ -89,19 +89,19 @@ export class DirGroupsReplyMessage implements MessageBase { const newObjQueryReplies: { GroupID: UUID, - GroupName: string, + GroupName: Buffer, Members: number, SearchOrder: number } = { GroupID: UUID.zero(), - GroupName: '', + GroupName: Buffer.allocUnsafe(0), Members: 0, SearchOrder: 0 }; newObjQueryReplies['GroupID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryReplies['GroupName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjQueryReplies['GroupName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjQueryReplies['Members'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/DirLandReply.ts b/lib/classes/messages/DirLandReply.ts index e5c2ed4..fbc62fb 100644 --- a/lib/classes/messages/DirLandReply.ts +++ b/lib/classes/messages/DirLandReply.ts @@ -19,7 +19,7 @@ export class DirLandReplyMessage implements MessageBase }; QueryReplies: { ParcelID: UUID; - Name: string; + Name: Buffer; Auction: boolean; ForSale: boolean; SalePrice: number; @@ -55,7 +55,7 @@ export class DirLandReplyMessage implements MessageBase this.QueryReplies[i]['ParcelID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.QueryReplies[i]['Name'].length, pos++); - buf.write(this.QueryReplies[i]['Name'], pos); + this.QueryReplies[i]['Name'].copy(buf, pos); pos += this.QueryReplies[i]['Name'].length; buf.writeUInt8((this.QueryReplies[i]['Auction']) ? 1 : 0, pos++); buf.writeUInt8((this.QueryReplies[i]['ForSale']) ? 1 : 0, pos++); @@ -93,14 +93,14 @@ export class DirLandReplyMessage implements MessageBase { const newObjQueryReplies: { ParcelID: UUID, - Name: string, + Name: Buffer, Auction: boolean, ForSale: boolean, SalePrice: number, ActualArea: number } = { ParcelID: UUID.zero(), - Name: '', + Name: Buffer.allocUnsafe(0), Auction: false, ForSale: false, SalePrice: 0, @@ -109,7 +109,7 @@ export class DirLandReplyMessage implements MessageBase newObjQueryReplies['ParcelID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryReplies['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjQueryReplies['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjQueryReplies['Auction'] = (buf.readUInt8(pos++) === 1); newObjQueryReplies['ForSale'] = (buf.readUInt8(pos++) === 1); diff --git a/lib/classes/messages/DirPeopleReply.ts b/lib/classes/messages/DirPeopleReply.ts index 823e9e5..78af95a 100644 --- a/lib/classes/messages/DirPeopleReply.ts +++ b/lib/classes/messages/DirPeopleReply.ts @@ -19,9 +19,9 @@ export class DirPeopleReplyMessage implements MessageBase }; QueryReplies: { AgentID: UUID; - FirstName: string; - LastName: string; - Group: string; + FirstName: Buffer; + LastName: Buffer; + Group: Buffer; Online: boolean; Reputation: number; }[]; @@ -55,13 +55,13 @@ export class DirPeopleReplyMessage implements MessageBase this.QueryReplies[i]['AgentID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.QueryReplies[i]['FirstName'].length, pos++); - buf.write(this.QueryReplies[i]['FirstName'], pos); + this.QueryReplies[i]['FirstName'].copy(buf, pos); pos += this.QueryReplies[i]['FirstName'].length; buf.writeUInt8(this.QueryReplies[i]['LastName'].length, pos++); - buf.write(this.QueryReplies[i]['LastName'], pos); + this.QueryReplies[i]['LastName'].copy(buf, pos); pos += this.QueryReplies[i]['LastName'].length; buf.writeUInt8(this.QueryReplies[i]['Group'].length, pos++); - buf.write(this.QueryReplies[i]['Group'], pos); + this.QueryReplies[i]['Group'].copy(buf, pos); pos += this.QueryReplies[i]['Group'].length; buf.writeUInt8((this.QueryReplies[i]['Online']) ? 1 : 0, pos++); buf.writeInt32LE(this.QueryReplies[i]['Reputation'], pos); @@ -96,29 +96,29 @@ export class DirPeopleReplyMessage implements MessageBase { const newObjQueryReplies: { AgentID: UUID, - FirstName: string, - LastName: string, - Group: string, + FirstName: Buffer, + LastName: Buffer, + Group: Buffer, Online: boolean, Reputation: number } = { AgentID: UUID.zero(), - FirstName: '', - LastName: '', - Group: '', + FirstName: Buffer.allocUnsafe(0), + LastName: Buffer.allocUnsafe(0), + Group: Buffer.allocUnsafe(0), Online: false, Reputation: 0 }; newObjQueryReplies['AgentID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryReplies['FirstName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjQueryReplies['FirstName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjQueryReplies['LastName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjQueryReplies['LastName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjQueryReplies['Group'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjQueryReplies['Group'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjQueryReplies['Online'] = (buf.readUInt8(pos++) === 1); newObjQueryReplies['Reputation'] = buf.readInt32LE(pos); diff --git a/lib/classes/messages/DirPlacesQuery.ts b/lib/classes/messages/DirPlacesQuery.ts index 210efef..4054b74 100644 --- a/lib/classes/messages/DirPlacesQuery.ts +++ b/lib/classes/messages/DirPlacesQuery.ts @@ -17,10 +17,10 @@ export class DirPlacesQueryMessage implements MessageBase }; QueryData: { QueryID: UUID; - QueryText: string; + QueryText: Buffer; QueryFlags: number; Category: number; - SimName: string; + SimName: Buffer; QueryStart: number; }; @@ -39,13 +39,13 @@ export class DirPlacesQueryMessage 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; buf.writeInt8(this.QueryData['Category'], pos++); buf.writeUInt8(this.QueryData['SimName'].length, pos++); - buf.write(this.QueryData['SimName'], pos); + this.QueryData['SimName'].copy(buf, pos); pos += this.QueryData['SimName'].length; buf.writeInt32LE(this.QueryData['QueryStart'], pos); pos += 4; @@ -70,29 +70,29 @@ export class DirPlacesQueryMessage implements MessageBase this.AgentData = newObjAgentData; const newObjQueryData: { QueryID: UUID, - QueryText: string, + QueryText: Buffer, QueryFlags: number, Category: number, - SimName: string, + SimName: Buffer, QueryStart: number } = { QueryID: UUID.zero(), - QueryText: '', + QueryText: Buffer.allocUnsafe(0), QueryFlags: 0, Category: 0, - SimName: '', + SimName: Buffer.allocUnsafe(0), QueryStart: 0 }; 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; newObjQueryData['Category'] = buf.readInt8(pos++); varLength = buf.readUInt8(pos++); - newObjQueryData['SimName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjQueryData['SimName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjQueryData['QueryStart'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/DirPlacesQueryBackend.ts b/lib/classes/messages/DirPlacesQueryBackend.ts index ef4c53d..b9e9bc0 100644 --- a/lib/classes/messages/DirPlacesQueryBackend.ts +++ b/lib/classes/messages/DirPlacesQueryBackend.ts @@ -16,10 +16,10 @@ export class DirPlacesQueryBackendMessage implements MessageBase }; QueryData: { QueryID: UUID; - QueryText: string; + QueryText: Buffer; QueryFlags: number; Category: number; - SimName: string; + SimName: Buffer; EstateID: number; Godlike: boolean; QueryStart: number; @@ -38,13 +38,13 @@ export class DirPlacesQueryBackendMessage 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; buf.writeInt8(this.QueryData['Category'], pos++); buf.writeUInt8(this.QueryData['SimName'].length, pos++); - buf.write(this.QueryData['SimName'], pos); + this.QueryData['SimName'].copy(buf, pos); pos += this.QueryData['SimName'].length; buf.writeUInt32LE(this.QueryData['EstateID'], pos); pos += 4; @@ -68,19 +68,19 @@ export class DirPlacesQueryBackendMessage implements MessageBase this.AgentData = newObjAgentData; const newObjQueryData: { QueryID: UUID, - QueryText: string, + QueryText: Buffer, QueryFlags: number, Category: number, - SimName: string, + SimName: Buffer, EstateID: number, Godlike: boolean, QueryStart: number } = { QueryID: UUID.zero(), - QueryText: '', + QueryText: Buffer.allocUnsafe(0), QueryFlags: 0, Category: 0, - SimName: '', + SimName: Buffer.allocUnsafe(0), EstateID: 0, Godlike: false, QueryStart: 0 @@ -88,13 +88,13 @@ export class DirPlacesQueryBackendMessage 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; newObjQueryData['Category'] = buf.readInt8(pos++); varLength = buf.readUInt8(pos++); - newObjQueryData['SimName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjQueryData['SimName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjQueryData['EstateID'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/DirPlacesReply.ts b/lib/classes/messages/DirPlacesReply.ts index a7f85c3..2a55ed6 100644 --- a/lib/classes/messages/DirPlacesReply.ts +++ b/lib/classes/messages/DirPlacesReply.ts @@ -19,7 +19,7 @@ export class DirPlacesReplyMessage implements MessageBase }[]; QueryReplies: { ParcelID: UUID; - Name: string; + Name: Buffer; ForSale: boolean; Auction: boolean; Dwell: number; @@ -62,7 +62,7 @@ export class DirPlacesReplyMessage implements MessageBase this.QueryReplies[i]['ParcelID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.QueryReplies[i]['Name'].length, pos++); - buf.write(this.QueryReplies[i]['Name'], pos); + this.QueryReplies[i]['Name'].copy(buf, pos); pos += this.QueryReplies[i]['Name'].length; buf.writeUInt8((this.QueryReplies[i]['ForSale']) ? 1 : 0, pos++); buf.writeUInt8((this.QueryReplies[i]['Auction']) ? 1 : 0, pos++); @@ -110,13 +110,13 @@ export class DirPlacesReplyMessage implements MessageBase { const newObjQueryReplies: { ParcelID: UUID, - Name: string, + Name: Buffer, ForSale: boolean, Auction: boolean, Dwell: number } = { ParcelID: UUID.zero(), - Name: '', + Name: Buffer.allocUnsafe(0), ForSale: false, Auction: false, Dwell: 0 @@ -124,7 +124,7 @@ export class DirPlacesReplyMessage implements MessageBase newObjQueryReplies['ParcelID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryReplies['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjQueryReplies['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjQueryReplies['ForSale'] = (buf.readUInt8(pos++) === 1); newObjQueryReplies['Auction'] = (buf.readUInt8(pos++) === 1); diff --git a/lib/classes/messages/DirPopularReply.ts b/lib/classes/messages/DirPopularReply.ts index 1d680e3..a363d85 100644 --- a/lib/classes/messages/DirPopularReply.ts +++ b/lib/classes/messages/DirPopularReply.ts @@ -19,7 +19,7 @@ export class DirPopularReplyMessage implements MessageBase }; QueryReplies: { ParcelID: UUID; - Name: string; + Name: Buffer; Dwell: number; }[]; @@ -52,7 +52,7 @@ export class DirPopularReplyMessage implements MessageBase this.QueryReplies[i]['ParcelID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.QueryReplies[i]['Name'].length, pos++); - buf.write(this.QueryReplies[i]['Name'], pos); + this.QueryReplies[i]['Name'].copy(buf, pos); pos += this.QueryReplies[i]['Name'].length; buf.writeFloatLE(this.QueryReplies[i]['Dwell'], pos); pos += 4; @@ -86,17 +86,17 @@ export class DirPopularReplyMessage implements MessageBase { const newObjQueryReplies: { ParcelID: UUID, - Name: string, + Name: Buffer, Dwell: number } = { ParcelID: UUID.zero(), - Name: '', + Name: Buffer.allocUnsafe(0), Dwell: 0 }; newObjQueryReplies['ParcelID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryReplies['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjQueryReplies['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjQueryReplies['Dwell'] = buf.readFloatLE(pos); pos += 4; diff --git a/lib/classes/messages/EdgeDataPacket.ts b/lib/classes/messages/EdgeDataPacket.ts index 24b1928..6b4eb8e 100644 --- a/lib/classes/messages/EdgeDataPacket.ts +++ b/lib/classes/messages/EdgeDataPacket.ts @@ -13,7 +13,7 @@ export class EdgeDataPacketMessage implements MessageBase EdgeData: { LayerType: number; Direction: number; - LayerData: string; + LayerData: Buffer; }; getSize(): number @@ -28,7 +28,7 @@ export class EdgeDataPacketMessage implements MessageBase buf.writeUInt8(this.EdgeData['Direction'], pos++); buf.writeUInt16LE(this.EdgeData['LayerData'].length, pos); pos += 2; - buf.write(this.EdgeData['LayerData'], pos); + this.EdgeData['LayerData'].copy(buf, pos); pos += this.EdgeData['LayerData'].length; return pos - startPos; } @@ -40,17 +40,17 @@ export class EdgeDataPacketMessage implements MessageBase const newObjEdgeData: { LayerType: number, Direction: number, - LayerData: string + LayerData: Buffer } = { LayerType: 0, Direction: 0, - LayerData: '' + LayerData: Buffer.allocUnsafe(0) }; newObjEdgeData['LayerType'] = buf.readUInt8(pos++); newObjEdgeData['Direction'] = buf.readUInt8(pos++); varLength = buf.readUInt16LE(pos); pos += 2; - newObjEdgeData['LayerData'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjEdgeData['LayerData'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.EdgeData = newObjEdgeData; return pos - startPos; diff --git a/lib/classes/messages/EmailMessageReply.ts b/lib/classes/messages/EmailMessageReply.ts index 85781d0..743c002 100644 --- a/lib/classes/messages/EmailMessageReply.ts +++ b/lib/classes/messages/EmailMessageReply.ts @@ -15,10 +15,10 @@ export class EmailMessageReplyMessage implements MessageBase ObjectID: UUID; More: number; Time: number; - FromAddress: string; - Subject: string; - Data: string; - MailFilter: string; + FromAddress: Buffer; + Subject: Buffer; + Data: Buffer; + MailFilter: Buffer; }; getSize(): number @@ -36,17 +36,17 @@ export class EmailMessageReplyMessage implements MessageBase buf.writeUInt32LE(this.DataBlock['Time'], pos); pos += 4; buf.writeUInt8(this.DataBlock['FromAddress'].length, pos++); - buf.write(this.DataBlock['FromAddress'], pos); + this.DataBlock['FromAddress'].copy(buf, pos); pos += this.DataBlock['FromAddress'].length; buf.writeUInt8(this.DataBlock['Subject'].length, pos++); - buf.write(this.DataBlock['Subject'], pos); + this.DataBlock['Subject'].copy(buf, pos); pos += this.DataBlock['Subject'].length; buf.writeUInt16LE(this.DataBlock['Data'].length, pos); pos += 2; - buf.write(this.DataBlock['Data'], pos); + this.DataBlock['Data'].copy(buf, pos); pos += this.DataBlock['Data'].length; buf.writeUInt8(this.DataBlock['MailFilter'].length, pos++); - buf.write(this.DataBlock['MailFilter'], pos); + this.DataBlock['MailFilter'].copy(buf, pos); pos += this.DataBlock['MailFilter'].length; return pos - startPos; } @@ -59,18 +59,18 @@ export class EmailMessageReplyMessage implements MessageBase ObjectID: UUID, More: number, Time: number, - FromAddress: string, - Subject: string, - Data: string, - MailFilter: string + FromAddress: Buffer, + Subject: Buffer, + Data: Buffer, + MailFilter: Buffer } = { ObjectID: UUID.zero(), More: 0, Time: 0, - FromAddress: '', - Subject: '', - Data: '', - MailFilter: '' + FromAddress: Buffer.allocUnsafe(0), + Subject: Buffer.allocUnsafe(0), + Data: Buffer.allocUnsafe(0), + MailFilter: Buffer.allocUnsafe(0) }; newObjDataBlock['ObjectID'] = new UUID(buf, pos); pos += 16; @@ -79,17 +79,17 @@ export class EmailMessageReplyMessage implements MessageBase newObjDataBlock['Time'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjDataBlock['FromAddress'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataBlock['FromAddress'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjDataBlock['Subject'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataBlock['Subject'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjDataBlock['Data'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataBlock['Data'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjDataBlock['MailFilter'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataBlock['MailFilter'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.DataBlock = newObjDataBlock; return pos - startPos; diff --git a/lib/classes/messages/EmailMessageRequest.ts b/lib/classes/messages/EmailMessageRequest.ts index 68a6741..bc0f651 100644 --- a/lib/classes/messages/EmailMessageRequest.ts +++ b/lib/classes/messages/EmailMessageRequest.ts @@ -13,8 +13,8 @@ export class EmailMessageRequestMessage implements MessageBase DataBlock: { ObjectID: UUID; - FromAddress: string; - Subject: string; + FromAddress: Buffer; + Subject: Buffer; }; getSize(): number @@ -28,10 +28,10 @@ export class EmailMessageRequestMessage implements MessageBase this.DataBlock['ObjectID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.DataBlock['FromAddress'].length, pos++); - buf.write(this.DataBlock['FromAddress'], pos); + this.DataBlock['FromAddress'].copy(buf, pos); pos += this.DataBlock['FromAddress'].length; buf.writeUInt8(this.DataBlock['Subject'].length, pos++); - buf.write(this.DataBlock['Subject'], pos); + this.DataBlock['Subject'].copy(buf, pos); pos += this.DataBlock['Subject'].length; return pos - startPos; } @@ -42,20 +42,20 @@ export class EmailMessageRequestMessage implements MessageBase let varLength = 0; const newObjDataBlock: { ObjectID: UUID, - FromAddress: string, - Subject: string + FromAddress: Buffer, + Subject: Buffer } = { ObjectID: UUID.zero(), - FromAddress: '', - Subject: '' + FromAddress: Buffer.allocUnsafe(0), + Subject: Buffer.allocUnsafe(0) }; newObjDataBlock['ObjectID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjDataBlock['FromAddress'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataBlock['FromAddress'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjDataBlock['Subject'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataBlock['Subject'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.DataBlock = newObjDataBlock; return pos - startPos; diff --git a/lib/classes/messages/Error.ts b/lib/classes/messages/Error.ts index 928e28b..2c8e54d 100644 --- a/lib/classes/messages/Error.ts +++ b/lib/classes/messages/Error.ts @@ -16,11 +16,11 @@ export class ErrorMessage implements MessageBase }; Data: { Code: number; - Token: string; + Token: Buffer; ID: UUID; - System: string; - Message: string; - Data: string; + System: Buffer; + Message: Buffer; + Data: Buffer; }; getSize(): number @@ -36,20 +36,20 @@ export class ErrorMessage implements MessageBase buf.writeInt32LE(this.Data['Code'], pos); pos += 4; buf.writeUInt8(this.Data['Token'].length, pos++); - buf.write(this.Data['Token'], pos); + this.Data['Token'].copy(buf, pos); pos += this.Data['Token'].length; this.Data['ID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.Data['System'].length, pos++); - buf.write(this.Data['System'], pos); + this.Data['System'].copy(buf, pos); pos += this.Data['System'].length; buf.writeUInt16LE(this.Data['Message'].length, pos); pos += 2; - buf.write(this.Data['Message'], pos); + this.Data['Message'].copy(buf, pos); pos += this.Data['Message'].length; buf.writeUInt16LE(this.Data['Data'].length, pos); pos += 2; - buf.write(this.Data['Data'], pos); + this.Data['Data'].copy(buf, pos); pos += this.Data['Data'].length; return pos - startPos; } @@ -68,36 +68,36 @@ export class ErrorMessage implements MessageBase this.AgentData = newObjAgentData; const newObjData: { Code: number, - Token: string, + Token: Buffer, ID: UUID, - System: string, - Message: string, - Data: string + System: Buffer, + Message: Buffer, + Data: Buffer } = { Code: 0, - Token: '', + Token: Buffer.allocUnsafe(0), ID: UUID.zero(), - System: '', - Message: '', - Data: '' + System: Buffer.allocUnsafe(0), + Message: Buffer.allocUnsafe(0), + Data: Buffer.allocUnsafe(0) }; newObjData['Code'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjData['Token'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Token'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjData['ID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['System'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['System'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjData['Message'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Message'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjData['Data'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Data'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.Data = newObjData; return pos - startPos; diff --git a/lib/classes/messages/EstateCovenantReply.ts b/lib/classes/messages/EstateCovenantReply.ts index aa4eafc..068ee9a 100644 --- a/lib/classes/messages/EstateCovenantReply.ts +++ b/lib/classes/messages/EstateCovenantReply.ts @@ -14,7 +14,7 @@ export class EstateCovenantReplyMessage implements MessageBase Data: { CovenantID: UUID; CovenantTimestamp: number; - EstateName: string; + EstateName: Buffer; EstateOwnerID: UUID; }; @@ -31,7 +31,7 @@ export class EstateCovenantReplyMessage implements MessageBase buf.writeUInt32LE(this.Data['CovenantTimestamp'], pos); pos += 4; buf.writeUInt8(this.Data['EstateName'].length, pos++); - buf.write(this.Data['EstateName'], pos); + this.Data['EstateName'].copy(buf, pos); pos += this.Data['EstateName'].length; this.Data['EstateOwnerID'].writeToBuffer(buf, pos); pos += 16; @@ -45,12 +45,12 @@ export class EstateCovenantReplyMessage implements MessageBase const newObjData: { CovenantID: UUID, CovenantTimestamp: number, - EstateName: string, + EstateName: Buffer, EstateOwnerID: UUID } = { CovenantID: UUID.zero(), CovenantTimestamp: 0, - EstateName: '', + EstateName: Buffer.allocUnsafe(0), EstateOwnerID: UUID.zero() }; newObjData['CovenantID'] = new UUID(buf, pos); @@ -58,7 +58,7 @@ export class EstateCovenantReplyMessage implements MessageBase newObjData['CovenantTimestamp'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjData['EstateName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['EstateName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjData['EstateOwnerID'] = new UUID(buf, pos); pos += 16; diff --git a/lib/classes/messages/EstateOwnerMessage.ts b/lib/classes/messages/EstateOwnerMessage.ts index 73bd954..04d9351 100644 --- a/lib/classes/messages/EstateOwnerMessage.ts +++ b/lib/classes/messages/EstateOwnerMessage.ts @@ -17,11 +17,11 @@ export class EstateOwnerMessageMessage implements MessageBase TransactionID: UUID; }; MethodData: { - Method: string; + Method: Buffer; Invoice: UUID; }; ParamList: { - Parameter: string; + Parameter: Buffer; }[]; getSize(): number @@ -49,7 +49,7 @@ export class EstateOwnerMessageMessage implements MessageBase this.AgentData['TransactionID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.MethodData['Method'].length, pos++); - buf.write(this.MethodData['Method'], pos); + this.MethodData['Method'].copy(buf, pos); pos += this.MethodData['Method'].length; this.MethodData['Invoice'].writeToBuffer(buf, pos); pos += 16; @@ -58,7 +58,7 @@ export class EstateOwnerMessageMessage implements MessageBase for (let i = 0; i < count; i++) { buf.writeUInt8(this.ParamList[i]['Parameter'].length, pos++); - buf.write(this.ParamList[i]['Parameter'], pos); + this.ParamList[i]['Parameter'].copy(buf, pos); pos += this.ParamList[i]['Parameter'].length; } return pos - startPos; @@ -85,14 +85,14 @@ export class EstateOwnerMessageMessage implements MessageBase pos += 16; this.AgentData = newObjAgentData; const newObjMethodData: { - Method: string, + Method: Buffer, Invoice: UUID } = { - Method: '', + Method: Buffer.allocUnsafe(0), Invoice: UUID.zero() }; varLength = buf.readUInt8(pos++); - newObjMethodData['Method'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMethodData['Method'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjMethodData['Invoice'] = new UUID(buf, pos); pos += 16; @@ -102,12 +102,12 @@ export class EstateOwnerMessageMessage implements MessageBase for (let i = 0; i < count; i++) { const newObjParamList: { - Parameter: string + Parameter: Buffer } = { - Parameter: '' + Parameter: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjParamList['Parameter'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjParamList['Parameter'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ParamList.push(newObjParamList); } diff --git a/lib/classes/messages/EventGodDelete.ts b/lib/classes/messages/EventGodDelete.ts index 4e4f8ca..7f9c867 100644 --- a/lib/classes/messages/EventGodDelete.ts +++ b/lib/classes/messages/EventGodDelete.ts @@ -20,7 +20,7 @@ export class EventGodDeleteMessage implements MessageBase }; QueryData: { QueryID: UUID; - QueryText: string; + QueryText: Buffer; QueryFlags: number; QueryStart: number; }; @@ -42,7 +42,7 @@ export class EventGodDeleteMessage 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; @@ -77,19 +77,19 @@ export class EventGodDeleteMessage implements MessageBase this.EventData = newObjEventData; const newObjQueryData: { QueryID: UUID, - QueryText: string, + QueryText: Buffer, QueryFlags: number, QueryStart: number } = { QueryID: UUID.zero(), - QueryText: '', + QueryText: Buffer.allocUnsafe(0), QueryFlags: 0, QueryStart: 0 }; 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; diff --git a/lib/classes/messages/EventInfoReply.ts b/lib/classes/messages/EventInfoReply.ts index 2e9e16e..242d916 100644 --- a/lib/classes/messages/EventInfoReply.ts +++ b/lib/classes/messages/EventInfoReply.ts @@ -17,16 +17,16 @@ export class EventInfoReplyMessage implements MessageBase }; EventData: { EventID: number; - Creator: string; - Name: string; - Category: string; - Desc: string; - Date: string; + Creator: Buffer; + Name: Buffer; + Category: Buffer; + Desc: Buffer; + Date: Buffer; DateUTC: number; Duration: number; Cover: number; Amount: number; - SimName: string; + SimName: Buffer; GlobalPos: Vector3; EventFlags: number; }; @@ -44,20 +44,20 @@ export class EventInfoReplyMessage implements MessageBase buf.writeUInt32LE(this.EventData['EventID'], pos); pos += 4; buf.writeUInt8(this.EventData['Creator'].length, pos++); - buf.write(this.EventData['Creator'], pos); + this.EventData['Creator'].copy(buf, pos); pos += this.EventData['Creator'].length; buf.writeUInt8(this.EventData['Name'].length, pos++); - buf.write(this.EventData['Name'], pos); + this.EventData['Name'].copy(buf, pos); pos += this.EventData['Name'].length; buf.writeUInt8(this.EventData['Category'].length, pos++); - buf.write(this.EventData['Category'], pos); + this.EventData['Category'].copy(buf, pos); pos += this.EventData['Category'].length; buf.writeUInt16LE(this.EventData['Desc'].length, pos); pos += 2; - buf.write(this.EventData['Desc'], pos); + this.EventData['Desc'].copy(buf, pos); pos += this.EventData['Desc'].length; buf.writeUInt8(this.EventData['Date'].length, pos++); - buf.write(this.EventData['Date'], pos); + this.EventData['Date'].copy(buf, pos); pos += this.EventData['Date'].length; buf.writeUInt32LE(this.EventData['DateUTC'], pos); pos += 4; @@ -68,7 +68,7 @@ export class EventInfoReplyMessage implements MessageBase buf.writeUInt32LE(this.EventData['Amount'], pos); pos += 4; buf.writeUInt8(this.EventData['SimName'].length, pos++); - buf.write(this.EventData['SimName'], pos); + this.EventData['SimName'].copy(buf, pos); pos += this.EventData['SimName'].length; this.EventData['GlobalPos'].writeToBuffer(buf, pos, true); pos += 24; @@ -91,50 +91,50 @@ export class EventInfoReplyMessage implements MessageBase this.AgentData = newObjAgentData; const newObjEventData: { EventID: number, - Creator: string, - Name: string, - Category: string, - Desc: string, - Date: string, + Creator: Buffer, + Name: Buffer, + Category: Buffer, + Desc: Buffer, + Date: Buffer, DateUTC: number, Duration: number, Cover: number, Amount: number, - SimName: string, + SimName: Buffer, GlobalPos: Vector3, EventFlags: number } = { EventID: 0, - Creator: '', - Name: '', - Category: '', - Desc: '', - Date: '', + Creator: Buffer.allocUnsafe(0), + Name: Buffer.allocUnsafe(0), + Category: Buffer.allocUnsafe(0), + Desc: Buffer.allocUnsafe(0), + Date: Buffer.allocUnsafe(0), DateUTC: 0, Duration: 0, Cover: 0, Amount: 0, - SimName: '', + SimName: Buffer.allocUnsafe(0), GlobalPos: Vector3.getZero(), EventFlags: 0 }; newObjEventData['EventID'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjEventData['Creator'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjEventData['Creator'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjEventData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjEventData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjEventData['Category'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjEventData['Category'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjEventData['Desc'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjEventData['Desc'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjEventData['Date'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjEventData['Date'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjEventData['DateUTC'] = buf.readUInt32LE(pos); pos += 4; @@ -145,7 +145,7 @@ export class EventInfoReplyMessage implements MessageBase newObjEventData['Amount'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjEventData['SimName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjEventData['SimName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjEventData['GlobalPos'] = new Vector3(buf, pos, true); pos += 24; diff --git a/lib/classes/messages/FeatureDisabled.ts b/lib/classes/messages/FeatureDisabled.ts index 4b7febb..e24ab49 100644 --- a/lib/classes/messages/FeatureDisabled.ts +++ b/lib/classes/messages/FeatureDisabled.ts @@ -12,7 +12,7 @@ export class FeatureDisabledMessage implements MessageBase id = Message.FeatureDisabled; FailureInfo: { - ErrorMessage: string; + ErrorMessage: Buffer; AgentID: UUID; TransactionID: UUID; }; @@ -26,7 +26,7 @@ export class FeatureDisabledMessage implements MessageBase { const startPos = pos; buf.writeUInt8(this.FailureInfo['ErrorMessage'].length, pos++); - buf.write(this.FailureInfo['ErrorMessage'], pos); + this.FailureInfo['ErrorMessage'].copy(buf, pos); pos += this.FailureInfo['ErrorMessage'].length; this.FailureInfo['AgentID'].writeToBuffer(buf, pos); pos += 16; @@ -40,16 +40,16 @@ export class FeatureDisabledMessage implements MessageBase const startPos = pos; let varLength = 0; const newObjFailureInfo: { - ErrorMessage: string, + ErrorMessage: Buffer, AgentID: UUID, TransactionID: UUID } = { - ErrorMessage: '', + ErrorMessage: Buffer.allocUnsafe(0), AgentID: UUID.zero(), TransactionID: UUID.zero() }; varLength = buf.readUInt8(pos++); - newObjFailureInfo['ErrorMessage'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjFailureInfo['ErrorMessage'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjFailureInfo['AgentID'] = new UUID(buf, pos); pos += 16; diff --git a/lib/classes/messages/FetchInventoryReply.ts b/lib/classes/messages/FetchInventoryReply.ts index 816de73..e45edc2 100644 --- a/lib/classes/messages/FetchInventoryReply.ts +++ b/lib/classes/messages/FetchInventoryReply.ts @@ -32,8 +32,8 @@ export class FetchInventoryReplyMessage implements MessageBase Flags: number; SaleType: number; SalePrice: number; - Name: string; - Description: string; + Name: Buffer; + Description: Buffer; CreationDate: number; CRC: number; }[]; @@ -93,10 +93,10 @@ export class FetchInventoryReplyMessage implements MessageBase buf.writeInt32LE(this.InventoryData[i]['SalePrice'], pos); pos += 4; buf.writeUInt8(this.InventoryData[i]['Name'].length, pos++); - buf.write(this.InventoryData[i]['Name'], pos); + this.InventoryData[i]['Name'].copy(buf, pos); pos += this.InventoryData[i]['Name'].length; buf.writeUInt8(this.InventoryData[i]['Description'].length, pos++); - buf.write(this.InventoryData[i]['Description'], pos); + this.InventoryData[i]['Description'].copy(buf, pos); pos += this.InventoryData[i]['Description'].length; buf.writeInt32LE(this.InventoryData[i]['CreationDate'], pos); pos += 4; @@ -140,8 +140,8 @@ export class FetchInventoryReplyMessage implements MessageBase Flags: number, SaleType: number, SalePrice: number, - Name: string, - Description: string, + Name: Buffer, + Description: Buffer, CreationDate: number, CRC: number } = { @@ -162,8 +162,8 @@ export class FetchInventoryReplyMessage implements MessageBase Flags: 0, SaleType: 0, SalePrice: 0, - Name: '', - Description: '', + Name: Buffer.allocUnsafe(0), + Description: Buffer.allocUnsafe(0), CreationDate: 0, CRC: 0 }; @@ -198,10 +198,10 @@ export class FetchInventoryReplyMessage implements MessageBase newObjInventoryData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjInventoryData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInventoryData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjInventoryData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInventoryData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjInventoryData['CreationDate'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/GenericMessage.ts b/lib/classes/messages/GenericMessage.ts index f797446..d740105 100644 --- a/lib/classes/messages/GenericMessage.ts +++ b/lib/classes/messages/GenericMessage.ts @@ -17,11 +17,11 @@ export class GenericMessageMessage implements MessageBase TransactionID: UUID; }; MethodData: { - Method: string; + Method: Buffer; Invoice: UUID; }; ParamList: { - Parameter: string; + Parameter: Buffer; }[]; getSize(): number @@ -49,7 +49,7 @@ export class GenericMessageMessage implements MessageBase this.AgentData['TransactionID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.MethodData['Method'].length, pos++); - buf.write(this.MethodData['Method'], pos); + this.MethodData['Method'].copy(buf, pos); pos += this.MethodData['Method'].length; this.MethodData['Invoice'].writeToBuffer(buf, pos); pos += 16; @@ -58,7 +58,7 @@ export class GenericMessageMessage implements MessageBase for (let i = 0; i < count; i++) { buf.writeUInt8(this.ParamList[i]['Parameter'].length, pos++); - buf.write(this.ParamList[i]['Parameter'], pos); + this.ParamList[i]['Parameter'].copy(buf, pos); pos += this.ParamList[i]['Parameter'].length; } return pos - startPos; @@ -85,14 +85,14 @@ export class GenericMessageMessage implements MessageBase pos += 16; this.AgentData = newObjAgentData; const newObjMethodData: { - Method: string, + Method: Buffer, Invoice: UUID } = { - Method: '', + Method: Buffer.allocUnsafe(0), Invoice: UUID.zero() }; varLength = buf.readUInt8(pos++); - newObjMethodData['Method'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMethodData['Method'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjMethodData['Invoice'] = new UUID(buf, pos); pos += 16; @@ -102,12 +102,12 @@ export class GenericMessageMessage implements MessageBase for (let i = 0; i < count; i++) { const newObjParamList: { - Parameter: string + Parameter: Buffer } = { - Parameter: '' + Parameter: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjParamList['Parameter'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjParamList['Parameter'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ParamList.push(newObjParamList); } diff --git a/lib/classes/messages/GodKickUser.ts b/lib/classes/messages/GodKickUser.ts index 9cad66e..7ae9236 100644 --- a/lib/classes/messages/GodKickUser.ts +++ b/lib/classes/messages/GodKickUser.ts @@ -16,7 +16,7 @@ export class GodKickUserMessage implements MessageBase GodSessionID: UUID; AgentID: UUID; KickFlags: number; - Reason: string; + Reason: Buffer; }; getSize(): number @@ -37,7 +37,7 @@ export class GodKickUserMessage implements MessageBase pos += 4; buf.writeUInt16LE(this.UserInfo['Reason'].length, pos); pos += 2; - buf.write(this.UserInfo['Reason'], pos); + this.UserInfo['Reason'].copy(buf, pos); pos += this.UserInfo['Reason'].length; return pos - startPos; } @@ -51,13 +51,13 @@ export class GodKickUserMessage implements MessageBase GodSessionID: UUID, AgentID: UUID, KickFlags: number, - Reason: string + Reason: Buffer } = { GodID: UUID.zero(), GodSessionID: UUID.zero(), AgentID: UUID.zero(), KickFlags: 0, - Reason: '' + Reason: Buffer.allocUnsafe(0) }; newObjUserInfo['GodID'] = new UUID(buf, pos); pos += 16; @@ -69,7 +69,7 @@ export class GodKickUserMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjUserInfo['Reason'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjUserInfo['Reason'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.UserInfo = newObjUserInfo; return pos - startPos; diff --git a/lib/classes/messages/GodUpdateRegionInfo.ts b/lib/classes/messages/GodUpdateRegionInfo.ts index 3b69a29..6c98728 100644 --- a/lib/classes/messages/GodUpdateRegionInfo.ts +++ b/lib/classes/messages/GodUpdateRegionInfo.ts @@ -17,7 +17,7 @@ export class GodUpdateRegionInfoMessage implements MessageBase SessionID: UUID; }; RegionInfo: { - SimName: string; + SimName: Buffer; EstateID: number; ParentEstateID: number; RegionFlags: number; @@ -43,7 +43,7 @@ export class GodUpdateRegionInfoMessage implements MessageBase this.AgentData['SessionID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.RegionInfo['SimName'].length, pos++); - buf.write(this.RegionInfo['SimName'], pos); + this.RegionInfo['SimName'].copy(buf, pos); pos += this.RegionInfo['SimName'].length; buf.writeUInt32LE(this.RegionInfo['EstateID'], pos); pos += 4; @@ -88,7 +88,7 @@ export class GodUpdateRegionInfoMessage implements MessageBase pos += 16; this.AgentData = newObjAgentData; const newObjRegionInfo: { - SimName: string, + SimName: Buffer, EstateID: number, ParentEstateID: number, RegionFlags: number, @@ -97,7 +97,7 @@ export class GodUpdateRegionInfoMessage implements MessageBase RedirectGridX: number, RedirectGridY: number } = { - SimName: '', + SimName: Buffer.allocUnsafe(0), EstateID: 0, ParentEstateID: 0, RegionFlags: 0, @@ -107,7 +107,7 @@ export class GodUpdateRegionInfoMessage implements MessageBase RedirectGridY: 0 }; varLength = buf.readUInt8(pos++); - newObjRegionInfo['SimName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjRegionInfo['SimName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjRegionInfo['EstateID'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/GodlikeMessage.ts b/lib/classes/messages/GodlikeMessage.ts index 99b5f21..6d68fc0 100644 --- a/lib/classes/messages/GodlikeMessage.ts +++ b/lib/classes/messages/GodlikeMessage.ts @@ -17,11 +17,11 @@ export class GodlikeMessageMessage implements MessageBase TransactionID: UUID; }; MethodData: { - Method: string; + Method: Buffer; Invoice: UUID; }; ParamList: { - Parameter: string; + Parameter: Buffer; }[]; getSize(): number @@ -49,7 +49,7 @@ export class GodlikeMessageMessage implements MessageBase this.AgentData['TransactionID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.MethodData['Method'].length, pos++); - buf.write(this.MethodData['Method'], pos); + this.MethodData['Method'].copy(buf, pos); pos += this.MethodData['Method'].length; this.MethodData['Invoice'].writeToBuffer(buf, pos); pos += 16; @@ -58,7 +58,7 @@ export class GodlikeMessageMessage implements MessageBase for (let i = 0; i < count; i++) { buf.writeUInt8(this.ParamList[i]['Parameter'].length, pos++); - buf.write(this.ParamList[i]['Parameter'], pos); + this.ParamList[i]['Parameter'].copy(buf, pos); pos += this.ParamList[i]['Parameter'].length; } return pos - startPos; @@ -85,14 +85,14 @@ export class GodlikeMessageMessage implements MessageBase pos += 16; this.AgentData = newObjAgentData; const newObjMethodData: { - Method: string, + Method: Buffer, Invoice: UUID } = { - Method: '', + Method: Buffer.allocUnsafe(0), Invoice: UUID.zero() }; varLength = buf.readUInt8(pos++); - newObjMethodData['Method'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMethodData['Method'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjMethodData['Invoice'] = new UUID(buf, pos); pos += 16; @@ -102,12 +102,12 @@ export class GodlikeMessageMessage implements MessageBase for (let i = 0; i < count; i++) { const newObjParamList: { - Parameter: string + Parameter: Buffer } = { - Parameter: '' + Parameter: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjParamList['Parameter'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjParamList['Parameter'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ParamList.push(newObjParamList); } diff --git a/lib/classes/messages/GroupAccountDetailsReply.ts b/lib/classes/messages/GroupAccountDetailsReply.ts index ffd53d1..c23be0d 100644 --- a/lib/classes/messages/GroupAccountDetailsReply.ts +++ b/lib/classes/messages/GroupAccountDetailsReply.ts @@ -19,10 +19,10 @@ export class GroupAccountDetailsReplyMessage implements MessageBase RequestID: UUID; IntervalDays: number; CurrentInterval: number; - StartDate: string; + StartDate: Buffer; }; HistoryData: { - Description: string; + Description: Buffer; Amount: number; }[]; @@ -55,14 +55,14 @@ export class GroupAccountDetailsReplyMessage implements MessageBase buf.writeInt32LE(this.MoneyData['CurrentInterval'], pos); pos += 4; buf.writeUInt8(this.MoneyData['StartDate'].length, pos++); - buf.write(this.MoneyData['StartDate'], pos); + this.MoneyData['StartDate'].copy(buf, pos); pos += this.MoneyData['StartDate'].length; const count = this.HistoryData.length; buf.writeUInt8(this.HistoryData.length, pos++); for (let i = 0; i < count; i++) { buf.writeUInt8(this.HistoryData[i]['Description'].length, pos++); - buf.write(this.HistoryData[i]['Description'], pos); + this.HistoryData[i]['Description'].copy(buf, pos); pos += this.HistoryData[i]['Description'].length; buf.writeInt32LE(this.HistoryData[i]['Amount'], pos); pos += 4; @@ -90,12 +90,12 @@ export class GroupAccountDetailsReplyMessage implements MessageBase RequestID: UUID, IntervalDays: number, CurrentInterval: number, - StartDate: string + StartDate: Buffer } = { RequestID: UUID.zero(), IntervalDays: 0, CurrentInterval: 0, - StartDate: '' + StartDate: Buffer.allocUnsafe(0) }; newObjMoneyData['RequestID'] = new UUID(buf, pos); pos += 16; @@ -104,7 +104,7 @@ export class GroupAccountDetailsReplyMessage implements MessageBase newObjMoneyData['CurrentInterval'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjMoneyData['StartDate'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMoneyData['StartDate'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.MoneyData = newObjMoneyData; const count = buf.readUInt8(pos++); @@ -112,14 +112,14 @@ export class GroupAccountDetailsReplyMessage implements MessageBase for (let i = 0; i < count; i++) { const newObjHistoryData: { - Description: string, + Description: Buffer, Amount: number } = { - Description: '', + Description: Buffer.allocUnsafe(0), Amount: 0 }; varLength = buf.readUInt8(pos++); - newObjHistoryData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjHistoryData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjHistoryData['Amount'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/GroupAccountSummaryReply.ts b/lib/classes/messages/GroupAccountSummaryReply.ts index a2c4c6d..8e1ae75 100644 --- a/lib/classes/messages/GroupAccountSummaryReply.ts +++ b/lib/classes/messages/GroupAccountSummaryReply.ts @@ -19,7 +19,7 @@ export class GroupAccountSummaryReplyMessage implements MessageBase RequestID: UUID; IntervalDays: number; CurrentInterval: number; - StartDate: string; + StartDate: Buffer; Balance: number; TotalCredits: number; TotalDebits: number; @@ -34,8 +34,8 @@ export class GroupAccountSummaryReplyMessage implements MessageBase GroupTaxEstimate: number; ParcelDirFeeEstimate: number; NonExemptMembers: number; - LastTaxDate: string; - TaxDate: string; + LastTaxDate: Buffer; + TaxDate: Buffer; }; getSize(): number @@ -57,7 +57,7 @@ export class GroupAccountSummaryReplyMessage implements MessageBase buf.writeInt32LE(this.MoneyData['CurrentInterval'], pos); pos += 4; buf.writeUInt8(this.MoneyData['StartDate'].length, pos++); - buf.write(this.MoneyData['StartDate'], pos); + this.MoneyData['StartDate'].copy(buf, pos); pos += this.MoneyData['StartDate'].length; buf.writeInt32LE(this.MoneyData['Balance'], pos); pos += 4; @@ -88,10 +88,10 @@ export class GroupAccountSummaryReplyMessage implements MessageBase buf.writeInt32LE(this.MoneyData['NonExemptMembers'], pos); pos += 4; buf.writeUInt8(this.MoneyData['LastTaxDate'].length, pos++); - buf.write(this.MoneyData['LastTaxDate'], pos); + this.MoneyData['LastTaxDate'].copy(buf, pos); pos += this.MoneyData['LastTaxDate'].length; buf.writeUInt8(this.MoneyData['TaxDate'].length, pos++); - buf.write(this.MoneyData['TaxDate'], pos); + this.MoneyData['TaxDate'].copy(buf, pos); pos += this.MoneyData['TaxDate'].length; return pos - startPos; } @@ -116,7 +116,7 @@ export class GroupAccountSummaryReplyMessage implements MessageBase RequestID: UUID, IntervalDays: number, CurrentInterval: number, - StartDate: string, + StartDate: Buffer, Balance: number, TotalCredits: number, TotalDebits: number, @@ -131,13 +131,13 @@ export class GroupAccountSummaryReplyMessage implements MessageBase GroupTaxEstimate: number, ParcelDirFeeEstimate: number, NonExemptMembers: number, - LastTaxDate: string, - TaxDate: string + LastTaxDate: Buffer, + TaxDate: Buffer } = { RequestID: UUID.zero(), IntervalDays: 0, CurrentInterval: 0, - StartDate: '', + StartDate: Buffer.allocUnsafe(0), Balance: 0, TotalCredits: 0, TotalDebits: 0, @@ -152,8 +152,8 @@ export class GroupAccountSummaryReplyMessage implements MessageBase GroupTaxEstimate: 0, ParcelDirFeeEstimate: 0, NonExemptMembers: 0, - LastTaxDate: '', - TaxDate: '' + LastTaxDate: Buffer.allocUnsafe(0), + TaxDate: Buffer.allocUnsafe(0) }; newObjMoneyData['RequestID'] = new UUID(buf, pos); pos += 16; @@ -162,7 +162,7 @@ export class GroupAccountSummaryReplyMessage implements MessageBase newObjMoneyData['CurrentInterval'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjMoneyData['StartDate'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMoneyData['StartDate'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjMoneyData['Balance'] = buf.readInt32LE(pos); pos += 4; @@ -193,10 +193,10 @@ export class GroupAccountSummaryReplyMessage implements MessageBase newObjMoneyData['NonExemptMembers'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjMoneyData['LastTaxDate'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMoneyData['LastTaxDate'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjMoneyData['TaxDate'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMoneyData['TaxDate'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.MoneyData = newObjMoneyData; return pos - startPos; diff --git a/lib/classes/messages/GroupAccountTransactionsReply.ts b/lib/classes/messages/GroupAccountTransactionsReply.ts index 93d8c64..d002cb5 100644 --- a/lib/classes/messages/GroupAccountTransactionsReply.ts +++ b/lib/classes/messages/GroupAccountTransactionsReply.ts @@ -19,13 +19,13 @@ export class GroupAccountTransactionsReplyMessage implements MessageBase RequestID: UUID; IntervalDays: number; CurrentInterval: number; - StartDate: string; + StartDate: Buffer; }; HistoryData: { - Time: string; - User: string; + Time: Buffer; + User: Buffer; Type: number; - Item: string; + Item: Buffer; Amount: number; }[]; @@ -58,22 +58,22 @@ export class GroupAccountTransactionsReplyMessage implements MessageBase buf.writeInt32LE(this.MoneyData['CurrentInterval'], pos); pos += 4; buf.writeUInt8(this.MoneyData['StartDate'].length, pos++); - buf.write(this.MoneyData['StartDate'], pos); + this.MoneyData['StartDate'].copy(buf, pos); pos += this.MoneyData['StartDate'].length; const count = this.HistoryData.length; buf.writeUInt8(this.HistoryData.length, pos++); for (let i = 0; i < count; i++) { buf.writeUInt8(this.HistoryData[i]['Time'].length, pos++); - buf.write(this.HistoryData[i]['Time'], pos); + this.HistoryData[i]['Time'].copy(buf, pos); pos += this.HistoryData[i]['Time'].length; buf.writeUInt8(this.HistoryData[i]['User'].length, pos++); - buf.write(this.HistoryData[i]['User'], pos); + this.HistoryData[i]['User'].copy(buf, pos); pos += this.HistoryData[i]['User'].length; buf.writeInt32LE(this.HistoryData[i]['Type'], pos); pos += 4; buf.writeUInt8(this.HistoryData[i]['Item'].length, pos++); - buf.write(this.HistoryData[i]['Item'], pos); + this.HistoryData[i]['Item'].copy(buf, pos); pos += this.HistoryData[i]['Item'].length; buf.writeInt32LE(this.HistoryData[i]['Amount'], pos); pos += 4; @@ -101,12 +101,12 @@ export class GroupAccountTransactionsReplyMessage implements MessageBase RequestID: UUID, IntervalDays: number, CurrentInterval: number, - StartDate: string + StartDate: Buffer } = { RequestID: UUID.zero(), IntervalDays: 0, CurrentInterval: 0, - StartDate: '' + StartDate: Buffer.allocUnsafe(0) }; newObjMoneyData['RequestID'] = new UUID(buf, pos); pos += 16; @@ -115,7 +115,7 @@ export class GroupAccountTransactionsReplyMessage implements MessageBase newObjMoneyData['CurrentInterval'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjMoneyData['StartDate'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMoneyData['StartDate'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.MoneyData = newObjMoneyData; const count = buf.readUInt8(pos++); @@ -123,28 +123,28 @@ export class GroupAccountTransactionsReplyMessage implements MessageBase for (let i = 0; i < count; i++) { const newObjHistoryData: { - Time: string, - User: string, + Time: Buffer, + User: Buffer, Type: number, - Item: string, + Item: Buffer, Amount: number } = { - Time: '', - User: '', + Time: Buffer.allocUnsafe(0), + User: Buffer.allocUnsafe(0), Type: 0, - Item: '', + Item: Buffer.allocUnsafe(0), Amount: 0 }; varLength = buf.readUInt8(pos++); - newObjHistoryData['Time'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjHistoryData['Time'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjHistoryData['User'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjHistoryData['User'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjHistoryData['Type'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjHistoryData['Item'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjHistoryData['Item'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjHistoryData['Amount'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/GroupActiveProposalItemReply.ts b/lib/classes/messages/GroupActiveProposalItemReply.ts index b878308..c04975c 100644 --- a/lib/classes/messages/GroupActiveProposalItemReply.ts +++ b/lib/classes/messages/GroupActiveProposalItemReply.ts @@ -22,14 +22,14 @@ export class GroupActiveProposalItemReplyMessage implements MessageBase ProposalData: { VoteID: UUID; VoteInitiator: UUID; - TerseDateID: string; - StartDateTime: string; - EndDateTime: string; + TerseDateID: Buffer; + StartDateTime: Buffer; + EndDateTime: Buffer; AlreadyVoted: boolean; - VoteCast: string; + VoteCast: Buffer; Majority: number; Quorum: number; - ProposalText: string; + ProposalText: Buffer; }[]; getSize(): number @@ -67,24 +67,24 @@ export class GroupActiveProposalItemReplyMessage implements MessageBase this.ProposalData[i]['VoteInitiator'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.ProposalData[i]['TerseDateID'].length, pos++); - buf.write(this.ProposalData[i]['TerseDateID'], pos); + this.ProposalData[i]['TerseDateID'].copy(buf, pos); pos += this.ProposalData[i]['TerseDateID'].length; buf.writeUInt8(this.ProposalData[i]['StartDateTime'].length, pos++); - buf.write(this.ProposalData[i]['StartDateTime'], pos); + this.ProposalData[i]['StartDateTime'].copy(buf, pos); pos += this.ProposalData[i]['StartDateTime'].length; buf.writeUInt8(this.ProposalData[i]['EndDateTime'].length, pos++); - buf.write(this.ProposalData[i]['EndDateTime'], pos); + this.ProposalData[i]['EndDateTime'].copy(buf, pos); pos += this.ProposalData[i]['EndDateTime'].length; buf.writeUInt8((this.ProposalData[i]['AlreadyVoted']) ? 1 : 0, pos++); buf.writeUInt8(this.ProposalData[i]['VoteCast'].length, pos++); - buf.write(this.ProposalData[i]['VoteCast'], pos); + this.ProposalData[i]['VoteCast'].copy(buf, pos); pos += this.ProposalData[i]['VoteCast'].length; buf.writeFloatLE(this.ProposalData[i]['Majority'], pos); pos += 4; buf.writeInt32LE(this.ProposalData[i]['Quorum'], pos); pos += 4; buf.writeUInt8(this.ProposalData[i]['ProposalText'].length, pos++); - buf.write(this.ProposalData[i]['ProposalText'], pos); + this.ProposalData[i]['ProposalText'].copy(buf, pos); pos += this.ProposalData[i]['ProposalText'].length; } return pos - startPos; @@ -125,49 +125,49 @@ export class GroupActiveProposalItemReplyMessage implements MessageBase const newObjProposalData: { VoteID: UUID, VoteInitiator: UUID, - TerseDateID: string, - StartDateTime: string, - EndDateTime: string, + TerseDateID: Buffer, + StartDateTime: Buffer, + EndDateTime: Buffer, AlreadyVoted: boolean, - VoteCast: string, + VoteCast: Buffer, Majority: number, Quorum: number, - ProposalText: string + ProposalText: Buffer } = { VoteID: UUID.zero(), VoteInitiator: UUID.zero(), - TerseDateID: '', - StartDateTime: '', - EndDateTime: '', + TerseDateID: Buffer.allocUnsafe(0), + StartDateTime: Buffer.allocUnsafe(0), + EndDateTime: Buffer.allocUnsafe(0), AlreadyVoted: false, - VoteCast: '', + VoteCast: Buffer.allocUnsafe(0), Majority: 0, Quorum: 0, - ProposalText: '' + ProposalText: Buffer.allocUnsafe(0) }; newObjProposalData['VoteID'] = new UUID(buf, pos); pos += 16; newObjProposalData['VoteInitiator'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjProposalData['TerseDateID'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjProposalData['TerseDateID'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjProposalData['StartDateTime'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjProposalData['StartDateTime'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjProposalData['EndDateTime'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjProposalData['EndDateTime'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjProposalData['AlreadyVoted'] = (buf.readUInt8(pos++) === 1); varLength = buf.readUInt8(pos++); - newObjProposalData['VoteCast'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjProposalData['VoteCast'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjProposalData['Majority'] = buf.readFloatLE(pos); pos += 4; newObjProposalData['Quorum'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjProposalData['ProposalText'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjProposalData['ProposalText'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ProposalData.push(newObjProposalData); } diff --git a/lib/classes/messages/GroupDataUpdate.ts b/lib/classes/messages/GroupDataUpdate.ts index f7c50e8..6a602c6 100644 --- a/lib/classes/messages/GroupDataUpdate.ts +++ b/lib/classes/messages/GroupDataUpdate.ts @@ -16,7 +16,7 @@ export class GroupDataUpdateMessage implements MessageBase AgentID: UUID; GroupID: UUID; AgentPowers: Long; - GroupTitle: string; + GroupTitle: Buffer; }[]; getSize(): number @@ -50,7 +50,7 @@ export class GroupDataUpdateMessage implements MessageBase buf.writeInt32LE(this.AgentGroupData[i]['AgentPowers'].high, pos); pos += 4; buf.writeUInt8(this.AgentGroupData[i]['GroupTitle'].length, pos++); - buf.write(this.AgentGroupData[i]['GroupTitle'], pos); + this.AgentGroupData[i]['GroupTitle'].copy(buf, pos); pos += this.AgentGroupData[i]['GroupTitle'].length; } return pos - startPos; @@ -68,12 +68,12 @@ export class GroupDataUpdateMessage implements MessageBase AgentID: UUID, GroupID: UUID, AgentPowers: Long, - GroupTitle: string + GroupTitle: Buffer } = { AgentID: UUID.zero(), GroupID: UUID.zero(), AgentPowers: Long.ZERO, - GroupTitle: '' + GroupTitle: Buffer.allocUnsafe(0) }; newObjAgentGroupData['AgentID'] = new UUID(buf, pos); pos += 16; @@ -82,7 +82,7 @@ export class GroupDataUpdateMessage implements MessageBase newObjAgentGroupData['AgentPowers'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4)); pos += 8; varLength = buf.readUInt8(pos++); - newObjAgentGroupData['GroupTitle'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAgentGroupData['GroupTitle'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.AgentGroupData.push(newObjAgentGroupData); } diff --git a/lib/classes/messages/GroupMembersReply.ts b/lib/classes/messages/GroupMembersReply.ts index 1f8c8dc..23b412e 100644 --- a/lib/classes/messages/GroupMembersReply.ts +++ b/lib/classes/messages/GroupMembersReply.ts @@ -23,9 +23,9 @@ export class GroupMembersReplyMessage implements MessageBase MemberData: { AgentID: UUID; Contribution: number; - OnlineStatus: string; + OnlineStatus: Buffer; AgentPowers: Long; - Title: string; + Title: Buffer; IsOwner: boolean; }[]; @@ -64,14 +64,14 @@ export class GroupMembersReplyMessage implements MessageBase buf.writeInt32LE(this.MemberData[i]['Contribution'], pos); pos += 4; buf.writeUInt8(this.MemberData[i]['OnlineStatus'].length, pos++); - buf.write(this.MemberData[i]['OnlineStatus'], pos); + this.MemberData[i]['OnlineStatus'].copy(buf, pos); pos += this.MemberData[i]['OnlineStatus'].length; buf.writeInt32LE(this.MemberData[i]['AgentPowers'].low, pos); pos += 4; buf.writeInt32LE(this.MemberData[i]['AgentPowers'].high, pos); pos += 4; buf.writeUInt8(this.MemberData[i]['Title'].length, pos++); - buf.write(this.MemberData[i]['Title'], pos); + this.MemberData[i]['Title'].copy(buf, pos); pos += this.MemberData[i]['Title'].length; buf.writeUInt8((this.MemberData[i]['IsOwner']) ? 1 : 0, pos++); } @@ -113,16 +113,16 @@ export class GroupMembersReplyMessage implements MessageBase const newObjMemberData: { AgentID: UUID, Contribution: number, - OnlineStatus: string, + OnlineStatus: Buffer, AgentPowers: Long, - Title: string, + Title: Buffer, IsOwner: boolean } = { AgentID: UUID.zero(), Contribution: 0, - OnlineStatus: '', + OnlineStatus: Buffer.allocUnsafe(0), AgentPowers: Long.ZERO, - Title: '', + Title: Buffer.allocUnsafe(0), IsOwner: false }; newObjMemberData['AgentID'] = new UUID(buf, pos); @@ -130,12 +130,12 @@ export class GroupMembersReplyMessage implements MessageBase newObjMemberData['Contribution'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjMemberData['OnlineStatus'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMemberData['OnlineStatus'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjMemberData['AgentPowers'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4)); pos += 8; varLength = buf.readUInt8(pos++); - newObjMemberData['Title'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMemberData['Title'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjMemberData['IsOwner'] = (buf.readUInt8(pos++) === 1); this.MemberData.push(newObjMemberData); diff --git a/lib/classes/messages/GroupNoticeAdd.ts b/lib/classes/messages/GroupNoticeAdd.ts index 9d21294..48f1829 100644 --- a/lib/classes/messages/GroupNoticeAdd.ts +++ b/lib/classes/messages/GroupNoticeAdd.ts @@ -18,9 +18,9 @@ export class GroupNoticeAddMessage implements MessageBase ToGroupID: UUID; ID: UUID; Dialog: number; - FromAgentName: string; - Message: string; - BinaryBucket: string; + FromAgentName: Buffer; + Message: Buffer; + BinaryBucket: Buffer; }; getSize(): number @@ -39,15 +39,15 @@ export class GroupNoticeAddMessage implements MessageBase pos += 16; buf.writeUInt8(this.MessageBlock['Dialog'], pos++); buf.writeUInt8(this.MessageBlock['FromAgentName'].length, pos++); - buf.write(this.MessageBlock['FromAgentName'], pos); + this.MessageBlock['FromAgentName'].copy(buf, pos); pos += this.MessageBlock['FromAgentName'].length; buf.writeUInt16LE(this.MessageBlock['Message'].length, pos); pos += 2; - buf.write(this.MessageBlock['Message'], pos); + this.MessageBlock['Message'].copy(buf, pos); pos += this.MessageBlock['Message'].length; buf.writeUInt16LE(this.MessageBlock['BinaryBucket'].length, pos); pos += 2; - buf.write(this.MessageBlock['BinaryBucket'], pos); + this.MessageBlock['BinaryBucket'].copy(buf, pos); pos += this.MessageBlock['BinaryBucket'].length; return pos - startPos; } @@ -68,16 +68,16 @@ export class GroupNoticeAddMessage implements MessageBase ToGroupID: UUID, ID: UUID, Dialog: number, - FromAgentName: string, - Message: string, - BinaryBucket: string + FromAgentName: Buffer, + Message: Buffer, + BinaryBucket: Buffer } = { ToGroupID: UUID.zero(), ID: UUID.zero(), Dialog: 0, - FromAgentName: '', - Message: '', - BinaryBucket: '' + FromAgentName: Buffer.allocUnsafe(0), + Message: Buffer.allocUnsafe(0), + BinaryBucket: Buffer.allocUnsafe(0) }; newObjMessageBlock['ToGroupID'] = new UUID(buf, pos); pos += 16; @@ -85,15 +85,15 @@ export class GroupNoticeAddMessage implements MessageBase pos += 16; newObjMessageBlock['Dialog'] = buf.readUInt8(pos++); varLength = buf.readUInt8(pos++); - newObjMessageBlock['FromAgentName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMessageBlock['FromAgentName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjMessageBlock['Message'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMessageBlock['Message'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjMessageBlock['BinaryBucket'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMessageBlock['BinaryBucket'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.MessageBlock = newObjMessageBlock; return pos - startPos; diff --git a/lib/classes/messages/GroupNoticesListReply.ts b/lib/classes/messages/GroupNoticesListReply.ts index ee74ee3..db536fc 100644 --- a/lib/classes/messages/GroupNoticesListReply.ts +++ b/lib/classes/messages/GroupNoticesListReply.ts @@ -18,8 +18,8 @@ export class GroupNoticesListReplyMessage implements MessageBase Data: { NoticeID: UUID; Timestamp: number; - FromName: string; - Subject: string; + FromName: Buffer; + Subject: Buffer; HasAttachment: boolean; AssetType: number; }[]; @@ -56,11 +56,11 @@ export class GroupNoticesListReplyMessage implements MessageBase pos += 4; buf.writeUInt16LE(this.Data[i]['FromName'].length, pos); pos += 2; - buf.write(this.Data[i]['FromName'], pos); + this.Data[i]['FromName'].copy(buf, pos); pos += this.Data[i]['FromName'].length; buf.writeUInt16LE(this.Data[i]['Subject'].length, pos); pos += 2; - buf.write(this.Data[i]['Subject'], pos); + this.Data[i]['Subject'].copy(buf, pos); pos += this.Data[i]['Subject'].length; buf.writeUInt8((this.Data[i]['HasAttachment']) ? 1 : 0, pos++); buf.writeUInt8(this.Data[i]['AssetType'], pos++); @@ -91,15 +91,15 @@ export class GroupNoticesListReplyMessage implements MessageBase const newObjData: { NoticeID: UUID, Timestamp: number, - FromName: string, - Subject: string, + FromName: Buffer, + Subject: Buffer, HasAttachment: boolean, AssetType: number } = { NoticeID: UUID.zero(), Timestamp: 0, - FromName: '', - Subject: '', + FromName: Buffer.allocUnsafe(0), + Subject: Buffer.allocUnsafe(0), HasAttachment: false, AssetType: 0 }; @@ -109,11 +109,11 @@ export class GroupNoticesListReplyMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjData['FromName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['FromName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjData['Subject'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Subject'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjData['HasAttachment'] = (buf.readUInt8(pos++) === 1); newObjData['AssetType'] = buf.readUInt8(pos++); diff --git a/lib/classes/messages/GroupProfileReply.ts b/lib/classes/messages/GroupProfileReply.ts index c462c28..61d5ade 100644 --- a/lib/classes/messages/GroupProfileReply.ts +++ b/lib/classes/messages/GroupProfileReply.ts @@ -17,10 +17,10 @@ export class GroupProfileReplyMessage implements MessageBase }; GroupData: { GroupID: UUID; - Name: string; - Charter: string; + Name: Buffer; + Charter: Buffer; ShowInList: boolean; - MemberTitle: string; + MemberTitle: Buffer; PowersMask: Long; InsigniaID: UUID; FounderID: UUID; @@ -47,15 +47,15 @@ export class GroupProfileReplyMessage implements MessageBase this.GroupData['GroupID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.GroupData['Name'].length, pos++); - buf.write(this.GroupData['Name'], pos); + this.GroupData['Name'].copy(buf, pos); pos += this.GroupData['Name'].length; buf.writeUInt16LE(this.GroupData['Charter'].length, pos); pos += 2; - buf.write(this.GroupData['Charter'], pos); + this.GroupData['Charter'].copy(buf, pos); pos += this.GroupData['Charter'].length; buf.writeUInt8((this.GroupData['ShowInList']) ? 1 : 0, pos++); buf.writeUInt8(this.GroupData['MemberTitle'].length, pos++); - buf.write(this.GroupData['MemberTitle'], pos); + this.GroupData['MemberTitle'].copy(buf, pos); pos += this.GroupData['MemberTitle'].length; buf.writeInt32LE(this.GroupData['PowersMask'].low, pos); pos += 4; @@ -95,10 +95,10 @@ export class GroupProfileReplyMessage implements MessageBase this.AgentData = newObjAgentData; const newObjGroupData: { GroupID: UUID, - Name: string, - Charter: string, + Name: Buffer, + Charter: Buffer, ShowInList: boolean, - MemberTitle: string, + MemberTitle: Buffer, PowersMask: Long, InsigniaID: UUID, FounderID: UUID, @@ -112,10 +112,10 @@ export class GroupProfileReplyMessage implements MessageBase OwnerRole: UUID } = { GroupID: UUID.zero(), - Name: '', - Charter: '', + Name: Buffer.allocUnsafe(0), + Charter: Buffer.allocUnsafe(0), ShowInList: false, - MemberTitle: '', + MemberTitle: Buffer.allocUnsafe(0), PowersMask: Long.ZERO, InsigniaID: UUID.zero(), FounderID: UUID.zero(), @@ -131,15 +131,15 @@ export class GroupProfileReplyMessage implements MessageBase newObjGroupData['GroupID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjGroupData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjGroupData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjGroupData['Charter'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjGroupData['Charter'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjGroupData['ShowInList'] = (buf.readUInt8(pos++) === 1); varLength = buf.readUInt8(pos++); - newObjGroupData['MemberTitle'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjGroupData['MemberTitle'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjGroupData['PowersMask'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4)); pos += 8; diff --git a/lib/classes/messages/GroupProposalBallot.ts b/lib/classes/messages/GroupProposalBallot.ts index b40bf71..02aa183 100644 --- a/lib/classes/messages/GroupProposalBallot.ts +++ b/lib/classes/messages/GroupProposalBallot.ts @@ -18,7 +18,7 @@ export class GroupProposalBallotMessage implements MessageBase ProposalData: { ProposalID: UUID; GroupID: UUID; - VoteCast: string; + VoteCast: Buffer; }; getSize(): number @@ -38,7 +38,7 @@ export class GroupProposalBallotMessage implements MessageBase this.ProposalData['GroupID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.ProposalData['VoteCast'].length, pos++); - buf.write(this.ProposalData['VoteCast'], pos); + this.ProposalData['VoteCast'].copy(buf, pos); pos += this.ProposalData['VoteCast'].length; return pos - startPos; } @@ -62,18 +62,18 @@ export class GroupProposalBallotMessage implements MessageBase const newObjProposalData: { ProposalID: UUID, GroupID: UUID, - VoteCast: string + VoteCast: Buffer } = { ProposalID: UUID.zero(), GroupID: UUID.zero(), - VoteCast: '' + VoteCast: Buffer.allocUnsafe(0) }; newObjProposalData['ProposalID'] = new UUID(buf, pos); pos += 16; newObjProposalData['GroupID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjProposalData['VoteCast'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjProposalData['VoteCast'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ProposalData = newObjProposalData; return pos - startPos; diff --git a/lib/classes/messages/GroupRoleDataReply.ts b/lib/classes/messages/GroupRoleDataReply.ts index ffc1ff8..3b8c57e 100644 --- a/lib/classes/messages/GroupRoleDataReply.ts +++ b/lib/classes/messages/GroupRoleDataReply.ts @@ -22,9 +22,9 @@ export class GroupRoleDataReplyMessage implements MessageBase }; RoleData: { RoleID: UUID; - Name: string; - Title: string; - Description: string; + Name: Buffer; + Title: Buffer; + Description: Buffer; Powers: Long; Members: number; }[]; @@ -62,13 +62,13 @@ export class GroupRoleDataReplyMessage implements MessageBase this.RoleData[i]['RoleID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.RoleData[i]['Name'].length, pos++); - buf.write(this.RoleData[i]['Name'], pos); + this.RoleData[i]['Name'].copy(buf, pos); pos += this.RoleData[i]['Name'].length; buf.writeUInt8(this.RoleData[i]['Title'].length, pos++); - buf.write(this.RoleData[i]['Title'], pos); + this.RoleData[i]['Title'].copy(buf, pos); pos += this.RoleData[i]['Title'].length; buf.writeUInt8(this.RoleData[i]['Description'].length, pos++); - buf.write(this.RoleData[i]['Description'], pos); + this.RoleData[i]['Description'].copy(buf, pos); pos += this.RoleData[i]['Description'].length; buf.writeInt32LE(this.RoleData[i]['Powers'].low, pos); pos += 4; @@ -114,29 +114,29 @@ export class GroupRoleDataReplyMessage implements MessageBase { const newObjRoleData: { RoleID: UUID, - Name: string, - Title: string, - Description: string, + Name: Buffer, + Title: Buffer, + Description: Buffer, Powers: Long, Members: number } = { RoleID: UUID.zero(), - Name: '', - Title: '', - Description: '', + Name: Buffer.allocUnsafe(0), + Title: Buffer.allocUnsafe(0), + Description: Buffer.allocUnsafe(0), Powers: Long.ZERO, Members: 0 }; newObjRoleData['RoleID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjRoleData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjRoleData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjRoleData['Title'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjRoleData['Title'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjRoleData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjRoleData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjRoleData['Powers'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4)); pos += 8; diff --git a/lib/classes/messages/GroupRoleUpdate.ts b/lib/classes/messages/GroupRoleUpdate.ts index 51e2443..64e821f 100644 --- a/lib/classes/messages/GroupRoleUpdate.ts +++ b/lib/classes/messages/GroupRoleUpdate.ts @@ -19,9 +19,9 @@ export class GroupRoleUpdateMessage implements MessageBase }; RoleData: { RoleID: UUID; - Name: string; - Description: string; - Title: string; + Name: Buffer; + Description: Buffer; + Title: Buffer; Powers: Long; UpdateType: number; }[]; @@ -57,13 +57,13 @@ export class GroupRoleUpdateMessage implements MessageBase this.RoleData[i]['RoleID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.RoleData[i]['Name'].length, pos++); - buf.write(this.RoleData[i]['Name'], pos); + this.RoleData[i]['Name'].copy(buf, pos); pos += this.RoleData[i]['Name'].length; buf.writeUInt8(this.RoleData[i]['Description'].length, pos++); - buf.write(this.RoleData[i]['Description'], pos); + this.RoleData[i]['Description'].copy(buf, pos); pos += this.RoleData[i]['Description'].length; buf.writeUInt8(this.RoleData[i]['Title'].length, pos++); - buf.write(this.RoleData[i]['Title'], pos); + this.RoleData[i]['Title'].copy(buf, pos); pos += this.RoleData[i]['Title'].length; buf.writeInt32LE(this.RoleData[i]['Powers'].low, pos); pos += 4; @@ -100,29 +100,29 @@ export class GroupRoleUpdateMessage implements MessageBase { const newObjRoleData: { RoleID: UUID, - Name: string, - Description: string, - Title: string, + Name: Buffer, + Description: Buffer, + Title: Buffer, Powers: Long, UpdateType: number } = { RoleID: UUID.zero(), - Name: '', - Description: '', - Title: '', + Name: Buffer.allocUnsafe(0), + Description: Buffer.allocUnsafe(0), + Title: Buffer.allocUnsafe(0), Powers: Long.ZERO, UpdateType: 0 }; newObjRoleData['RoleID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjRoleData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjRoleData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjRoleData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjRoleData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjRoleData['Title'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjRoleData['Title'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjRoleData['Powers'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4)); pos += 8; diff --git a/lib/classes/messages/GroupTitlesReply.ts b/lib/classes/messages/GroupTitlesReply.ts index c313d5d..234a786 100644 --- a/lib/classes/messages/GroupTitlesReply.ts +++ b/lib/classes/messages/GroupTitlesReply.ts @@ -17,7 +17,7 @@ export class GroupTitlesReplyMessage implements MessageBase RequestID: UUID; }; GroupData: { - Title: string; + Title: Buffer; RoleID: UUID; Selected: boolean; }[]; @@ -51,7 +51,7 @@ export class GroupTitlesReplyMessage implements MessageBase for (let i = 0; i < count; i++) { buf.writeUInt8(this.GroupData[i]['Title'].length, pos++); - buf.write(this.GroupData[i]['Title'], pos); + this.GroupData[i]['Title'].copy(buf, pos); pos += this.GroupData[i]['Title'].length; this.GroupData[i]['RoleID'].writeToBuffer(buf, pos); pos += 16; @@ -85,16 +85,16 @@ export class GroupTitlesReplyMessage implements MessageBase for (let i = 0; i < count; i++) { const newObjGroupData: { - Title: string, + Title: Buffer, RoleID: UUID, Selected: boolean } = { - Title: '', + Title: Buffer.allocUnsafe(0), RoleID: UUID.zero(), Selected: false }; varLength = buf.readUInt8(pos++); - newObjGroupData['Title'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjGroupData['Title'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjGroupData['RoleID'] = new UUID(buf, pos); pos += 16; diff --git a/lib/classes/messages/GroupVoteHistoryItemReply.ts b/lib/classes/messages/GroupVoteHistoryItemReply.ts index dc357ad..f018224 100644 --- a/lib/classes/messages/GroupVoteHistoryItemReply.ts +++ b/lib/classes/messages/GroupVoteHistoryItemReply.ts @@ -21,19 +21,19 @@ export class GroupVoteHistoryItemReplyMessage implements MessageBase }; HistoryItemData: { VoteID: UUID; - TerseDateID: string; - StartDateTime: string; - EndDateTime: string; + TerseDateID: Buffer; + StartDateTime: Buffer; + EndDateTime: Buffer; VoteInitiator: UUID; - VoteType: string; - VoteResult: string; + VoteType: Buffer; + VoteResult: Buffer; Majority: number; Quorum: number; - ProposalText: string; + ProposalText: Buffer; }; VoteItem: { CandidateID: UUID; - VoteCast: string; + VoteCast: Buffer; NumVotes: number; }[]; @@ -66,21 +66,21 @@ export class GroupVoteHistoryItemReplyMessage implements MessageBase this.HistoryItemData['VoteID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.HistoryItemData['TerseDateID'].length, pos++); - buf.write(this.HistoryItemData['TerseDateID'], pos); + this.HistoryItemData['TerseDateID'].copy(buf, pos); pos += this.HistoryItemData['TerseDateID'].length; buf.writeUInt8(this.HistoryItemData['StartDateTime'].length, pos++); - buf.write(this.HistoryItemData['StartDateTime'], pos); + this.HistoryItemData['StartDateTime'].copy(buf, pos); pos += this.HistoryItemData['StartDateTime'].length; buf.writeUInt8(this.HistoryItemData['EndDateTime'].length, pos++); - buf.write(this.HistoryItemData['EndDateTime'], pos); + this.HistoryItemData['EndDateTime'].copy(buf, pos); pos += this.HistoryItemData['EndDateTime'].length; this.HistoryItemData['VoteInitiator'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.HistoryItemData['VoteType'].length, pos++); - buf.write(this.HistoryItemData['VoteType'], pos); + this.HistoryItemData['VoteType'].copy(buf, pos); pos += this.HistoryItemData['VoteType'].length; buf.writeUInt8(this.HistoryItemData['VoteResult'].length, pos++); - buf.write(this.HistoryItemData['VoteResult'], pos); + this.HistoryItemData['VoteResult'].copy(buf, pos); pos += this.HistoryItemData['VoteResult'].length; buf.writeFloatLE(this.HistoryItemData['Majority'], pos); pos += 4; @@ -88,7 +88,7 @@ export class GroupVoteHistoryItemReplyMessage implements MessageBase pos += 4; buf.writeUInt16LE(this.HistoryItemData['ProposalText'].length, pos); pos += 2; - buf.write(this.HistoryItemData['ProposalText'], pos); + this.HistoryItemData['ProposalText'].copy(buf, pos); pos += this.HistoryItemData['ProposalText'].length; const count = this.VoteItem.length; buf.writeUInt8(this.VoteItem.length, pos++); @@ -97,7 +97,7 @@ export class GroupVoteHistoryItemReplyMessage implements MessageBase this.VoteItem[i]['CandidateID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.VoteItem[i]['VoteCast'].length, pos++); - buf.write(this.VoteItem[i]['VoteCast'], pos); + this.VoteItem[i]['VoteCast'].copy(buf, pos); pos += this.VoteItem[i]['VoteCast'].length; buf.writeInt32LE(this.VoteItem[i]['NumVotes'], pos); pos += 4; @@ -135,45 +135,45 @@ export class GroupVoteHistoryItemReplyMessage implements MessageBase this.TransactionData = newObjTransactionData; const newObjHistoryItemData: { VoteID: UUID, - TerseDateID: string, - StartDateTime: string, - EndDateTime: string, + TerseDateID: Buffer, + StartDateTime: Buffer, + EndDateTime: Buffer, VoteInitiator: UUID, - VoteType: string, - VoteResult: string, + VoteType: Buffer, + VoteResult: Buffer, Majority: number, Quorum: number, - ProposalText: string + ProposalText: Buffer } = { VoteID: UUID.zero(), - TerseDateID: '', - StartDateTime: '', - EndDateTime: '', + TerseDateID: Buffer.allocUnsafe(0), + StartDateTime: Buffer.allocUnsafe(0), + EndDateTime: Buffer.allocUnsafe(0), VoteInitiator: UUID.zero(), - VoteType: '', - VoteResult: '', + VoteType: Buffer.allocUnsafe(0), + VoteResult: Buffer.allocUnsafe(0), Majority: 0, Quorum: 0, - ProposalText: '' + ProposalText: Buffer.allocUnsafe(0) }; newObjHistoryItemData['VoteID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjHistoryItemData['TerseDateID'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjHistoryItemData['TerseDateID'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjHistoryItemData['StartDateTime'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjHistoryItemData['StartDateTime'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjHistoryItemData['EndDateTime'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjHistoryItemData['EndDateTime'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjHistoryItemData['VoteInitiator'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjHistoryItemData['VoteType'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjHistoryItemData['VoteType'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjHistoryItemData['VoteResult'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjHistoryItemData['VoteResult'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjHistoryItemData['Majority'] = buf.readFloatLE(pos); pos += 4; @@ -181,7 +181,7 @@ export class GroupVoteHistoryItemReplyMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjHistoryItemData['ProposalText'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjHistoryItemData['ProposalText'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.HistoryItemData = newObjHistoryItemData; const count = buf.readUInt8(pos++); @@ -190,17 +190,17 @@ export class GroupVoteHistoryItemReplyMessage implements MessageBase { const newObjVoteItem: { CandidateID: UUID, - VoteCast: string, + VoteCast: Buffer, NumVotes: number } = { CandidateID: UUID.zero(), - VoteCast: '', + VoteCast: Buffer.allocUnsafe(0), NumVotes: 0 }; newObjVoteItem['CandidateID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjVoteItem['VoteCast'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjVoteItem['VoteCast'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjVoteItem['NumVotes'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/ImageData.ts b/lib/classes/messages/ImageData.ts index e1dda19..5a04020 100644 --- a/lib/classes/messages/ImageData.ts +++ b/lib/classes/messages/ImageData.ts @@ -18,7 +18,7 @@ export class ImageDataMessage implements MessageBase Packets: number; }; ImageData: { - Data: string; + Data: Buffer; }; getSize(): number @@ -38,7 +38,7 @@ export class ImageDataMessage implements MessageBase pos += 2; buf.writeUInt16LE(this.ImageData['Data'].length, pos); pos += 2; - buf.write(this.ImageData['Data'], pos); + this.ImageData['Data'].copy(buf, pos); pos += this.ImageData['Data'].length; return pos - startPos; } @@ -67,13 +67,13 @@ export class ImageDataMessage implements MessageBase pos += 2; this.ImageID = newObjImageID; const newObjImageData: { - Data: string + Data: Buffer } = { - Data: '' + Data: Buffer.allocUnsafe(0) }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjImageData['Data'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjImageData['Data'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ImageData = newObjImageData; return pos - startPos; diff --git a/lib/classes/messages/ImagePacket.ts b/lib/classes/messages/ImagePacket.ts index 6a9a3f7..a1c186c 100644 --- a/lib/classes/messages/ImagePacket.ts +++ b/lib/classes/messages/ImagePacket.ts @@ -16,7 +16,7 @@ export class ImagePacketMessage implements MessageBase Packet: number; }; ImageData: { - Data: string; + Data: Buffer; }; getSize(): number @@ -33,7 +33,7 @@ export class ImagePacketMessage implements MessageBase pos += 2; buf.writeUInt16LE(this.ImageData['Data'].length, pos); pos += 2; - buf.write(this.ImageData['Data'], pos); + this.ImageData['Data'].copy(buf, pos); pos += this.ImageData['Data'].length; return pos - startPos; } @@ -55,13 +55,13 @@ export class ImagePacketMessage implements MessageBase pos += 2; this.ImageID = newObjImageID; const newObjImageData: { - Data: string + Data: Buffer } = { - Data: '' + Data: Buffer.allocUnsafe(0) }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjImageData['Data'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjImageData['Data'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ImageData = newObjImageData; return pos - startPos; diff --git a/lib/classes/messages/ImprovedInstantMessage.ts b/lib/classes/messages/ImprovedInstantMessage.ts index 02c6ac5..483f3fa 100644 --- a/lib/classes/messages/ImprovedInstantMessage.ts +++ b/lib/classes/messages/ImprovedInstantMessage.ts @@ -26,9 +26,9 @@ export class ImprovedInstantMessageMessage implements MessageBase Dialog: number; ID: UUID; Timestamp: number; - FromAgentName: string; - Message: string; - BinaryBucket: string; + FromAgentName: Buffer; + Message: Buffer; + BinaryBucket: Buffer; }; EstateBlock: { EstateID: number; @@ -62,15 +62,15 @@ export class ImprovedInstantMessageMessage implements MessageBase buf.writeUInt32LE(this.MessageBlock['Timestamp'], pos); pos += 4; buf.writeUInt8(this.MessageBlock['FromAgentName'].length, pos++); - buf.write(this.MessageBlock['FromAgentName'], pos); + this.MessageBlock['FromAgentName'].copy(buf, pos); pos += this.MessageBlock['FromAgentName'].length; buf.writeUInt16LE(this.MessageBlock['Message'].length, pos); pos += 2; - buf.write(this.MessageBlock['Message'], pos); + this.MessageBlock['Message'].copy(buf, pos); pos += this.MessageBlock['Message'].length; buf.writeUInt16LE(this.MessageBlock['BinaryBucket'].length, pos); pos += 2; - buf.write(this.MessageBlock['BinaryBucket'], pos); + this.MessageBlock['BinaryBucket'].copy(buf, pos); pos += this.MessageBlock['BinaryBucket'].length; buf.writeUInt32LE(this.EstateBlock['EstateID'], pos); pos += 4; @@ -103,9 +103,9 @@ export class ImprovedInstantMessageMessage implements MessageBase Dialog: number, ID: UUID, Timestamp: number, - FromAgentName: string, - Message: string, - BinaryBucket: string + FromAgentName: Buffer, + Message: Buffer, + BinaryBucket: Buffer } = { FromGroup: false, ToAgentID: UUID.zero(), @@ -116,9 +116,9 @@ export class ImprovedInstantMessageMessage implements MessageBase Dialog: 0, ID: UUID.zero(), Timestamp: 0, - FromAgentName: '', - Message: '', - BinaryBucket: '' + FromAgentName: Buffer.allocUnsafe(0), + Message: Buffer.allocUnsafe(0), + BinaryBucket: Buffer.allocUnsafe(0) }; newObjMessageBlock['FromGroup'] = (buf.readUInt8(pos++) === 1); newObjMessageBlock['ToAgentID'] = new UUID(buf, pos); @@ -136,15 +136,15 @@ export class ImprovedInstantMessageMessage implements MessageBase newObjMessageBlock['Timestamp'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjMessageBlock['FromAgentName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMessageBlock['FromAgentName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjMessageBlock['Message'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMessageBlock['Message'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjMessageBlock['BinaryBucket'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMessageBlock['BinaryBucket'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.MessageBlock = newObjMessageBlock; const newObjEstateBlock: { diff --git a/lib/classes/messages/ImprovedTerseObjectUpdate.ts b/lib/classes/messages/ImprovedTerseObjectUpdate.ts index 3076559..7fcbb3e 100644 --- a/lib/classes/messages/ImprovedTerseObjectUpdate.ts +++ b/lib/classes/messages/ImprovedTerseObjectUpdate.ts @@ -16,8 +16,8 @@ export class ImprovedTerseObjectUpdateMessage implements MessageBase TimeDilation: number; }; ObjectData: { - Data: string; - TextureEntry: string; + Data: Buffer; + TextureEntry: Buffer; }[]; getSize(): number @@ -49,11 +49,11 @@ export class ImprovedTerseObjectUpdateMessage implements MessageBase for (let i = 0; i < count; i++) { buf.writeUInt8(this.ObjectData[i]['Data'].length, pos++); - buf.write(this.ObjectData[i]['Data'], pos); + this.ObjectData[i]['Data'].copy(buf, pos); pos += this.ObjectData[i]['Data'].length; buf.writeUInt16LE(this.ObjectData[i]['TextureEntry'].length, pos); pos += 2; - buf.write(this.ObjectData[i]['TextureEntry'], pos); + this.ObjectData[i]['TextureEntry'].copy(buf, pos); pos += this.ObjectData[i]['TextureEntry'].length; } return pos - startPos; @@ -80,18 +80,18 @@ export class ImprovedTerseObjectUpdateMessage implements MessageBase for (let i = 0; i < count; i++) { const newObjObjectData: { - Data: string, - TextureEntry: string + Data: Buffer, + TextureEntry: Buffer } = { - Data: '', - TextureEntry: '' + Data: Buffer.allocUnsafe(0), + TextureEntry: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjObjectData['Data'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['Data'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjObjectData['TextureEntry'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['TextureEntry'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ObjectData.push(newObjObjectData); } diff --git a/lib/classes/messages/InitiateDownload.ts b/lib/classes/messages/InitiateDownload.ts index 85a4696..5b97b90 100644 --- a/lib/classes/messages/InitiateDownload.ts +++ b/lib/classes/messages/InitiateDownload.ts @@ -15,8 +15,8 @@ export class InitiateDownloadMessage implements MessageBase AgentID: UUID; }; FileData: { - SimFilename: string; - ViewerFilename: string; + SimFilename: Buffer; + ViewerFilename: Buffer; }; getSize(): number @@ -30,10 +30,10 @@ export class InitiateDownloadMessage implements MessageBase this.AgentData['AgentID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.FileData['SimFilename'].length, pos++); - buf.write(this.FileData['SimFilename'], pos); + this.FileData['SimFilename'].copy(buf, pos); pos += this.FileData['SimFilename'].length; buf.writeUInt8(this.FileData['ViewerFilename'].length, pos++); - buf.write(this.FileData['ViewerFilename'], pos); + this.FileData['ViewerFilename'].copy(buf, pos); pos += this.FileData['ViewerFilename'].length; return pos - startPos; } @@ -51,17 +51,17 @@ export class InitiateDownloadMessage implements MessageBase pos += 16; this.AgentData = newObjAgentData; const newObjFileData: { - SimFilename: string, - ViewerFilename: string + SimFilename: Buffer, + ViewerFilename: Buffer } = { - SimFilename: '', - ViewerFilename: '' + SimFilename: Buffer.allocUnsafe(0), + ViewerFilename: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjFileData['SimFilename'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjFileData['SimFilename'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjFileData['ViewerFilename'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjFileData['ViewerFilename'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.FileData = newObjFileData; return pos - startPos; diff --git a/lib/classes/messages/InternalScriptMail.ts b/lib/classes/messages/InternalScriptMail.ts index 822f587..c416622 100644 --- a/lib/classes/messages/InternalScriptMail.ts +++ b/lib/classes/messages/InternalScriptMail.ts @@ -12,10 +12,10 @@ export class InternalScriptMailMessage implements MessageBase id = Message.InternalScriptMail; DataBlock: { - From: string; + From: Buffer; To: UUID; - Subject: string; - Body: string; + Subject: Buffer; + Body: Buffer; }; getSize(): number @@ -27,16 +27,16 @@ export class InternalScriptMailMessage implements MessageBase { const startPos = pos; buf.writeUInt8(this.DataBlock['From'].length, pos++); - buf.write(this.DataBlock['From'], pos); + this.DataBlock['From'].copy(buf, pos); pos += this.DataBlock['From'].length; this.DataBlock['To'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.DataBlock['Subject'].length, pos++); - buf.write(this.DataBlock['Subject'], pos); + this.DataBlock['Subject'].copy(buf, pos); pos += this.DataBlock['Subject'].length; buf.writeUInt16LE(this.DataBlock['Body'].length, pos); pos += 2; - buf.write(this.DataBlock['Body'], pos); + this.DataBlock['Body'].copy(buf, pos); pos += this.DataBlock['Body'].length; return pos - startPos; } @@ -46,27 +46,27 @@ export class InternalScriptMailMessage implements MessageBase const startPos = pos; let varLength = 0; const newObjDataBlock: { - From: string, + From: Buffer, To: UUID, - Subject: string, - Body: string + Subject: Buffer, + Body: Buffer } = { - From: '', + From: Buffer.allocUnsafe(0), To: UUID.zero(), - Subject: '', - Body: '' + Subject: Buffer.allocUnsafe(0), + Body: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjDataBlock['From'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataBlock['From'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjDataBlock['To'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjDataBlock['Subject'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataBlock['Subject'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjDataBlock['Body'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataBlock['Body'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.DataBlock = newObjDataBlock; return pos - startPos; diff --git a/lib/classes/messages/InventoryDescendents.ts b/lib/classes/messages/InventoryDescendents.ts index 3ee4ab3..8ce5ab5 100644 --- a/lib/classes/messages/InventoryDescendents.ts +++ b/lib/classes/messages/InventoryDescendents.ts @@ -22,7 +22,7 @@ export class InventoryDescendentsMessage implements MessageBase FolderID: UUID; ParentID: UUID; Type: number; - Name: string; + Name: Buffer; }[]; ItemData: { ItemID: UUID; @@ -42,8 +42,8 @@ export class InventoryDescendentsMessage implements MessageBase Flags: number; SaleType: number; SalePrice: number; - Name: string; - Description: string; + Name: Buffer; + Description: Buffer; CreationDate: number; CRC: number; }[]; @@ -86,7 +86,7 @@ export class InventoryDescendentsMessage implements MessageBase pos += 16; buf.writeInt8(this.FolderData[i]['Type'], pos++); buf.writeUInt8(this.FolderData[i]['Name'].length, pos++); - buf.write(this.FolderData[i]['Name'], pos); + this.FolderData[i]['Name'].copy(buf, pos); pos += this.FolderData[i]['Name'].length; } count = this.ItemData.length; @@ -124,10 +124,10 @@ export class InventoryDescendentsMessage implements MessageBase buf.writeInt32LE(this.ItemData[i]['SalePrice'], pos); pos += 4; buf.writeUInt8(this.ItemData[i]['Name'].length, pos++); - buf.write(this.ItemData[i]['Name'], pos); + this.ItemData[i]['Name'].copy(buf, pos); pos += this.ItemData[i]['Name'].length; buf.writeUInt8(this.ItemData[i]['Description'].length, pos++); - buf.write(this.ItemData[i]['Description'], pos); + this.ItemData[i]['Description'].copy(buf, pos); pos += this.ItemData[i]['Description'].length; buf.writeInt32LE(this.ItemData[i]['CreationDate'], pos); pos += 4; @@ -173,12 +173,12 @@ export class InventoryDescendentsMessage implements MessageBase FolderID: UUID, ParentID: UUID, Type: number, - Name: string + Name: Buffer } = { FolderID: UUID.zero(), ParentID: UUID.zero(), Type: 0, - Name: '' + Name: Buffer.allocUnsafe(0) }; newObjFolderData['FolderID'] = new UUID(buf, pos); pos += 16; @@ -186,7 +186,7 @@ export class InventoryDescendentsMessage implements MessageBase pos += 16; newObjFolderData['Type'] = buf.readInt8(pos++); varLength = buf.readUInt8(pos++); - newObjFolderData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjFolderData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.FolderData.push(newObjFolderData); } @@ -212,8 +212,8 @@ export class InventoryDescendentsMessage implements MessageBase Flags: number, SaleType: number, SalePrice: number, - Name: string, - Description: string, + Name: Buffer, + Description: Buffer, CreationDate: number, CRC: number } = { @@ -234,8 +234,8 @@ export class InventoryDescendentsMessage implements MessageBase Flags: 0, SaleType: 0, SalePrice: 0, - Name: '', - Description: '', + Name: Buffer.allocUnsafe(0), + Description: Buffer.allocUnsafe(0), CreationDate: 0, CRC: 0 }; @@ -270,10 +270,10 @@ export class InventoryDescendentsMessage implements MessageBase newObjItemData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjItemData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjItemData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjItemData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjItemData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjItemData['CreationDate'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/KickUser.ts b/lib/classes/messages/KickUser.ts index 24c127b..b4d6c24 100644 --- a/lib/classes/messages/KickUser.ts +++ b/lib/classes/messages/KickUser.ts @@ -19,7 +19,7 @@ export class KickUserMessage implements MessageBase UserInfo: { AgentID: UUID; SessionID: UUID; - Reason: string; + Reason: Buffer; }; getSize(): number @@ -40,7 +40,7 @@ export class KickUserMessage implements MessageBase pos += 16; buf.writeUInt16LE(this.UserInfo['Reason'].length, pos); pos += 2; - buf.write(this.UserInfo['Reason'], pos); + this.UserInfo['Reason'].copy(buf, pos); pos += this.UserInfo['Reason'].length; return pos - startPos; } @@ -64,11 +64,11 @@ export class KickUserMessage implements MessageBase const newObjUserInfo: { AgentID: UUID, SessionID: UUID, - Reason: string + Reason: Buffer } = { AgentID: UUID.zero(), SessionID: UUID.zero(), - Reason: '' + Reason: Buffer.allocUnsafe(0) }; newObjUserInfo['AgentID'] = new UUID(buf, pos); pos += 16; @@ -76,7 +76,7 @@ export class KickUserMessage implements MessageBase pos += 16; varLength = buf.readUInt16LE(pos); pos += 2; - newObjUserInfo['Reason'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjUserInfo['Reason'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.UserInfo = newObjUserInfo; return pos - startPos; diff --git a/lib/classes/messages/LandStatReply.ts b/lib/classes/messages/LandStatReply.ts index ce081d4..39496de 100644 --- a/lib/classes/messages/LandStatReply.ts +++ b/lib/classes/messages/LandStatReply.ts @@ -23,8 +23,8 @@ export class LandStatReplyMessage implements MessageBase LocationY: number; LocationZ: number; Score: number; - TaskName: string; - OwnerName: string; + TaskName: Buffer; + OwnerName: Buffer; }[]; getSize(): number @@ -68,10 +68,10 @@ export class LandStatReplyMessage implements MessageBase buf.writeFloatLE(this.ReportData[i]['Score'], pos); pos += 4; buf.writeUInt8(this.ReportData[i]['TaskName'].length, pos++); - buf.write(this.ReportData[i]['TaskName'], pos); + this.ReportData[i]['TaskName'].copy(buf, pos); pos += this.ReportData[i]['TaskName'].length; buf.writeUInt8(this.ReportData[i]['OwnerName'].length, pos++); - buf.write(this.ReportData[i]['OwnerName'], pos); + this.ReportData[i]['OwnerName'].copy(buf, pos); pos += this.ReportData[i]['OwnerName'].length; } return pos - startPos; @@ -108,8 +108,8 @@ export class LandStatReplyMessage implements MessageBase LocationY: number, LocationZ: number, Score: number, - TaskName: string, - OwnerName: string + TaskName: Buffer, + OwnerName: Buffer } = { TaskLocalID: 0, TaskID: UUID.zero(), @@ -117,8 +117,8 @@ export class LandStatReplyMessage implements MessageBase LocationY: 0, LocationZ: 0, Score: 0, - TaskName: '', - OwnerName: '' + TaskName: Buffer.allocUnsafe(0), + OwnerName: Buffer.allocUnsafe(0) }; newObjReportData['TaskLocalID'] = buf.readUInt32LE(pos); pos += 4; @@ -133,10 +133,10 @@ export class LandStatReplyMessage implements MessageBase newObjReportData['Score'] = buf.readFloatLE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjReportData['TaskName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjReportData['TaskName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjReportData['OwnerName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjReportData['OwnerName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ReportData.push(newObjReportData); } diff --git a/lib/classes/messages/LandStatRequest.ts b/lib/classes/messages/LandStatRequest.ts index bd9d258..cd355c5 100644 --- a/lib/classes/messages/LandStatRequest.ts +++ b/lib/classes/messages/LandStatRequest.ts @@ -18,7 +18,7 @@ export class LandStatRequestMessage implements MessageBase RequestData: { ReportType: number; RequestFlags: number; - Filter: string; + Filter: Buffer; ParcelLocalID: number; }; @@ -39,7 +39,7 @@ export class LandStatRequestMessage implements MessageBase buf.writeUInt32LE(this.RequestData['RequestFlags'], pos); pos += 4; buf.writeUInt8(this.RequestData['Filter'].length, pos++); - buf.write(this.RequestData['Filter'], pos); + this.RequestData['Filter'].copy(buf, pos); pos += this.RequestData['Filter'].length; buf.writeInt32LE(this.RequestData['ParcelLocalID'], pos); pos += 4; @@ -65,12 +65,12 @@ export class LandStatRequestMessage implements MessageBase const newObjRequestData: { ReportType: number, RequestFlags: number, - Filter: string, + Filter: Buffer, ParcelLocalID: number } = { ReportType: 0, RequestFlags: 0, - Filter: '', + Filter: Buffer.allocUnsafe(0), ParcelLocalID: 0 }; newObjRequestData['ReportType'] = buf.readUInt32LE(pos); @@ -78,7 +78,7 @@ export class LandStatRequestMessage implements MessageBase newObjRequestData['RequestFlags'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjRequestData['Filter'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjRequestData['Filter'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjRequestData['ParcelLocalID'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/LayerData.ts b/lib/classes/messages/LayerData.ts index 16e7846..30841d2 100644 --- a/lib/classes/messages/LayerData.ts +++ b/lib/classes/messages/LayerData.ts @@ -14,7 +14,7 @@ export class LayerDataMessage implements MessageBase Type: number; }; LayerData: { - Data: string; + Data: Buffer; }; getSize(): number @@ -28,7 +28,7 @@ export class LayerDataMessage implements MessageBase buf.writeUInt8(this.LayerID['Type'], pos++); buf.writeUInt16LE(this.LayerData['Data'].length, pos); pos += 2; - buf.write(this.LayerData['Data'], pos); + this.LayerData['Data'].copy(buf, pos); pos += this.LayerData['Data'].length; return pos - startPos; } @@ -45,13 +45,13 @@ export class LayerDataMessage implements MessageBase newObjLayerID['Type'] = buf.readUInt8(pos++); this.LayerID = newObjLayerID; const newObjLayerData: { - Data: string + Data: Buffer } = { - Data: '' + Data: Buffer.allocUnsafe(0) }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjLayerData['Data'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjLayerData['Data'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.LayerData = newObjLayerData; return pos - startPos; diff --git a/lib/classes/messages/LinkInventoryItem.ts b/lib/classes/messages/LinkInventoryItem.ts index 03c592e..25b25d7 100644 --- a/lib/classes/messages/LinkInventoryItem.ts +++ b/lib/classes/messages/LinkInventoryItem.ts @@ -22,8 +22,8 @@ export class LinkInventoryItemMessage implements MessageBase OldItemID: UUID; Type: number; InvType: number; - Name: string; - Description: string; + Name: Buffer; + Description: Buffer; }; getSize(): number @@ -49,10 +49,10 @@ export class LinkInventoryItemMessage implements MessageBase buf.writeInt8(this.InventoryBlock['Type'], pos++); buf.writeInt8(this.InventoryBlock['InvType'], pos++); 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; return pos - startPos; } @@ -80,8 +80,8 @@ export class LinkInventoryItemMessage implements MessageBase OldItemID: UUID, Type: number, InvType: number, - Name: string, - Description: string + Name: Buffer, + Description: Buffer } = { CallbackID: 0, FolderID: UUID.zero(), @@ -89,8 +89,8 @@ export class LinkInventoryItemMessage implements MessageBase OldItemID: UUID.zero(), Type: 0, InvType: 0, - Name: '', - Description: '' + Name: Buffer.allocUnsafe(0), + Description: Buffer.allocUnsafe(0) }; newObjInventoryBlock['CallbackID'] = buf.readUInt32LE(pos); pos += 4; @@ -103,10 +103,10 @@ export class LinkInventoryItemMessage implements MessageBase newObjInventoryBlock['Type'] = buf.readInt8(pos++); newObjInventoryBlock['InvType'] = buf.readInt8(pos++); 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; this.InventoryBlock = newObjInventoryBlock; return pos - startPos; diff --git a/lib/classes/messages/LiveHelpGroupReply.ts b/lib/classes/messages/LiveHelpGroupReply.ts index 6cd9b08..69a07f6 100644 --- a/lib/classes/messages/LiveHelpGroupReply.ts +++ b/lib/classes/messages/LiveHelpGroupReply.ts @@ -14,7 +14,7 @@ export class LiveHelpGroupReplyMessage implements MessageBase ReplyData: { RequestID: UUID; GroupID: UUID; - Selection: string; + Selection: Buffer; }; getSize(): number @@ -30,7 +30,7 @@ export class LiveHelpGroupReplyMessage implements MessageBase this.ReplyData['GroupID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.ReplyData['Selection'].length, pos++); - buf.write(this.ReplyData['Selection'], pos); + this.ReplyData['Selection'].copy(buf, pos); pos += this.ReplyData['Selection'].length; return pos - startPos; } @@ -42,18 +42,18 @@ export class LiveHelpGroupReplyMessage implements MessageBase const newObjReplyData: { RequestID: UUID, GroupID: UUID, - Selection: string + Selection: Buffer } = { RequestID: UUID.zero(), GroupID: UUID.zero(), - Selection: '' + Selection: Buffer.allocUnsafe(0) }; newObjReplyData['RequestID'] = new UUID(buf, pos); pos += 16; newObjReplyData['GroupID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjReplyData['Selection'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjReplyData['Selection'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ReplyData = newObjReplyData; return pos - startPos; diff --git a/lib/classes/messages/LoadURL.ts b/lib/classes/messages/LoadURL.ts index 2201e45..b664dda 100644 --- a/lib/classes/messages/LoadURL.ts +++ b/lib/classes/messages/LoadURL.ts @@ -12,12 +12,12 @@ export class LoadURLMessage implements MessageBase id = Message.LoadURL; Data: { - ObjectName: string; + ObjectName: Buffer; ObjectID: UUID; OwnerID: UUID; OwnerIsGroup: boolean; - Message: string; - URL: string; + Message: Buffer; + URL: Buffer; }; getSize(): number @@ -29,7 +29,7 @@ export class LoadURLMessage implements MessageBase { const startPos = pos; buf.writeUInt8(this.Data['ObjectName'].length, pos++); - buf.write(this.Data['ObjectName'], pos); + this.Data['ObjectName'].copy(buf, pos); pos += this.Data['ObjectName'].length; this.Data['ObjectID'].writeToBuffer(buf, pos); pos += 16; @@ -37,10 +37,10 @@ export class LoadURLMessage implements MessageBase pos += 16; buf.writeUInt8((this.Data['OwnerIsGroup']) ? 1 : 0, pos++); buf.writeUInt8(this.Data['Message'].length, pos++); - buf.write(this.Data['Message'], pos); + this.Data['Message'].copy(buf, pos); pos += this.Data['Message'].length; buf.writeUInt8(this.Data['URL'].length, pos++); - buf.write(this.Data['URL'], pos); + this.Data['URL'].copy(buf, pos); pos += this.Data['URL'].length; return pos - startPos; } @@ -50,22 +50,22 @@ export class LoadURLMessage implements MessageBase const startPos = pos; let varLength = 0; const newObjData: { - ObjectName: string, + ObjectName: Buffer, ObjectID: UUID, OwnerID: UUID, OwnerIsGroup: boolean, - Message: string, - URL: string + Message: Buffer, + URL: Buffer } = { - ObjectName: '', + ObjectName: Buffer.allocUnsafe(0), ObjectID: UUID.zero(), OwnerID: UUID.zero(), OwnerIsGroup: false, - Message: '', - URL: '' + Message: Buffer.allocUnsafe(0), + URL: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjData['ObjectName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['ObjectName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjData['ObjectID'] = new UUID(buf, pos); pos += 16; @@ -73,10 +73,10 @@ export class LoadURLMessage implements MessageBase pos += 16; newObjData['OwnerIsGroup'] = (buf.readUInt8(pos++) === 1); varLength = buf.readUInt8(pos++); - newObjData['Message'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Message'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjData['URL'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['URL'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.Data = newObjData; return pos - startPos; diff --git a/lib/classes/messages/LogDwellTime.ts b/lib/classes/messages/LogDwellTime.ts index 3d7b44c..0cfd92e 100644 --- a/lib/classes/messages/LogDwellTime.ts +++ b/lib/classes/messages/LogDwellTime.ts @@ -15,7 +15,7 @@ export class LogDwellTimeMessage implements MessageBase AgentID: UUID; SessionID: UUID; Duration: number; - SimName: string; + SimName: Buffer; RegionX: number; RegionY: number; AvgAgentsInView: number; @@ -37,7 +37,7 @@ export class LogDwellTimeMessage implements MessageBase buf.writeFloatLE(this.DwellInfo['Duration'], pos); pos += 4; buf.writeUInt8(this.DwellInfo['SimName'].length, pos++); - buf.write(this.DwellInfo['SimName'], pos); + this.DwellInfo['SimName'].copy(buf, pos); pos += this.DwellInfo['SimName'].length; buf.writeUInt32LE(this.DwellInfo['RegionX'], pos); pos += 4; @@ -56,7 +56,7 @@ export class LogDwellTimeMessage implements MessageBase AgentID: UUID, SessionID: UUID, Duration: number, - SimName: string, + SimName: Buffer, RegionX: number, RegionY: number, AvgAgentsInView: number, @@ -65,7 +65,7 @@ export class LogDwellTimeMessage implements MessageBase AgentID: UUID.zero(), SessionID: UUID.zero(), Duration: 0, - SimName: '', + SimName: Buffer.allocUnsafe(0), RegionX: 0, RegionY: 0, AvgAgentsInView: 0, @@ -78,7 +78,7 @@ export class LogDwellTimeMessage implements MessageBase newObjDwellInfo['Duration'] = buf.readFloatLE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjDwellInfo['SimName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDwellInfo['SimName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjDwellInfo['RegionX'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/LogTextMessage.ts b/lib/classes/messages/LogTextMessage.ts index 09fda8e..a7c1a9f 100644 --- a/lib/classes/messages/LogTextMessage.ts +++ b/lib/classes/messages/LogTextMessage.ts @@ -17,7 +17,7 @@ export class LogTextMessageMessage implements MessageBase GlobalX: number; GlobalY: number; Time: number; - Message: string; + Message: Buffer; }[]; getSize(): number @@ -54,7 +54,7 @@ export class LogTextMessageMessage implements MessageBase pos += 4; buf.writeUInt16LE(this.DataBlock[i]['Message'].length, pos); pos += 2; - buf.write(this.DataBlock[i]['Message'], pos); + this.DataBlock[i]['Message'].copy(buf, pos); pos += this.DataBlock[i]['Message'].length; } return pos - startPos; @@ -74,14 +74,14 @@ export class LogTextMessageMessage implements MessageBase GlobalX: number, GlobalY: number, Time: number, - Message: string + Message: Buffer } = { FromAgentId: UUID.zero(), ToAgentId: UUID.zero(), GlobalX: 0, GlobalY: 0, Time: 0, - Message: '' + Message: Buffer.allocUnsafe(0) }; newObjDataBlock['FromAgentId'] = new UUID(buf, pos); pos += 16; @@ -95,7 +95,7 @@ export class LogTextMessageMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjDataBlock['Message'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataBlock['Message'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.DataBlock.push(newObjDataBlock); } diff --git a/lib/classes/messages/MapBlockReply.ts b/lib/classes/messages/MapBlockReply.ts index d1cf9b4..ac42fd7 100644 --- a/lib/classes/messages/MapBlockReply.ts +++ b/lib/classes/messages/MapBlockReply.ts @@ -18,7 +18,7 @@ export class MapBlockReplyMessage implements MessageBase Data: { X: number; Y: number; - Name: string; + Name: Buffer; Access: number; RegionFlags: number; WaterHeight: number; @@ -57,7 +57,7 @@ export class MapBlockReplyMessage implements MessageBase buf.writeUInt16LE(this.Data[i]['Y'], pos); pos += 2; buf.writeUInt8(this.Data[i]['Name'].length, pos++); - buf.write(this.Data[i]['Name'], pos); + this.Data[i]['Name'].copy(buf, pos); pos += this.Data[i]['Name'].length; buf.writeUInt8(this.Data[i]['Access'], pos++); buf.writeUInt32LE(this.Data[i]['RegionFlags'], pos); @@ -93,7 +93,7 @@ export class MapBlockReplyMessage implements MessageBase const newObjData: { X: number, Y: number, - Name: string, + Name: Buffer, Access: number, RegionFlags: number, WaterHeight: number, @@ -102,7 +102,7 @@ export class MapBlockReplyMessage implements MessageBase } = { X: 0, Y: 0, - Name: '', + Name: Buffer.allocUnsafe(0), Access: 0, RegionFlags: 0, WaterHeight: 0, @@ -114,7 +114,7 @@ export class MapBlockReplyMessage implements MessageBase newObjData['Y'] = buf.readUInt16LE(pos); pos += 2; varLength = buf.readUInt8(pos++); - newObjData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjData['Access'] = buf.readUInt8(pos++); newObjData['RegionFlags'] = buf.readUInt32LE(pos); diff --git a/lib/classes/messages/MapItemReply.ts b/lib/classes/messages/MapItemReply.ts index eb9f522..f200c3f 100644 --- a/lib/classes/messages/MapItemReply.ts +++ b/lib/classes/messages/MapItemReply.ts @@ -24,7 +24,7 @@ export class MapItemReplyMessage implements MessageBase ID: UUID; Extra: number; Extra2: number; - Name: string; + Name: Buffer; }[]; getSize(): number @@ -66,7 +66,7 @@ export class MapItemReplyMessage implements MessageBase buf.writeInt32LE(this.Data[i]['Extra2'], pos); pos += 4; buf.writeUInt8(this.Data[i]['Name'].length, pos++); - buf.write(this.Data[i]['Name'], pos); + this.Data[i]['Name'].copy(buf, pos); pos += this.Data[i]['Name'].length; } return pos - startPos; @@ -106,14 +106,14 @@ export class MapItemReplyMessage implements MessageBase ID: UUID, Extra: number, Extra2: number, - Name: string + Name: Buffer } = { X: 0, Y: 0, ID: UUID.zero(), Extra: 0, Extra2: 0, - Name: '' + Name: Buffer.allocUnsafe(0) }; newObjData['X'] = buf.readUInt32LE(pos); pos += 4; @@ -126,7 +126,7 @@ export class MapItemReplyMessage implements MessageBase newObjData['Extra2'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.Data.push(newObjData); } diff --git a/lib/classes/messages/MapNameRequest.ts b/lib/classes/messages/MapNameRequest.ts index d713e89..5ec7299 100644 --- a/lib/classes/messages/MapNameRequest.ts +++ b/lib/classes/messages/MapNameRequest.ts @@ -19,7 +19,7 @@ export class MapNameRequestMessage implements MessageBase Godlike: boolean; }; NameData: { - Name: string; + Name: Buffer; }; getSize(): number @@ -40,7 +40,7 @@ export class MapNameRequestMessage implements MessageBase pos += 4; buf.writeUInt8((this.AgentData['Godlike']) ? 1 : 0, pos++); buf.writeUInt8(this.NameData['Name'].length, pos++); - buf.write(this.NameData['Name'], pos); + this.NameData['Name'].copy(buf, pos); pos += this.NameData['Name'].length; return pos - startPos; } @@ -73,12 +73,12 @@ export class MapNameRequestMessage implements MessageBase newObjAgentData['Godlike'] = (buf.readUInt8(pos++) === 1); this.AgentData = newObjAgentData; const newObjNameData: { - Name: string + Name: Buffer } = { - Name: '' + Name: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjNameData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjNameData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.NameData = newObjNameData; return pos - startPos; diff --git a/lib/classes/messages/MoneyBalanceReply.ts b/lib/classes/messages/MoneyBalanceReply.ts index b8251fa..0ed46a9 100644 --- a/lib/classes/messages/MoneyBalanceReply.ts +++ b/lib/classes/messages/MoneyBalanceReply.ts @@ -18,7 +18,7 @@ export class MoneyBalanceReplyMessage implements MessageBase MoneyBalance: number; SquareMetersCredit: number; SquareMetersCommitted: number; - Description: string; + Description: Buffer; }; TransactionInfo: { TransactionType: number; @@ -27,7 +27,7 @@ export class MoneyBalanceReplyMessage implements MessageBase DestID: UUID; IsDestGroup: boolean; Amount: number; - ItemDescription: string; + ItemDescription: Buffer; }; getSize(): number @@ -50,7 +50,7 @@ export class MoneyBalanceReplyMessage implements MessageBase buf.writeInt32LE(this.MoneyData['SquareMetersCommitted'], pos); pos += 4; buf.writeUInt8(this.MoneyData['Description'].length, pos++); - buf.write(this.MoneyData['Description'], pos); + this.MoneyData['Description'].copy(buf, pos); pos += this.MoneyData['Description'].length; buf.writeInt32LE(this.TransactionInfo['TransactionType'], pos); pos += 4; @@ -63,7 +63,7 @@ export class MoneyBalanceReplyMessage implements MessageBase buf.writeInt32LE(this.TransactionInfo['Amount'], pos); pos += 4; buf.writeUInt8(this.TransactionInfo['ItemDescription'].length, pos++); - buf.write(this.TransactionInfo['ItemDescription'], pos); + this.TransactionInfo['ItemDescription'].copy(buf, pos); pos += this.TransactionInfo['ItemDescription'].length; return pos - startPos; } @@ -79,7 +79,7 @@ export class MoneyBalanceReplyMessage implements MessageBase MoneyBalance: number, SquareMetersCredit: number, SquareMetersCommitted: number, - Description: string + Description: Buffer } = { AgentID: UUID.zero(), TransactionID: UUID.zero(), @@ -87,7 +87,7 @@ export class MoneyBalanceReplyMessage implements MessageBase MoneyBalance: 0, SquareMetersCredit: 0, SquareMetersCommitted: 0, - Description: '' + Description: Buffer.allocUnsafe(0) }; newObjMoneyData['AgentID'] = new UUID(buf, pos); pos += 16; @@ -101,7 +101,7 @@ export class MoneyBalanceReplyMessage implements MessageBase newObjMoneyData['SquareMetersCommitted'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjMoneyData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMoneyData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.MoneyData = newObjMoneyData; const newObjTransactionInfo: { @@ -111,7 +111,7 @@ export class MoneyBalanceReplyMessage implements MessageBase DestID: UUID, IsDestGroup: boolean, Amount: number, - ItemDescription: string + ItemDescription: Buffer } = { TransactionType: 0, SourceID: UUID.zero(), @@ -119,7 +119,7 @@ export class MoneyBalanceReplyMessage implements MessageBase DestID: UUID.zero(), IsDestGroup: false, Amount: 0, - ItemDescription: '' + ItemDescription: Buffer.allocUnsafe(0) }; newObjTransactionInfo['TransactionType'] = buf.readInt32LE(pos); pos += 4; @@ -132,7 +132,7 @@ export class MoneyBalanceReplyMessage implements MessageBase newObjTransactionInfo['Amount'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjTransactionInfo['ItemDescription'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjTransactionInfo['ItemDescription'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.TransactionInfo = newObjTransactionInfo; return pos - startPos; diff --git a/lib/classes/messages/MoneyTransferBackend.ts b/lib/classes/messages/MoneyTransferBackend.ts index 0adbc69..c5b2883 100644 --- a/lib/classes/messages/MoneyTransferBackend.ts +++ b/lib/classes/messages/MoneyTransferBackend.ts @@ -24,7 +24,7 @@ export class MoneyTransferBackendMessage implements MessageBase RegionID: UUID; GridX: number; GridY: number; - Description: string; + Description: Buffer; }; getSize(): number @@ -57,7 +57,7 @@ export class MoneyTransferBackendMessage implements MessageBase buf.writeUInt32LE(this.MoneyData['GridY'], pos); pos += 4; buf.writeUInt8(this.MoneyData['Description'].length, pos++); - buf.write(this.MoneyData['Description'], pos); + this.MoneyData['Description'].copy(buf, pos); pos += this.MoneyData['Description'].length; return pos - startPos; } @@ -79,7 +79,7 @@ export class MoneyTransferBackendMessage implements MessageBase RegionID: UUID, GridX: number, GridY: number, - Description: string + Description: Buffer } = { TransactionID: UUID.zero(), TransactionTime: 0, @@ -93,7 +93,7 @@ export class MoneyTransferBackendMessage implements MessageBase RegionID: UUID.zero(), GridX: 0, GridY: 0, - Description: '' + Description: Buffer.allocUnsafe(0) }; newObjMoneyData['TransactionID'] = new UUID(buf, pos); pos += 16; @@ -117,7 +117,7 @@ export class MoneyTransferBackendMessage implements MessageBase newObjMoneyData['GridY'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjMoneyData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMoneyData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.MoneyData = newObjMoneyData; return pos - startPos; diff --git a/lib/classes/messages/MoneyTransferRequest.ts b/lib/classes/messages/MoneyTransferRequest.ts index 6b27ddb..6fbe8cb 100644 --- a/lib/classes/messages/MoneyTransferRequest.ts +++ b/lib/classes/messages/MoneyTransferRequest.ts @@ -23,7 +23,7 @@ export class MoneyTransferRequestMessage implements MessageBase AggregatePermNextOwner: number; AggregatePermInventory: number; TransactionType: number; - Description: string; + Description: Buffer; }; getSize(): number @@ -50,7 +50,7 @@ export class MoneyTransferRequestMessage implements MessageBase buf.writeInt32LE(this.MoneyData['TransactionType'], pos); pos += 4; buf.writeUInt8(this.MoneyData['Description'].length, pos++); - buf.write(this.MoneyData['Description'], pos); + this.MoneyData['Description'].copy(buf, pos); pos += this.MoneyData['Description'].length; return pos - startPos; } @@ -79,7 +79,7 @@ export class MoneyTransferRequestMessage implements MessageBase AggregatePermNextOwner: number, AggregatePermInventory: number, TransactionType: number, - Description: string + Description: Buffer } = { SourceID: UUID.zero(), DestID: UUID.zero(), @@ -88,7 +88,7 @@ export class MoneyTransferRequestMessage implements MessageBase AggregatePermNextOwner: 0, AggregatePermInventory: 0, TransactionType: 0, - Description: '' + Description: Buffer.allocUnsafe(0) }; newObjMoneyData['SourceID'] = new UUID(buf, pos); pos += 16; @@ -102,7 +102,7 @@ export class MoneyTransferRequestMessage implements MessageBase newObjMoneyData['TransactionType'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjMoneyData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMoneyData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.MoneyData = newObjMoneyData; return pos - startPos; diff --git a/lib/classes/messages/MoveInventoryItem.ts b/lib/classes/messages/MoveInventoryItem.ts index 15d6152..34f1729 100644 --- a/lib/classes/messages/MoveInventoryItem.ts +++ b/lib/classes/messages/MoveInventoryItem.ts @@ -19,7 +19,7 @@ export class MoveInventoryItemMessage implements MessageBase InventoryData: { ItemID: UUID; FolderID: UUID; - NewName: string; + NewName: Buffer; }[]; getSize(): number @@ -54,7 +54,7 @@ export class MoveInventoryItemMessage implements MessageBase this.InventoryData[i]['FolderID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.InventoryData[i]['NewName'].length, pos++); - buf.write(this.InventoryData[i]['NewName'], pos); + this.InventoryData[i]['NewName'].copy(buf, pos); pos += this.InventoryData[i]['NewName'].length; } return pos - startPos; @@ -86,18 +86,18 @@ export class MoveInventoryItemMessage implements MessageBase const newObjInventoryData: { ItemID: UUID, FolderID: UUID, - NewName: string + NewName: Buffer } = { ItemID: UUID.zero(), FolderID: UUID.zero(), - NewName: '' + NewName: Buffer.allocUnsafe(0) }; newObjInventoryData['ItemID'] = new UUID(buf, pos); pos += 16; newObjInventoryData['FolderID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjInventoryData['NewName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInventoryData['NewName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.InventoryData.push(newObjInventoryData); } diff --git a/lib/classes/messages/MultipleObjectUpdate.ts b/lib/classes/messages/MultipleObjectUpdate.ts index 1d1643d..0c243d6 100644 --- a/lib/classes/messages/MultipleObjectUpdate.ts +++ b/lib/classes/messages/MultipleObjectUpdate.ts @@ -18,7 +18,7 @@ export class MultipleObjectUpdateMessage implements MessageBase ObjectData: { ObjectLocalID: number; Type: number; - Data: string; + Data: Buffer; }[]; getSize(): number @@ -51,7 +51,7 @@ export class MultipleObjectUpdateMessage implements MessageBase pos += 4; buf.writeUInt8(this.ObjectData[i]['Type'], pos++); buf.writeUInt8(this.ObjectData[i]['Data'].length, pos++); - buf.write(this.ObjectData[i]['Data'], pos); + this.ObjectData[i]['Data'].copy(buf, pos); pos += this.ObjectData[i]['Data'].length; } return pos - startPos; @@ -80,17 +80,17 @@ export class MultipleObjectUpdateMessage implements MessageBase const newObjObjectData: { ObjectLocalID: number, Type: number, - Data: string + Data: Buffer } = { ObjectLocalID: 0, Type: 0, - Data: '' + Data: Buffer.allocUnsafe(0) }; newObjObjectData['ObjectLocalID'] = buf.readUInt32LE(pos); pos += 4; newObjObjectData['Type'] = buf.readUInt8(pos++); varLength = buf.readUInt8(pos++); - newObjObjectData['Data'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['Data'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ObjectData.push(newObjObjectData); } diff --git a/lib/classes/messages/MuteListUpdate.ts b/lib/classes/messages/MuteListUpdate.ts index 12bca8c..343376f 100644 --- a/lib/classes/messages/MuteListUpdate.ts +++ b/lib/classes/messages/MuteListUpdate.ts @@ -13,7 +13,7 @@ export class MuteListUpdateMessage implements MessageBase MuteData: { AgentID: UUID; - Filename: string; + Filename: Buffer; }; getSize(): number @@ -27,7 +27,7 @@ export class MuteListUpdateMessage implements MessageBase this.MuteData['AgentID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.MuteData['Filename'].length, pos++); - buf.write(this.MuteData['Filename'], pos); + this.MuteData['Filename'].copy(buf, pos); pos += this.MuteData['Filename'].length; return pos - startPos; } @@ -38,15 +38,15 @@ export class MuteListUpdateMessage implements MessageBase let varLength = 0; const newObjMuteData: { AgentID: UUID, - Filename: string + Filename: Buffer } = { AgentID: UUID.zero(), - Filename: '' + Filename: Buffer.allocUnsafe(0) }; newObjMuteData['AgentID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjMuteData['Filename'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMuteData['Filename'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.MuteData = newObjMuteData; return pos - startPos; diff --git a/lib/classes/messages/NameValuePair.ts b/lib/classes/messages/NameValuePair.ts index 516b557..e3ad874 100644 --- a/lib/classes/messages/NameValuePair.ts +++ b/lib/classes/messages/NameValuePair.ts @@ -15,7 +15,7 @@ export class NameValuePairMessage implements MessageBase ID: UUID; }; NameValueData: { - NVPair: string; + NVPair: Buffer; }[]; getSize(): number @@ -44,7 +44,7 @@ export class NameValuePairMessage implements MessageBase { buf.writeUInt16LE(this.NameValueData[i]['NVPair'].length, pos); pos += 2; - buf.write(this.NameValueData[i]['NVPair'], pos); + this.NameValueData[i]['NVPair'].copy(buf, pos); pos += this.NameValueData[i]['NVPair'].length; } return pos - startPos; @@ -67,13 +67,13 @@ export class NameValuePairMessage implements MessageBase for (let i = 0; i < count; i++) { const newObjNameValueData: { - NVPair: string + NVPair: Buffer } = { - NVPair: '' + NVPair: Buffer.allocUnsafe(0) }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjNameValueData['NVPair'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjNameValueData['NVPair'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.NameValueData.push(newObjNameValueData); } diff --git a/lib/classes/messages/NeighborList.ts b/lib/classes/messages/NeighborList.ts index 833f406..fc93f91 100644 --- a/lib/classes/messages/NeighborList.ts +++ b/lib/classes/messages/NeighborList.ts @@ -18,7 +18,7 @@ export class NeighborListMessage implements MessageBase PublicIP: IPAddress; PublicPort: number; RegionID: UUID; - Name: string; + Name: Buffer; SimAccess: number; }[]; @@ -54,7 +54,7 @@ export class NeighborListMessage implements MessageBase this.NeighborBlock[i]['RegionID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.NeighborBlock[i]['Name'].length, pos++); - buf.write(this.NeighborBlock[i]['Name'], pos); + this.NeighborBlock[i]['Name'].copy(buf, pos); pos += this.NeighborBlock[i]['Name'].length; buf.writeUInt8(this.NeighborBlock[i]['SimAccess'], pos++); } @@ -74,7 +74,7 @@ export class NeighborListMessage implements MessageBase PublicIP: IPAddress, PublicPort: number, RegionID: UUID, - Name: string, + Name: Buffer, SimAccess: number } = { IP: IPAddress.zero(), @@ -82,7 +82,7 @@ export class NeighborListMessage implements MessageBase PublicIP: IPAddress.zero(), PublicPort: 0, RegionID: UUID.zero(), - Name: '', + Name: Buffer.allocUnsafe(0), SimAccess: 0 }; newObjNeighborBlock['IP'] = new IPAddress(buf, pos); @@ -96,7 +96,7 @@ export class NeighborListMessage implements MessageBase newObjNeighborBlock['RegionID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjNeighborBlock['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjNeighborBlock['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjNeighborBlock['SimAccess'] = buf.readUInt8(pos++); this.NeighborBlock.push(newObjNeighborBlock); diff --git a/lib/classes/messages/ObjectDescription.ts b/lib/classes/messages/ObjectDescription.ts index 2ca455a..cdd359d 100644 --- a/lib/classes/messages/ObjectDescription.ts +++ b/lib/classes/messages/ObjectDescription.ts @@ -17,7 +17,7 @@ export class ObjectDescriptionMessage implements MessageBase }; ObjectData: { LocalID: number; - Description: string; + Description: Buffer; }[]; getSize(): number @@ -49,7 +49,7 @@ export class ObjectDescriptionMessage implements MessageBase buf.writeUInt32LE(this.ObjectData[i]['LocalID'], pos); pos += 4; buf.writeUInt8(this.ObjectData[i]['Description'].length, pos++); - buf.write(this.ObjectData[i]['Description'], pos); + this.ObjectData[i]['Description'].copy(buf, pos); pos += this.ObjectData[i]['Description'].length; } return pos - startPos; @@ -77,15 +77,15 @@ export class ObjectDescriptionMessage implements MessageBase { const newObjObjectData: { LocalID: number, - Description: string + Description: Buffer } = { LocalID: 0, - Description: '' + Description: Buffer.allocUnsafe(0) }; newObjObjectData['LocalID'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjObjectData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ObjectData.push(newObjObjectData); } diff --git a/lib/classes/messages/ObjectExtraParams.ts b/lib/classes/messages/ObjectExtraParams.ts index 0ef906e..91b9cda 100644 --- a/lib/classes/messages/ObjectExtraParams.ts +++ b/lib/classes/messages/ObjectExtraParams.ts @@ -20,7 +20,7 @@ export class ObjectExtraParamsMessage implements MessageBase ParamType: number; ParamInUse: boolean; ParamSize: number; - ParamData: string; + ParamData: Buffer; }[]; getSize(): number @@ -57,7 +57,7 @@ export class ObjectExtraParamsMessage implements MessageBase buf.writeUInt32LE(this.ObjectData[i]['ParamSize'], pos); pos += 4; buf.writeUInt8(this.ObjectData[i]['ParamData'].length, pos++); - buf.write(this.ObjectData[i]['ParamData'], pos); + this.ObjectData[i]['ParamData'].copy(buf, pos); pos += this.ObjectData[i]['ParamData'].length; } return pos - startPos; @@ -88,13 +88,13 @@ export class ObjectExtraParamsMessage implements MessageBase ParamType: number, ParamInUse: boolean, ParamSize: number, - ParamData: string + ParamData: Buffer } = { ObjectLocalID: 0, ParamType: 0, ParamInUse: false, ParamSize: 0, - ParamData: '' + ParamData: Buffer.allocUnsafe(0) }; newObjObjectData['ObjectLocalID'] = buf.readUInt32LE(pos); pos += 4; @@ -104,7 +104,7 @@ export class ObjectExtraParamsMessage implements MessageBase newObjObjectData['ParamSize'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjObjectData['ParamData'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['ParamData'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ObjectData.push(newObjObjectData); } diff --git a/lib/classes/messages/ObjectImage.ts b/lib/classes/messages/ObjectImage.ts index d39e54b..2c59b71 100644 --- a/lib/classes/messages/ObjectImage.ts +++ b/lib/classes/messages/ObjectImage.ts @@ -17,8 +17,8 @@ export class ObjectImageMessage implements MessageBase }; ObjectData: { ObjectLocalID: number; - MediaURL: string; - TextureEntry: string; + MediaURL: Buffer; + TextureEntry: Buffer; }[]; getSize(): number @@ -50,11 +50,11 @@ export class ObjectImageMessage implements MessageBase buf.writeUInt32LE(this.ObjectData[i]['ObjectLocalID'], pos); pos += 4; buf.writeUInt8(this.ObjectData[i]['MediaURL'].length, pos++); - buf.write(this.ObjectData[i]['MediaURL'], pos); + this.ObjectData[i]['MediaURL'].copy(buf, pos); pos += this.ObjectData[i]['MediaURL'].length; buf.writeUInt16LE(this.ObjectData[i]['TextureEntry'].length, pos); pos += 2; - buf.write(this.ObjectData[i]['TextureEntry'], pos); + this.ObjectData[i]['TextureEntry'].copy(buf, pos); pos += this.ObjectData[i]['TextureEntry'].length; } return pos - startPos; @@ -82,21 +82,21 @@ export class ObjectImageMessage implements MessageBase { const newObjObjectData: { ObjectLocalID: number, - MediaURL: string, - TextureEntry: string + MediaURL: Buffer, + TextureEntry: Buffer } = { ObjectLocalID: 0, - MediaURL: '', - TextureEntry: '' + MediaURL: Buffer.allocUnsafe(0), + TextureEntry: Buffer.allocUnsafe(0) }; newObjObjectData['ObjectLocalID'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjObjectData['MediaURL'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['MediaURL'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjObjectData['TextureEntry'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['TextureEntry'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ObjectData.push(newObjObjectData); } diff --git a/lib/classes/messages/ObjectName.ts b/lib/classes/messages/ObjectName.ts index f10301d..51272b4 100644 --- a/lib/classes/messages/ObjectName.ts +++ b/lib/classes/messages/ObjectName.ts @@ -17,7 +17,7 @@ export class ObjectNameMessage implements MessageBase }; ObjectData: { LocalID: number; - Name: string; + Name: Buffer; }[]; getSize(): number @@ -49,7 +49,7 @@ export class ObjectNameMessage implements MessageBase buf.writeUInt32LE(this.ObjectData[i]['LocalID'], pos); pos += 4; buf.writeUInt8(this.ObjectData[i]['Name'].length, pos++); - buf.write(this.ObjectData[i]['Name'], pos); + this.ObjectData[i]['Name'].copy(buf, pos); pos += this.ObjectData[i]['Name'].length; } return pos - startPos; @@ -77,15 +77,15 @@ export class ObjectNameMessage implements MessageBase { const newObjObjectData: { LocalID: number, - Name: string + Name: Buffer } = { LocalID: 0, - Name: '' + Name: Buffer.allocUnsafe(0) }; newObjObjectData['LocalID'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjObjectData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ObjectData.push(newObjObjectData); } diff --git a/lib/classes/messages/ObjectProperties.ts b/lib/classes/messages/ObjectProperties.ts index 50800b2..45e8886 100644 --- a/lib/classes/messages/ObjectProperties.ts +++ b/lib/classes/messages/ObjectProperties.ts @@ -35,11 +35,11 @@ export class ObjectPropertiesMessage implements MessageBase FolderID: UUID; FromTaskID: UUID; LastOwnerID: UUID; - Name: string; - Description: string; - TouchName: string; - SitName: string; - TextureID: string; + Name: Buffer; + Description: Buffer; + TouchName: Buffer; + SitName: Buffer; + TextureID: Buffer; }[]; getSize(): number @@ -107,19 +107,19 @@ export class ObjectPropertiesMessage implements MessageBase this.ObjectData[i]['LastOwnerID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.ObjectData[i]['Name'].length, pos++); - buf.write(this.ObjectData[i]['Name'], pos); + this.ObjectData[i]['Name'].copy(buf, pos); pos += this.ObjectData[i]['Name'].length; buf.writeUInt8(this.ObjectData[i]['Description'].length, pos++); - buf.write(this.ObjectData[i]['Description'], pos); + this.ObjectData[i]['Description'].copy(buf, pos); pos += this.ObjectData[i]['Description'].length; buf.writeUInt8(this.ObjectData[i]['TouchName'].length, pos++); - buf.write(this.ObjectData[i]['TouchName'], pos); + this.ObjectData[i]['TouchName'].copy(buf, pos); pos += this.ObjectData[i]['TouchName'].length; buf.writeUInt8(this.ObjectData[i]['SitName'].length, pos++); - buf.write(this.ObjectData[i]['SitName'], pos); + this.ObjectData[i]['SitName'].copy(buf, pos); pos += this.ObjectData[i]['SitName'].length; buf.writeUInt8(this.ObjectData[i]['TextureID'].length, pos++); - buf.write(this.ObjectData[i]['TextureID'], pos); + this.ObjectData[i]['TextureID'].copy(buf, pos); pos += this.ObjectData[i]['TextureID'].length; } return pos - startPos; @@ -156,11 +156,11 @@ export class ObjectPropertiesMessage implements MessageBase FolderID: UUID, FromTaskID: UUID, LastOwnerID: UUID, - Name: string, - Description: string, - TouchName: string, - SitName: string, - TextureID: string + Name: Buffer, + Description: Buffer, + TouchName: Buffer, + SitName: Buffer, + TextureID: Buffer } = { ObjectID: UUID.zero(), CreatorID: UUID.zero(), @@ -184,11 +184,11 @@ export class ObjectPropertiesMessage implements MessageBase FolderID: UUID.zero(), FromTaskID: UUID.zero(), LastOwnerID: UUID.zero(), - Name: '', - Description: '', - TouchName: '', - SitName: '', - TextureID: '' + Name: Buffer.allocUnsafe(0), + Description: Buffer.allocUnsafe(0), + TouchName: Buffer.allocUnsafe(0), + SitName: Buffer.allocUnsafe(0), + TextureID: Buffer.allocUnsafe(0) }; newObjObjectData['ObjectID'] = new UUID(buf, pos); pos += 16; @@ -231,19 +231,19 @@ export class ObjectPropertiesMessage implements MessageBase newObjObjectData['LastOwnerID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjObjectData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['TouchName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['TouchName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['SitName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['SitName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['TextureID'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['TextureID'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ObjectData.push(newObjObjectData); } diff --git a/lib/classes/messages/ObjectPropertiesFamily.ts b/lib/classes/messages/ObjectPropertiesFamily.ts index 69e429c..dd59223 100644 --- a/lib/classes/messages/ObjectPropertiesFamily.ts +++ b/lib/classes/messages/ObjectPropertiesFamily.ts @@ -26,8 +26,8 @@ export class ObjectPropertiesFamilyMessage implements MessageBase SalePrice: number; Category: number; LastOwnerID: UUID; - Name: string; - Description: string; + Name: Buffer; + Description: Buffer; }; getSize(): number @@ -66,10 +66,10 @@ export class ObjectPropertiesFamilyMessage implements MessageBase this.ObjectData['LastOwnerID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.ObjectData['Name'].length, pos++); - buf.write(this.ObjectData['Name'], pos); + this.ObjectData['Name'].copy(buf, pos); pos += this.ObjectData['Name'].length; buf.writeUInt8(this.ObjectData['Description'].length, pos++); - buf.write(this.ObjectData['Description'], pos); + this.ObjectData['Description'].copy(buf, pos); pos += this.ObjectData['Description'].length; return pos - startPos; } @@ -93,8 +93,8 @@ export class ObjectPropertiesFamilyMessage implements MessageBase SalePrice: number, Category: number, LastOwnerID: UUID, - Name: string, - Description: string + Name: Buffer, + Description: Buffer } = { RequestFlags: 0, ObjectID: UUID.zero(), @@ -110,8 +110,8 @@ export class ObjectPropertiesFamilyMessage implements MessageBase SalePrice: 0, Category: 0, LastOwnerID: UUID.zero(), - Name: '', - Description: '' + Name: Buffer.allocUnsafe(0), + Description: Buffer.allocUnsafe(0) }; newObjObjectData['RequestFlags'] = buf.readUInt32LE(pos); pos += 4; @@ -141,10 +141,10 @@ export class ObjectPropertiesFamilyMessage implements MessageBase newObjObjectData['LastOwnerID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjObjectData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ObjectData = newObjObjectData; return pos - startPos; diff --git a/lib/classes/messages/ObjectUpdate.ts b/lib/classes/messages/ObjectUpdate.ts index a7a06ac..8965962 100644 --- a/lib/classes/messages/ObjectUpdate.ts +++ b/lib/classes/messages/ObjectUpdate.ts @@ -26,7 +26,7 @@ export class ObjectUpdateMessage implements MessageBase Material: number; ClickAction: number; Scale: Vector3; - ObjectData: string; + ObjectData: Buffer; ParentID: number; UpdateFlags: number; PathCurve: number; @@ -47,15 +47,15 @@ export class ObjectUpdateMessage implements MessageBase ProfileBegin: number; ProfileEnd: number; ProfileHollow: number; - TextureEntry: string; - TextureAnim: string; - NameValue: string; - Data: string; - Text: string; + TextureEntry: Buffer; + TextureAnim: Buffer; + NameValue: Buffer; + Data: Buffer; + Text: Buffer; TextColor: Buffer; - MediaURL: string; - PSBlock: string; - ExtraParams: string; + MediaURL: Buffer; + PSBlock: Buffer; + ExtraParams: Buffer; Sound: UUID; OwnerID: UUID; Gain: number; @@ -107,7 +107,7 @@ export class ObjectUpdateMessage implements MessageBase this.ObjectData[i]['Scale'].writeToBuffer(buf, pos, false); pos += 12; buf.writeUInt8(this.ObjectData[i]['ObjectData'].length, pos++); - buf.write(this.ObjectData[i]['ObjectData'], pos); + this.ObjectData[i]['ObjectData'].copy(buf, pos); pos += this.ObjectData[i]['ObjectData'].length; buf.writeUInt32LE(this.ObjectData[i]['ParentID'], pos); pos += 4; @@ -138,32 +138,32 @@ export class ObjectUpdateMessage implements MessageBase pos += 2; buf.writeUInt16LE(this.ObjectData[i]['TextureEntry'].length, pos); pos += 2; - buf.write(this.ObjectData[i]['TextureEntry'], pos); + this.ObjectData[i]['TextureEntry'].copy(buf, pos); pos += this.ObjectData[i]['TextureEntry'].length; buf.writeUInt8(this.ObjectData[i]['TextureAnim'].length, pos++); - buf.write(this.ObjectData[i]['TextureAnim'], pos); + this.ObjectData[i]['TextureAnim'].copy(buf, pos); pos += this.ObjectData[i]['TextureAnim'].length; buf.writeUInt16LE(this.ObjectData[i]['NameValue'].length, pos); pos += 2; - buf.write(this.ObjectData[i]['NameValue'], pos); + this.ObjectData[i]['NameValue'].copy(buf, pos); pos += this.ObjectData[i]['NameValue'].length; buf.writeUInt16LE(this.ObjectData[i]['Data'].length, pos); pos += 2; - buf.write(this.ObjectData[i]['Data'], pos); + this.ObjectData[i]['Data'].copy(buf, pos); pos += this.ObjectData[i]['Data'].length; buf.writeUInt8(this.ObjectData[i]['Text'].length, pos++); - buf.write(this.ObjectData[i]['Text'], pos); + this.ObjectData[i]['Text'].copy(buf, pos); pos += this.ObjectData[i]['Text'].length; this.ObjectData[i]['TextColor'].copy(buf, pos); pos += 4; buf.writeUInt8(this.ObjectData[i]['MediaURL'].length, pos++); - buf.write(this.ObjectData[i]['MediaURL'], pos); + this.ObjectData[i]['MediaURL'].copy(buf, pos); pos += this.ObjectData[i]['MediaURL'].length; buf.writeUInt8(this.ObjectData[i]['PSBlock'].length, pos++); - buf.write(this.ObjectData[i]['PSBlock'], pos); + this.ObjectData[i]['PSBlock'].copy(buf, pos); pos += this.ObjectData[i]['PSBlock'].length; buf.writeUInt8(this.ObjectData[i]['ExtraParams'].length, pos++); - buf.write(this.ObjectData[i]['ExtraParams'], pos); + this.ObjectData[i]['ExtraParams'].copy(buf, pos); pos += this.ObjectData[i]['ExtraParams'].length; this.ObjectData[i]['Sound'].writeToBuffer(buf, pos); pos += 16; @@ -212,7 +212,7 @@ export class ObjectUpdateMessage implements MessageBase Material: number, ClickAction: number, Scale: Vector3, - ObjectData: string, + ObjectData: Buffer, ParentID: number, UpdateFlags: number, PathCurve: number, @@ -233,15 +233,15 @@ export class ObjectUpdateMessage implements MessageBase ProfileBegin: number, ProfileEnd: number, ProfileHollow: number, - TextureEntry: string, - TextureAnim: string, - NameValue: string, - Data: string, - Text: string, + TextureEntry: Buffer, + TextureAnim: Buffer, + NameValue: Buffer, + Data: Buffer, + Text: Buffer, TextColor: Buffer, - MediaURL: string, - PSBlock: string, - ExtraParams: string, + MediaURL: Buffer, + PSBlock: Buffer, + ExtraParams: Buffer, Sound: UUID, OwnerID: UUID, Gain: number, @@ -259,7 +259,7 @@ export class ObjectUpdateMessage implements MessageBase Material: 0, ClickAction: 0, Scale: Vector3.getZero(), - ObjectData: '', + ObjectData: Buffer.allocUnsafe(0), ParentID: 0, UpdateFlags: 0, PathCurve: 0, @@ -280,15 +280,15 @@ export class ObjectUpdateMessage implements MessageBase ProfileBegin: 0, ProfileEnd: 0, ProfileHollow: 0, - TextureEntry: '', - TextureAnim: '', - NameValue: '', - Data: '', - Text: '', + TextureEntry: Buffer.allocUnsafe(0), + TextureAnim: Buffer.allocUnsafe(0), + NameValue: Buffer.allocUnsafe(0), + Data: Buffer.allocUnsafe(0), + Text: Buffer.allocUnsafe(0), TextColor: Buffer.allocUnsafe(0), - MediaURL: '', - PSBlock: '', - ExtraParams: '', + MediaURL: Buffer.allocUnsafe(0), + PSBlock: Buffer.allocUnsafe(0), + ExtraParams: Buffer.allocUnsafe(0), Sound: UUID.zero(), OwnerID: UUID.zero(), Gain: 0, @@ -311,7 +311,7 @@ export class ObjectUpdateMessage implements MessageBase newObjObjectData['Scale'] = new Vector3(buf, pos, false); pos += 12; varLength = buf.readUInt8(pos++); - newObjObjectData['ObjectData'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['ObjectData'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjObjectData['ParentID'] = buf.readUInt32LE(pos); pos += 4; @@ -342,32 +342,32 @@ export class ObjectUpdateMessage implements MessageBase pos += 2; varLength = buf.readUInt16LE(pos); pos += 2; - newObjObjectData['TextureEntry'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['TextureEntry'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['TextureAnim'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['TextureAnim'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjObjectData['NameValue'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['NameValue'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjObjectData['Data'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['Data'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['Text'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['Text'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjObjectData['TextColor'] = buf.slice(pos, pos + 4); pos += 4; varLength = buf.readUInt8(pos++); - newObjObjectData['MediaURL'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['MediaURL'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['PSBlock'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['PSBlock'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['ExtraParams'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['ExtraParams'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjObjectData['Sound'] = new UUID(buf, pos); pos += 16; diff --git a/lib/classes/messages/ObjectUpdateCompressed.ts b/lib/classes/messages/ObjectUpdateCompressed.ts index e1e78a5..8d9baa2 100644 --- a/lib/classes/messages/ObjectUpdateCompressed.ts +++ b/lib/classes/messages/ObjectUpdateCompressed.ts @@ -17,7 +17,7 @@ export class ObjectUpdateCompressedMessage implements MessageBase }; ObjectData: { UpdateFlags: number; - Data: string; + Data: Buffer; }[]; getSize(): number @@ -52,7 +52,7 @@ export class ObjectUpdateCompressedMessage implements MessageBase pos += 4; buf.writeUInt16LE(this.ObjectData[i]['Data'].length, pos); pos += 2; - buf.write(this.ObjectData[i]['Data'], pos); + this.ObjectData[i]['Data'].copy(buf, pos); pos += this.ObjectData[i]['Data'].length; } return pos - startPos; @@ -80,16 +80,16 @@ export class ObjectUpdateCompressedMessage implements MessageBase { const newObjObjectData: { UpdateFlags: number, - Data: string + Data: Buffer } = { UpdateFlags: 0, - Data: '' + Data: Buffer.allocUnsafe(0) }; newObjObjectData['UpdateFlags'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjObjectData['Data'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['Data'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ObjectData.push(newObjObjectData); } diff --git a/lib/classes/messages/ParcelInfoReply.ts b/lib/classes/messages/ParcelInfoReply.ts index c12fe34..01556d5 100644 --- a/lib/classes/messages/ParcelInfoReply.ts +++ b/lib/classes/messages/ParcelInfoReply.ts @@ -17,15 +17,15 @@ export class ParcelInfoReplyMessage implements MessageBase Data: { ParcelID: UUID; OwnerID: UUID; - Name: string; - Desc: string; + Name: Buffer; + Desc: Buffer; ActualArea: number; BillableArea: number; Flags: number; GlobalX: number; GlobalY: number; GlobalZ: number; - SimName: string; + SimName: Buffer; SnapshotID: UUID; Dwell: number; SalePrice: number; @@ -47,10 +47,10 @@ export class ParcelInfoReplyMessage implements MessageBase this.Data['OwnerID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.Data['Name'].length, pos++); - buf.write(this.Data['Name'], pos); + this.Data['Name'].copy(buf, pos); pos += this.Data['Name'].length; buf.writeUInt8(this.Data['Desc'].length, pos++); - buf.write(this.Data['Desc'], pos); + this.Data['Desc'].copy(buf, pos); pos += this.Data['Desc'].length; buf.writeInt32LE(this.Data['ActualArea'], pos); pos += 4; @@ -64,7 +64,7 @@ export class ParcelInfoReplyMessage implements MessageBase buf.writeFloatLE(this.Data['GlobalZ'], pos); pos += 4; buf.writeUInt8(this.Data['SimName'].length, pos++); - buf.write(this.Data['SimName'], pos); + this.Data['SimName'].copy(buf, pos); pos += this.Data['SimName'].length; this.Data['SnapshotID'].writeToBuffer(buf, pos); pos += 16; @@ -92,15 +92,15 @@ export class ParcelInfoReplyMessage implements MessageBase const newObjData: { ParcelID: UUID, OwnerID: UUID, - Name: string, - Desc: string, + Name: Buffer, + Desc: Buffer, ActualArea: number, BillableArea: number, Flags: number, GlobalX: number, GlobalY: number, GlobalZ: number, - SimName: string, + SimName: Buffer, SnapshotID: UUID, Dwell: number, SalePrice: number, @@ -108,15 +108,15 @@ export class ParcelInfoReplyMessage implements MessageBase } = { ParcelID: UUID.zero(), OwnerID: UUID.zero(), - Name: '', - Desc: '', + Name: Buffer.allocUnsafe(0), + Desc: Buffer.allocUnsafe(0), ActualArea: 0, BillableArea: 0, Flags: 0, GlobalX: 0, GlobalY: 0, GlobalZ: 0, - SimName: '', + SimName: Buffer.allocUnsafe(0), SnapshotID: UUID.zero(), Dwell: 0, SalePrice: 0, @@ -127,10 +127,10 @@ export class ParcelInfoReplyMessage implements MessageBase newObjData['OwnerID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjData['Desc'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Desc'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjData['ActualArea'] = buf.readInt32LE(pos); pos += 4; @@ -144,7 +144,7 @@ export class ParcelInfoReplyMessage implements MessageBase newObjData['GlobalZ'] = buf.readFloatLE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjData['SimName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['SimName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjData['SnapshotID'] = new UUID(buf, pos); pos += 16; diff --git a/lib/classes/messages/ParcelMediaUpdate.ts b/lib/classes/messages/ParcelMediaUpdate.ts index 2be1ebd..2e0fae3 100644 --- a/lib/classes/messages/ParcelMediaUpdate.ts +++ b/lib/classes/messages/ParcelMediaUpdate.ts @@ -12,13 +12,13 @@ export class ParcelMediaUpdateMessage implements MessageBase id = Message.ParcelMediaUpdate; DataBlock: { - MediaURL: string; + MediaURL: Buffer; MediaID: UUID; MediaAutoScale: number; }; DataBlockExtended: { - MediaType: string; - MediaDesc: string; + MediaType: Buffer; + MediaDesc: Buffer; MediaWidth: number; MediaHeight: number; MediaLoop: number; @@ -33,16 +33,16 @@ export class ParcelMediaUpdateMessage implements MessageBase { const startPos = pos; buf.writeUInt8(this.DataBlock['MediaURL'].length, pos++); - buf.write(this.DataBlock['MediaURL'], pos); + this.DataBlock['MediaURL'].copy(buf, pos); pos += this.DataBlock['MediaURL'].length; this.DataBlock['MediaID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.DataBlock['MediaAutoScale'], pos++); buf.writeUInt8(this.DataBlockExtended['MediaType'].length, pos++); - buf.write(this.DataBlockExtended['MediaType'], pos); + this.DataBlockExtended['MediaType'].copy(buf, pos); pos += this.DataBlockExtended['MediaType'].length; buf.writeUInt8(this.DataBlockExtended['MediaDesc'].length, pos++); - buf.write(this.DataBlockExtended['MediaDesc'], pos); + this.DataBlockExtended['MediaDesc'].copy(buf, pos); pos += this.DataBlockExtended['MediaDesc'].length; buf.writeInt32LE(this.DataBlockExtended['MediaWidth'], pos); pos += 4; @@ -57,39 +57,39 @@ export class ParcelMediaUpdateMessage implements MessageBase const startPos = pos; let varLength = 0; const newObjDataBlock: { - MediaURL: string, + MediaURL: Buffer, MediaID: UUID, MediaAutoScale: number } = { - MediaURL: '', + MediaURL: Buffer.allocUnsafe(0), MediaID: UUID.zero(), MediaAutoScale: 0 }; varLength = buf.readUInt8(pos++); - newObjDataBlock['MediaURL'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataBlock['MediaURL'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjDataBlock['MediaID'] = new UUID(buf, pos); pos += 16; newObjDataBlock['MediaAutoScale'] = buf.readUInt8(pos++); this.DataBlock = newObjDataBlock; const newObjDataBlockExtended: { - MediaType: string, - MediaDesc: string, + MediaType: Buffer, + MediaDesc: Buffer, MediaWidth: number, MediaHeight: number, MediaLoop: number } = { - MediaType: '', - MediaDesc: '', + MediaType: Buffer.allocUnsafe(0), + MediaDesc: Buffer.allocUnsafe(0), MediaWidth: 0, MediaHeight: 0, MediaLoop: 0 }; varLength = buf.readUInt8(pos++); - newObjDataBlockExtended['MediaType'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataBlockExtended['MediaType'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjDataBlockExtended['MediaDesc'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataBlockExtended['MediaDesc'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjDataBlockExtended['MediaWidth'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/ParcelOverlay.ts b/lib/classes/messages/ParcelOverlay.ts index 1c5d5bf..490c37d 100644 --- a/lib/classes/messages/ParcelOverlay.ts +++ b/lib/classes/messages/ParcelOverlay.ts @@ -12,7 +12,7 @@ export class ParcelOverlayMessage implements MessageBase ParcelData: { SequenceID: number; - Data: string; + Data: Buffer; }; getSize(): number @@ -27,7 +27,7 @@ export class ParcelOverlayMessage implements MessageBase pos += 4; buf.writeUInt16LE(this.ParcelData['Data'].length, pos); pos += 2; - buf.write(this.ParcelData['Data'], pos); + this.ParcelData['Data'].copy(buf, pos); pos += this.ParcelData['Data'].length; return pos - startPos; } @@ -38,16 +38,16 @@ export class ParcelOverlayMessage implements MessageBase let varLength = 0; const newObjParcelData: { SequenceID: number, - Data: string + Data: Buffer } = { SequenceID: 0, - Data: '' + Data: Buffer.allocUnsafe(0) }; newObjParcelData['SequenceID'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjParcelData['Data'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjParcelData['Data'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ParcelData = newObjParcelData; return pos - startPos; diff --git a/lib/classes/messages/ParcelProperties.ts b/lib/classes/messages/ParcelProperties.ts index d5fb09f..f689e4e 100644 --- a/lib/classes/messages/ParcelProperties.ts +++ b/lib/classes/messages/ParcelProperties.ts @@ -28,7 +28,7 @@ export class ParcelPropertiesMessage implements MessageBase RentPrice: number; AABBMin: Vector3; AABBMax: Vector3; - Bitmap: string; + Bitmap: Buffer; Area: number; Status: number; SimWideMaxPrims: number; @@ -43,10 +43,10 @@ export class ParcelPropertiesMessage implements MessageBase OtherCleanTime: number; ParcelFlags: number; SalePrice: number; - Name: string; - Desc: string; - MusicURL: string; - MediaURL: string; + Name: Buffer; + Desc: Buffer; + MusicURL: Buffer; + MediaURL: Buffer; MediaID: UUID; MediaAutoScale: number; GroupID: UUID; @@ -108,7 +108,7 @@ export class ParcelPropertiesMessage implements MessageBase pos += 12; buf.writeUInt16LE(this.ParcelData['Bitmap'].length, pos); pos += 2; - buf.write(this.ParcelData['Bitmap'], pos); + this.ParcelData['Bitmap'].copy(buf, pos); pos += this.ParcelData['Bitmap'].length; buf.writeInt32LE(this.ParcelData['Area'], pos); pos += 4; @@ -138,16 +138,16 @@ export class ParcelPropertiesMessage implements MessageBase buf.writeInt32LE(this.ParcelData['SalePrice'], pos); pos += 4; buf.writeUInt8(this.ParcelData['Name'].length, pos++); - buf.write(this.ParcelData['Name'], pos); + this.ParcelData['Name'].copy(buf, pos); pos += this.ParcelData['Name'].length; buf.writeUInt8(this.ParcelData['Desc'].length, pos++); - buf.write(this.ParcelData['Desc'], pos); + this.ParcelData['Desc'].copy(buf, pos); pos += this.ParcelData['Desc'].length; buf.writeUInt8(this.ParcelData['MusicURL'].length, pos++); - buf.write(this.ParcelData['MusicURL'], pos); + this.ParcelData['MusicURL'].copy(buf, pos); pos += this.ParcelData['MusicURL'].length; buf.writeUInt8(this.ParcelData['MediaURL'].length, pos++); - buf.write(this.ParcelData['MediaURL'], pos); + this.ParcelData['MediaURL'].copy(buf, pos); pos += this.ParcelData['MediaURL'].length; this.ParcelData['MediaID'].writeToBuffer(buf, pos); pos += 16; @@ -197,7 +197,7 @@ export class ParcelPropertiesMessage implements MessageBase RentPrice: number, AABBMin: Vector3, AABBMax: Vector3, - Bitmap: string, + Bitmap: Buffer, Area: number, Status: number, SimWideMaxPrims: number, @@ -212,10 +212,10 @@ export class ParcelPropertiesMessage implements MessageBase OtherCleanTime: number, ParcelFlags: number, SalePrice: number, - Name: string, - Desc: string, - MusicURL: string, - MediaURL: string, + Name: Buffer, + Desc: Buffer, + MusicURL: Buffer, + MediaURL: Buffer, MediaID: UUID, MediaAutoScale: number, GroupID: UUID, @@ -247,7 +247,7 @@ export class ParcelPropertiesMessage implements MessageBase RentPrice: 0, AABBMin: Vector3.getZero(), AABBMax: Vector3.getZero(), - Bitmap: '', + Bitmap: Buffer.allocUnsafe(0), Area: 0, Status: 0, SimWideMaxPrims: 0, @@ -262,10 +262,10 @@ export class ParcelPropertiesMessage implements MessageBase OtherCleanTime: 0, ParcelFlags: 0, SalePrice: 0, - Name: '', - Desc: '', - MusicURL: '', - MediaURL: '', + Name: Buffer.allocUnsafe(0), + Desc: Buffer.allocUnsafe(0), + MusicURL: Buffer.allocUnsafe(0), + MediaURL: Buffer.allocUnsafe(0), MediaID: UUID.zero(), MediaAutoScale: 0, GroupID: UUID.zero(), @@ -312,7 +312,7 @@ export class ParcelPropertiesMessage implements MessageBase pos += 12; varLength = buf.readUInt16LE(pos); pos += 2; - newObjParcelData['Bitmap'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjParcelData['Bitmap'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjParcelData['Area'] = buf.readInt32LE(pos); pos += 4; @@ -342,16 +342,16 @@ export class ParcelPropertiesMessage implements MessageBase newObjParcelData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjParcelData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjParcelData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjParcelData['Desc'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjParcelData['Desc'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjParcelData['MusicURL'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjParcelData['MusicURL'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjParcelData['MediaURL'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjParcelData['MediaURL'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjParcelData['MediaID'] = new UUID(buf, pos); pos += 16; diff --git a/lib/classes/messages/ParcelPropertiesUpdate.ts b/lib/classes/messages/ParcelPropertiesUpdate.ts index 884a030..45c6e4c 100644 --- a/lib/classes/messages/ParcelPropertiesUpdate.ts +++ b/lib/classes/messages/ParcelPropertiesUpdate.ts @@ -21,10 +21,10 @@ export class ParcelPropertiesUpdateMessage implements MessageBase Flags: number; ParcelFlags: number; SalePrice: number; - Name: string; - Desc: string; - MusicURL: string; - MediaURL: string; + Name: Buffer; + Desc: Buffer; + MusicURL: Buffer; + MediaURL: Buffer; MediaID: UUID; MediaAutoScale: number; GroupID: UUID; @@ -59,16 +59,16 @@ export class ParcelPropertiesUpdateMessage implements MessageBase buf.writeInt32LE(this.ParcelData['SalePrice'], pos); pos += 4; buf.writeUInt8(this.ParcelData['Name'].length, pos++); - buf.write(this.ParcelData['Name'], pos); + this.ParcelData['Name'].copy(buf, pos); pos += this.ParcelData['Name'].length; buf.writeUInt8(this.ParcelData['Desc'].length, pos++); - buf.write(this.ParcelData['Desc'], pos); + this.ParcelData['Desc'].copy(buf, pos); pos += this.ParcelData['Desc'].length; buf.writeUInt8(this.ParcelData['MusicURL'].length, pos++); - buf.write(this.ParcelData['MusicURL'], pos); + this.ParcelData['MusicURL'].copy(buf, pos); pos += this.ParcelData['MusicURL'].length; buf.writeUInt8(this.ParcelData['MediaURL'].length, pos++); - buf.write(this.ParcelData['MediaURL'], pos); + this.ParcelData['MediaURL'].copy(buf, pos); pos += this.ParcelData['MediaURL'].length; this.ParcelData['MediaID'].writeToBuffer(buf, pos); pos += 16; @@ -113,10 +113,10 @@ export class ParcelPropertiesUpdateMessage implements MessageBase Flags: number, ParcelFlags: number, SalePrice: number, - Name: string, - Desc: string, - MusicURL: string, - MediaURL: string, + Name: Buffer, + Desc: Buffer, + MusicURL: Buffer, + MediaURL: Buffer, MediaID: UUID, MediaAutoScale: number, GroupID: UUID, @@ -133,10 +133,10 @@ export class ParcelPropertiesUpdateMessage implements MessageBase Flags: 0, ParcelFlags: 0, SalePrice: 0, - Name: '', - Desc: '', - MusicURL: '', - MediaURL: '', + Name: Buffer.allocUnsafe(0), + Desc: Buffer.allocUnsafe(0), + MusicURL: Buffer.allocUnsafe(0), + MediaURL: Buffer.allocUnsafe(0), MediaID: UUID.zero(), MediaAutoScale: 0, GroupID: UUID.zero(), @@ -158,16 +158,16 @@ export class ParcelPropertiesUpdateMessage implements MessageBase newObjParcelData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjParcelData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjParcelData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjParcelData['Desc'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjParcelData['Desc'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjParcelData['MusicURL'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjParcelData['MusicURL'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjParcelData['MediaURL'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjParcelData['MediaURL'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjParcelData['MediaID'] = new UUID(buf, pos); pos += 16; diff --git a/lib/classes/messages/ParcelRename.ts b/lib/classes/messages/ParcelRename.ts index 0f3e1ed..71a905c 100644 --- a/lib/classes/messages/ParcelRename.ts +++ b/lib/classes/messages/ParcelRename.ts @@ -13,7 +13,7 @@ export class ParcelRenameMessage implements MessageBase ParcelData: { ParcelID: UUID; - NewName: string; + NewName: Buffer; }[]; getSize(): number @@ -41,7 +41,7 @@ export class ParcelRenameMessage implements MessageBase this.ParcelData[i]['ParcelID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.ParcelData[i]['NewName'].length, pos++); - buf.write(this.ParcelData[i]['NewName'], pos); + this.ParcelData[i]['NewName'].copy(buf, pos); pos += this.ParcelData[i]['NewName'].length; } return pos - startPos; @@ -57,15 +57,15 @@ export class ParcelRenameMessage implements MessageBase { const newObjParcelData: { ParcelID: UUID, - NewName: string + NewName: Buffer } = { ParcelID: UUID.zero(), - NewName: '' + NewName: Buffer.allocUnsafe(0) }; newObjParcelData['ParcelID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjParcelData['NewName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjParcelData['NewName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ParcelData.push(newObjParcelData); } diff --git a/lib/classes/messages/PickInfoReply.ts b/lib/classes/messages/PickInfoReply.ts index 33a0b60..a18b473 100644 --- a/lib/classes/messages/PickInfoReply.ts +++ b/lib/classes/messages/PickInfoReply.ts @@ -20,12 +20,12 @@ export class PickInfoReplyMessage implements MessageBase CreatorID: UUID; TopPick: boolean; ParcelID: UUID; - Name: string; - Desc: string; + Name: Buffer; + Desc: Buffer; SnapshotID: UUID; - User: string; - OriginalName: string; - SimName: string; + User: Buffer; + OriginalName: Buffer; + SimName: Buffer; PosGlobal: Vector3; SortOrder: number; Enabled: boolean; @@ -49,22 +49,22 @@ export class PickInfoReplyMessage implements MessageBase this.Data['ParcelID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.Data['Name'].length, pos++); - buf.write(this.Data['Name'], pos); + this.Data['Name'].copy(buf, pos); pos += this.Data['Name'].length; buf.writeUInt16LE(this.Data['Desc'].length, pos); pos += 2; - buf.write(this.Data['Desc'], pos); + this.Data['Desc'].copy(buf, pos); pos += this.Data['Desc'].length; this.Data['SnapshotID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.Data['User'].length, pos++); - buf.write(this.Data['User'], pos); + this.Data['User'].copy(buf, pos); pos += this.Data['User'].length; buf.writeUInt8(this.Data['OriginalName'].length, pos++); - buf.write(this.Data['OriginalName'], pos); + this.Data['OriginalName'].copy(buf, pos); pos += this.Data['OriginalName'].length; buf.writeUInt8(this.Data['SimName'].length, pos++); - buf.write(this.Data['SimName'], pos); + this.Data['SimName'].copy(buf, pos); pos += this.Data['SimName'].length; this.Data['PosGlobal'].writeToBuffer(buf, pos, true); pos += 24; @@ -91,12 +91,12 @@ export class PickInfoReplyMessage implements MessageBase CreatorID: UUID, TopPick: boolean, ParcelID: UUID, - Name: string, - Desc: string, + Name: Buffer, + Desc: Buffer, SnapshotID: UUID, - User: string, - OriginalName: string, - SimName: string, + User: Buffer, + OriginalName: Buffer, + SimName: Buffer, PosGlobal: Vector3, SortOrder: number, Enabled: boolean @@ -105,12 +105,12 @@ export class PickInfoReplyMessage implements MessageBase CreatorID: UUID.zero(), TopPick: false, ParcelID: UUID.zero(), - Name: '', - Desc: '', + Name: Buffer.allocUnsafe(0), + Desc: Buffer.allocUnsafe(0), SnapshotID: UUID.zero(), - User: '', - OriginalName: '', - SimName: '', + User: Buffer.allocUnsafe(0), + OriginalName: Buffer.allocUnsafe(0), + SimName: Buffer.allocUnsafe(0), PosGlobal: Vector3.getZero(), SortOrder: 0, Enabled: false @@ -123,22 +123,22 @@ export class PickInfoReplyMessage implements MessageBase newObjData['ParcelID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjData['Desc'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Desc'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjData['SnapshotID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['User'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['User'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjData['OriginalName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['OriginalName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjData['SimName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['SimName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjData['PosGlobal'] = new Vector3(buf, pos, true); pos += 24; diff --git a/lib/classes/messages/PickInfoUpdate.ts b/lib/classes/messages/PickInfoUpdate.ts index 77ec2c9..c8723b5 100644 --- a/lib/classes/messages/PickInfoUpdate.ts +++ b/lib/classes/messages/PickInfoUpdate.ts @@ -21,8 +21,8 @@ export class PickInfoUpdateMessage implements MessageBase CreatorID: UUID; TopPick: boolean; ParcelID: UUID; - Name: string; - Desc: string; + Name: Buffer; + Desc: Buffer; SnapshotID: UUID; PosGlobal: Vector3; SortOrder: number; @@ -49,11 +49,11 @@ export class PickInfoUpdateMessage implements MessageBase this.Data['ParcelID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.Data['Name'].length, pos++); - buf.write(this.Data['Name'], pos); + this.Data['Name'].copy(buf, pos); pos += this.Data['Name'].length; buf.writeUInt16LE(this.Data['Desc'].length, pos); pos += 2; - buf.write(this.Data['Desc'], pos); + this.Data['Desc'].copy(buf, pos); pos += this.Data['Desc'].length; this.Data['SnapshotID'].writeToBuffer(buf, pos); pos += 16; @@ -86,8 +86,8 @@ export class PickInfoUpdateMessage implements MessageBase CreatorID: UUID, TopPick: boolean, ParcelID: UUID, - Name: string, - Desc: string, + Name: Buffer, + Desc: Buffer, SnapshotID: UUID, PosGlobal: Vector3, SortOrder: number, @@ -97,8 +97,8 @@ export class PickInfoUpdateMessage implements MessageBase CreatorID: UUID.zero(), TopPick: false, ParcelID: UUID.zero(), - Name: '', - Desc: '', + Name: Buffer.allocUnsafe(0), + Desc: Buffer.allocUnsafe(0), SnapshotID: UUID.zero(), PosGlobal: Vector3.getZero(), SortOrder: 0, @@ -112,11 +112,11 @@ export class PickInfoUpdateMessage implements MessageBase newObjData['ParcelID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjData['Desc'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Desc'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjData['SnapshotID'] = new UUID(buf, pos); pos += 16; diff --git a/lib/classes/messages/PlacesQuery.ts b/lib/classes/messages/PlacesQuery.ts index fca1845..80251ff 100644 --- a/lib/classes/messages/PlacesQuery.ts +++ b/lib/classes/messages/PlacesQuery.ts @@ -20,10 +20,10 @@ export class PlacesQueryMessage implements MessageBase TransactionID: UUID; }; QueryData: { - QueryText: string; + QueryText: Buffer; QueryFlags: number; Category: number; - SimName: string; + SimName: Buffer; }; getSize(): number @@ -43,13 +43,13 @@ export class PlacesQueryMessage implements MessageBase this.TransactionData['TransactionID'].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; buf.writeInt8(this.QueryData['Category'], pos++); buf.writeUInt8(this.QueryData['SimName'].length, pos++); - buf.write(this.QueryData['SimName'], pos); + this.QueryData['SimName'].copy(buf, pos); pos += this.QueryData['SimName'].length; return pos - startPos; } @@ -83,24 +83,24 @@ export class PlacesQueryMessage implements MessageBase pos += 16; this.TransactionData = newObjTransactionData; const newObjQueryData: { - QueryText: string, + QueryText: Buffer, QueryFlags: number, Category: number, - SimName: string + SimName: Buffer } = { - QueryText: '', + QueryText: Buffer.allocUnsafe(0), QueryFlags: 0, Category: 0, - SimName: '' + SimName: Buffer.allocUnsafe(0) }; 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; newObjQueryData['Category'] = buf.readInt8(pos++); varLength = buf.readUInt8(pos++); - newObjQueryData['SimName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjQueryData['SimName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.QueryData = newObjQueryData; return pos - startPos; diff --git a/lib/classes/messages/PlacesReply.ts b/lib/classes/messages/PlacesReply.ts index d857449..7315e8a 100644 --- a/lib/classes/messages/PlacesReply.ts +++ b/lib/classes/messages/PlacesReply.ts @@ -20,15 +20,15 @@ export class PlacesReplyMessage implements MessageBase }; QueryData: { OwnerID: UUID; - Name: string; - Desc: string; + Name: Buffer; + Desc: Buffer; ActualArea: number; BillableArea: number; Flags: number; GlobalX: number; GlobalY: number; GlobalZ: number; - SimName: string; + SimName: Buffer; SnapshotID: UUID; Dwell: number; Price: number; @@ -65,10 +65,10 @@ export class PlacesReplyMessage implements MessageBase this.QueryData[i]['OwnerID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.QueryData[i]['Name'].length, pos++); - buf.write(this.QueryData[i]['Name'], pos); + this.QueryData[i]['Name'].copy(buf, pos); pos += this.QueryData[i]['Name'].length; buf.writeUInt8(this.QueryData[i]['Desc'].length, pos++); - buf.write(this.QueryData[i]['Desc'], pos); + this.QueryData[i]['Desc'].copy(buf, pos); pos += this.QueryData[i]['Desc'].length; buf.writeInt32LE(this.QueryData[i]['ActualArea'], pos); pos += 4; @@ -82,7 +82,7 @@ export class PlacesReplyMessage implements MessageBase buf.writeFloatLE(this.QueryData[i]['GlobalZ'], pos); pos += 4; buf.writeUInt8(this.QueryData[i]['SimName'].length, pos++); - buf.write(this.QueryData[i]['SimName'], pos); + this.QueryData[i]['SimName'].copy(buf, pos); pos += this.QueryData[i]['SimName'].length; this.QueryData[i]['SnapshotID'].writeToBuffer(buf, pos); pos += 16; @@ -124,29 +124,29 @@ export class PlacesReplyMessage implements MessageBase { const newObjQueryData: { OwnerID: UUID, - Name: string, - Desc: string, + Name: Buffer, + Desc: Buffer, ActualArea: number, BillableArea: number, Flags: number, GlobalX: number, GlobalY: number, GlobalZ: number, - SimName: string, + SimName: Buffer, SnapshotID: UUID, Dwell: number, Price: number } = { OwnerID: UUID.zero(), - Name: '', - Desc: '', + Name: Buffer.allocUnsafe(0), + Desc: Buffer.allocUnsafe(0), ActualArea: 0, BillableArea: 0, Flags: 0, GlobalX: 0, GlobalY: 0, GlobalZ: 0, - SimName: '', + SimName: Buffer.allocUnsafe(0), SnapshotID: UUID.zero(), Dwell: 0, Price: 0 @@ -154,10 +154,10 @@ export class PlacesReplyMessage implements MessageBase newObjQueryData['OwnerID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjQueryData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjQueryData['Desc'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjQueryData['Desc'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjQueryData['ActualArea'] = buf.readInt32LE(pos); pos += 4; @@ -171,7 +171,7 @@ export class PlacesReplyMessage implements MessageBase newObjQueryData['GlobalZ'] = buf.readFloatLE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjQueryData['SimName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjQueryData['SimName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjQueryData['SnapshotID'] = new UUID(buf, pos); pos += 16; diff --git a/lib/classes/messages/RegionHandshake.ts b/lib/classes/messages/RegionHandshake.ts index e59609f..2a81438 100644 --- a/lib/classes/messages/RegionHandshake.ts +++ b/lib/classes/messages/RegionHandshake.ts @@ -15,7 +15,7 @@ export class RegionHandshakeMessage implements MessageBase RegionInfo: { RegionFlags: number; SimAccess: number; - SimName: string; + SimName: Buffer; SimOwner: UUID; IsEstateManager: boolean; WaterHeight: number; @@ -44,9 +44,9 @@ export class RegionHandshakeMessage implements MessageBase RegionInfo3: { CPUClassID: number; CPURatio: number; - ColoName: string; - ProductSKU: string; - ProductName: string; + ColoName: Buffer; + ProductSKU: Buffer; + ProductName: Buffer; }; RegionInfo4: { RegionFlagsExtended: Long; @@ -65,7 +65,7 @@ export class RegionHandshakeMessage implements MessageBase pos += 4; buf.writeUInt8(this.RegionInfo['SimAccess'], pos++); buf.writeUInt8(this.RegionInfo['SimName'].length, pos++); - buf.write(this.RegionInfo['SimName'], pos); + this.RegionInfo['SimName'].copy(buf, pos); pos += this.RegionInfo['SimName'].length; this.RegionInfo['SimOwner'].writeToBuffer(buf, pos); pos += 16; @@ -115,13 +115,13 @@ export class RegionHandshakeMessage implements MessageBase buf.writeInt32LE(this.RegionInfo3['CPURatio'], pos); pos += 4; buf.writeUInt8(this.RegionInfo3['ColoName'].length, pos++); - buf.write(this.RegionInfo3['ColoName'], pos); + this.RegionInfo3['ColoName'].copy(buf, pos); pos += this.RegionInfo3['ColoName'].length; buf.writeUInt8(this.RegionInfo3['ProductSKU'].length, pos++); - buf.write(this.RegionInfo3['ProductSKU'], pos); + this.RegionInfo3['ProductSKU'].copy(buf, pos); pos += this.RegionInfo3['ProductSKU'].length; buf.writeUInt8(this.RegionInfo3['ProductName'].length, pos++); - buf.write(this.RegionInfo3['ProductName'], pos); + this.RegionInfo3['ProductName'].copy(buf, pos); pos += this.RegionInfo3['ProductName'].length; const count = this.RegionInfo4.length; buf.writeUInt8(this.RegionInfo4.length, pos++); @@ -146,7 +146,7 @@ export class RegionHandshakeMessage implements MessageBase const newObjRegionInfo: { RegionFlags: number, SimAccess: number, - SimName: string, + SimName: Buffer, SimOwner: UUID, IsEstateManager: boolean, WaterHeight: number, @@ -171,7 +171,7 @@ export class RegionHandshakeMessage implements MessageBase } = { RegionFlags: 0, SimAccess: 0, - SimName: '', + SimName: Buffer.allocUnsafe(0), SimOwner: UUID.zero(), IsEstateManager: false, WaterHeight: 0, @@ -198,7 +198,7 @@ export class RegionHandshakeMessage implements MessageBase pos += 4; newObjRegionInfo['SimAccess'] = buf.readUInt8(pos++); varLength = buf.readUInt8(pos++); - newObjRegionInfo['SimName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjRegionInfo['SimName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjRegionInfo['SimOwner'] = new UUID(buf, pos); pos += 16; @@ -253,28 +253,28 @@ export class RegionHandshakeMessage implements MessageBase const newObjRegionInfo3: { CPUClassID: number, CPURatio: number, - ColoName: string, - ProductSKU: string, - ProductName: string + ColoName: Buffer, + ProductSKU: Buffer, + ProductName: Buffer } = { CPUClassID: 0, CPURatio: 0, - ColoName: '', - ProductSKU: '', - ProductName: '' + ColoName: Buffer.allocUnsafe(0), + ProductSKU: Buffer.allocUnsafe(0), + ProductName: Buffer.allocUnsafe(0) }; newObjRegionInfo3['CPUClassID'] = buf.readInt32LE(pos); pos += 4; newObjRegionInfo3['CPURatio'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjRegionInfo3['ColoName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjRegionInfo3['ColoName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjRegionInfo3['ProductSKU'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjRegionInfo3['ProductSKU'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjRegionInfo3['ProductName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjRegionInfo3['ProductName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.RegionInfo3 = newObjRegionInfo3; const count = buf.readUInt8(pos++); diff --git a/lib/classes/messages/RegionInfo.ts b/lib/classes/messages/RegionInfo.ts index 602e812..cd568b2 100644 --- a/lib/classes/messages/RegionInfo.ts +++ b/lib/classes/messages/RegionInfo.ts @@ -17,7 +17,7 @@ export class RegionInfoMessage implements MessageBase SessionID: UUID; }; RegionInfo: { - SimName: string; + SimName: Buffer; EstateID: number; ParentEstateID: number; RegionFlags: number; @@ -35,8 +35,8 @@ export class RegionInfoMessage implements MessageBase SunHour: number; }; RegionInfo2: { - ProductSKU: string; - ProductName: string; + ProductSKU: Buffer; + ProductName: Buffer; MaxAgents32: number; HardMaxAgents: number; HardMaxObjects: number; @@ -58,7 +58,7 @@ export class RegionInfoMessage implements MessageBase this.AgentData['SessionID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.RegionInfo['SimName'].length, pos++); - buf.write(this.RegionInfo['SimName'], pos); + this.RegionInfo['SimName'].copy(buf, pos); pos += this.RegionInfo['SimName'].length; buf.writeUInt32LE(this.RegionInfo['EstateID'], pos); pos += 4; @@ -88,10 +88,10 @@ export class RegionInfoMessage implements MessageBase buf.writeFloatLE(this.RegionInfo['SunHour'], pos); pos += 4; buf.writeUInt8(this.RegionInfo2['ProductSKU'].length, pos++); - buf.write(this.RegionInfo2['ProductSKU'], pos); + this.RegionInfo2['ProductSKU'].copy(buf, pos); pos += this.RegionInfo2['ProductSKU'].length; buf.writeUInt8(this.RegionInfo2['ProductName'].length, pos++); - buf.write(this.RegionInfo2['ProductName'], pos); + this.RegionInfo2['ProductName'].copy(buf, pos); pos += this.RegionInfo2['ProductName'].length; buf.writeUInt32LE(this.RegionInfo2['MaxAgents32'], pos); pos += 4; @@ -128,7 +128,7 @@ export class RegionInfoMessage implements MessageBase pos += 16; this.AgentData = newObjAgentData; const newObjRegionInfo: { - SimName: string, + SimName: Buffer, EstateID: number, ParentEstateID: number, RegionFlags: number, @@ -145,7 +145,7 @@ export class RegionInfoMessage implements MessageBase UseEstateSun: boolean, SunHour: number } = { - SimName: '', + SimName: Buffer.allocUnsafe(0), EstateID: 0, ParentEstateID: 0, RegionFlags: 0, @@ -163,7 +163,7 @@ export class RegionInfoMessage implements MessageBase SunHour: 0 }; varLength = buf.readUInt8(pos++); - newObjRegionInfo['SimName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjRegionInfo['SimName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjRegionInfo['EstateID'] = buf.readUInt32LE(pos); pos += 4; @@ -194,23 +194,23 @@ export class RegionInfoMessage implements MessageBase pos += 4; this.RegionInfo = newObjRegionInfo; const newObjRegionInfo2: { - ProductSKU: string, - ProductName: string, + ProductSKU: Buffer, + ProductName: Buffer, MaxAgents32: number, HardMaxAgents: number, HardMaxObjects: number } = { - ProductSKU: '', - ProductName: '', + ProductSKU: Buffer.allocUnsafe(0), + ProductName: Buffer.allocUnsafe(0), MaxAgents32: 0, HardMaxAgents: 0, HardMaxObjects: 0 }; varLength = buf.readUInt8(pos++); - newObjRegionInfo2['ProductSKU'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjRegionInfo2['ProductSKU'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjRegionInfo2['ProductName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjRegionInfo2['ProductName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjRegionInfo2['MaxAgents32'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/RegionPresenceResponse.ts b/lib/classes/messages/RegionPresenceResponse.ts index 88c77e2..0376d07 100644 --- a/lib/classes/messages/RegionPresenceResponse.ts +++ b/lib/classes/messages/RegionPresenceResponse.ts @@ -20,7 +20,7 @@ export class RegionPresenceResponseMessage implements MessageBase ExternalRegionIP: IPAddress; RegionPort: number; ValidUntil: number; - Message: string; + Message: Buffer; }[]; getSize(): number @@ -60,7 +60,7 @@ export class RegionPresenceResponseMessage implements MessageBase buf.writeDoubleLE(this.RegionData[i]['ValidUntil'], pos); pos += 8; buf.writeUInt8(this.RegionData[i]['Message'].length, pos++); - buf.write(this.RegionData[i]['Message'], pos); + this.RegionData[i]['Message'].copy(buf, pos); pos += this.RegionData[i]['Message'].length; } return pos - startPos; @@ -81,7 +81,7 @@ export class RegionPresenceResponseMessage implements MessageBase ExternalRegionIP: IPAddress, RegionPort: number, ValidUntil: number, - Message: string + Message: Buffer } = { RegionID: UUID.zero(), RegionHandle: Long.ZERO, @@ -89,7 +89,7 @@ export class RegionPresenceResponseMessage implements MessageBase ExternalRegionIP: IPAddress.zero(), RegionPort: 0, ValidUntil: 0, - Message: '' + Message: Buffer.allocUnsafe(0) }; newObjRegionData['RegionID'] = new UUID(buf, pos); pos += 16; @@ -104,7 +104,7 @@ export class RegionPresenceResponseMessage implements MessageBase newObjRegionData['ValidUntil'] = buf.readDoubleLE(pos); pos += 8; varLength = buf.readUInt8(pos++); - newObjRegionData['Message'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjRegionData['Message'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.RegionData.push(newObjRegionData); } diff --git a/lib/classes/messages/RemoveMuteListEntry.ts b/lib/classes/messages/RemoveMuteListEntry.ts index de291c9..aa9f14d 100644 --- a/lib/classes/messages/RemoveMuteListEntry.ts +++ b/lib/classes/messages/RemoveMuteListEntry.ts @@ -17,7 +17,7 @@ export class RemoveMuteListEntryMessage implements MessageBase }; MuteData: { MuteID: UUID; - MuteName: string; + MuteName: Buffer; }; getSize(): number @@ -35,7 +35,7 @@ export class RemoveMuteListEntryMessage implements MessageBase this.MuteData['MuteID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.MuteData['MuteName'].length, pos++); - buf.write(this.MuteData['MuteName'], pos); + this.MuteData['MuteName'].copy(buf, pos); pos += this.MuteData['MuteName'].length; return pos - startPos; } @@ -58,15 +58,15 @@ export class RemoveMuteListEntryMessage implements MessageBase this.AgentData = newObjAgentData; const newObjMuteData: { MuteID: UUID, - MuteName: string + MuteName: Buffer } = { MuteID: UUID.zero(), - MuteName: '' + MuteName: Buffer.allocUnsafe(0) }; newObjMuteData['MuteID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjMuteData['MuteName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMuteData['MuteName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.MuteData = newObjMuteData; return pos - startPos; diff --git a/lib/classes/messages/RemoveNameValuePair.ts b/lib/classes/messages/RemoveNameValuePair.ts index 96ed080..c72e28e 100644 --- a/lib/classes/messages/RemoveNameValuePair.ts +++ b/lib/classes/messages/RemoveNameValuePair.ts @@ -15,7 +15,7 @@ export class RemoveNameValuePairMessage implements MessageBase ID: UUID; }; NameValueData: { - NVPair: string; + NVPair: Buffer; }[]; getSize(): number @@ -44,7 +44,7 @@ export class RemoveNameValuePairMessage implements MessageBase { buf.writeUInt16LE(this.NameValueData[i]['NVPair'].length, pos); pos += 2; - buf.write(this.NameValueData[i]['NVPair'], pos); + this.NameValueData[i]['NVPair'].copy(buf, pos); pos += this.NameValueData[i]['NVPair'].length; } return pos - startPos; @@ -67,13 +67,13 @@ export class RemoveNameValuePairMessage implements MessageBase for (let i = 0; i < count; i++) { const newObjNameValueData: { - NVPair: string + NVPair: Buffer } = { - NVPair: '' + NVPair: Buffer.allocUnsafe(0) }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjNameValueData['NVPair'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjNameValueData['NVPair'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.NameValueData.push(newObjNameValueData); } diff --git a/lib/classes/messages/ReplyTaskInventory.ts b/lib/classes/messages/ReplyTaskInventory.ts index f5b1119..54c68e0 100644 --- a/lib/classes/messages/ReplyTaskInventory.ts +++ b/lib/classes/messages/ReplyTaskInventory.ts @@ -14,7 +14,7 @@ export class ReplyTaskInventoryMessage implements MessageBase InventoryData: { TaskID: UUID; Serial: number; - Filename: string; + Filename: Buffer; }; getSize(): number @@ -30,7 +30,7 @@ export class ReplyTaskInventoryMessage implements MessageBase buf.writeInt16LE(this.InventoryData['Serial'], pos); pos += 2; buf.writeUInt8(this.InventoryData['Filename'].length, pos++); - buf.write(this.InventoryData['Filename'], pos); + this.InventoryData['Filename'].copy(buf, pos); pos += this.InventoryData['Filename'].length; return pos - startPos; } @@ -42,18 +42,18 @@ export class ReplyTaskInventoryMessage implements MessageBase const newObjInventoryData: { TaskID: UUID, Serial: number, - Filename: string + Filename: Buffer } = { TaskID: UUID.zero(), Serial: 0, - Filename: '' + Filename: Buffer.allocUnsafe(0) }; newObjInventoryData['TaskID'] = new UUID(buf, pos); pos += 16; newObjInventoryData['Serial'] = buf.readInt16LE(pos); pos += 2; varLength = buf.readUInt8(pos++); - newObjInventoryData['Filename'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInventoryData['Filename'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.InventoryData = newObjInventoryData; return pos - startPos; diff --git a/lib/classes/messages/RequestXfer.ts b/lib/classes/messages/RequestXfer.ts index 13b2cb8..4158187 100644 --- a/lib/classes/messages/RequestXfer.ts +++ b/lib/classes/messages/RequestXfer.ts @@ -14,7 +14,7 @@ export class RequestXferMessage implements MessageBase XferID: { ID: Long; - Filename: string; + Filename: Buffer; FilePath: number; DeleteOnCompletion: boolean; UseBigPackets: boolean; @@ -35,7 +35,7 @@ export class RequestXferMessage implements MessageBase buf.writeInt32LE(this.XferID['ID'].high, pos); pos += 4; buf.writeUInt8(this.XferID['Filename'].length, pos++); - buf.write(this.XferID['Filename'], pos); + this.XferID['Filename'].copy(buf, pos); pos += this.XferID['Filename'].length; buf.writeUInt8(this.XferID['FilePath'], pos++); buf.writeUInt8((this.XferID['DeleteOnCompletion']) ? 1 : 0, pos++); @@ -53,7 +53,7 @@ export class RequestXferMessage implements MessageBase let varLength = 0; const newObjXferID: { ID: Long, - Filename: string, + Filename: Buffer, FilePath: number, DeleteOnCompletion: boolean, UseBigPackets: boolean, @@ -61,7 +61,7 @@ export class RequestXferMessage implements MessageBase VFileType: number } = { ID: Long.ZERO, - Filename: '', + Filename: Buffer.allocUnsafe(0), FilePath: 0, DeleteOnCompletion: false, UseBigPackets: false, @@ -71,7 +71,7 @@ export class RequestXferMessage implements MessageBase newObjXferID['ID'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4)); pos += 8; varLength = buf.readUInt8(pos++); - newObjXferID['Filename'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjXferID['Filename'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjXferID['FilePath'] = buf.readUInt8(pos++); newObjXferID['DeleteOnCompletion'] = (buf.readUInt8(pos++) === 1); diff --git a/lib/classes/messages/RezMultipleAttachmentsFromInv.ts b/lib/classes/messages/RezMultipleAttachmentsFromInv.ts index 0671c3e..9fcc23e 100644 --- a/lib/classes/messages/RezMultipleAttachmentsFromInv.ts +++ b/lib/classes/messages/RezMultipleAttachmentsFromInv.ts @@ -28,8 +28,8 @@ export class RezMultipleAttachmentsFromInvMessage implements MessageBase GroupMask: number; EveryoneMask: number; NextOwnerMask: number; - Name: string; - Description: string; + Name: Buffer; + Description: Buffer; }[]; getSize(): number @@ -76,10 +76,10 @@ export class RezMultipleAttachmentsFromInvMessage implements MessageBase buf.writeUInt32LE(this.ObjectData[i]['NextOwnerMask'], pos); pos += 4; buf.writeUInt8(this.ObjectData[i]['Name'].length, pos++); - buf.write(this.ObjectData[i]['Name'], pos); + this.ObjectData[i]['Name'].copy(buf, pos); pos += this.ObjectData[i]['Name'].length; buf.writeUInt8(this.ObjectData[i]['Description'].length, pos++); - buf.write(this.ObjectData[i]['Description'], pos); + this.ObjectData[i]['Description'].copy(buf, pos); pos += this.ObjectData[i]['Description'].length; } return pos - startPos; @@ -127,8 +127,8 @@ export class RezMultipleAttachmentsFromInvMessage implements MessageBase GroupMask: number, EveryoneMask: number, NextOwnerMask: number, - Name: string, - Description: string + Name: Buffer, + Description: Buffer } = { ItemID: UUID.zero(), OwnerID: UUID.zero(), @@ -137,8 +137,8 @@ export class RezMultipleAttachmentsFromInvMessage implements MessageBase GroupMask: 0, EveryoneMask: 0, NextOwnerMask: 0, - Name: '', - Description: '' + Name: Buffer.allocUnsafe(0), + Description: Buffer.allocUnsafe(0) }; newObjObjectData['ItemID'] = new UUID(buf, pos); pos += 16; @@ -154,10 +154,10 @@ export class RezMultipleAttachmentsFromInvMessage implements MessageBase newObjObjectData['NextOwnerMask'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjObjectData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ObjectData.push(newObjObjectData); } diff --git a/lib/classes/messages/RezObject.ts b/lib/classes/messages/RezObject.ts index a7bcb46..fd1b30c 100644 --- a/lib/classes/messages/RezObject.ts +++ b/lib/classes/messages/RezObject.ts @@ -49,8 +49,8 @@ export class RezObjectMessage implements MessageBase Flags: number; SaleType: number; SalePrice: number; - Name: string; - Description: string; + Name: Buffer; + Description: Buffer; CreationDate: number; CRC: number; }; @@ -120,10 +120,10 @@ export class RezObjectMessage implements MessageBase buf.writeInt32LE(this.InventoryData['SalePrice'], pos); pos += 4; buf.writeUInt8(this.InventoryData['Name'].length, pos++); - buf.write(this.InventoryData['Name'], pos); + this.InventoryData['Name'].copy(buf, pos); pos += this.InventoryData['Name'].length; buf.writeUInt8(this.InventoryData['Description'].length, pos++); - buf.write(this.InventoryData['Description'], pos); + this.InventoryData['Description'].copy(buf, pos); pos += this.InventoryData['Description'].length; buf.writeInt32LE(this.InventoryData['CreationDate'], pos); pos += 4; @@ -218,8 +218,8 @@ export class RezObjectMessage implements MessageBase Flags: number, SaleType: number, SalePrice: number, - Name: string, - Description: string, + Name: Buffer, + Description: Buffer, CreationDate: number, CRC: number } = { @@ -240,8 +240,8 @@ export class RezObjectMessage implements MessageBase Flags: 0, SaleType: 0, SalePrice: 0, - Name: '', - Description: '', + Name: Buffer.allocUnsafe(0), + Description: Buffer.allocUnsafe(0), CreationDate: 0, CRC: 0 }; @@ -276,10 +276,10 @@ export class RezObjectMessage implements MessageBase newObjInventoryData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjInventoryData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInventoryData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjInventoryData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInventoryData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjInventoryData['CreationDate'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/RezRestoreToWorld.ts b/lib/classes/messages/RezRestoreToWorld.ts index 7c10512..1859c32 100644 --- a/lib/classes/messages/RezRestoreToWorld.ts +++ b/lib/classes/messages/RezRestoreToWorld.ts @@ -33,8 +33,8 @@ export class RezRestoreToWorldMessage implements MessageBase Flags: number; SaleType: number; SalePrice: number; - Name: string; - Description: string; + Name: Buffer; + Description: Buffer; CreationDate: number; CRC: number; }; @@ -82,10 +82,10 @@ export class RezRestoreToWorldMessage implements MessageBase buf.writeInt32LE(this.InventoryData['SalePrice'], pos); pos += 4; buf.writeUInt8(this.InventoryData['Name'].length, pos++); - buf.write(this.InventoryData['Name'], pos); + this.InventoryData['Name'].copy(buf, pos); pos += this.InventoryData['Name'].length; buf.writeUInt8(this.InventoryData['Description'].length, pos++); - buf.write(this.InventoryData['Description'], pos); + this.InventoryData['Description'].copy(buf, pos); pos += this.InventoryData['Description'].length; buf.writeInt32LE(this.InventoryData['CreationDate'], pos); pos += 4; @@ -128,8 +128,8 @@ export class RezRestoreToWorldMessage implements MessageBase Flags: number, SaleType: number, SalePrice: number, - Name: string, - Description: string, + Name: Buffer, + Description: Buffer, CreationDate: number, CRC: number } = { @@ -150,8 +150,8 @@ export class RezRestoreToWorldMessage implements MessageBase Flags: 0, SaleType: 0, SalePrice: 0, - Name: '', - Description: '', + Name: Buffer.allocUnsafe(0), + Description: Buffer.allocUnsafe(0), CreationDate: 0, CRC: 0 }; @@ -186,10 +186,10 @@ export class RezRestoreToWorldMessage implements MessageBase newObjInventoryData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjInventoryData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInventoryData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjInventoryData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInventoryData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjInventoryData['CreationDate'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/RezScript.ts b/lib/classes/messages/RezScript.ts index 93bd4bd..9c62e16 100644 --- a/lib/classes/messages/RezScript.ts +++ b/lib/classes/messages/RezScript.ts @@ -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; diff --git a/lib/classes/messages/RezSingleAttachmentFromInv.ts b/lib/classes/messages/RezSingleAttachmentFromInv.ts index 7d6ac84..b6d7412 100644 --- a/lib/classes/messages/RezSingleAttachmentFromInv.ts +++ b/lib/classes/messages/RezSingleAttachmentFromInv.ts @@ -23,8 +23,8 @@ export class RezSingleAttachmentFromInvMessage implements MessageBase GroupMask: number; EveryoneMask: number; NextOwnerMask: number; - Name: string; - Description: string; + Name: Buffer; + Description: Buffer; }; getSize(): number @@ -53,10 +53,10 @@ export class RezSingleAttachmentFromInvMessage implements MessageBase buf.writeUInt32LE(this.ObjectData['NextOwnerMask'], pos); pos += 4; buf.writeUInt8(this.ObjectData['Name'].length, pos++); - buf.write(this.ObjectData['Name'], pos); + this.ObjectData['Name'].copy(buf, pos); pos += this.ObjectData['Name'].length; buf.writeUInt8(this.ObjectData['Description'].length, pos++); - buf.write(this.ObjectData['Description'], pos); + this.ObjectData['Description'].copy(buf, pos); pos += this.ObjectData['Description'].length; return pos - startPos; } @@ -85,8 +85,8 @@ export class RezSingleAttachmentFromInvMessage implements MessageBase GroupMask: number, EveryoneMask: number, NextOwnerMask: number, - Name: string, - Description: string + Name: Buffer, + Description: Buffer } = { ItemID: UUID.zero(), OwnerID: UUID.zero(), @@ -95,8 +95,8 @@ export class RezSingleAttachmentFromInvMessage implements MessageBase GroupMask: 0, EveryoneMask: 0, NextOwnerMask: 0, - Name: '', - Description: '' + Name: Buffer.allocUnsafe(0), + Description: Buffer.allocUnsafe(0) }; newObjObjectData['ItemID'] = new UUID(buf, pos); pos += 16; @@ -112,10 +112,10 @@ export class RezSingleAttachmentFromInvMessage implements MessageBase newObjObjectData['NextOwnerMask'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjObjectData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjObjectData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ObjectData = newObjObjectData; return pos - startPos; diff --git a/lib/classes/messages/RoutedMoneyBalanceReply.ts b/lib/classes/messages/RoutedMoneyBalanceReply.ts index c27d8d7..b650c23 100644 --- a/lib/classes/messages/RoutedMoneyBalanceReply.ts +++ b/lib/classes/messages/RoutedMoneyBalanceReply.ts @@ -23,7 +23,7 @@ export class RoutedMoneyBalanceReplyMessage implements MessageBase MoneyBalance: number; SquareMetersCredit: number; SquareMetersCommitted: number; - Description: string; + Description: Buffer; }; TransactionInfo: { TransactionType: number; @@ -32,7 +32,7 @@ export class RoutedMoneyBalanceReplyMessage implements MessageBase DestID: UUID; IsDestGroup: boolean; Amount: number; - ItemDescription: string; + ItemDescription: Buffer; }; getSize(): number @@ -59,7 +59,7 @@ export class RoutedMoneyBalanceReplyMessage implements MessageBase buf.writeInt32LE(this.MoneyData['SquareMetersCommitted'], pos); pos += 4; buf.writeUInt8(this.MoneyData['Description'].length, pos++); - buf.write(this.MoneyData['Description'], pos); + this.MoneyData['Description'].copy(buf, pos); pos += this.MoneyData['Description'].length; buf.writeInt32LE(this.TransactionInfo['TransactionType'], pos); pos += 4; @@ -72,7 +72,7 @@ export class RoutedMoneyBalanceReplyMessage implements MessageBase buf.writeInt32LE(this.TransactionInfo['Amount'], pos); pos += 4; buf.writeUInt8(this.TransactionInfo['ItemDescription'].length, pos++); - buf.write(this.TransactionInfo['ItemDescription'], pos); + this.TransactionInfo['ItemDescription'].copy(buf, pos); pos += this.TransactionInfo['ItemDescription'].length; return pos - startPos; } @@ -100,7 +100,7 @@ export class RoutedMoneyBalanceReplyMessage implements MessageBase MoneyBalance: number, SquareMetersCredit: number, SquareMetersCommitted: number, - Description: string + Description: Buffer } = { AgentID: UUID.zero(), TransactionID: UUID.zero(), @@ -108,7 +108,7 @@ export class RoutedMoneyBalanceReplyMessage implements MessageBase MoneyBalance: 0, SquareMetersCredit: 0, SquareMetersCommitted: 0, - Description: '' + Description: Buffer.allocUnsafe(0) }; newObjMoneyData['AgentID'] = new UUID(buf, pos); pos += 16; @@ -122,7 +122,7 @@ export class RoutedMoneyBalanceReplyMessage implements MessageBase newObjMoneyData['SquareMetersCommitted'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjMoneyData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMoneyData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.MoneyData = newObjMoneyData; const newObjTransactionInfo: { @@ -132,7 +132,7 @@ export class RoutedMoneyBalanceReplyMessage implements MessageBase DestID: UUID, IsDestGroup: boolean, Amount: number, - ItemDescription: string + ItemDescription: Buffer } = { TransactionType: 0, SourceID: UUID.zero(), @@ -140,7 +140,7 @@ export class RoutedMoneyBalanceReplyMessage implements MessageBase DestID: UUID.zero(), IsDestGroup: false, Amount: 0, - ItemDescription: '' + ItemDescription: Buffer.allocUnsafe(0) }; newObjTransactionInfo['TransactionType'] = buf.readInt32LE(pos); pos += 4; @@ -153,7 +153,7 @@ export class RoutedMoneyBalanceReplyMessage implements MessageBase newObjTransactionInfo['Amount'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjTransactionInfo['ItemDescription'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjTransactionInfo['ItemDescription'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.TransactionInfo = newObjTransactionInfo; return pos - startPos; diff --git a/lib/classes/messages/RpcScriptReplyInbound.ts b/lib/classes/messages/RpcScriptReplyInbound.ts index 4f1a250..e4c285a 100644 --- a/lib/classes/messages/RpcScriptReplyInbound.ts +++ b/lib/classes/messages/RpcScriptReplyInbound.ts @@ -16,7 +16,7 @@ export class RpcScriptReplyInboundMessage implements MessageBase ItemID: UUID; ChannelID: UUID; IntValue: number; - StringValue: string; + StringValue: Buffer; }; getSize(): number @@ -37,7 +37,7 @@ export class RpcScriptReplyInboundMessage implements MessageBase pos += 4; buf.writeUInt16LE(this.DataBlock['StringValue'].length, pos); pos += 2; - buf.write(this.DataBlock['StringValue'], pos); + this.DataBlock['StringValue'].copy(buf, pos); pos += this.DataBlock['StringValue'].length; return pos - startPos; } @@ -51,13 +51,13 @@ export class RpcScriptReplyInboundMessage implements MessageBase ItemID: UUID, ChannelID: UUID, IntValue: number, - StringValue: string + StringValue: Buffer } = { TaskID: UUID.zero(), ItemID: UUID.zero(), ChannelID: UUID.zero(), IntValue: 0, - StringValue: '' + StringValue: Buffer.allocUnsafe(0) }; newObjDataBlock['TaskID'] = new UUID(buf, pos); pos += 16; @@ -69,7 +69,7 @@ export class RpcScriptReplyInboundMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjDataBlock['StringValue'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataBlock['StringValue'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.DataBlock = newObjDataBlock; return pos - startPos; diff --git a/lib/classes/messages/RpcScriptRequestInbound.ts b/lib/classes/messages/RpcScriptRequestInbound.ts index bf32fcf..60b1af0 100644 --- a/lib/classes/messages/RpcScriptRequestInbound.ts +++ b/lib/classes/messages/RpcScriptRequestInbound.ts @@ -20,7 +20,7 @@ export class RpcScriptRequestInboundMessage implements MessageBase ItemID: UUID; ChannelID: UUID; IntValue: number; - StringValue: string; + StringValue: Buffer; }; getSize(): number @@ -45,7 +45,7 @@ export class RpcScriptRequestInboundMessage implements MessageBase pos += 4; buf.writeUInt16LE(this.DataBlock['StringValue'].length, pos); pos += 2; - buf.write(this.DataBlock['StringValue'], pos); + this.DataBlock['StringValue'].copy(buf, pos); pos += this.DataBlock['StringValue'].length; return pos - startPos; } @@ -71,13 +71,13 @@ export class RpcScriptRequestInboundMessage implements MessageBase ItemID: UUID, ChannelID: UUID, IntValue: number, - StringValue: string + StringValue: Buffer } = { TaskID: UUID.zero(), ItemID: UUID.zero(), ChannelID: UUID.zero(), IntValue: 0, - StringValue: '' + StringValue: Buffer.allocUnsafe(0) }; newObjDataBlock['TaskID'] = new UUID(buf, pos); pos += 16; @@ -89,7 +89,7 @@ export class RpcScriptRequestInboundMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjDataBlock['StringValue'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataBlock['StringValue'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.DataBlock = newObjDataBlock; return pos - startPos; diff --git a/lib/classes/messages/RpcScriptRequestInboundForward.ts b/lib/classes/messages/RpcScriptRequestInboundForward.ts index 6293203..1d021ab 100644 --- a/lib/classes/messages/RpcScriptRequestInboundForward.ts +++ b/lib/classes/messages/RpcScriptRequestInboundForward.ts @@ -19,7 +19,7 @@ export class RpcScriptRequestInboundForwardMessage implements MessageBase ItemID: UUID; ChannelID: UUID; IntValue: number; - StringValue: string; + StringValue: Buffer; }; getSize(): number @@ -44,7 +44,7 @@ export class RpcScriptRequestInboundForwardMessage implements MessageBase pos += 4; buf.writeUInt16LE(this.DataBlock['StringValue'].length, pos); pos += 2; - buf.write(this.DataBlock['StringValue'], pos); + this.DataBlock['StringValue'].copy(buf, pos); pos += this.DataBlock['StringValue'].length; return pos - startPos; } @@ -60,7 +60,7 @@ export class RpcScriptRequestInboundForwardMessage implements MessageBase ItemID: UUID, ChannelID: UUID, IntValue: number, - StringValue: string + StringValue: Buffer } = { RPCServerIP: IPAddress.zero(), RPCServerPort: 0, @@ -68,7 +68,7 @@ export class RpcScriptRequestInboundForwardMessage implements MessageBase ItemID: UUID.zero(), ChannelID: UUID.zero(), IntValue: 0, - StringValue: '' + StringValue: Buffer.allocUnsafe(0) }; newObjDataBlock['RPCServerIP'] = new IPAddress(buf, pos); pos += 4; @@ -84,7 +84,7 @@ export class RpcScriptRequestInboundForwardMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjDataBlock['StringValue'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataBlock['StringValue'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.DataBlock = newObjDataBlock; return pos - startPos; diff --git a/lib/classes/messages/ScriptDataReply.ts b/lib/classes/messages/ScriptDataReply.ts index becd765..5c5ecc4 100644 --- a/lib/classes/messages/ScriptDataReply.ts +++ b/lib/classes/messages/ScriptDataReply.ts @@ -13,7 +13,7 @@ export class ScriptDataReplyMessage implements MessageBase DataBlock: { Hash: Long; - Reply: string; + Reply: Buffer; }[]; getSize(): number @@ -44,7 +44,7 @@ export class ScriptDataReplyMessage implements MessageBase pos += 4; buf.writeUInt16LE(this.DataBlock[i]['Reply'].length, pos); pos += 2; - buf.write(this.DataBlock[i]['Reply'], pos); + this.DataBlock[i]['Reply'].copy(buf, pos); pos += this.DataBlock[i]['Reply'].length; } return pos - startPos; @@ -60,16 +60,16 @@ export class ScriptDataReplyMessage implements MessageBase { const newObjDataBlock: { Hash: Long, - Reply: string + Reply: Buffer } = { Hash: Long.ZERO, - Reply: '' + Reply: Buffer.allocUnsafe(0) }; newObjDataBlock['Hash'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4)); pos += 8; varLength = buf.readUInt16LE(pos); pos += 2; - newObjDataBlock['Reply'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataBlock['Reply'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.DataBlock.push(newObjDataBlock); } diff --git a/lib/classes/messages/ScriptDataRequest.ts b/lib/classes/messages/ScriptDataRequest.ts index dc1446a..3bad0be 100644 --- a/lib/classes/messages/ScriptDataRequest.ts +++ b/lib/classes/messages/ScriptDataRequest.ts @@ -14,7 +14,7 @@ export class ScriptDataRequestMessage implements MessageBase DataBlock: { Hash: Long; RequestType: number; - Request: string; + Request: Buffer; }[]; getSize(): number @@ -46,7 +46,7 @@ export class ScriptDataRequestMessage implements MessageBase buf.writeInt8(this.DataBlock[i]['RequestType'], pos++); buf.writeUInt16LE(this.DataBlock[i]['Request'].length, pos); pos += 2; - buf.write(this.DataBlock[i]['Request'], pos); + this.DataBlock[i]['Request'].copy(buf, pos); pos += this.DataBlock[i]['Request'].length; } return pos - startPos; @@ -63,18 +63,18 @@ export class ScriptDataRequestMessage implements MessageBase const newObjDataBlock: { Hash: Long, RequestType: number, - Request: string + Request: Buffer } = { Hash: Long.ZERO, RequestType: 0, - Request: '' + Request: Buffer.allocUnsafe(0) }; newObjDataBlock['Hash'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4)); pos += 8; newObjDataBlock['RequestType'] = buf.readInt8(pos++); varLength = buf.readUInt16LE(pos); pos += 2; - newObjDataBlock['Request'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataBlock['Request'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.DataBlock.push(newObjDataBlock); } diff --git a/lib/classes/messages/ScriptDialog.ts b/lib/classes/messages/ScriptDialog.ts index 87d3acb..6b0d644 100644 --- a/lib/classes/messages/ScriptDialog.ts +++ b/lib/classes/messages/ScriptDialog.ts @@ -13,15 +13,15 @@ export class ScriptDialogMessage implements MessageBase Data: { ObjectID: UUID; - FirstName: string; - LastName: string; - ObjectName: string; - Message: string; + FirstName: Buffer; + LastName: Buffer; + ObjectName: Buffer; + Message: Buffer; ChatChannel: number; ImageID: UUID; }; Buttons: { - ButtonLabel: string; + ButtonLabel: Buffer; }[]; OwnerData: { OwnerID: UUID; @@ -48,17 +48,17 @@ export class ScriptDialogMessage implements MessageBase this.Data['ObjectID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.Data['FirstName'].length, pos++); - buf.write(this.Data['FirstName'], pos); + this.Data['FirstName'].copy(buf, pos); pos += this.Data['FirstName'].length; buf.writeUInt8(this.Data['LastName'].length, pos++); - buf.write(this.Data['LastName'], pos); + this.Data['LastName'].copy(buf, pos); pos += this.Data['LastName'].length; buf.writeUInt8(this.Data['ObjectName'].length, pos++); - buf.write(this.Data['ObjectName'], pos); + this.Data['ObjectName'].copy(buf, pos); pos += this.Data['ObjectName'].length; buf.writeUInt16LE(this.Data['Message'].length, pos); pos += 2; - buf.write(this.Data['Message'], pos); + this.Data['Message'].copy(buf, pos); pos += this.Data['Message'].length; buf.writeInt32LE(this.Data['ChatChannel'], pos); pos += 4; @@ -69,7 +69,7 @@ export class ScriptDialogMessage implements MessageBase for (let i = 0; i < count; i++) { buf.writeUInt8(this.Buttons[i]['ButtonLabel'].length, pos++); - buf.write(this.Buttons[i]['ButtonLabel'], pos); + this.Buttons[i]['ButtonLabel'].copy(buf, pos); pos += this.Buttons[i]['ButtonLabel'].length; } count = this.OwnerData.length; @@ -88,35 +88,35 @@ export class ScriptDialogMessage implements MessageBase let varLength = 0; const newObjData: { ObjectID: UUID, - FirstName: string, - LastName: string, - ObjectName: string, - Message: string, + FirstName: Buffer, + LastName: Buffer, + ObjectName: Buffer, + Message: Buffer, ChatChannel: number, ImageID: UUID } = { ObjectID: UUID.zero(), - FirstName: '', - LastName: '', - ObjectName: '', - Message: '', + FirstName: Buffer.allocUnsafe(0), + LastName: Buffer.allocUnsafe(0), + ObjectName: Buffer.allocUnsafe(0), + Message: Buffer.allocUnsafe(0), ChatChannel: 0, ImageID: UUID.zero() }; newObjData['ObjectID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['FirstName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['FirstName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjData['LastName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['LastName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjData['ObjectName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['ObjectName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjData['Message'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Message'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjData['ChatChannel'] = buf.readInt32LE(pos); pos += 4; @@ -128,12 +128,12 @@ export class ScriptDialogMessage implements MessageBase for (let i = 0; i < count; i++) { const newObjButtons: { - ButtonLabel: string + ButtonLabel: Buffer } = { - ButtonLabel: '' + ButtonLabel: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjButtons['ButtonLabel'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjButtons['ButtonLabel'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.Buttons.push(newObjButtons); } diff --git a/lib/classes/messages/ScriptDialogReply.ts b/lib/classes/messages/ScriptDialogReply.ts index 3a1a9b1..0bef066 100644 --- a/lib/classes/messages/ScriptDialogReply.ts +++ b/lib/classes/messages/ScriptDialogReply.ts @@ -19,7 +19,7 @@ export class ScriptDialogReplyMessage implements MessageBase ObjectID: UUID; ChatChannel: number; ButtonIndex: number; - ButtonLabel: string; + ButtonLabel: Buffer; }; getSize(): number @@ -41,7 +41,7 @@ export class ScriptDialogReplyMessage implements MessageBase buf.writeInt32LE(this.Data['ButtonIndex'], pos); pos += 4; buf.writeUInt8(this.Data['ButtonLabel'].length, pos++); - buf.write(this.Data['ButtonLabel'], pos); + this.Data['ButtonLabel'].copy(buf, pos); pos += this.Data['ButtonLabel'].length; return pos - startPos; } @@ -66,12 +66,12 @@ export class ScriptDialogReplyMessage implements MessageBase ObjectID: UUID, ChatChannel: number, ButtonIndex: number, - ButtonLabel: string + ButtonLabel: Buffer } = { ObjectID: UUID.zero(), ChatChannel: 0, ButtonIndex: 0, - ButtonLabel: '' + ButtonLabel: Buffer.allocUnsafe(0) }; newObjData['ObjectID'] = new UUID(buf, pos); pos += 16; @@ -80,7 +80,7 @@ export class ScriptDialogReplyMessage implements MessageBase newObjData['ButtonIndex'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjData['ButtonLabel'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['ButtonLabel'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.Data = newObjData; return pos - startPos; diff --git a/lib/classes/messages/ScriptMailRegistration.ts b/lib/classes/messages/ScriptMailRegistration.ts index eef636e..45183e9 100644 --- a/lib/classes/messages/ScriptMailRegistration.ts +++ b/lib/classes/messages/ScriptMailRegistration.ts @@ -12,7 +12,7 @@ export class ScriptMailRegistrationMessage implements MessageBase id = Message.ScriptMailRegistration; DataBlock: { - TargetIP: string; + TargetIP: Buffer; TargetPort: number; TaskID: UUID; Flags: number; @@ -27,7 +27,7 @@ export class ScriptMailRegistrationMessage implements MessageBase { const startPos = pos; buf.writeUInt8(this.DataBlock['TargetIP'].length, pos++); - buf.write(this.DataBlock['TargetIP'], pos); + this.DataBlock['TargetIP'].copy(buf, pos); pos += this.DataBlock['TargetIP'].length; buf.writeUInt16LE(this.DataBlock['TargetPort'], pos); pos += 2; @@ -43,18 +43,18 @@ export class ScriptMailRegistrationMessage implements MessageBase const startPos = pos; let varLength = 0; const newObjDataBlock: { - TargetIP: string, + TargetIP: Buffer, TargetPort: number, TaskID: UUID, Flags: number } = { - TargetIP: '', + TargetIP: Buffer.allocUnsafe(0), TargetPort: 0, TaskID: UUID.zero(), Flags: 0 }; varLength = buf.readUInt8(pos++); - newObjDataBlock['TargetIP'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataBlock['TargetIP'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjDataBlock['TargetPort'] = buf.readUInt16LE(pos); pos += 2; diff --git a/lib/classes/messages/ScriptQuestion.ts b/lib/classes/messages/ScriptQuestion.ts index 3a042e5..8040c5c 100644 --- a/lib/classes/messages/ScriptQuestion.ts +++ b/lib/classes/messages/ScriptQuestion.ts @@ -14,8 +14,8 @@ export class ScriptQuestionMessage implements MessageBase Data: { TaskID: UUID; ItemID: UUID; - ObjectName: string; - ObjectOwner: string; + ObjectName: Buffer; + ObjectOwner: Buffer; Questions: number; }; Experience: { @@ -35,10 +35,10 @@ export class ScriptQuestionMessage implements MessageBase this.Data['ItemID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.Data['ObjectName'].length, pos++); - buf.write(this.Data['ObjectName'], pos); + this.Data['ObjectName'].copy(buf, pos); pos += this.Data['ObjectName'].length; buf.writeUInt8(this.Data['ObjectOwner'].length, pos++); - buf.write(this.Data['ObjectOwner'], pos); + this.Data['ObjectOwner'].copy(buf, pos); pos += this.Data['ObjectOwner'].length; buf.writeInt32LE(this.Data['Questions'], pos); pos += 4; @@ -54,14 +54,14 @@ export class ScriptQuestionMessage implements MessageBase const newObjData: { TaskID: UUID, ItemID: UUID, - ObjectName: string, - ObjectOwner: string, + ObjectName: Buffer, + ObjectOwner: Buffer, Questions: number } = { TaskID: UUID.zero(), ItemID: UUID.zero(), - ObjectName: '', - ObjectOwner: '', + ObjectName: Buffer.allocUnsafe(0), + ObjectOwner: Buffer.allocUnsafe(0), Questions: 0 }; newObjData['TaskID'] = new UUID(buf, pos); @@ -69,10 +69,10 @@ export class ScriptQuestionMessage implements MessageBase newObjData['ItemID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['ObjectName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['ObjectName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjData['ObjectOwner'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['ObjectOwner'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjData['Questions'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/ScriptSensorReply.ts b/lib/classes/messages/ScriptSensorReply.ts index 67efdff..80baaa0 100644 --- a/lib/classes/messages/ScriptSensorReply.ts +++ b/lib/classes/messages/ScriptSensorReply.ts @@ -23,7 +23,7 @@ export class ScriptSensorReplyMessage implements MessageBase Position: Vector3; Velocity: Vector3; Rotation: Quaternion; - Name: string; + Name: Buffer; Type: number; Range: number; }[]; @@ -65,7 +65,7 @@ export class ScriptSensorReplyMessage implements MessageBase this.SensedData[i]['Rotation'].writeToBuffer(buf, pos); pos += 12; buf.writeUInt8(this.SensedData[i]['Name'].length, pos++); - buf.write(this.SensedData[i]['Name'], pos); + this.SensedData[i]['Name'].copy(buf, pos); pos += this.SensedData[i]['Name'].length; buf.writeInt32LE(this.SensedData[i]['Type'], pos); pos += 4; @@ -98,7 +98,7 @@ export class ScriptSensorReplyMessage implements MessageBase Position: Vector3, Velocity: Vector3, Rotation: Quaternion, - Name: string, + Name: Buffer, Type: number, Range: number } = { @@ -108,7 +108,7 @@ export class ScriptSensorReplyMessage implements MessageBase Position: Vector3.getZero(), Velocity: Vector3.getZero(), Rotation: Quaternion.getIdentity(), - Name: '', + Name: Buffer.allocUnsafe(0), Type: 0, Range: 0 }; @@ -125,7 +125,7 @@ export class ScriptSensorReplyMessage implements MessageBase newObjSensedData['Rotation'] = new Quaternion(buf, pos); pos += 12; varLength = buf.readUInt8(pos++); - newObjSensedData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjSensedData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjSensedData['Type'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/ScriptSensorRequest.ts b/lib/classes/messages/ScriptSensorRequest.ts index a366833..7517c69 100644 --- a/lib/classes/messages/ScriptSensorRequest.ts +++ b/lib/classes/messages/ScriptSensorRequest.ts @@ -20,7 +20,7 @@ export class ScriptSensorRequestMessage implements MessageBase SearchID: UUID; SearchPos: Vector3; SearchDir: Quaternion; - SearchName: string; + SearchName: Buffer; Type: number; Range: number; Arc: number; @@ -47,7 +47,7 @@ export class ScriptSensorRequestMessage implements MessageBase this.Requester['SearchDir'].writeToBuffer(buf, pos); pos += 12; buf.writeUInt8(this.Requester['SearchName'].length, pos++); - buf.write(this.Requester['SearchName'], pos); + this.Requester['SearchName'].copy(buf, pos); pos += this.Requester['SearchName'].length; buf.writeInt32LE(this.Requester['Type'], pos); pos += 4; @@ -73,7 +73,7 @@ export class ScriptSensorRequestMessage implements MessageBase SearchID: UUID, SearchPos: Vector3, SearchDir: Quaternion, - SearchName: string, + SearchName: Buffer, Type: number, Range: number, Arc: number, @@ -85,7 +85,7 @@ export class ScriptSensorRequestMessage implements MessageBase SearchID: UUID.zero(), SearchPos: Vector3.getZero(), SearchDir: Quaternion.getIdentity(), - SearchName: '', + SearchName: Buffer.allocUnsafe(0), Type: 0, Range: 0, Arc: 0, @@ -103,7 +103,7 @@ export class ScriptSensorRequestMessage implements MessageBase newObjRequester['SearchDir'] = new Quaternion(buf, pos); pos += 12; varLength = buf.readUInt8(pos++); - newObjRequester['SearchName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjRequester['SearchName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjRequester['Type'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/ScriptTeleportRequest.ts b/lib/classes/messages/ScriptTeleportRequest.ts index 3ad0f3e..6cc13ff 100644 --- a/lib/classes/messages/ScriptTeleportRequest.ts +++ b/lib/classes/messages/ScriptTeleportRequest.ts @@ -12,8 +12,8 @@ export class ScriptTeleportRequestMessage implements MessageBase id = Message.ScriptTeleportRequest; Data: { - ObjectName: string; - SimName: string; + ObjectName: Buffer; + SimName: Buffer; SimPosition: Vector3; LookAt: Vector3; }; @@ -27,10 +27,10 @@ export class ScriptTeleportRequestMessage implements MessageBase { const startPos = pos; buf.writeUInt8(this.Data['ObjectName'].length, pos++); - buf.write(this.Data['ObjectName'], pos); + this.Data['ObjectName'].copy(buf, pos); pos += this.Data['ObjectName'].length; buf.writeUInt8(this.Data['SimName'].length, pos++); - buf.write(this.Data['SimName'], pos); + this.Data['SimName'].copy(buf, pos); pos += this.Data['SimName'].length; this.Data['SimPosition'].writeToBuffer(buf, pos, false); pos += 12; @@ -44,21 +44,21 @@ export class ScriptTeleportRequestMessage implements MessageBase const startPos = pos; let varLength = 0; const newObjData: { - ObjectName: string, - SimName: string, + ObjectName: Buffer, + SimName: Buffer, SimPosition: Vector3, LookAt: Vector3 } = { - ObjectName: '', - SimName: '', + ObjectName: Buffer.allocUnsafe(0), + SimName: Buffer.allocUnsafe(0), SimPosition: Vector3.getZero(), LookAt: Vector3.getZero() }; varLength = buf.readUInt8(pos++); - newObjData['ObjectName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['ObjectName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjData['SimName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['SimName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjData['SimPosition'] = new Vector3(buf, pos, false); pos += 12; diff --git a/lib/classes/messages/SendPostcard.ts b/lib/classes/messages/SendPostcard.ts index 9a8c05c..cb538c3 100644 --- a/lib/classes/messages/SendPostcard.ts +++ b/lib/classes/messages/SendPostcard.ts @@ -17,11 +17,11 @@ export class SendPostcardMessage implements MessageBase SessionID: UUID; AssetID: UUID; PosGlobal: Vector3; - To: string; - From: string; - Name: string; - Subject: string; - Msg: string; + To: Buffer; + From: Buffer; + Name: Buffer; + Subject: Buffer; + Msg: Buffer; AllowPublish: boolean; MaturePublish: boolean; }; @@ -43,20 +43,20 @@ export class SendPostcardMessage implements MessageBase this.AgentData['PosGlobal'].writeToBuffer(buf, pos, true); pos += 24; buf.writeUInt8(this.AgentData['To'].length, pos++); - buf.write(this.AgentData['To'], pos); + this.AgentData['To'].copy(buf, pos); pos += this.AgentData['To'].length; buf.writeUInt8(this.AgentData['From'].length, pos++); - buf.write(this.AgentData['From'], pos); + this.AgentData['From'].copy(buf, pos); pos += this.AgentData['From'].length; buf.writeUInt8(this.AgentData['Name'].length, pos++); - buf.write(this.AgentData['Name'], pos); + this.AgentData['Name'].copy(buf, pos); pos += this.AgentData['Name'].length; buf.writeUInt8(this.AgentData['Subject'].length, pos++); - buf.write(this.AgentData['Subject'], pos); + this.AgentData['Subject'].copy(buf, pos); pos += this.AgentData['Subject'].length; buf.writeUInt16LE(this.AgentData['Msg'].length, pos); pos += 2; - buf.write(this.AgentData['Msg'], pos); + this.AgentData['Msg'].copy(buf, pos); pos += this.AgentData['Msg'].length; buf.writeUInt8((this.AgentData['AllowPublish']) ? 1 : 0, pos++); buf.writeUInt8((this.AgentData['MaturePublish']) ? 1 : 0, pos++); @@ -72,11 +72,11 @@ export class SendPostcardMessage implements MessageBase SessionID: UUID, AssetID: UUID, PosGlobal: Vector3, - To: string, - From: string, - Name: string, - Subject: string, - Msg: string, + To: Buffer, + From: Buffer, + Name: Buffer, + Subject: Buffer, + Msg: Buffer, AllowPublish: boolean, MaturePublish: boolean } = { @@ -84,11 +84,11 @@ export class SendPostcardMessage implements MessageBase SessionID: UUID.zero(), AssetID: UUID.zero(), PosGlobal: Vector3.getZero(), - To: '', - From: '', - Name: '', - Subject: '', - Msg: '', + To: Buffer.allocUnsafe(0), + From: Buffer.allocUnsafe(0), + Name: Buffer.allocUnsafe(0), + Subject: Buffer.allocUnsafe(0), + Msg: Buffer.allocUnsafe(0), AllowPublish: false, MaturePublish: false }; @@ -101,20 +101,20 @@ export class SendPostcardMessage implements MessageBase newObjAgentData['PosGlobal'] = new Vector3(buf, pos, true); pos += 24; varLength = buf.readUInt8(pos++); - newObjAgentData['To'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAgentData['To'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjAgentData['From'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAgentData['From'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjAgentData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAgentData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjAgentData['Subject'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAgentData['Subject'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjAgentData['Msg'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAgentData['Msg'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjAgentData['AllowPublish'] = (buf.readUInt8(pos++) === 1); newObjAgentData['MaturePublish'] = (buf.readUInt8(pos++) === 1); diff --git a/lib/classes/messages/SendXferPacket.ts b/lib/classes/messages/SendXferPacket.ts index 733da80..2ee7d97 100644 --- a/lib/classes/messages/SendXferPacket.ts +++ b/lib/classes/messages/SendXferPacket.ts @@ -16,7 +16,7 @@ export class SendXferPacketMessage implements MessageBase Packet: number; }; DataPacket: { - Data: string; + Data: Buffer; }; getSize(): number @@ -35,7 +35,7 @@ export class SendXferPacketMessage implements MessageBase pos += 4; buf.writeUInt16LE(this.DataPacket['Data'].length, pos); pos += 2; - buf.write(this.DataPacket['Data'], pos); + this.DataPacket['Data'].copy(buf, pos); pos += this.DataPacket['Data'].length; return pos - startPos; } @@ -57,13 +57,13 @@ export class SendXferPacketMessage implements MessageBase pos += 4; this.XferID = newObjXferID; const newObjDataPacket: { - Data: string + Data: Buffer } = { - Data: '' + Data: Buffer.allocUnsafe(0) }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjDataPacket['Data'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataPacket['Data'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.DataPacket = newObjDataPacket; return pos - startPos; diff --git a/lib/classes/messages/SetSimPresenceInDatabase.ts b/lib/classes/messages/SetSimPresenceInDatabase.ts index fd9fd24..ee921df 100644 --- a/lib/classes/messages/SetSimPresenceInDatabase.ts +++ b/lib/classes/messages/SetSimPresenceInDatabase.ts @@ -13,13 +13,13 @@ export class SetSimPresenceInDatabaseMessage implements MessageBase SimData: { RegionID: UUID; - HostName: string; + HostName: Buffer; GridX: number; GridY: number; PID: number; AgentCount: number; TimeToLive: number; - Status: string; + Status: Buffer; }; getSize(): number @@ -33,7 +33,7 @@ export class SetSimPresenceInDatabaseMessage implements MessageBase this.SimData['RegionID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.SimData['HostName'].length, pos++); - buf.write(this.SimData['HostName'], pos); + this.SimData['HostName'].copy(buf, pos); pos += this.SimData['HostName'].length; buf.writeUInt32LE(this.SimData['GridX'], pos); pos += 4; @@ -46,7 +46,7 @@ export class SetSimPresenceInDatabaseMessage implements MessageBase buf.writeInt32LE(this.SimData['TimeToLive'], pos); pos += 4; buf.writeUInt8(this.SimData['Status'].length, pos++); - buf.write(this.SimData['Status'], pos); + this.SimData['Status'].copy(buf, pos); pos += this.SimData['Status'].length; return pos - startPos; } @@ -57,27 +57,27 @@ export class SetSimPresenceInDatabaseMessage implements MessageBase let varLength = 0; const newObjSimData: { RegionID: UUID, - HostName: string, + HostName: Buffer, GridX: number, GridY: number, PID: number, AgentCount: number, TimeToLive: number, - Status: string + Status: Buffer } = { RegionID: UUID.zero(), - HostName: '', + HostName: Buffer.allocUnsafe(0), GridX: 0, GridY: 0, PID: 0, AgentCount: 0, TimeToLive: 0, - Status: '' + Status: Buffer.allocUnsafe(0) }; newObjSimData['RegionID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjSimData['HostName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjSimData['HostName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjSimData['GridX'] = buf.readUInt32LE(pos); pos += 4; @@ -90,7 +90,7 @@ export class SetSimPresenceInDatabaseMessage implements MessageBase newObjSimData['TimeToLive'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjSimData['Status'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjSimData['Status'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.SimData = newObjSimData; return pos - startPos; diff --git a/lib/classes/messages/SetSimStatusInDatabase.ts b/lib/classes/messages/SetSimStatusInDatabase.ts index 9ef44cd..fdcfcfb 100644 --- a/lib/classes/messages/SetSimStatusInDatabase.ts +++ b/lib/classes/messages/SetSimStatusInDatabase.ts @@ -13,13 +13,13 @@ export class SetSimStatusInDatabaseMessage implements MessageBase Data: { RegionID: UUID; - HostName: string; + HostName: Buffer; X: number; Y: number; PID: number; AgentCount: number; TimeToLive: number; - Status: string; + Status: Buffer; }; getSize(): number @@ -33,7 +33,7 @@ export class SetSimStatusInDatabaseMessage implements MessageBase this.Data['RegionID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.Data['HostName'].length, pos++); - buf.write(this.Data['HostName'], pos); + this.Data['HostName'].copy(buf, pos); pos += this.Data['HostName'].length; buf.writeInt32LE(this.Data['X'], pos); pos += 4; @@ -46,7 +46,7 @@ export class SetSimStatusInDatabaseMessage implements MessageBase buf.writeInt32LE(this.Data['TimeToLive'], pos); pos += 4; buf.writeUInt8(this.Data['Status'].length, pos++); - buf.write(this.Data['Status'], pos); + this.Data['Status'].copy(buf, pos); pos += this.Data['Status'].length; return pos - startPos; } @@ -57,27 +57,27 @@ export class SetSimStatusInDatabaseMessage implements MessageBase let varLength = 0; const newObjData: { RegionID: UUID, - HostName: string, + HostName: Buffer, X: number, Y: number, PID: number, AgentCount: number, TimeToLive: number, - Status: string + Status: Buffer } = { RegionID: UUID.zero(), - HostName: '', + HostName: Buffer.allocUnsafe(0), X: 0, Y: 0, PID: 0, AgentCount: 0, TimeToLive: 0, - Status: '' + Status: Buffer.allocUnsafe(0) }; newObjData['RegionID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['HostName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['HostName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjData['X'] = buf.readInt32LE(pos); pos += 4; @@ -90,7 +90,7 @@ export class SetSimStatusInDatabaseMessage implements MessageBase newObjData['TimeToLive'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjData['Status'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjData['Status'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.Data = newObjData; return pos - startPos; diff --git a/lib/classes/messages/SetStartLocationRequest.ts b/lib/classes/messages/SetStartLocationRequest.ts index a1a56bb..32b858d 100644 --- a/lib/classes/messages/SetStartLocationRequest.ts +++ b/lib/classes/messages/SetStartLocationRequest.ts @@ -17,7 +17,7 @@ export class SetStartLocationRequestMessage implements MessageBase SessionID: UUID; }; StartLocationData: { - SimName: string; + SimName: Buffer; LocationID: number; LocationPos: Vector3; LocationLookAt: Vector3; @@ -36,7 +36,7 @@ export class SetStartLocationRequestMessage implements MessageBase this.AgentData['SessionID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.StartLocationData['SimName'].length, pos++); - buf.write(this.StartLocationData['SimName'], pos); + this.StartLocationData['SimName'].copy(buf, pos); pos += this.StartLocationData['SimName'].length; buf.writeUInt32LE(this.StartLocationData['LocationID'], pos); pos += 4; @@ -64,18 +64,18 @@ export class SetStartLocationRequestMessage implements MessageBase pos += 16; this.AgentData = newObjAgentData; const newObjStartLocationData: { - SimName: string, + SimName: Buffer, LocationID: number, LocationPos: Vector3, LocationLookAt: Vector3 } = { - SimName: '', + SimName: Buffer.allocUnsafe(0), LocationID: 0, LocationPos: Vector3.getZero(), LocationLookAt: Vector3.getZero() }; varLength = buf.readUInt8(pos++); - newObjStartLocationData['SimName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjStartLocationData['SimName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjStartLocationData['LocationID'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/SimulatorPresentAtLocation.ts b/lib/classes/messages/SimulatorPresentAtLocation.ts index 3b1482f..58ef7fd 100644 --- a/lib/classes/messages/SimulatorPresentAtLocation.ts +++ b/lib/classes/messages/SimulatorPresentAtLocation.ts @@ -24,7 +24,7 @@ export class SimulatorPresentAtLocationMessage implements MessageBase Port: number; }[]; SimulatorBlock: { - SimName: string; + SimName: Buffer; SimAccess: number; RegionFlags: number; RegionID: UUID; @@ -61,7 +61,7 @@ export class SimulatorPresentAtLocationMessage implements MessageBase pos += 2; } buf.writeUInt8(this.SimulatorBlock['SimName'].length, pos++); - buf.write(this.SimulatorBlock['SimName'], pos); + this.SimulatorBlock['SimName'].copy(buf, pos); pos += this.SimulatorBlock['SimName'].length; buf.writeUInt8(this.SimulatorBlock['SimAccess'], pos++); buf.writeUInt32LE(this.SimulatorBlock['RegionFlags'], pos); @@ -124,14 +124,14 @@ export class SimulatorPresentAtLocationMessage implements MessageBase this.NeighborBlock.push(newObjNeighborBlock); } const newObjSimulatorBlock: { - SimName: string, + SimName: Buffer, SimAccess: number, RegionFlags: number, RegionID: UUID, EstateID: number, ParentEstateID: number } = { - SimName: '', + SimName: Buffer.allocUnsafe(0), SimAccess: 0, RegionFlags: 0, RegionID: UUID.zero(), @@ -139,7 +139,7 @@ export class SimulatorPresentAtLocationMessage implements MessageBase ParentEstateID: 0 }; varLength = buf.readUInt8(pos++); - newObjSimulatorBlock['SimName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjSimulatorBlock['SimName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjSimulatorBlock['SimAccess'] = buf.readUInt8(pos++); newObjSimulatorBlock['RegionFlags'] = buf.readUInt32LE(pos); diff --git a/lib/classes/messages/SimulatorReady.ts b/lib/classes/messages/SimulatorReady.ts index d27797b..b077457 100644 --- a/lib/classes/messages/SimulatorReady.ts +++ b/lib/classes/messages/SimulatorReady.ts @@ -13,7 +13,7 @@ export class SimulatorReadyMessage implements MessageBase id = Message.SimulatorReady; SimulatorBlock: { - SimName: string; + SimName: Buffer; SimAccess: number; RegionFlags: number; RegionID: UUID; @@ -34,7 +34,7 @@ export class SimulatorReadyMessage implements MessageBase { const startPos = pos; buf.writeUInt8(this.SimulatorBlock['SimName'].length, pos++); - buf.write(this.SimulatorBlock['SimName'], pos); + this.SimulatorBlock['SimName'].copy(buf, pos); pos += this.SimulatorBlock['SimName'].length; buf.writeUInt8(this.SimulatorBlock['SimAccess'], pos++); buf.writeUInt32LE(this.SimulatorBlock['RegionFlags'], pos); @@ -56,14 +56,14 @@ export class SimulatorReadyMessage implements MessageBase const startPos = pos; let varLength = 0; const newObjSimulatorBlock: { - SimName: string, + SimName: Buffer, SimAccess: number, RegionFlags: number, RegionID: UUID, EstateID: number, ParentEstateID: number } = { - SimName: '', + SimName: Buffer.allocUnsafe(0), SimAccess: 0, RegionFlags: 0, RegionID: UUID.zero(), @@ -71,7 +71,7 @@ export class SimulatorReadyMessage implements MessageBase ParentEstateID: 0 }; varLength = buf.readUInt8(pos++); - newObjSimulatorBlock['SimName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjSimulatorBlock['SimName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjSimulatorBlock['SimAccess'] = buf.readUInt8(pos++); newObjSimulatorBlock['RegionFlags'] = buf.readUInt32LE(pos); diff --git a/lib/classes/messages/StartAuction.ts b/lib/classes/messages/StartAuction.ts index 2b5ceb4..4d11332 100644 --- a/lib/classes/messages/StartAuction.ts +++ b/lib/classes/messages/StartAuction.ts @@ -17,7 +17,7 @@ export class StartAuctionMessage implements MessageBase ParcelData: { ParcelID: UUID; SnapshotID: UUID; - Name: string; + Name: Buffer; }; getSize(): number @@ -35,7 +35,7 @@ export class StartAuctionMessage implements MessageBase this.ParcelData['SnapshotID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.ParcelData['Name'].length, pos++); - buf.write(this.ParcelData['Name'], pos); + this.ParcelData['Name'].copy(buf, pos); pos += this.ParcelData['Name'].length; return pos - startPos; } @@ -55,18 +55,18 @@ export class StartAuctionMessage implements MessageBase const newObjParcelData: { ParcelID: UUID, SnapshotID: UUID, - Name: string + Name: Buffer } = { ParcelID: UUID.zero(), SnapshotID: UUID.zero(), - Name: '' + Name: Buffer.allocUnsafe(0) }; newObjParcelData['ParcelID'] = new UUID(buf, pos); pos += 16; newObjParcelData['SnapshotID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjParcelData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjParcelData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ParcelData = newObjParcelData; return pos - startPos; diff --git a/lib/classes/messages/StartGroupProposal.ts b/lib/classes/messages/StartGroupProposal.ts index 4d40049..1caa716 100644 --- a/lib/classes/messages/StartGroupProposal.ts +++ b/lib/classes/messages/StartGroupProposal.ts @@ -20,7 +20,7 @@ export class StartGroupProposalMessage implements MessageBase Quorum: number; Majority: number; Duration: number; - ProposalText: string; + ProposalText: Buffer; }; getSize(): number @@ -44,7 +44,7 @@ export class StartGroupProposalMessage implements MessageBase buf.writeInt32LE(this.ProposalData['Duration'], pos); pos += 4; buf.writeUInt8(this.ProposalData['ProposalText'].length, pos++); - buf.write(this.ProposalData['ProposalText'], pos); + this.ProposalData['ProposalText'].copy(buf, pos); pos += this.ProposalData['ProposalText'].length; return pos - startPos; } @@ -70,13 +70,13 @@ export class StartGroupProposalMessage implements MessageBase Quorum: number, Majority: number, Duration: number, - ProposalText: string + ProposalText: Buffer } = { GroupID: UUID.zero(), Quorum: 0, Majority: 0, Duration: 0, - ProposalText: '' + ProposalText: Buffer.allocUnsafe(0) }; newObjProposalData['GroupID'] = new UUID(buf, pos); pos += 16; @@ -87,7 +87,7 @@ export class StartGroupProposalMessage implements MessageBase newObjProposalData['Duration'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjProposalData['ProposalText'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjProposalData['ProposalText'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ProposalData = newObjProposalData; return pos - startPos; diff --git a/lib/classes/messages/StartLure.ts b/lib/classes/messages/StartLure.ts index 1dcb5d6..81ff0d6 100644 --- a/lib/classes/messages/StartLure.ts +++ b/lib/classes/messages/StartLure.ts @@ -17,7 +17,7 @@ export class StartLureMessage implements MessageBase }; Info: { LureType: number; - Message: string; + Message: Buffer; }; TargetData: { TargetID: UUID; @@ -37,7 +37,7 @@ export class StartLureMessage implements MessageBase pos += 16; buf.writeUInt8(this.Info['LureType'], pos++); buf.writeUInt8(this.Info['Message'].length, pos++); - buf.write(this.Info['Message'], pos); + this.Info['Message'].copy(buf, pos); pos += this.Info['Message'].length; const count = this.TargetData.length; buf.writeUInt8(this.TargetData.length, pos++); @@ -67,14 +67,14 @@ export class StartLureMessage implements MessageBase this.AgentData = newObjAgentData; const newObjInfo: { LureType: number, - Message: string + Message: Buffer } = { LureType: 0, - Message: '' + Message: Buffer.allocUnsafe(0) }; newObjInfo['LureType'] = buf.readUInt8(pos++); varLength = buf.readUInt8(pos++); - newObjInfo['Message'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInfo['Message'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.Info = newObjInfo; const count = buf.readUInt8(pos++); diff --git a/lib/classes/messages/StateSave.ts b/lib/classes/messages/StateSave.ts index 6bea93e..1aacfe0 100644 --- a/lib/classes/messages/StateSave.ts +++ b/lib/classes/messages/StateSave.ts @@ -16,7 +16,7 @@ export class StateSaveMessage implements MessageBase SessionID: UUID; }; DataBlock: { - Filename: string; + Filename: Buffer; }; getSize(): number @@ -32,7 +32,7 @@ export class StateSaveMessage implements MessageBase this.AgentData['SessionID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.DataBlock['Filename'].length, pos++); - buf.write(this.DataBlock['Filename'], pos); + this.DataBlock['Filename'].copy(buf, pos); pos += this.DataBlock['Filename'].length; return pos - startPos; } @@ -54,12 +54,12 @@ export class StateSaveMessage implements MessageBase pos += 16; this.AgentData = newObjAgentData; const newObjDataBlock: { - Filename: string + Filename: Buffer } = { - Filename: '' + Filename: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjDataBlock['Filename'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjDataBlock['Filename'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.DataBlock = newObjDataBlock; return pos - startPos; diff --git a/lib/classes/messages/SystemMessage.ts b/lib/classes/messages/SystemMessage.ts index 4779bee..427382e 100644 --- a/lib/classes/messages/SystemMessage.ts +++ b/lib/classes/messages/SystemMessage.ts @@ -12,12 +12,12 @@ export class SystemMessageMessage implements MessageBase id = Message.SystemMessage; MethodData: { - Method: string; + Method: Buffer; Invoice: UUID; Digest: Buffer; }; ParamList: { - Parameter: string; + Parameter: Buffer; }[]; getSize(): number @@ -39,7 +39,7 @@ export class SystemMessageMessage implements MessageBase { const startPos = pos; buf.writeUInt8(this.MethodData['Method'].length, pos++); - buf.write(this.MethodData['Method'], pos); + this.MethodData['Method'].copy(buf, pos); pos += this.MethodData['Method'].length; this.MethodData['Invoice'].writeToBuffer(buf, pos); pos += 16; @@ -50,7 +50,7 @@ export class SystemMessageMessage implements MessageBase for (let i = 0; i < count; i++) { buf.writeUInt8(this.ParamList[i]['Parameter'].length, pos++); - buf.write(this.ParamList[i]['Parameter'], pos); + this.ParamList[i]['Parameter'].copy(buf, pos); pos += this.ParamList[i]['Parameter'].length; } return pos - startPos; @@ -61,16 +61,16 @@ export class SystemMessageMessage implements MessageBase const startPos = pos; let varLength = 0; const newObjMethodData: { - Method: string, + Method: Buffer, Invoice: UUID, Digest: Buffer } = { - Method: '', + Method: Buffer.allocUnsafe(0), Invoice: UUID.zero(), Digest: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjMethodData['Method'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMethodData['Method'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjMethodData['Invoice'] = new UUID(buf, pos); pos += 16; @@ -82,12 +82,12 @@ export class SystemMessageMessage implements MessageBase for (let i = 0; i < count; i++) { const newObjParamList: { - Parameter: string + Parameter: Buffer } = { - Parameter: '' + Parameter: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjParamList['Parameter'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjParamList['Parameter'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ParamList.push(newObjParamList); } diff --git a/lib/classes/messages/TelehubInfo.ts b/lib/classes/messages/TelehubInfo.ts index 663d394..73535b0 100644 --- a/lib/classes/messages/TelehubInfo.ts +++ b/lib/classes/messages/TelehubInfo.ts @@ -15,7 +15,7 @@ export class TelehubInfoMessage implements MessageBase TelehubBlock: { ObjectID: UUID; - ObjectName: string; + ObjectName: Buffer; TelehubPos: Vector3; TelehubRot: Quaternion; }; @@ -34,7 +34,7 @@ export class TelehubInfoMessage implements MessageBase this.TelehubBlock['ObjectID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.TelehubBlock['ObjectName'].length, pos++); - buf.write(this.TelehubBlock['ObjectName'], pos); + this.TelehubBlock['ObjectName'].copy(buf, pos); pos += this.TelehubBlock['ObjectName'].length; this.TelehubBlock['TelehubPos'].writeToBuffer(buf, pos, false); pos += 12; @@ -56,19 +56,19 @@ export class TelehubInfoMessage implements MessageBase let varLength = 0; const newObjTelehubBlock: { ObjectID: UUID, - ObjectName: string, + ObjectName: Buffer, TelehubPos: Vector3, TelehubRot: Quaternion } = { ObjectID: UUID.zero(), - ObjectName: '', + ObjectName: Buffer.allocUnsafe(0), TelehubPos: Vector3.getZero(), TelehubRot: Quaternion.getIdentity() }; newObjTelehubBlock['ObjectID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjTelehubBlock['ObjectName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjTelehubBlock['ObjectName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjTelehubBlock['TelehubPos'] = new Vector3(buf, pos, false); pos += 12; diff --git a/lib/classes/messages/TeleportFailed.ts b/lib/classes/messages/TeleportFailed.ts index fe59301..db28f8b 100644 --- a/lib/classes/messages/TeleportFailed.ts +++ b/lib/classes/messages/TeleportFailed.ts @@ -13,11 +13,11 @@ export class TeleportFailedMessage implements MessageBase Info: { AgentID: UUID; - Reason: string; + Reason: Buffer; }; AlertInfo: { - Message: string; - ExtraParams: string; + Message: Buffer; + ExtraParams: Buffer; }[]; getSize(): number @@ -41,17 +41,17 @@ export class TeleportFailedMessage implements MessageBase this.Info['AgentID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.Info['Reason'].length, pos++); - buf.write(this.Info['Reason'], pos); + this.Info['Reason'].copy(buf, pos); pos += this.Info['Reason'].length; const count = this.AlertInfo.length; buf.writeUInt8(this.AlertInfo.length, pos++); for (let i = 0; i < count; i++) { buf.writeUInt8(this.AlertInfo[i]['Message'].length, pos++); - buf.write(this.AlertInfo[i]['Message'], pos); + this.AlertInfo[i]['Message'].copy(buf, pos); pos += this.AlertInfo[i]['Message'].length; buf.writeUInt8(this.AlertInfo[i]['ExtraParams'].length, pos++); - buf.write(this.AlertInfo[i]['ExtraParams'], pos); + this.AlertInfo[i]['ExtraParams'].copy(buf, pos); pos += this.AlertInfo[i]['ExtraParams'].length; } return pos - startPos; @@ -63,15 +63,15 @@ export class TeleportFailedMessage implements MessageBase let varLength = 0; const newObjInfo: { AgentID: UUID, - Reason: string + Reason: Buffer } = { AgentID: UUID.zero(), - Reason: '' + Reason: Buffer.allocUnsafe(0) }; newObjInfo['AgentID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjInfo['Reason'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInfo['Reason'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.Info = newObjInfo; const count = buf.readUInt8(pos++); @@ -79,17 +79,17 @@ export class TeleportFailedMessage implements MessageBase for (let i = 0; i < count; i++) { const newObjAlertInfo: { - Message: string, - ExtraParams: string + Message: Buffer, + ExtraParams: Buffer } = { - Message: '', - ExtraParams: '' + Message: Buffer.allocUnsafe(0), + ExtraParams: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjAlertInfo['Message'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAlertInfo['Message'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjAlertInfo['ExtraParams'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAlertInfo['ExtraParams'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.AlertInfo.push(newObjAlertInfo); } diff --git a/lib/classes/messages/TeleportFinish.ts b/lib/classes/messages/TeleportFinish.ts index 178dec8..5cb212f 100644 --- a/lib/classes/messages/TeleportFinish.ts +++ b/lib/classes/messages/TeleportFinish.ts @@ -19,7 +19,7 @@ export class TeleportFinishMessage implements MessageBase SimIP: IPAddress; SimPort: number; RegionHandle: Long; - SeedCapability: string; + SeedCapability: Buffer; SimAccess: number; TeleportFlags: number; }; @@ -46,7 +46,7 @@ export class TeleportFinishMessage implements MessageBase pos += 4; buf.writeUInt16LE(this.Info['SeedCapability'].length, pos); pos += 2; - buf.write(this.Info['SeedCapability'], pos); + this.Info['SeedCapability'].copy(buf, pos); pos += this.Info['SeedCapability'].length; buf.writeUInt8(this.Info['SimAccess'], pos++); buf.writeUInt32LE(this.Info['TeleportFlags'], pos); @@ -64,7 +64,7 @@ export class TeleportFinishMessage implements MessageBase SimIP: IPAddress, SimPort: number, RegionHandle: Long, - SeedCapability: string, + SeedCapability: Buffer, SimAccess: number, TeleportFlags: number } = { @@ -73,7 +73,7 @@ export class TeleportFinishMessage implements MessageBase SimIP: IPAddress.zero(), SimPort: 0, RegionHandle: Long.ZERO, - SeedCapability: '', + SeedCapability: Buffer.allocUnsafe(0), SimAccess: 0, TeleportFlags: 0 }; @@ -89,7 +89,7 @@ export class TeleportFinishMessage implements MessageBase pos += 8; varLength = buf.readUInt16LE(pos); pos += 2; - newObjInfo['SeedCapability'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInfo['SeedCapability'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjInfo['SimAccess'] = buf.readUInt8(pos++); newObjInfo['TeleportFlags'] = buf.readUInt32LE(pos); diff --git a/lib/classes/messages/TeleportProgress.ts b/lib/classes/messages/TeleportProgress.ts index 784da24..7de5b68 100644 --- a/lib/classes/messages/TeleportProgress.ts +++ b/lib/classes/messages/TeleportProgress.ts @@ -16,7 +16,7 @@ export class TeleportProgressMessage implements MessageBase }; Info: { TeleportFlags: number; - Message: string; + Message: Buffer; }; getSize(): number @@ -32,7 +32,7 @@ export class TeleportProgressMessage implements MessageBase buf.writeUInt32LE(this.Info['TeleportFlags'], pos); pos += 4; buf.writeUInt8(this.Info['Message'].length, pos++); - buf.write(this.Info['Message'], pos); + this.Info['Message'].copy(buf, pos); pos += this.Info['Message'].length; return pos - startPos; } @@ -51,15 +51,15 @@ export class TeleportProgressMessage implements MessageBase this.AgentData = newObjAgentData; const newObjInfo: { TeleportFlags: number, - Message: string + Message: Buffer } = { TeleportFlags: 0, - Message: '' + Message: Buffer.allocUnsafe(0) }; newObjInfo['TeleportFlags'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjInfo['Message'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInfo['Message'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.Info = newObjInfo; return pos - startPos; diff --git a/lib/classes/messages/TransferInfo.ts b/lib/classes/messages/TransferInfo.ts index 7f8e2f2..a3d1b45 100644 --- a/lib/classes/messages/TransferInfo.ts +++ b/lib/classes/messages/TransferInfo.ts @@ -17,7 +17,7 @@ export class TransferInfoMessage implements MessageBase TargetType: number; Status: number; Size: number; - Params: string; + Params: Buffer; }; getSize(): number @@ -40,7 +40,7 @@ export class TransferInfoMessage implements MessageBase pos += 4; buf.writeUInt16LE(this.TransferInfo['Params'].length, pos); pos += 2; - buf.write(this.TransferInfo['Params'], pos); + this.TransferInfo['Params'].copy(buf, pos); pos += this.TransferInfo['Params'].length; return pos - startPos; } @@ -55,14 +55,14 @@ export class TransferInfoMessage implements MessageBase TargetType: number, Status: number, Size: number, - Params: string + Params: Buffer } = { TransferID: UUID.zero(), ChannelType: 0, TargetType: 0, Status: 0, Size: 0, - Params: '' + Params: Buffer.allocUnsafe(0) }; newObjTransferInfo['TransferID'] = new UUID(buf, pos); pos += 16; @@ -76,7 +76,7 @@ export class TransferInfoMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjTransferInfo['Params'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjTransferInfo['Params'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.TransferInfo = newObjTransferInfo; return pos - startPos; diff --git a/lib/classes/messages/TransferPacket.ts b/lib/classes/messages/TransferPacket.ts index 15dc145..acffbfa 100644 --- a/lib/classes/messages/TransferPacket.ts +++ b/lib/classes/messages/TransferPacket.ts @@ -16,7 +16,7 @@ export class TransferPacketMessage implements MessageBase ChannelType: number; Packet: number; Status: number; - Data: string; + Data: Buffer; }; getSize(): number @@ -37,7 +37,7 @@ export class TransferPacketMessage implements MessageBase pos += 4; buf.writeUInt16LE(this.TransferData['Data'].length, pos); pos += 2; - buf.write(this.TransferData['Data'], pos); + this.TransferData['Data'].copy(buf, pos); pos += this.TransferData['Data'].length; return pos - startPos; } @@ -51,13 +51,13 @@ export class TransferPacketMessage implements MessageBase ChannelType: number, Packet: number, Status: number, - Data: string + Data: Buffer } = { TransferID: UUID.zero(), ChannelType: 0, Packet: 0, Status: 0, - Data: '' + Data: Buffer.allocUnsafe(0) }; newObjTransferData['TransferID'] = new UUID(buf, pos); pos += 16; @@ -69,7 +69,7 @@ export class TransferPacketMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjTransferData['Data'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjTransferData['Data'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.TransferData = newObjTransferData; return pos - startPos; diff --git a/lib/classes/messages/TransferRequest.ts b/lib/classes/messages/TransferRequest.ts index da050c9..523f666 100644 --- a/lib/classes/messages/TransferRequest.ts +++ b/lib/classes/messages/TransferRequest.ts @@ -16,7 +16,7 @@ export class TransferRequestMessage implements MessageBase ChannelType: number; SourceType: number; Priority: number; - Params: string; + Params: Buffer; }; getSize(): number @@ -37,7 +37,7 @@ export class TransferRequestMessage implements MessageBase pos += 4; buf.writeUInt16LE(this.TransferInfo['Params'].length, pos); pos += 2; - buf.write(this.TransferInfo['Params'], pos); + this.TransferInfo['Params'].copy(buf, pos); pos += this.TransferInfo['Params'].length; return pos - startPos; } @@ -51,13 +51,13 @@ export class TransferRequestMessage implements MessageBase ChannelType: number, SourceType: number, Priority: number, - Params: string + Params: Buffer } = { TransferID: UUID.zero(), ChannelType: 0, SourceType: 0, Priority: 0, - Params: '' + Params: Buffer.allocUnsafe(0) }; newObjTransferInfo['TransferID'] = new UUID(buf, pos); pos += 16; @@ -69,7 +69,7 @@ export class TransferRequestMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjTransferInfo['Params'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjTransferInfo['Params'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.TransferInfo = newObjTransferInfo; return pos - startPos; diff --git a/lib/classes/messages/UUIDGroupNameReply.ts b/lib/classes/messages/UUIDGroupNameReply.ts index 97f8af5..94e4cbd 100644 --- a/lib/classes/messages/UUIDGroupNameReply.ts +++ b/lib/classes/messages/UUIDGroupNameReply.ts @@ -13,7 +13,7 @@ export class UUIDGroupNameReplyMessage implements MessageBase UUIDNameBlock: { ID: UUID; - GroupName: string; + GroupName: Buffer; }[]; getSize(): number @@ -41,7 +41,7 @@ export class UUIDGroupNameReplyMessage implements MessageBase this.UUIDNameBlock[i]['ID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.UUIDNameBlock[i]['GroupName'].length, pos++); - buf.write(this.UUIDNameBlock[i]['GroupName'], pos); + this.UUIDNameBlock[i]['GroupName'].copy(buf, pos); pos += this.UUIDNameBlock[i]['GroupName'].length; } return pos - startPos; @@ -57,15 +57,15 @@ export class UUIDGroupNameReplyMessage implements MessageBase { const newObjUUIDNameBlock: { ID: UUID, - GroupName: string + GroupName: Buffer } = { ID: UUID.zero(), - GroupName: '' + GroupName: Buffer.allocUnsafe(0) }; newObjUUIDNameBlock['ID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjUUIDNameBlock['GroupName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjUUIDNameBlock['GroupName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.UUIDNameBlock.push(newObjUUIDNameBlock); } diff --git a/lib/classes/messages/UUIDNameReply.ts b/lib/classes/messages/UUIDNameReply.ts index 5e69016..3a3d882 100644 --- a/lib/classes/messages/UUIDNameReply.ts +++ b/lib/classes/messages/UUIDNameReply.ts @@ -13,8 +13,8 @@ export class UUIDNameReplyMessage implements MessageBase UUIDNameBlock: { ID: UUID; - FirstName: string; - LastName: string; + FirstName: Buffer; + LastName: Buffer; }[]; getSize(): number @@ -42,10 +42,10 @@ export class UUIDNameReplyMessage implements MessageBase this.UUIDNameBlock[i]['ID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.UUIDNameBlock[i]['FirstName'].length, pos++); - buf.write(this.UUIDNameBlock[i]['FirstName'], pos); + this.UUIDNameBlock[i]['FirstName'].copy(buf, pos); pos += this.UUIDNameBlock[i]['FirstName'].length; buf.writeUInt8(this.UUIDNameBlock[i]['LastName'].length, pos++); - buf.write(this.UUIDNameBlock[i]['LastName'], pos); + this.UUIDNameBlock[i]['LastName'].copy(buf, pos); pos += this.UUIDNameBlock[i]['LastName'].length; } return pos - startPos; @@ -61,20 +61,20 @@ export class UUIDNameReplyMessage implements MessageBase { const newObjUUIDNameBlock: { ID: UUID, - FirstName: string, - LastName: string + FirstName: Buffer, + LastName: Buffer } = { ID: UUID.zero(), - FirstName: '', - LastName: '' + FirstName: Buffer.allocUnsafe(0), + LastName: Buffer.allocUnsafe(0) }; newObjUUIDNameBlock['ID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjUUIDNameBlock['FirstName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjUUIDNameBlock['FirstName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjUUIDNameBlock['LastName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjUUIDNameBlock['LastName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.UUIDNameBlock.push(newObjUUIDNameBlock); } diff --git a/lib/classes/messages/UpdateAttachment.ts b/lib/classes/messages/UpdateAttachment.ts index 7e5d098..fef44aa 100644 --- a/lib/classes/messages/UpdateAttachment.ts +++ b/lib/classes/messages/UpdateAttachment.ts @@ -40,8 +40,8 @@ export class UpdateAttachmentMessage 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 UpdateAttachmentMessage implements MessageBase buf.writeInt32LE(this.InventoryData['SalePrice'], pos); pos += 4; buf.writeUInt8(this.InventoryData['Name'].length, pos++); - buf.write(this.InventoryData['Name'], pos); + this.InventoryData['Name'].copy(buf, pos); pos += this.InventoryData['Name'].length; buf.writeUInt8(this.InventoryData['Description'].length, pos++); - buf.write(this.InventoryData['Description'], pos); + this.InventoryData['Description'].copy(buf, pos); pos += this.InventoryData['Description'].length; buf.writeInt32LE(this.InventoryData['CreationDate'], pos); pos += 4; @@ -155,8 +155,8 @@ export class UpdateAttachmentMessage implements MessageBase Flags: number, SaleType: number, SalePrice: number, - Name: string, - Description: string, + Name: Buffer, + Description: Buffer, CreationDate: number, CRC: number } = { @@ -177,8 +177,8 @@ export class UpdateAttachmentMessage implements MessageBase Flags: 0, SaleType: 0, SalePrice: 0, - Name: '', - Description: '', + Name: Buffer.allocUnsafe(0), + Description: Buffer.allocUnsafe(0), CreationDate: 0, CRC: 0 }; @@ -213,10 +213,10 @@ export class UpdateAttachmentMessage implements MessageBase newObjInventoryData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjInventoryData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInventoryData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjInventoryData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInventoryData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjInventoryData['CreationDate'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/UpdateCreateInventoryItem.ts b/lib/classes/messages/UpdateCreateInventoryItem.ts index b643bdd..bf02815 100644 --- a/lib/classes/messages/UpdateCreateInventoryItem.ts +++ b/lib/classes/messages/UpdateCreateInventoryItem.ts @@ -35,8 +35,8 @@ export class UpdateCreateInventoryItemMessage implements MessageBase Flags: number; SaleType: number; SalePrice: number; - Name: string; - Description: string; + Name: Buffer; + Description: Buffer; CreationDate: number; CRC: number; }[]; @@ -101,10 +101,10 @@ export class UpdateCreateInventoryItemMessage implements MessageBase buf.writeInt32LE(this.InventoryData[i]['SalePrice'], pos); pos += 4; buf.writeUInt8(this.InventoryData[i]['Name'].length, pos++); - buf.write(this.InventoryData[i]['Name'], pos); + this.InventoryData[i]['Name'].copy(buf, pos); pos += this.InventoryData[i]['Name'].length; buf.writeUInt8(this.InventoryData[i]['Description'].length, pos++); - buf.write(this.InventoryData[i]['Description'], pos); + this.InventoryData[i]['Description'].copy(buf, pos); pos += this.InventoryData[i]['Description'].length; buf.writeInt32LE(this.InventoryData[i]['CreationDate'], pos); pos += 4; @@ -156,8 +156,8 @@ export class UpdateCreateInventoryItemMessage implements MessageBase Flags: number, SaleType: number, SalePrice: number, - Name: string, - Description: string, + Name: Buffer, + Description: Buffer, CreationDate: number, CRC: number } = { @@ -179,8 +179,8 @@ export class UpdateCreateInventoryItemMessage implements MessageBase Flags: 0, SaleType: 0, SalePrice: 0, - Name: '', - Description: '', + Name: Buffer.allocUnsafe(0), + Description: Buffer.allocUnsafe(0), CreationDate: 0, CRC: 0 }; @@ -217,10 +217,10 @@ export class UpdateCreateInventoryItemMessage implements MessageBase newObjInventoryData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjInventoryData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInventoryData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjInventoryData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInventoryData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjInventoryData['CreationDate'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/UpdateGroupInfo.ts b/lib/classes/messages/UpdateGroupInfo.ts index b375de2..c5cdc78 100644 --- a/lib/classes/messages/UpdateGroupInfo.ts +++ b/lib/classes/messages/UpdateGroupInfo.ts @@ -17,7 +17,7 @@ export class UpdateGroupInfoMessage implements MessageBase }; GroupData: { GroupID: UUID; - Charter: string; + Charter: Buffer; ShowInList: boolean; InsigniaID: UUID; MembershipFee: number; @@ -42,7 +42,7 @@ export class UpdateGroupInfoMessage implements MessageBase pos += 16; buf.writeUInt16LE(this.GroupData['Charter'].length, pos); pos += 2; - buf.write(this.GroupData['Charter'], pos); + this.GroupData['Charter'].copy(buf, pos); pos += this.GroupData['Charter'].length; buf.writeUInt8((this.GroupData['ShowInList']) ? 1 : 0, pos++); this.GroupData['InsigniaID'].writeToBuffer(buf, pos); @@ -73,7 +73,7 @@ export class UpdateGroupInfoMessage implements MessageBase this.AgentData = newObjAgentData; const newObjGroupData: { GroupID: UUID, - Charter: string, + Charter: Buffer, ShowInList: boolean, InsigniaID: UUID, MembershipFee: number, @@ -82,7 +82,7 @@ export class UpdateGroupInfoMessage implements MessageBase MaturePublish: boolean } = { GroupID: UUID.zero(), - Charter: '', + Charter: Buffer.allocUnsafe(0), ShowInList: false, InsigniaID: UUID.zero(), MembershipFee: 0, @@ -94,7 +94,7 @@ export class UpdateGroupInfoMessage implements MessageBase pos += 16; varLength = buf.readUInt16LE(pos); pos += 2; - newObjGroupData['Charter'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjGroupData['Charter'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjGroupData['ShowInList'] = (buf.readUInt8(pos++) === 1); newObjGroupData['InsigniaID'] = new UUID(buf, pos); diff --git a/lib/classes/messages/UpdateInventoryFolder.ts b/lib/classes/messages/UpdateInventoryFolder.ts index 1ce1ccb..60ea872 100644 --- a/lib/classes/messages/UpdateInventoryFolder.ts +++ b/lib/classes/messages/UpdateInventoryFolder.ts @@ -19,7 +19,7 @@ export class UpdateInventoryFolderMessage implements MessageBase FolderID: UUID; ParentID: UUID; Type: number; - Name: string; + Name: Buffer; }[]; getSize(): number @@ -54,7 +54,7 @@ export class UpdateInventoryFolderMessage implements MessageBase pos += 16; buf.writeInt8(this.FolderData[i]['Type'], pos++); buf.writeUInt8(this.FolderData[i]['Name'].length, pos++); - buf.write(this.FolderData[i]['Name'], pos); + this.FolderData[i]['Name'].copy(buf, pos); pos += this.FolderData[i]['Name'].length; } return pos - startPos; @@ -84,12 +84,12 @@ export class UpdateInventoryFolderMessage implements MessageBase FolderID: UUID, ParentID: UUID, Type: number, - Name: string + Name: Buffer } = { FolderID: UUID.zero(), ParentID: UUID.zero(), Type: 0, - Name: '' + Name: Buffer.allocUnsafe(0) }; newObjFolderData['FolderID'] = new UUID(buf, pos); pos += 16; @@ -97,7 +97,7 @@ export class UpdateInventoryFolderMessage implements MessageBase pos += 16; newObjFolderData['Type'] = buf.readInt8(pos++); varLength = buf.readUInt8(pos++); - newObjFolderData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjFolderData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.FolderData.push(newObjFolderData); } diff --git a/lib/classes/messages/UpdateInventoryItem.ts b/lib/classes/messages/UpdateInventoryItem.ts index 13fd8ea..0b23f01 100644 --- a/lib/classes/messages/UpdateInventoryItem.ts +++ b/lib/classes/messages/UpdateInventoryItem.ts @@ -35,8 +35,8 @@ export class UpdateInventoryItemMessage implements MessageBase Flags: number; SaleType: number; SalePrice: number; - Name: string; - Description: string; + Name: Buffer; + Description: Buffer; CreationDate: number; CRC: number; }[]; @@ -102,10 +102,10 @@ export class UpdateInventoryItemMessage implements MessageBase buf.writeInt32LE(this.InventoryData[i]['SalePrice'], pos); pos += 4; buf.writeUInt8(this.InventoryData[i]['Name'].length, pos++); - buf.write(this.InventoryData[i]['Name'], pos); + this.InventoryData[i]['Name'].copy(buf, pos); pos += this.InventoryData[i]['Name'].length; buf.writeUInt8(this.InventoryData[i]['Description'].length, pos++); - buf.write(this.InventoryData[i]['Description'], pos); + this.InventoryData[i]['Description'].copy(buf, pos); pos += this.InventoryData[i]['Description'].length; buf.writeInt32LE(this.InventoryData[i]['CreationDate'], pos); pos += 4; @@ -158,8 +158,8 @@ export class UpdateInventoryItemMessage implements MessageBase Flags: number, SaleType: number, SalePrice: number, - Name: string, - Description: string, + Name: Buffer, + Description: Buffer, CreationDate: number, CRC: number } = { @@ -181,8 +181,8 @@ export class UpdateInventoryItemMessage implements MessageBase Flags: 0, SaleType: 0, SalePrice: 0, - Name: '', - Description: '', + Name: Buffer.allocUnsafe(0), + Description: Buffer.allocUnsafe(0), CreationDate: 0, CRC: 0 }; @@ -219,10 +219,10 @@ export class UpdateInventoryItemMessage implements MessageBase newObjInventoryData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjInventoryData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInventoryData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjInventoryData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInventoryData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjInventoryData['CreationDate'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/UpdateMuteListEntry.ts b/lib/classes/messages/UpdateMuteListEntry.ts index c1f16f0..debebe2 100644 --- a/lib/classes/messages/UpdateMuteListEntry.ts +++ b/lib/classes/messages/UpdateMuteListEntry.ts @@ -17,7 +17,7 @@ export class UpdateMuteListEntryMessage implements MessageBase }; MuteData: { MuteID: UUID; - MuteName: string; + MuteName: Buffer; MuteType: number; MuteFlags: number; }; @@ -37,7 +37,7 @@ export class UpdateMuteListEntryMessage implements MessageBase this.MuteData['MuteID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.MuteData['MuteName'].length, pos++); - buf.write(this.MuteData['MuteName'], pos); + this.MuteData['MuteName'].copy(buf, pos); pos += this.MuteData['MuteName'].length; buf.writeInt32LE(this.MuteData['MuteType'], pos); pos += 4; @@ -64,19 +64,19 @@ export class UpdateMuteListEntryMessage implements MessageBase this.AgentData = newObjAgentData; const newObjMuteData: { MuteID: UUID, - MuteName: string, + MuteName: Buffer, MuteType: number, MuteFlags: number } = { MuteID: UUID.zero(), - MuteName: '', + MuteName: Buffer.allocUnsafe(0), MuteType: 0, MuteFlags: 0 }; newObjMuteData['MuteID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjMuteData['MuteName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjMuteData['MuteName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjMuteData['MuteType'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/UpdateParcel.ts b/lib/classes/messages/UpdateParcel.ts index 2e173bc..4f6908d 100644 --- a/lib/classes/messages/UpdateParcel.ts +++ b/lib/classes/messages/UpdateParcel.ts @@ -19,9 +19,9 @@ export class UpdateParcelMessage implements MessageBase OwnerID: UUID; GroupOwned: boolean; Status: number; - Name: string; - Description: string; - MusicURL: string; + Name: Buffer; + Description: Buffer; + MusicURL: Buffer; RegionX: number; RegionY: number; ActualArea: number; @@ -56,13 +56,13 @@ export class UpdateParcelMessage implements MessageBase buf.writeUInt8((this.ParcelData['GroupOwned']) ? 1 : 0, pos++); buf.writeUInt8(this.ParcelData['Status'], pos++); buf.writeUInt8(this.ParcelData['Name'].length, pos++); - buf.write(this.ParcelData['Name'], pos); + this.ParcelData['Name'].copy(buf, pos); pos += this.ParcelData['Name'].length; buf.writeUInt8(this.ParcelData['Description'].length, pos++); - buf.write(this.ParcelData['Description'], pos); + this.ParcelData['Description'].copy(buf, pos); pos += this.ParcelData['Description'].length; buf.writeUInt8(this.ParcelData['MusicURL'].length, pos++); - buf.write(this.ParcelData['MusicURL'], pos); + this.ParcelData['MusicURL'].copy(buf, pos); pos += this.ParcelData['MusicURL'].length; buf.writeFloatLE(this.ParcelData['RegionX'], pos); pos += 4; @@ -98,9 +98,9 @@ export class UpdateParcelMessage implements MessageBase OwnerID: UUID, GroupOwned: boolean, Status: number, - Name: string, - Description: string, - MusicURL: string, + Name: Buffer, + Description: Buffer, + MusicURL: Buffer, RegionX: number, RegionY: number, ActualArea: number, @@ -120,9 +120,9 @@ export class UpdateParcelMessage implements MessageBase OwnerID: UUID.zero(), GroupOwned: false, Status: 0, - Name: '', - Description: '', - MusicURL: '', + Name: Buffer.allocUnsafe(0), + Description: Buffer.allocUnsafe(0), + MusicURL: Buffer.allocUnsafe(0), RegionX: 0, RegionY: 0, ActualArea: 0, @@ -146,13 +146,13 @@ export class UpdateParcelMessage implements MessageBase newObjParcelData['GroupOwned'] = (buf.readUInt8(pos++) === 1); newObjParcelData['Status'] = buf.readUInt8(pos++); varLength = buf.readUInt8(pos++); - newObjParcelData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjParcelData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjParcelData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjParcelData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjParcelData['MusicURL'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjParcelData['MusicURL'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjParcelData['RegionX'] = buf.readFloatLE(pos); pos += 4; diff --git a/lib/classes/messages/UpdateSimulator.ts b/lib/classes/messages/UpdateSimulator.ts index 7873502..d8888fb 100644 --- a/lib/classes/messages/UpdateSimulator.ts +++ b/lib/classes/messages/UpdateSimulator.ts @@ -13,7 +13,7 @@ export class UpdateSimulatorMessage implements MessageBase SimulatorInfo: { RegionID: UUID; - SimName: string; + SimName: Buffer; EstateID: number; SimAccess: number; }; @@ -29,7 +29,7 @@ export class UpdateSimulatorMessage implements MessageBase this.SimulatorInfo['RegionID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.SimulatorInfo['SimName'].length, pos++); - buf.write(this.SimulatorInfo['SimName'], pos); + this.SimulatorInfo['SimName'].copy(buf, pos); pos += this.SimulatorInfo['SimName'].length; buf.writeUInt32LE(this.SimulatorInfo['EstateID'], pos); pos += 4; @@ -43,19 +43,19 @@ export class UpdateSimulatorMessage implements MessageBase let varLength = 0; const newObjSimulatorInfo: { RegionID: UUID, - SimName: string, + SimName: Buffer, EstateID: number, SimAccess: number } = { RegionID: UUID.zero(), - SimName: '', + SimName: Buffer.allocUnsafe(0), EstateID: 0, SimAccess: 0 }; newObjSimulatorInfo['RegionID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjSimulatorInfo['SimName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjSimulatorInfo['SimName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjSimulatorInfo['EstateID'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/UpdateTaskInventory.ts b/lib/classes/messages/UpdateTaskInventory.ts index ab797f7..8721b99 100644 --- a/lib/classes/messages/UpdateTaskInventory.ts +++ b/lib/classes/messages/UpdateTaskInventory.ts @@ -37,8 +37,8 @@ export class UpdateTaskInventoryMessage implements MessageBase Flags: number; SaleType: number; SalePrice: number; - Name: string; - Description: string; + Name: Buffer; + Description: Buffer; CreationDate: number; CRC: number; }; @@ -89,10 +89,10 @@ export class UpdateTaskInventoryMessage implements MessageBase buf.writeInt32LE(this.InventoryData['SalePrice'], pos); pos += 4; buf.writeUInt8(this.InventoryData['Name'].length, pos++); - buf.write(this.InventoryData['Name'], pos); + this.InventoryData['Name'].copy(buf, pos); pos += this.InventoryData['Name'].length; buf.writeUInt8(this.InventoryData['Description'].length, pos++); - buf.write(this.InventoryData['Description'], pos); + this.InventoryData['Description'].copy(buf, pos); pos += this.InventoryData['Description'].length; buf.writeInt32LE(this.InventoryData['CreationDate'], pos); pos += 4; @@ -146,8 +146,8 @@ export class UpdateTaskInventoryMessage implements MessageBase Flags: number, SaleType: number, SalePrice: number, - Name: string, - Description: string, + Name: Buffer, + Description: Buffer, CreationDate: number, CRC: number } = { @@ -168,8 +168,8 @@ export class UpdateTaskInventoryMessage implements MessageBase Flags: 0, SaleType: 0, SalePrice: 0, - Name: '', - Description: '', + Name: Buffer.allocUnsafe(0), + Description: Buffer.allocUnsafe(0), CreationDate: 0, CRC: 0 }; @@ -204,10 +204,10 @@ export class UpdateTaskInventoryMessage implements MessageBase newObjInventoryData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjInventoryData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInventoryData['Name'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjInventoryData['Description'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjInventoryData['Description'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjInventoryData['CreationDate'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/UpdateUserInfo.ts b/lib/classes/messages/UpdateUserInfo.ts index 018eea2..2cd8387 100644 --- a/lib/classes/messages/UpdateUserInfo.ts +++ b/lib/classes/messages/UpdateUserInfo.ts @@ -17,7 +17,7 @@ export class UpdateUserInfoMessage implements MessageBase }; UserData: { IMViaEMail: boolean; - DirectoryVisibility: string; + DirectoryVisibility: Buffer; }; getSize(): number @@ -34,7 +34,7 @@ export class UpdateUserInfoMessage implements MessageBase pos += 16; buf.writeUInt8((this.UserData['IMViaEMail']) ? 1 : 0, pos++); buf.writeUInt8(this.UserData['DirectoryVisibility'].length, pos++); - buf.write(this.UserData['DirectoryVisibility'], pos); + this.UserData['DirectoryVisibility'].copy(buf, pos); pos += this.UserData['DirectoryVisibility'].length; return pos - startPos; } @@ -57,14 +57,14 @@ export class UpdateUserInfoMessage implements MessageBase this.AgentData = newObjAgentData; const newObjUserData: { IMViaEMail: boolean, - DirectoryVisibility: string + DirectoryVisibility: Buffer } = { IMViaEMail: false, - DirectoryVisibility: '' + DirectoryVisibility: Buffer.allocUnsafe(0) }; newObjUserData['IMViaEMail'] = (buf.readUInt8(pos++) === 1); varLength = buf.readUInt8(pos++); - newObjUserData['DirectoryVisibility'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjUserData['DirectoryVisibility'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.UserData = newObjUserData; return pos - startPos; diff --git a/lib/classes/messages/UserInfoReply.ts b/lib/classes/messages/UserInfoReply.ts index 408bb0a..8a37ea6 100644 --- a/lib/classes/messages/UserInfoReply.ts +++ b/lib/classes/messages/UserInfoReply.ts @@ -16,8 +16,8 @@ export class UserInfoReplyMessage implements MessageBase }; UserData: { IMViaEMail: boolean; - DirectoryVisibility: string; - EMail: string; + DirectoryVisibility: Buffer; + EMail: Buffer; }; getSize(): number @@ -32,11 +32,11 @@ export class UserInfoReplyMessage implements MessageBase pos += 16; buf.writeUInt8((this.UserData['IMViaEMail']) ? 1 : 0, pos++); buf.writeUInt8(this.UserData['DirectoryVisibility'].length, pos++); - buf.write(this.UserData['DirectoryVisibility'], pos); + this.UserData['DirectoryVisibility'].copy(buf, pos); pos += this.UserData['DirectoryVisibility'].length; buf.writeUInt16LE(this.UserData['EMail'].length, pos); pos += 2; - buf.write(this.UserData['EMail'], pos); + this.UserData['EMail'].copy(buf, pos); pos += this.UserData['EMail'].length; return pos - startPos; } @@ -55,20 +55,20 @@ export class UserInfoReplyMessage implements MessageBase this.AgentData = newObjAgentData; const newObjUserData: { IMViaEMail: boolean, - DirectoryVisibility: string, - EMail: string + DirectoryVisibility: Buffer, + EMail: Buffer } = { IMViaEMail: false, - DirectoryVisibility: '', - EMail: '' + DirectoryVisibility: Buffer.allocUnsafe(0), + EMail: Buffer.allocUnsafe(0) }; newObjUserData['IMViaEMail'] = (buf.readUInt8(pos++) === 1); varLength = buf.readUInt8(pos++); - newObjUserData['DirectoryVisibility'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjUserData['DirectoryVisibility'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjUserData['EMail'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjUserData['EMail'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.UserData = newObjUserData; return pos - startPos; diff --git a/lib/classes/messages/UserReport.ts b/lib/classes/messages/UserReport.ts index 249eb85..9cc84f8 100644 --- a/lib/classes/messages/UserReport.ts +++ b/lib/classes/messages/UserReport.ts @@ -24,11 +24,11 @@ export class UserReportMessage implements MessageBase ScreenshotID: UUID; ObjectID: UUID; AbuserID: UUID; - AbuseRegionName: string; + AbuseRegionName: Buffer; AbuseRegionID: UUID; - Summary: string; - Details: string; - VersionString: string; + Summary: Buffer; + Details: Buffer; + VersionString: Buffer; }; getSize(): number @@ -55,19 +55,19 @@ export class UserReportMessage implements MessageBase this.ReportData['AbuserID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.ReportData['AbuseRegionName'].length, pos++); - buf.write(this.ReportData['AbuseRegionName'], pos); + this.ReportData['AbuseRegionName'].copy(buf, pos); pos += this.ReportData['AbuseRegionName'].length; this.ReportData['AbuseRegionID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.ReportData['Summary'].length, pos++); - buf.write(this.ReportData['Summary'], pos); + this.ReportData['Summary'].copy(buf, pos); pos += this.ReportData['Summary'].length; buf.writeUInt16LE(this.ReportData['Details'].length, pos); pos += 2; - buf.write(this.ReportData['Details'], pos); + this.ReportData['Details'].copy(buf, pos); pos += this.ReportData['Details'].length; buf.writeUInt8(this.ReportData['VersionString'].length, pos++); - buf.write(this.ReportData['VersionString'], pos); + this.ReportData['VersionString'].copy(buf, pos); pos += this.ReportData['VersionString'].length; return pos - startPos; } @@ -96,11 +96,11 @@ export class UserReportMessage implements MessageBase ScreenshotID: UUID, ObjectID: UUID, AbuserID: UUID, - AbuseRegionName: string, + AbuseRegionName: Buffer, AbuseRegionID: UUID, - Summary: string, - Details: string, - VersionString: string + Summary: Buffer, + Details: Buffer, + VersionString: Buffer } = { ReportType: 0, Category: 0, @@ -109,11 +109,11 @@ export class UserReportMessage implements MessageBase ScreenshotID: UUID.zero(), ObjectID: UUID.zero(), AbuserID: UUID.zero(), - AbuseRegionName: '', + AbuseRegionName: Buffer.allocUnsafe(0), AbuseRegionID: UUID.zero(), - Summary: '', - Details: '', - VersionString: '' + Summary: Buffer.allocUnsafe(0), + Details: Buffer.allocUnsafe(0), + VersionString: Buffer.allocUnsafe(0) }; newObjReportData['ReportType'] = buf.readUInt8(pos++); newObjReportData['Category'] = buf.readUInt8(pos++); @@ -127,19 +127,19 @@ export class UserReportMessage implements MessageBase newObjReportData['AbuserID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjReportData['AbuseRegionName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjReportData['AbuseRegionName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjReportData['AbuseRegionID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjReportData['Summary'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjReportData['Summary'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjReportData['Details'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjReportData['Details'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjReportData['VersionString'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjReportData['VersionString'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ReportData = newObjReportData; return pos - startPos; diff --git a/lib/classes/messages/UserReportInternal.ts b/lib/classes/messages/UserReportInternal.ts index e57b854..3971d22 100644 --- a/lib/classes/messages/UserReportInternal.ts +++ b/lib/classes/messages/UserReportInternal.ts @@ -25,11 +25,11 @@ export class UserReportInternalMessage implements MessageBase CreatorID: UUID; RegionID: UUID; AbuserID: UUID; - AbuseRegionName: string; + AbuseRegionName: Buffer; AbuseRegionID: UUID; - Summary: string; - Details: string; - VersionString: string; + Summary: Buffer; + Details: Buffer; + VersionString: Buffer; }; getSize(): number @@ -63,19 +63,19 @@ export class UserReportInternalMessage implements MessageBase this.ReportData['AbuserID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.ReportData['AbuseRegionName'].length, pos++); - buf.write(this.ReportData['AbuseRegionName'], pos); + this.ReportData['AbuseRegionName'].copy(buf, pos); pos += this.ReportData['AbuseRegionName'].length; this.ReportData['AbuseRegionID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.ReportData['Summary'].length, pos++); - buf.write(this.ReportData['Summary'], pos); + this.ReportData['Summary'].copy(buf, pos); pos += this.ReportData['Summary'].length; buf.writeUInt16LE(this.ReportData['Details'].length, pos); pos += 2; - buf.write(this.ReportData['Details'], pos); + this.ReportData['Details'].copy(buf, pos); pos += this.ReportData['Details'].length; buf.writeUInt8(this.ReportData['VersionString'].length, pos++); - buf.write(this.ReportData['VersionString'], pos); + this.ReportData['VersionString'].copy(buf, pos); pos += this.ReportData['VersionString'].length; return pos - startPos; } @@ -97,11 +97,11 @@ export class UserReportInternalMessage implements MessageBase CreatorID: UUID, RegionID: UUID, AbuserID: UUID, - AbuseRegionName: string, + AbuseRegionName: Buffer, AbuseRegionID: UUID, - Summary: string, - Details: string, - VersionString: string + Summary: Buffer, + Details: Buffer, + VersionString: Buffer } = { ReportType: 0, Category: 0, @@ -115,11 +115,11 @@ export class UserReportInternalMessage implements MessageBase CreatorID: UUID.zero(), RegionID: UUID.zero(), AbuserID: UUID.zero(), - AbuseRegionName: '', + AbuseRegionName: Buffer.allocUnsafe(0), AbuseRegionID: UUID.zero(), - Summary: '', - Details: '', - VersionString: '' + Summary: Buffer.allocUnsafe(0), + Details: Buffer.allocUnsafe(0), + VersionString: Buffer.allocUnsafe(0) }; newObjReportData['ReportType'] = buf.readUInt8(pos++); newObjReportData['Category'] = buf.readUInt8(pos++); @@ -144,19 +144,19 @@ export class UserReportInternalMessage implements MessageBase newObjReportData['AbuserID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjReportData['AbuseRegionName'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjReportData['AbuseRegionName'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; newObjReportData['AbuseRegionID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjReportData['Summary'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjReportData['Summary'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjReportData['Details'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjReportData['Details'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjReportData['VersionString'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjReportData['VersionString'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.ReportData = newObjReportData; return pos - startPos; diff --git a/lib/classes/messages/ViewerEffect.ts b/lib/classes/messages/ViewerEffect.ts index 2c4cf54..ce3fee9 100644 --- a/lib/classes/messages/ViewerEffect.ts +++ b/lib/classes/messages/ViewerEffect.ts @@ -21,7 +21,7 @@ export class ViewerEffectMessage implements MessageBase Type: number; Duration: number; Color: Buffer; - TypeData: string; + TypeData: Buffer; }[]; getSize(): number @@ -60,7 +60,7 @@ export class ViewerEffectMessage implements MessageBase this.Effect[i]['Color'].copy(buf, pos); pos += 4; buf.writeUInt8(this.Effect[i]['TypeData'].length, pos++); - buf.write(this.Effect[i]['TypeData'], pos); + this.Effect[i]['TypeData'].copy(buf, pos); pos += this.Effect[i]['TypeData'].length; } return pos - startPos; @@ -92,14 +92,14 @@ export class ViewerEffectMessage implements MessageBase Type: number, Duration: number, Color: Buffer, - TypeData: string + TypeData: Buffer } = { ID: UUID.zero(), AgentID: UUID.zero(), Type: 0, Duration: 0, Color: Buffer.allocUnsafe(0), - TypeData: '' + TypeData: Buffer.allocUnsafe(0) }; newObjEffect['ID'] = new UUID(buf, pos); pos += 16; @@ -111,7 +111,7 @@ export class ViewerEffectMessage implements MessageBase newObjEffect['Color'] = buf.slice(pos, pos + 4); pos += 4; varLength = buf.readUInt8(pos++); - newObjEffect['TypeData'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjEffect['TypeData'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.Effect.push(newObjEffect); } diff --git a/lib/classes/messages/ViewerStats.ts b/lib/classes/messages/ViewerStats.ts index 8dba6f3..a289de3 100644 --- a/lib/classes/messages/ViewerStats.ts +++ b/lib/classes/messages/ViewerStats.ts @@ -25,9 +25,9 @@ export class ViewerStatsMessage implements MessageBase MetersTraveled: number; RegionsVisited: number; SysRAM: number; - SysOS: string; - SysCPU: string; - SysGPU: string; + SysOS: Buffer; + SysCPU: Buffer; + SysGPU: Buffer; }; DownloadTotals: { World: number; @@ -85,13 +85,13 @@ export class ViewerStatsMessage implements MessageBase buf.writeUInt32LE(this.AgentData['SysRAM'], pos); pos += 4; buf.writeUInt8(this.AgentData['SysOS'].length, pos++); - buf.write(this.AgentData['SysOS'], pos); + this.AgentData['SysOS'].copy(buf, pos); pos += this.AgentData['SysOS'].length; buf.writeUInt8(this.AgentData['SysCPU'].length, pos++); - buf.write(this.AgentData['SysCPU'], pos); + this.AgentData['SysCPU'].copy(buf, pos); pos += this.AgentData['SysCPU'].length; buf.writeUInt8(this.AgentData['SysGPU'].length, pos++); - buf.write(this.AgentData['SysGPU'], pos); + this.AgentData['SysGPU'].copy(buf, pos); pos += this.AgentData['SysGPU'].length; buf.writeUInt32LE(this.DownloadTotals['World'], pos); pos += 4; @@ -152,9 +152,9 @@ export class ViewerStatsMessage implements MessageBase MetersTraveled: number, RegionsVisited: number, SysRAM: number, - SysOS: string, - SysCPU: string, - SysGPU: string + SysOS: Buffer, + SysCPU: Buffer, + SysGPU: Buffer } = { AgentID: UUID.zero(), SessionID: UUID.zero(), @@ -168,9 +168,9 @@ export class ViewerStatsMessage implements MessageBase MetersTraveled: 0, RegionsVisited: 0, SysRAM: 0, - SysOS: '', - SysCPU: '', - SysGPU: '' + SysOS: Buffer.allocUnsafe(0), + SysCPU: Buffer.allocUnsafe(0), + SysGPU: Buffer.allocUnsafe(0) }; newObjAgentData['AgentID'] = new UUID(buf, pos); pos += 16; @@ -196,13 +196,13 @@ export class ViewerStatsMessage implements MessageBase newObjAgentData['SysRAM'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjAgentData['SysOS'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAgentData['SysOS'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjAgentData['SysCPU'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAgentData['SysCPU'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; varLength = buf.readUInt8(pos++); - newObjAgentData['SysGPU'] = buf.toString('utf8', pos, pos + (varLength - 1)); + newObjAgentData['SysGPU'] = buf.slice(pos, pos + (varLength - 1)); pos += varLength; this.AgentData = newObjAgentData; const newObjDownloadTotals: { diff --git a/tools/writePacketClasses.js b/tools/writePacketClasses.js index ff33e56..cbe5112 100644 --- a/tools/writePacketClasses.js +++ b/tools/writePacketClasses.js @@ -202,7 +202,7 @@ messages.forEach((message) => jstype = 'boolean'; break; case 'Variable': - jstype = 'string'; + jstype = 'Buffer'; if (block.type === 'Single') { @@ -211,7 +211,7 @@ messages.forEach((message) => else { //Variable parameter in variable or multi block - tricky edge case - blockVariableSize.push('this.calculateVarVarSize(this.'+block.name+', \''+param.name+'\', '+param.size+')') + blockVariableSize.push('this.calculateVarVarSize(this.'+block.name+', \''+param.name+'\', '+param.size+')'); calcVarVar = true; } break; @@ -447,7 +447,7 @@ messages.forEach((message) => classString += spaces + ' buf.writeUInt16LE(' + val + '.length, pos);\n'; classString += spaces + ' pos += 2;\n'; } - classString += spaces + ' buf.write(' + val + ', pos);\n'; + classString += spaces + ' ' + val + '.copy(buf, pos);\n'; classString += spaces + ' pos += ' + val + '.length;\n'; break; case 'LLVector4': @@ -615,8 +615,8 @@ messages.forEach((message) => jsvalue = 'false'; break; case 'Variable': - jstype = 'string'; - jsvalue = '\'\''; + jstype = 'Buffer'; + jsvalue = 'Buffer.allocUnsafe(0)'; break; case 'LLVector4': jstype = 'Vector4'; @@ -714,7 +714,7 @@ messages.forEach((message) => { console.error("INVALID VARIABLE LENGTH: " + param.size); } - classString += spaces + ' newObj' + block.name + '[\'' + param.name + '\'] = buf.toString(\'utf8\', pos, pos + (varLength - 1));\n'; + classString += spaces + ' newObj' + block.name + '[\'' + param.name + '\'] = buf.slice(pos, pos + (varLength - 1));\n'; classString += spaces + ' pos += varLength;\n'; break; case 'LLVector4':