From d0658438b9345f9b6180c908a468a78ad30dbcf4 Mon Sep 17 00:00:00 2001 From: Casper Warden <216465704+casperwardensl@users.noreply.github.com> Date: Thu, 30 Nov 2017 04:11:59 +0000 Subject: [PATCH] Teleports, Asset upload / download, Restructure stuff, Fix varlength read bug, BVH parser, agent initial appearance and animation glitches, LLSD + Caps + Event queue --- example/testBot.js | 30 +- lib/Bot.ts | 470 ++++++++++++++++-- lib/classes/Agent.ts | 239 ++++++++- lib/classes/Assets.ts | 4 + lib/classes/BVH.ts | 61 +++ lib/classes/BVHJoint.ts | 62 +++ lib/classes/BVHJointKeyframe.ts | 7 + lib/classes/Caps.ts | 269 ++++++++++ lib/classes/Circuit.ts | 83 +++- lib/classes/ClientEvents.ts | 11 + lib/classes/Comms.ts | 258 ++++++++++ lib/classes/EventQueueClient.ts | 383 ++++++++++++++ lib/classes/IPAddress.ts | 5 +- lib/classes/Inventory.ts | 7 + lib/classes/LoginResponse.ts | 11 +- lib/classes/NameValue.ts | 7 + lib/classes/Object.ts | 74 +++ lib/classes/ObjectStore.ts | 422 ++++++++++++++++ lib/classes/Packet.ts | 25 +- lib/classes/Quaternion.ts | 2 +- lib/classes/Region.ts | 28 +- lib/classes/UUID.ts | 13 +- lib/classes/Utils.ts | 127 +++++ lib/classes/Vector3.ts | 4 +- lib/classes/Vector4.ts | 2 +- lib/classes/Wearable.ts | 8 + lib/classes/Zerocoder.ts | 6 +- lib/classes/llsd.d.ts | 1 + lib/classes/messages/AgentAlertMessage.ts | 2 +- lib/classes/messages/AgentAnimation.ts | 2 +- .../messages/AgentCachedTextureResponse.ts | 2 +- lib/classes/messages/AgentDataUpdate.ts | 8 +- lib/classes/messages/AgentGroupDataUpdate.ts | 2 +- lib/classes/messages/AgentMovementComplete.ts | 2 +- lib/classes/messages/AgentSetAppearance.ts | 2 +- lib/classes/messages/AgentThrottle.ts | 2 +- lib/classes/messages/AlertMessage.ts | 6 +- lib/classes/messages/AssetUploadRequest.ts | 2 +- lib/classes/messages/AvatarAnimation.ts | 2 +- lib/classes/messages/AvatarAppearance.ts | 2 +- lib/classes/messages/AvatarClassifiedReply.ts | 2 +- lib/classes/messages/AvatarGroupsReply.ts | 4 +- lib/classes/messages/AvatarInterestsReply.ts | 6 +- lib/classes/messages/AvatarInterestsUpdate.ts | 6 +- lib/classes/messages/AvatarNotesReply.ts | 2 +- lib/classes/messages/AvatarNotesUpdate.ts | 2 +- lib/classes/messages/AvatarPickerReply.ts | 4 +- lib/classes/messages/AvatarPickerRequest.ts | 2 +- .../messages/AvatarPickerRequestBackend.ts | 2 +- lib/classes/messages/AvatarPicksReply.ts | 2 +- lib/classes/messages/AvatarPropertiesReply.ts | 10 +- .../messages/AvatarPropertiesUpdate.ts | 6 +- lib/classes/messages/AvatarTextureUpdate.ts | 2 +- lib/classes/messages/BulkUpdateInventory.ts | 6 +- lib/classes/messages/ChatFromSimulator.ts | 4 +- lib/classes/messages/ChatFromViewer.ts | 2 +- lib/classes/messages/ChatPass.ts | 4 +- lib/classes/messages/ChildAgentUpdate.ts | 8 +- lib/classes/messages/ClassifiedInfoReply.ts | 8 +- lib/classes/messages/ClassifiedInfoUpdate.ts | 4 +- lib/classes/messages/CopyInventoryItem.ts | 2 +- lib/classes/messages/CreateGroupReply.ts | 2 +- lib/classes/messages/CreateGroupRequest.ts | 4 +- .../messages/CreateGroupRequestExtended.ts | 4 +- lib/classes/messages/CreateInventoryFolder.ts | 2 +- lib/classes/messages/CreateInventoryItem.ts | 4 +- .../messages/CreateLandmarkForEvent.ts | 2 +- lib/classes/messages/CrossedRegion.ts | 2 +- lib/classes/messages/DirClassifiedQuery.ts | 2 +- .../messages/DirClassifiedQueryBackend.ts | 2 +- lib/classes/messages/DirClassifiedReply.ts | 2 +- lib/classes/messages/DirEventsReply.ts | 4 +- lib/classes/messages/DirFindQuery.ts | 2 +- lib/classes/messages/DirFindQueryBackend.ts | 2 +- lib/classes/messages/DirGroupsReply.ts | 2 +- lib/classes/messages/DirLandReply.ts | 2 +- lib/classes/messages/DirPeopleReply.ts | 6 +- lib/classes/messages/DirPlacesQuery.ts | 4 +- lib/classes/messages/DirPlacesQueryBackend.ts | 4 +- lib/classes/messages/DirPlacesReply.ts | 2 +- lib/classes/messages/DirPopularReply.ts | 2 +- lib/classes/messages/EdgeDataPacket.ts | 2 +- lib/classes/messages/EmailMessageReply.ts | 8 +- lib/classes/messages/EmailMessageRequest.ts | 4 +- lib/classes/messages/Error.ts | 8 +- lib/classes/messages/EstateCovenantReply.ts | 2 +- lib/classes/messages/EstateOwnerMessage.ts | 4 +- lib/classes/messages/EventGodDelete.ts | 2 +- lib/classes/messages/EventInfoReply.ts | 12 +- lib/classes/messages/FeatureDisabled.ts | 2 +- lib/classes/messages/FetchInventoryReply.ts | 4 +- lib/classes/messages/GenericMessage.ts | 4 +- lib/classes/messages/GodKickUser.ts | 2 +- lib/classes/messages/GodUpdateRegionInfo.ts | 2 +- lib/classes/messages/GodlikeMessage.ts | 4 +- .../messages/GroupAccountDetailsReply.ts | 4 +- .../messages/GroupAccountSummaryReply.ts | 6 +- .../messages/GroupAccountTransactionsReply.ts | 8 +- .../messages/GroupActiveProposalItemReply.ts | 10 +- lib/classes/messages/GroupDataUpdate.ts | 2 +- lib/classes/messages/GroupMembersReply.ts | 4 +- lib/classes/messages/GroupNoticeAdd.ts | 6 +- lib/classes/messages/GroupNoticesListReply.ts | 4 +- lib/classes/messages/GroupProfileReply.ts | 6 +- lib/classes/messages/GroupProposalBallot.ts | 2 +- lib/classes/messages/GroupRoleDataReply.ts | 6 +- lib/classes/messages/GroupRoleUpdate.ts | 6 +- lib/classes/messages/GroupTitlesReply.ts | 2 +- .../messages/GroupVoteHistoryItemReply.ts | 14 +- lib/classes/messages/ImageData.ts | 2 +- lib/classes/messages/ImagePacket.ts | 2 +- .../messages/ImprovedInstantMessage.ts | 6 +- .../messages/ImprovedTerseObjectUpdate.ts | 4 +- lib/classes/messages/InitiateDownload.ts | 4 +- lib/classes/messages/InternalScriptMail.ts | 6 +- lib/classes/messages/InventoryDescendents.ts | 6 +- lib/classes/messages/KickUser.ts | 2 +- lib/classes/messages/LandStatReply.ts | 4 +- lib/classes/messages/LandStatRequest.ts | 2 +- lib/classes/messages/LayerData.ts | 2 +- lib/classes/messages/LinkInventoryItem.ts | 4 +- lib/classes/messages/LiveHelpGroupReply.ts | 2 +- lib/classes/messages/LoadURL.ts | 6 +- lib/classes/messages/LogDwellTime.ts | 2 +- lib/classes/messages/LogTextMessage.ts | 2 +- lib/classes/messages/MapBlockReply.ts | 2 +- lib/classes/messages/MapItemReply.ts | 2 +- lib/classes/messages/MapNameRequest.ts | 2 +- lib/classes/messages/MoneyBalanceReply.ts | 4 +- lib/classes/messages/MoneyTransferBackend.ts | 2 +- lib/classes/messages/MoneyTransferRequest.ts | 2 +- lib/classes/messages/MoveInventoryItem.ts | 2 +- lib/classes/messages/MultipleObjectUpdate.ts | 2 +- lib/classes/messages/MuteListUpdate.ts | 2 +- lib/classes/messages/NameValuePair.ts | 2 +- lib/classes/messages/NeighborList.ts | 2 +- lib/classes/messages/ObjectDescription.ts | 2 +- lib/classes/messages/ObjectExtraParams.ts | 2 +- lib/classes/messages/ObjectImage.ts | 4 +- lib/classes/messages/ObjectName.ts | 2 +- lib/classes/messages/ObjectProperties.ts | 10 +- .../messages/ObjectPropertiesFamily.ts | 4 +- lib/classes/messages/ObjectUpdate.ts | 18 +- .../messages/ObjectUpdateCompressed.ts | 2 +- lib/classes/messages/ParcelInfoReply.ts | 6 +- lib/classes/messages/ParcelMediaUpdate.ts | 6 +- lib/classes/messages/ParcelOverlay.ts | 2 +- lib/classes/messages/ParcelProperties.ts | 10 +- .../messages/ParcelPropertiesUpdate.ts | 8 +- lib/classes/messages/ParcelRename.ts | 2 +- lib/classes/messages/PickInfoReply.ts | 10 +- lib/classes/messages/PickInfoUpdate.ts | 4 +- lib/classes/messages/PlacesQuery.ts | 4 +- lib/classes/messages/PlacesReply.ts | 6 +- lib/classes/messages/RegionHandshake.ts | 8 +- lib/classes/messages/RegionInfo.ts | 6 +- .../messages/RegionPresenceResponse.ts | 2 +- lib/classes/messages/RemoveMuteListEntry.ts | 2 +- lib/classes/messages/RemoveNameValuePair.ts | 2 +- lib/classes/messages/ReplyTaskInventory.ts | 2 +- lib/classes/messages/RequestXfer.ts | 2 +- .../messages/RezMultipleAttachmentsFromInv.ts | 4 +- lib/classes/messages/RezObject.ts | 4 +- lib/classes/messages/RezRestoreToWorld.ts | 4 +- lib/classes/messages/RezScript.ts | 4 +- .../messages/RezSingleAttachmentFromInv.ts | 4 +- .../messages/RoutedMoneyBalanceReply.ts | 4 +- lib/classes/messages/RpcScriptReplyInbound.ts | 2 +- .../messages/RpcScriptRequestInbound.ts | 2 +- .../RpcScriptRequestInboundForward.ts | 2 +- lib/classes/messages/ScriptDataReply.ts | 2 +- lib/classes/messages/ScriptDataRequest.ts | 2 +- lib/classes/messages/ScriptDialog.ts | 10 +- lib/classes/messages/ScriptDialogReply.ts | 2 +- .../messages/ScriptMailRegistration.ts | 2 +- lib/classes/messages/ScriptQuestion.ts | 4 +- lib/classes/messages/ScriptSensorReply.ts | 2 +- lib/classes/messages/ScriptSensorRequest.ts | 2 +- lib/classes/messages/ScriptTeleportRequest.ts | 4 +- lib/classes/messages/SendPostcard.ts | 10 +- lib/classes/messages/SendXferPacket.ts | 2 +- .../messages/SetSimPresenceInDatabase.ts | 4 +- .../messages/SetSimStatusInDatabase.ts | 4 +- .../messages/SetStartLocationRequest.ts | 2 +- .../messages/SimulatorPresentAtLocation.ts | 2 +- lib/classes/messages/SimulatorReady.ts | 2 +- lib/classes/messages/StartAuction.ts | 2 +- lib/classes/messages/StartGroupProposal.ts | 2 +- lib/classes/messages/StartLure.ts | 2 +- lib/classes/messages/StateSave.ts | 2 +- lib/classes/messages/SystemMessage.ts | 4 +- lib/classes/messages/TelehubInfo.ts | 2 +- lib/classes/messages/TeleportFailed.ts | 6 +- lib/classes/messages/TeleportFinish.ts | 2 +- lib/classes/messages/TeleportProgress.ts | 2 +- lib/classes/messages/TransferInfo.ts | 2 +- lib/classes/messages/TransferPacket.ts | 2 +- lib/classes/messages/TransferRequest.ts | 2 +- lib/classes/messages/UUIDGroupNameReply.ts | 2 +- lib/classes/messages/UUIDNameReply.ts | 4 +- lib/classes/messages/UpdateAttachment.ts | 4 +- .../messages/UpdateCreateInventoryItem.ts | 4 +- lib/classes/messages/UpdateGroupInfo.ts | 2 +- lib/classes/messages/UpdateInventoryFolder.ts | 2 +- lib/classes/messages/UpdateInventoryItem.ts | 4 +- lib/classes/messages/UpdateMuteListEntry.ts | 2 +- lib/classes/messages/UpdateParcel.ts | 6 +- lib/classes/messages/UpdateSimulator.ts | 2 +- lib/classes/messages/UpdateTaskInventory.ts | 4 +- lib/classes/messages/UpdateUserInfo.ts | 2 +- lib/classes/messages/UserInfoReply.ts | 4 +- lib/classes/messages/UserReport.ts | 8 +- lib/classes/messages/UserReportInternal.ts | 8 +- lib/classes/messages/ViewerEffect.ts | 2 +- lib/classes/messages/ViewerStats.ts | 6 +- lib/enums/AgentFlags.ts | 4 + lib/enums/AgentState.ts | 5 + lib/enums/AssetType.ts | 39 ++ lib/enums/AttachmentPoint.ts | 44 ++ lib/enums/BuiltInAnimations.ts | 138 +++++ lib/enums/ChatAudible.ts | 6 + lib/enums/ChatSourceType.ts | 6 + lib/enums/ChatType.ts | 13 + lib/enums/CompressedFlags.ts | 14 + lib/enums/ControlFlags.ts | 36 ++ lib/enums/ExtraParamType.ts | 8 + lib/enums/GridItemType.ts | 12 + lib/enums/GridLayerType.ts | 6 + lib/enums/HTTPAssets.ts | 23 + lib/enums/InstantMessageDialog.ts | 46 ++ lib/enums/InventorySortOrder.ts | 7 + lib/enums/InventoryType.ts | 27 + lib/enums/PCode.ts | 10 + lib/enums/RegionProtocolFlags.ts | 5 + lib/enums/SoundFlags.ts | 10 + lib/enums/TeleportEventType.ts | 7 + lib/enums/TeleportFlags.ts | 23 + lib/enums/TransferChannelType.ts | 7 + lib/enums/TransferSourceTypes.ts | 10 + lib/enums/Tree.ts | 24 + lib/events/ChatEvent.ts | 17 + lib/events/LureEvent.ts | 13 + lib/events/MapInfoReply.ts | 12 + lib/events/TeleportEvent.ts | 10 + lib/index.ts | 14 +- package.json | 6 +- tools/writePacketClasses.js | 2 +- 247 files changed, 3470 insertions(+), 459 deletions(-) create mode 100644 lib/classes/Assets.ts create mode 100644 lib/classes/BVH.ts create mode 100644 lib/classes/BVHJoint.ts create mode 100644 lib/classes/BVHJointKeyframe.ts create mode 100644 lib/classes/Caps.ts create mode 100644 lib/classes/ClientEvents.ts create mode 100644 lib/classes/Comms.ts create mode 100644 lib/classes/EventQueueClient.ts create mode 100644 lib/classes/NameValue.ts create mode 100644 lib/classes/Object.ts create mode 100644 lib/classes/ObjectStore.ts create mode 100644 lib/classes/Wearable.ts create mode 100644 lib/classes/llsd.d.ts create mode 100644 lib/enums/AgentFlags.ts create mode 100644 lib/enums/AgentState.ts create mode 100644 lib/enums/AssetType.ts create mode 100644 lib/enums/AttachmentPoint.ts create mode 100644 lib/enums/BuiltInAnimations.ts create mode 100644 lib/enums/ChatAudible.ts create mode 100644 lib/enums/ChatSourceType.ts create mode 100644 lib/enums/ChatType.ts create mode 100644 lib/enums/CompressedFlags.ts create mode 100644 lib/enums/ControlFlags.ts create mode 100644 lib/enums/ExtraParamType.ts create mode 100644 lib/enums/GridItemType.ts create mode 100644 lib/enums/GridLayerType.ts create mode 100644 lib/enums/HTTPAssets.ts create mode 100644 lib/enums/InstantMessageDialog.ts create mode 100644 lib/enums/InventorySortOrder.ts create mode 100644 lib/enums/InventoryType.ts create mode 100644 lib/enums/PCode.ts create mode 100644 lib/enums/RegionProtocolFlags.ts create mode 100644 lib/enums/SoundFlags.ts create mode 100644 lib/enums/TeleportEventType.ts create mode 100644 lib/enums/TeleportFlags.ts create mode 100644 lib/enums/TransferChannelType.ts create mode 100644 lib/enums/TransferSourceTypes.ts create mode 100644 lib/enums/Tree.ts create mode 100644 lib/events/ChatEvent.ts create mode 100644 lib/events/LureEvent.ts create mode 100644 lib/events/MapInfoReply.ts create mode 100644 lib/events/TeleportEvent.ts diff --git a/example/testBot.js b/example/testBot.js index 60a61dc..a6f787b 100644 --- a/example/testBot.js +++ b/example/testBot.js @@ -2,6 +2,7 @@ const nmv = require('../dist/index'); const loginParameters = new nmv.LoginParameters(); const parameters = require('./loginParameters.json'); +const fs = require('fs'); loginParameters.firstName = parameters.firstName; loginParameters.lastName = parameters.lastName; @@ -14,28 +15,23 @@ let resp = null; bot.login().then((response) => { + bot.clientEvents.onLure.subscribe((lureEvent) => + { + bot.getRegionMapInfo(lureEvent.gridX, lureEvent.gridY).then((regionInfo) => + { + console.log('Auto-accepting teleport lure to ' + regionInfo.name + ' (' + regionInfo.avatars.length + ' avatar' + ((regionInfo.avatars.length === 1)?'':'s') + ' present) from ' + lureEvent.fromName + ' with message: ' + lureEvent.lureMessage); + bot.acceptTeleport(lureEvent); + }); + }); + //Establish circuit wit region resp = response; return bot.connectToSim(); }).then(() => { - 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(); + // Do some stuff + + // When it's time to go home, call bot.close(); }).catch((error) => { console.log("Error:"); diff --git a/lib/Bot.ts b/lib/Bot.ts index 63bd847..2b05c03 100644 --- a/lib/Bot.ts +++ b/lib/Bot.ts @@ -3,8 +3,6 @@ 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'; @@ -13,53 +11,46 @@ import {Packet} from './classes/Packet'; import {Region} from './classes/Region'; import {LogoutRequestMessage} from './classes/messages/LogoutRequest'; import {Utils} from './classes/Utils'; +import {RegionHandshakeReplyMessage} from './classes/messages/RegionHandshakeReply'; +import {RegionProtocolFlags} from './enums/RegionProtocolFlags'; +import {AgentThrottleMessage} from './classes/messages/AgentThrottle'; +import {AgentDataUpdateRequestMessage} from './classes/messages/AgentDataUpdateRequest'; +import {RegionHandleRequestMessage} from './classes/messages/RegionHandleRequest'; +import {RegionIDAndHandleReplyMessage} from './classes/messages/RegionIDAndHandleReply'; +import * as Long from 'long'; +import {MapItemRequestMessage} from './classes/messages/MapItemRequest'; +import {GridItemType} from './enums/GridItemType'; +import {MapItemReplyMessage} from './classes/messages/MapItemReply'; +import {MapBlockRequestMessage} from './classes/messages/MapBlockRequest'; +import {MapBlockReplyMessage} from './classes/messages/MapBlockReply'; +import {MapInfoReply} from './events/MapInfoReply'; +import {TeleportLureRequestMessage} from './classes/messages/TeleportLureRequest'; +import {LureEvent} from './events/LureEvent'; +import {TeleportFlags} from './enums/TeleportFlags'; +import {TeleportProgressMessage} from './classes/messages/TeleportProgress'; +import {TeleportStartMessage} from './classes/messages/TeleportStart'; +import {SoundTriggerMessage} from './classes/messages/SoundTrigger'; +import {AttachedSoundMessage} from './classes/messages/AttachedSound'; +import {AvatarAnimationMessage} from './classes/messages/AvatarAnimation'; +import {HTTPAssets} from './enums/HTTPAssets'; +import * as LLSD from 'llsd'; +import {TeleportEvent} from './events/TeleportEvent'; +import {ClientEvents} from './classes/ClientEvents'; +import {TeleportEventType} from './enums/TeleportEventType'; export class Bot { - loginParams: LoginParameters; - currentRegion: Region; - agent: Agent; + private loginParams: LoginParameters; + private currentRegion: Region; + private agent: Agent; + private throttleGenCounter = 0; + private clientEvents: ClientEvents | null = null; constructor(login: LoginParameters) { this.loginParams = 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) => @@ -67,6 +58,7 @@ export class Bot const loginHandler = new LoginHandler(); loginHandler.Login(this.loginParams).then((response: LoginResponse) => { + this.clientEvents = response.clientEvents; this.currentRegion = response.region; this.agent = response.agent; resolve(response); @@ -96,12 +88,246 @@ export class Bot console.error('Timeout waiting for logout reply') }).then(() => { - circuit.shutdown(); + this.agent.shutdown(); + this.currentRegion.shutdown(); + delete this.currentRegion; + delete this.agent; resolve(); }); }); } + setBandwidth(total: number) + { + const circuit = this.currentRegion.circuit; + const agentThrottle: AgentThrottleMessage = new AgentThrottleMessage(); + agentThrottle.AgentData = { + AgentID: this.agent.agentID, + SessionID: circuit.sessionID, + CircuitCode: circuit.circuitCode + }; + + const throttleData = Buffer.allocUnsafe(28); + let pos = 0; + + const resendThrottle = total * 0.1; + const landThrottle = total * 0.172; + const windThrottle = total * 0.05; + const cloudThrottle = total * 0.05; + const taskThrottle = total * 0.234; + const textureThrottle = total * 0.234; + const assetThrottle = total * 0.160; + + + throttleData.writeFloatLE(resendThrottle, pos); pos += 4; + throttleData.writeFloatLE(landThrottle, pos); pos += 4; + throttleData.writeFloatLE(windThrottle, pos); pos += 4; + throttleData.writeFloatLE(cloudThrottle, pos); pos += 4; + throttleData.writeFloatLE(taskThrottle, pos); pos += 4; + throttleData.writeFloatLE(textureThrottle, pos); pos += 4; + throttleData.writeFloatLE(assetThrottle, pos); + + agentThrottle.Throttle = { + GenCounter: this.throttleGenCounter++, + Throttles: throttleData + }; + circuit.sendMessage(agentThrottle, PacketFlags.Reliable); + } + + acceptTeleport(lure: LureEvent): Promise + { + return new Promise((resolve, reject) => + { + const circuit = this.currentRegion.circuit; + const tlr = new TeleportLureRequestMessage(); + tlr.Info = { + AgentID: this.agent.agentID, + SessionID: circuit.sessionID, + LureID: lure.lureID, + TeleportFlags: TeleportFlags.ViaLure + }; + circuit.sendMessage(tlr, PacketFlags.Reliable); + if (this.currentRegion.caps.eventQueueClient) + { + if (this.clientEvents === null) + { + reject(new Error('ClientEvents is null')); + return; + } + const subscription = this.clientEvents.onTeleportEvent.subscribe((e: TeleportEvent) => + { + if (e.eventType === TeleportEventType.TeleportFailed || e.eventType === TeleportEventType.TeleportCompleted) + { + subscription.unsubscribe(); + } + if (e.eventType === TeleportEventType.TeleportFailed) + { + reject(e); + } + else if (e.eventType === TeleportEventType.TeleportCompleted) + { + if (e.simIP === 'local') + { + // Local TP - no need for any other shindiggery + resolve(e); + return; + } + + if (this.clientEvents === null) + { + reject(new Error('ClientEvents is null')); + return; + } + + // Successful teleport! First, rip apart circuit + this.currentRegion.shutdown(); + const region: Region = new Region(this.agent, this.clientEvents); + region.circuit.circuitCode = this.currentRegion.circuit.circuitCode; + region.circuit.secureSessionID = this.currentRegion.circuit.secureSessionID; + region.circuit.sessionID = this.currentRegion.circuit.sessionID; + region.circuit.udpBlacklist = this.currentRegion.circuit.udpBlacklist; + region.circuit.ipAddress = e.simIP; + region.circuit.port = e.simPort; + this.agent.setCurrentRegion(region); + this.currentRegion = region; + this.currentRegion.activateCaps(e.seedCapability); + this.connectToSim().then(() => + { + resolve(e); + }).catch((error) => + { + reject(e); + }); + } + }); + } + }); + } + + getRegionHandle(regionID: UUID): Promise + { + return new Promise((resolve, reject) => + { + const circuit = this.currentRegion.circuit; + const msg: RegionHandleRequestMessage = new RegionHandleRequestMessage(); + msg.RequestBlock = { + RegionID: regionID, + }; + circuit.sendMessage(msg, PacketFlags.Reliable); + circuit.waitForMessage(Message.RegionIDAndHandleReply, 10000, (packet: Packet) => + { + const filterMsg = packet.message as RegionIDAndHandleReplyMessage; + return (filterMsg.ReplyBlock.RegionID.toString() === regionID.toString()); + }).then((packet: Packet) => + { + const responseMsg = packet.message as RegionIDAndHandleReplyMessage; + resolve(responseMsg.ReplyBlock.RegionHandle); + }); + }); + } + + getRegionMapInfo(gridX: number, gridY: number): Promise + { + return new Promise((resolve, reject) => + { + const circuit = this.currentRegion.circuit; + const response = new MapInfoReply(); + const msg: MapBlockRequestMessage = new MapBlockRequestMessage(); + msg.AgentData = { + AgentID: this.agent.agentID, + SessionID: circuit.sessionID, + Flags: 65536, + EstateID: 0, + Godlike: true + }; + msg.PositionData = { + MinX: (gridX / 256), + MaxX: (gridX / 256), + MinY: (gridY / 256), + MaxY: (gridY / 256) + }; + circuit.sendMessage(msg, PacketFlags.Reliable); + circuit.waitForMessage(Message.MapBlockReply, 10000, (packet: Packet) => + { + const filterMsg = packet.message as MapBlockReplyMessage; + let found = false; + filterMsg.Data.forEach((data) => + { + if (data.X === (gridX / 256) && data.Y === (gridY / 256)) + { + found = true; + } + }); + return found; + }).then((packet: Packet) => + { + const responseMsg = packet.message as MapBlockReplyMessage; + responseMsg.Data.forEach((data) => + { + if (data.X === (gridX / 256) && data.Y === (gridY / 256)) + { + response.name = Utils.BufferToStringSimple(data.Name); + response.accessFlags = data.Access; + response.mapImage = data.MapImageID; + } + }); + + // Now get the region handle + const regionHandle: Long = Utils.RegionCoordinatesToHandle(gridX, gridY); + + const mi = new MapItemRequestMessage(); + mi.AgentData = { + AgentID: this.agent.agentID, + SessionID: circuit.sessionID, + Flags: 2, + EstateID: 0, + Godlike: false + }; + mi.RequestData = { + ItemType: GridItemType.AgentLocations, + RegionHandle: regionHandle + }; + circuit.sendMessage(mi, PacketFlags.Reliable); + const minX = Math.floor(gridX / 256) * 256; + const maxX = minX + 256; + const minY = Math.floor(gridY / 256) * 256; + const maxY = minY + 256; + response.avatars = []; + circuit.waitForMessage(Message.MapItemReply, 10000, (packet: Packet) => + { + const filterMsg = packet.message as MapItemReplyMessage; + let found = false; + filterMsg.Data.forEach((data) => + { + // Check if avatar is within our bounds + if (data.X >= minX && data.X <= maxX && data.Y >= minY && data.Y <= maxY) + { + found = true; + } + }); + return found; + }).then((packet2: Packet) => + { + const responseMsg2 = packet2.message as MapItemReplyMessage; + responseMsg2.Data.forEach((data) => + { + response.avatars.push({ + X: data.X, + Y: data.Y + }); + }); + resolve(response); + }).catch((err) => + { + reject(err); + }); + }).catch((err) => + { + reject(err); + }); + }); + } + connectToSim() { return new Promise((resolve, reject) => @@ -126,6 +352,126 @@ export class Bot return circuit.waitForMessage(Message.RegionHandshake, 10000); }).then((packet: Packet) => { + const handshakeReply: RegionHandshakeReplyMessage = new RegionHandshakeReplyMessage(); + handshakeReply.AgentData = { + AgentID: this.agent.agentID, + SessionID: circuit.sessionID + }; + handshakeReply.RegionInfo = { + Flags: RegionProtocolFlags.SelfAppearanceSupport | RegionProtocolFlags.AgentAppearanceService + }; + return circuit.waitForAck(circuit.sendMessage(handshakeReply, PacketFlags.Reliable), 10000) + }).then(() => + { + this.setBandwidth(1536000); + + const agentRequest = new AgentDataUpdateRequestMessage(); + agentRequest.AgentData = { + AgentID: this.agent.agentID, + SessionID: circuit.sessionID + }; + circuit.sendMessage(agentRequest, PacketFlags.Reliable); + this.agent.setInitialAppearance(); + this.agent.circuitActive(); + + circuit.subscribeToMessages( + [ + Message.TeleportFailed, + Message.TeleportFinish, + Message.TeleportLocal, + Message.TeleportStart, + Message.TeleportProgress, + Message.TeleportCancel, + Message.SoundTrigger, + Message.AttachedSound, + Message.AvatarAnimation + ], (packet: Packet) => + { + switch (packet.message.id) + { + case Message.TeleportLocal: + { + const tpEvent = new TeleportEvent(); + tpEvent.message = ''; + tpEvent.eventType = TeleportEventType.TeleportCompleted; + tpEvent.simIP = 'local'; + tpEvent.simPort = 0; + tpEvent.seedCapability = ''; + + if (this.clientEvents === null) + { + reject(new Error('ClientEvents is null')); + return; + } + + this.clientEvents.onTeleportEvent.next(tpEvent); + break; + } + case Message.TeleportStart: + { + const teleportStart = packet.message as TeleportStartMessage; + + const tpEvent = new TeleportEvent(); + tpEvent.message = ''; + tpEvent.eventType = TeleportEventType.TeleportStarted; + tpEvent.simIP = ''; + tpEvent.simPort = 0; + tpEvent.seedCapability = ''; + + if (this.clientEvents === null) + { + reject(new Error('ClientEvents is null')); + return; + } + + this.clientEvents.onTeleportEvent.next(tpEvent); + break; + } + case Message.TeleportProgress: + { + const teleportProgress = packet.message as TeleportProgressMessage; + const message = Utils.BufferToStringSimple(teleportProgress.Info.Message); + + const tpEvent = new TeleportEvent(); + tpEvent.message = message; + tpEvent.eventType = TeleportEventType.TeleportProgress; + tpEvent.simIP = ''; + tpEvent.simPort = 0; + tpEvent.seedCapability = ''; + + if (this.clientEvents === null) + { + reject(new Error('ClientEvents is null')); + return; + } + + this.clientEvents.onTeleportEvent.next(tpEvent); + break; + } + case Message.SoundTrigger: + { + const soundTrigger = packet.message as SoundTriggerMessage; + const soundID = soundTrigger.SoundData.SoundID; + // TODO: SoundTrigger clientEvent + break; + } + case Message.AttachedSound: + { + const attachedSound = packet.message as AttachedSoundMessage; + const soundID = attachedSound.DataBlock.SoundID; + // TODO: AttachedSound clientEvent + break; + } + case Message.AvatarAnimation: + { + const avatarAnimation = packet.message as AvatarAnimationMessage; + // TODO: AvatarAnimation clientEvent + break; + } + } + }); + + resolve(); }).catch((error) => { @@ -133,4 +479,46 @@ export class Bot }); }); } + + downloadAsset(type: HTTPAssets, uuid: UUID) + { + return this.currentRegion.caps.downloadAsset(uuid, type); + } + + uploadAsset(type: HTTPAssets, data: Buffer, name: string, description: string): Promise + { + return new Promise((resolve, reject) => + { + if (this.agent && this.agent.inventory && this.agent.inventory.main && this.agent.inventory.main.root) + { + this.currentRegion.caps.capsRequestXML('NewFileAgentInventory', { + 'folder_id': new LLSD.UUID(this.agent.inventory.main.root.toString()), + 'asset_type': type, + 'inventory_type': Utils.HTTPAssetTypeToInventoryType(type), + 'name': name, + 'description': description, + 'everyone_mask': (1 << 13) | (1 << 14) | (1 << 15) | (1 << 19), + 'group_mask': (1 << 13) | (1 << 14) | (1 << 15) | (1 << 19), + 'next_owner_mask': (1 << 13) | (1 << 14) | (1 << 15) | (1 << 19), + 'expected_upload_cost': 0 + }).then((response: any) => + { + if (response['state'] === 'upload') + { + const uploadURL = response['uploader']; + this.currentRegion.caps.capsRequestUpload(uploadURL, data).then((responseUpload: any) => + { + resolve(new UUID(responseUpload['new_asset'].toString())); + }).catch((err) => + { + reject(err); + }); + } + }).catch((err) => + { + console.log(err); + }) + } + }); + } } diff --git a/lib/classes/Agent.ts b/lib/classes/Agent.ts index e5a983e..022c85c 100644 --- a/lib/classes/Agent.ts +++ b/lib/classes/Agent.ts @@ -2,15 +2,41 @@ import {UUID} from './UUID'; import {Vector3} from './Vector3'; import {Inventory} from './Inventory'; import Long = require('long'); +import {Wearable} from './Wearable'; +import {ControlFlags} from '../enums/ControlFlags'; +import {Region} from './Region'; +import {Message} from '../enums/Message'; +import {Packet} from './Packet'; +import {AvatarAnimationMessage} from './messages/AvatarAnimation'; +import {AgentUpdateMessage} from './messages/AgentUpdate'; +import {Quaternion} from './Quaternion'; +import {AgentState} from '../enums/AgentState'; +import {AgentFlags} from '../enums/AgentFlags'; +import {BuiltInAnimations} from '../enums/BuiltInAnimations'; +import * as LLSD from 'llsd'; +import {AssetType} from '../enums/AssetType'; +import {GameObject} from './Object'; +import {AgentWearablesRequestMessage} from './messages/AgentWearablesRequest'; +import {PacketFlags} from '../enums/PacketFlags'; +import {AgentWearablesUpdateMessage} from './messages/AgentWearablesUpdate'; +import {InventorySortOrder} from '../enums/InventorySortOrder'; +import {RezSingleAttachmentFromInvMessage} from './messages/RezSingleAttachmentFromInv'; +import {AttachmentPoint} from '../enums/AttachmentPoint'; +import {Utils} from './Utils'; +import {AgentAnimationMessage} from './messages/AgentAnimation'; +import {ClientEvents} from './ClientEvents'; export class Agent { firstName: string; lastName: string; + localID = 0; agentID: UUID; accessMax: string; regionAccess: string; agentAccess: string; + currentRegion: Region; + controlFlags: ControlFlags = 0; openID: { 'token'?: string, 'url'?: string @@ -41,9 +67,218 @@ export class Agent itemID: UUID }[] = []; agentAppearanceService: string; + wearables?: { + attachments: Wearable[]; + serialNumber: number + }; + agentUpdateTimer: number | null = null; + private clientEvents: ClientEvents; - constructor() + constructor(clientEvents: ClientEvents) { - this.inventory = new Inventory(); + this.inventory = new Inventory(clientEvents); + this.clientEvents = clientEvents; } + + setCurrentRegion(region: Region) + { + this.currentRegion = region; + this.currentRegion.circuit.subscribeToMessages([ + Message.AvatarAnimation + ], this.onAnimState.bind(this)); + } + circuitActive() + { + this.agentUpdateTimer = setInterval(this.sendAgentUpdate.bind(this), 1000); + } + sendAgentUpdate() + { + if (!this.currentRegion) + { + return; + } + const circuit = this.currentRegion.circuit; + const agentUpdate: AgentUpdateMessage = new AgentUpdateMessage(); + agentUpdate.AgentData = { + AgentID: this.agentID, + SessionID: circuit.sessionID, + HeadRotation: Quaternion.getIdentity(), + BodyRotation: Quaternion.getIdentity(), + State: AgentState.None, + CameraCenter: new Vector3([199.58, 203.95, 24.304]), + CameraAtAxis: new Vector3([0.979546, 0.105575, -0.171303]), + CameraLeftAxis: new Vector3([-0.107158, 0.994242, 0]), + CameraUpAxis: new Vector3([0.170316, 0.018357, 0.985218]), + Far: 128, + ControlFlags: this.controlFlags, + Flags: AgentFlags.None + }; + circuit.sendMessage(agentUpdate, 0); + } + shutdown() + { + if (this.agentUpdateTimer !== null) + { + clearInterval(this.agentUpdateTimer); + this.agentUpdateTimer = null; + } + } + onAnimState(packet: Packet) + { + if (packet.message.id === Message.AvatarAnimation) + { + const animMsg = packet.message as AvatarAnimationMessage; + if (animMsg.Sender.ID.toString() === this.agentID.toString()) + { + animMsg.AnimationList.forEach((anim) => + { + const a = anim.AnimID.toString(); + if (a === BuiltInAnimations.STANDUP || + a === BuiltInAnimations.PRE_JUMP || + a === BuiltInAnimations.LAND || + a === BuiltInAnimations.MEDIUM_LAND || + a === BuiltInAnimations.WALK || + a === BuiltInAnimations.RUN) + { + // TODO: Pretty sure this isn't the best way to do this + this.controlFlags = ControlFlags.AGENT_CONTROL_FINISH_ANIM; + console.log('Stopping animation ' + a); + this.sendAgentUpdate(); + this.controlFlags = 0; + } + }); + } + } + } + + private animate(anim: UUID[], run: boolean): Promise + { + + const circuit = this.currentRegion.circuit; + const animPacket = new AgentAnimationMessage(); + animPacket.AgentData = { + AgentID: this.agentID, + SessionID: circuit.sessionID + }; + animPacket.PhysicalAvatarEventList = []; + animPacket.AnimationList = []; + anim.forEach((a) => + { + animPacket.AnimationList.push({ + AnimID: a, + StartAnim: run + }); + }); + + return circuit.waitForAck(circuit.sendMessage(animPacket, PacketFlags.Reliable), 10000); + } + + startAnimations(anim: UUID[]): Promise + { + return this.animate(anim, true); + } + + stopAnimations(anim: UUID[]): Promise + { + return this.animate(anim, false); + } + + setInitialAppearance() + { + const circuit = this.currentRegion.circuit; + const wearablesRequest: AgentWearablesRequestMessage = new AgentWearablesRequestMessage(); + wearablesRequest.AgentData = { + AgentID: this.agentID, + SessionID: circuit.sessionID + }; + circuit.sendMessage(wearablesRequest, PacketFlags.Reliable); + circuit.waitForMessage(Message.AgentWearablesUpdate, 10000).then((packet: Packet) => + { + const wearables = packet.message as AgentWearablesUpdateMessage; + if (!this.wearables || wearables.AgentData.SerialNum > this.wearables.serialNumber) + { + this.wearables = { + serialNumber: wearables.AgentData.SerialNum, + attachments: [] + }; + wearables.WearableData.forEach((wearable) => + { + if (this.wearables && this.wearables.attachments) + { + this.wearables.attachments.push({ + itemID: wearable.ItemID, + assetID: wearable.AssetID, + wearableType: wearable.WearableType + }); + } + }); + } + + this.inventory.main.skeleton.forEach((folder) => + { + if (folder.typeDefault === AssetType.CurrentOutfitFolder) + { + const folderID = folder.folderID; + + const requestFolder = { + folder_id: new LLSD.UUID(folderID), + owner_id: new LLSD.UUID(this.agentID), + fetch_folders: true, + fetch_items: true, + sort_order: InventorySortOrder.ByName + }; + const requestedFolders = { + 'folders': [ + requestFolder + ] + }; + this.currentRegion.caps.capsRequestXML('FetchInventoryDescendents2', requestedFolders).then((folderContents: any) => + { + const currentOutfitFolderContents = folderContents['folders'][0]['items']; + const wornObjects = this.currentRegion.objects.getObjectsByParent(this.localID); + currentOutfitFolderContents.forEach((item: any) => + { + if (item.type === 6) + { + let found = false; + wornObjects.forEach((obj: GameObject) => + { + if (obj.NameValue['AttachItemID']) + { + if (item['item_id'].toString() === obj.NameValue['AttachItemID'].value) + { + found = true; + } + } + }); + + if (!found) + { + const rsafi = new RezSingleAttachmentFromInvMessage(); + rsafi.AgentData = { + AgentID: this.agentID, + SessionID: circuit.sessionID + }; + rsafi.ObjectData = { + ItemID: new UUID(item['item_id'].toString()), + OwnerID: this.agentID, + AttachmentPt: 0x80 | AttachmentPoint.Default, + ItemFlags: item['flags'], + GroupMask: item['permissions']['group_mask'], + EveryoneMask: item['permissions']['everyone_mask'], + NextOwnerMask: item['permissions']['next_owner_mask'], + Name: Utils.StringToBuffer(item['name']), + Description: Utils.StringToBuffer(item['desc']) + }; + circuit.sendMessage(rsafi, PacketFlags.Reliable); + } + } + }); + }); + + } + }); + }); + } + } diff --git a/lib/classes/Assets.ts b/lib/classes/Assets.ts new file mode 100644 index 0000000..3866b82 --- /dev/null +++ b/lib/classes/Assets.ts @@ -0,0 +1,4 @@ +export class Assets +{ + +} \ No newline at end of file diff --git a/lib/classes/BVH.ts b/lib/classes/BVH.ts new file mode 100644 index 0000000..576edb1 --- /dev/null +++ b/lib/classes/BVH.ts @@ -0,0 +1,61 @@ +import {Utils} from './Utils'; +import {BVHJoint} from './BVHJoint'; +import {BVHJointKeyframe} from './BVHJointKeyframe'; + +export class BVH +{ + priority: number; + length: number; + expressionName: string; + inPoint: number; + outPoint: number; + loop: number; + easeInTime: number; + easeOutTime: number; + handPose: number; + jointCount: number; + joints: BVHJoint[] = []; + + // Decodes the binary LL animation format into human-readable BVH. + readFromBuffer(buf: Buffer, pos: number): number + { + const header1 = buf.readUInt16LE(pos); + pos = pos + 2; + const header2 = buf.readUInt16LE(pos); + pos = pos + 2; + if (header1 !== 1 || header2 !== 0) + { + console.error('BVH Decoder: invalid data'); + return 0; + } + this.priority = buf.readInt32LE(pos); + pos = pos + 4; + this.length = buf.readFloatLE(pos); + pos = pos + 4; + let result = Utils.BufferToString(buf, pos); + pos += result.readLength; + this.expressionName = result.result; + this.inPoint = buf.readFloatLE(pos); + pos += 4; + this.outPoint = buf.readFloatLE(pos); + pos += 4; + this.loop = buf.readInt32LE(pos); + pos += 4; + this.easeInTime = buf.readFloatLE(pos); + pos += 4; + this.easeOutTime = buf.readFloatLE(pos); + pos += 4; + this.handPose = buf.readUInt32LE(pos); + pos += 4; + this.jointCount = buf.readUInt32LE(pos); + pos += 4; + + for (let x = 0; x < this.jointCount; x++) + { + const joint = new BVHJoint(); + pos = joint.readFromBuffer(buf, pos, this.inPoint, this.outPoint); + this.joints.push(joint); + } + return pos; + } +} \ No newline at end of file diff --git a/lib/classes/BVHJoint.ts b/lib/classes/BVHJoint.ts new file mode 100644 index 0000000..efbf634 --- /dev/null +++ b/lib/classes/BVHJoint.ts @@ -0,0 +1,62 @@ +import {Utils} from './Utils'; +import {Vector3} from './Vector3'; +import {BVHJointKeyframe} from './BVHJointKeyframe'; + +export class BVHJoint +{ + name: string; + priority: number; + + rotationKeyframeCount: number; + rotationKeyframes: BVHJointKeyframe[] = []; + + positionKeyframeCount: number; + positionKeyframes: BVHJointKeyframe[] = []; + + + readFromBuffer(buf: Buffer, pos: number, inPoint: number, outPoint: number): number + { + const result = Utils.BufferToString(buf, pos); + pos += result.readLength; + this.name = result.result; + + this.priority = buf.readInt32LE(pos); + pos = pos + 4; + this.rotationKeyframeCount = buf.readInt32LE(pos); + pos = pos + 4; + + for (let x = 0; x < this.rotationKeyframeCount; x++) + { + const jointKF = new BVHJointKeyframe(); + jointKF.time = Utils.UInt16ToFloat(buf.readUInt16LE(pos), inPoint, outPoint); + pos = pos + 2; + const x = Utils.UInt16ToFloat(buf.readUInt16LE(pos), -1.0, 1.0); + pos = pos + 2; + const y = Utils.UInt16ToFloat(buf.readUInt16LE(pos), -1.0, 1.0); + pos = pos + 2; + const z = Utils.UInt16ToFloat(buf.readUInt16LE(pos), -1.0, 1.0); + pos = pos + 2; + jointKF.transform = new Vector3([x, y, z]); + this.rotationKeyframes.push(jointKF); + } + + this.positionKeyframeCount = buf.readInt32LE(pos); + pos = pos + 4; + + for (let x = 0; x < this.positionKeyframeCount; x++) + { + const jointKF = new BVHJointKeyframe(); + jointKF.time = Utils.UInt16ToFloat(buf.readUInt16LE(pos), inPoint, outPoint); + pos = pos + 2; + const x = Utils.UInt16ToFloat(buf.readUInt16LE(pos), -1.0, 1.0); + pos = pos + 2; + const y = Utils.UInt16ToFloat(buf.readUInt16LE(pos), -1.0, 1.0); + pos = pos + 2; + const z = Utils.UInt16ToFloat(buf.readUInt16LE(pos), -1.0, 1.0); + pos = pos + 2; + jointKF.transform = new Vector3([x, y, z]); + this.positionKeyframes.push(jointKF); + } + return pos; + } +} \ No newline at end of file diff --git a/lib/classes/BVHJointKeyframe.ts b/lib/classes/BVHJointKeyframe.ts new file mode 100644 index 0000000..8b30c92 --- /dev/null +++ b/lib/classes/BVHJointKeyframe.ts @@ -0,0 +1,7 @@ +import {Vector3} from './Vector3'; + +export class BVHJointKeyframe +{ + time: number; + transform: Vector3; +} \ No newline at end of file diff --git a/lib/classes/Caps.ts b/lib/classes/Caps.ts new file mode 100644 index 0000000..14c2480 --- /dev/null +++ b/lib/classes/Caps.ts @@ -0,0 +1,269 @@ +import * as LLSD from 'llsd'; +import * as request from 'request'; +import {Region} from './Region'; +import {Subject} from 'rxjs/Subject'; +import {Subscription} from 'rxjs/Subscription'; +import {EventQueueClient} from './EventQueueClient'; +import {UUID} from './UUID'; +import {HTTPAssets} from '../enums/HTTPAssets'; +import {ClientEvents} from "./ClientEvents"; + +export class Caps +{ + private region: Region; + private onGotSeedCap: Subject = new Subject(); + private gotSeedCap: boolean = false; + private capabilities: { [key: string]: string } = {}; + private clientEvents: ClientEvents; + eventQueueClient: EventQueueClient | null = null; + + constructor(region: Region, seedURL: string, clientEvents: ClientEvents) + { + this.clientEvents = clientEvents; + this.region = region; + const req: string[] = []; + req.push('AgentPreferences'); + req.push('AgentState'); + req.push('AttachmentResources'); + req.push('AvatarPickerSearch'); + req.push('AvatarRenderInfo'); + req.push('CharacterProperties'); + req.push('ChatSessionRequest'); + req.push('CopyInventoryFromNotecard'); + req.push('CreateInventoryCategory'); + req.push('DispatchRegionInfo'); + req.push('DirectDelivery'); + req.push('EnvironmentSettings'); + req.push('EstateChangeInfo'); + req.push('EventQueueGet'); + req.push('FacebookConnect'); + req.push('FlickrConnect'); + req.push('TwitterConnect'); + req.push('FetchLib2'); + req.push('FetchLibDescendents2'); + req.push('FetchInventory2'); + req.push('FetchInventoryDescendents2'); + req.push('IncrementCOFVersion'); + req.push('GetDisplayNames'); + req.push('GetExperiences'); + req.push('AgentExperiences'); + req.push('FindExperienceByName'); + req.push('GetExperienceInfo'); + req.push('GetAdminExperiences'); + req.push('GetCreatorExperiences'); + req.push('ExperiencePreferences'); + req.push('GroupExperiences'); + req.push('UpdateExperience'); + req.push('IsExperienceAdmin'); + req.push('IsExperienceContributor'); + req.push('RegionExperiences'); + req.push('GetMetadata'); + req.push('GetObjectCost'); + req.push('GetObjectPhysicsData'); + req.push('GroupAPIv1'); + req.push('GroupMemberData'); + req.push('GroupProposalBallot'); + req.push('HomeLocation'); + req.push('LandResources'); + req.push('LSLSyntax'); + req.push('MapLayer'); + req.push('MapLayerGod'); + req.push('MeshUploadFlag'); + req.push('NavMeshGenerationStatus'); + req.push('NewFileAgentInventory'); + req.push('ObjectMedia'); + req.push('ObjectMediaNavigate'); + req.push('ObjectNavMeshProperties'); + req.push('ParcelPropertiesUpdate'); + req.push('ParcelVoiceInfoRequest'); + req.push('ProductInfoRequest'); + req.push('ProvisionVoiceAccountRequest'); + req.push('RemoteParcelRequest'); + req.push('RenderMaterials'); + req.push('RequestTextureDownload'); + req.push('ResourceCostSelected'); + req.push('RetrieveNavMeshSrc'); + req.push('SearchStatRequest'); + req.push('SearchStatTracking'); + req.push('SendPostcard'); + req.push('SendUserReport'); + req.push('SendUserReportWithScreenshot'); + req.push('ServerReleaseNotes'); + req.push('SetDisplayName'); + req.push('SimConsoleAsync'); + req.push('SimulatorFeatures'); + req.push('StartGroupProposal'); + req.push('TerrainNavMeshProperties'); + req.push('TextureStats'); + req.push('UntrustedSimulatorMessage'); + req.push('UpdateAgentInformation'); + req.push('UpdateAgentLanguage'); + req.push('UpdateAvatarAppearance'); + req.push('UpdateGestureAgentInventory'); + req.push('UpdateGestureTaskInventory'); + req.push('UpdateNotecardAgentInventory'); + req.push('UpdateNotecardTaskInventory'); + req.push('UpdateScriptAgent'); + req.push('UpdateScriptTask'); + req.push('UploadBakedTexture'); + req.push('ViewerAsset'); + req.push('ViewerMetrics'); + req.push('ViewerStartAuction'); + req.push('ViewerStats'); + + this.request(seedURL, LLSD.LLSD.formatXML(req), 'application/llsd+xml').then((body: string) => + { + this.capabilities = LLSD.LLSD.parseXML(body); + this.gotSeedCap = true; + this.onGotSeedCap.next(); + if (this.capabilities['EventQueueGet']) + { + if (this.eventQueueClient !== null) + { + this.eventQueueClient.shutdown(); + } + this.eventQueueClient = new EventQueueClient(this, this.clientEvents); + } + }).catch((err) => + { + console.error('Error getting seed capability'); + console.error(err); + }); + } + + downloadAsset(uuid: UUID, type: HTTPAssets): Promise + { + return new Promise((resolve, reject) => + { + this.getCapability('ViewerAsset').then((url) => + { + const assetURL = url + '/?' + type + '_id=' + uuid.toString(); + request({ + 'uri': assetURL, + 'rejectUnauthorized': false, + 'method': 'GET', + 'encoding': null + }, (err, res, body) => + { + if (err) + { + reject(err); + } + else + { + resolve(body); + } + }); + }); + }); + } + + request(url: string, data: string | Buffer, contentType: string): Promise + { + return new Promise((resolve, reject) => + { + request({ + 'headers': { + 'Content-Length': data.length, + 'Content-Type': contentType + }, + 'uri': url, + 'body': data, + 'rejectUnauthorized': false, + 'method': 'POST' + }, (err, res, body) => + { + if (err) + { + reject(err); + } + else + { + resolve(body); + } + }); + }); + } + + waitForSeedCapability(): Promise + { + return new Promise((resolve, reject) => + { + if (this.gotSeedCap) + { + resolve(); + } + else + { + const sub: Subscription = this.onGotSeedCap.subscribe(() => + { + sub.unsubscribe(); + resolve(); + }); + } + }); + } + + getCapability(capability: string): Promise + { + return new Promise((resolve, reject) => + { + this.waitForSeedCapability().then(() => + { + if (this.capabilities[capability]) + { + resolve(this.capabilities[capability]); + } + else + { + reject(new Error('Capability not available')); + } + }); + }); + } + + capsRequestUpload(url: string, data: Buffer): Promise + { + return new Promise((resolve, reject) => + { + this.request(url, data, 'application/octet-stream').then((body: string) => + { + resolve(LLSD.LLSD.parseXML(body)); + }).catch((err) => + { + console.error(err); + reject(err); + }); + }); + } + + capsRequestXML(capability: string, data: any): Promise + { + return new Promise((resolve, reject) => + { + this.getCapability(capability).then((url) => + { + this.request(url, LLSD.LLSD.formatXML(data), 'application/llsd+xml').then((body: string) => + { + resolve(LLSD.LLSD.parseXML(body)); + }).catch((err) => + { + console.error(err); + reject(err); + }); + }).catch((err) => + { + reject(err); + }); + }); + } + + shutdown() + { + this.onGotSeedCap.complete(); + if (this.eventQueueClient) + { + this.eventQueueClient.shutdown(); + } + } +} diff --git a/lib/classes/Circuit.ts b/lib/classes/Circuit.ts index 7489c78..5ac629c 100644 --- a/lib/classes/Circuit.ts +++ b/lib/classes/Circuit.ts @@ -1,5 +1,5 @@ import {UUID} from './UUID'; -import {AddressInfo, Socket} from 'dgram'; +import {Socket} from 'dgram'; import * as dgram from 'dgram'; import {PacketFlags} from '../enums/PacketFlags'; import {Packet} from './Packet'; @@ -10,17 +10,17 @@ import {StartPingCheckMessage} from './messages/StartPingCheck'; import {CompletePingCheckMessage} from './messages/CompletePingCheck'; import {Subscription} from 'rxjs/Subscription'; import {Subject} from 'rxjs/Subject'; +import 'rxjs/add/operator/filter'; import Timer = NodeJS.Timer; +import {ClientEvents} from "./ClientEvents"; export class Circuit { - agentID: UUID; secureSessionID: UUID; sessionID: UUID; circuitCode: number; udpBlacklist: string[]; timestamp: number; - seedCapability: string; client: Socket | null = null; port: number; ipAddress: string; @@ -32,16 +32,35 @@ export class Circuit timeout: number } } = {}; + receivedPackets: { + [key: number]: number + } = {}; + private clientEvents: ClientEvents; - onPacketReceived: Subject; - onAckReceived: Subject; + private onPacketReceived: Subject; + private onAckReceived: Subject; - constructor() + constructor(clientEvents: ClientEvents) { + this.clientEvents = clientEvents; this.onPacketReceived = new Subject(); this.onAckReceived = new Subject(); } + subscribeToMessages(ids: number[], callback: (packet: Packet) => void) + { + const lookupObject: {[key: number]: boolean} = {}; + ids.forEach((id) => + { + lookupObject[id] = true; + }); + + return this.onPacketReceived.filter((packet: Packet) => + { + return lookupObject[packet.message.id] === true; + }).subscribe(callback); + } + sendMessage(message: MessageBase, flags: PacketFlags): number { const packet: Packet = new Packet(); @@ -130,19 +149,27 @@ export class Circuit shutdown() { + Object.keys(this.awaitingAck).forEach((sequenceNumber: string) => + { + clearTimeout(this.awaitingAck[parseInt(sequenceNumber, 10)].timeout); + delete this.awaitingAck[parseInt(sequenceNumber, 10)]; + }); + Object.keys(this.receivedPackets).forEach((sequenceNumber: string) => + { + const seq: number = parseInt(sequenceNumber, 10); + clearTimeout(this.receivedPackets[seq]); + delete this.receivedPackets[seq]; + }); 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; + this.onPacketReceived.complete(); + this.onAckReceived.complete(); } } - waitForMessage(id: Message, timeout: number): Promise + waitForMessage(id: Message, timeout: number, filter?: (packet: Packet) => boolean): Promise { return new Promise((resolve, reject) => { @@ -162,9 +189,9 @@ export class Circuit } }, timeout); - handleObj.subscription = this.onPacketReceived.subscribe((packet: Packet) => + handleObj.subscription = this.subscribeToMessages([id], (packet: Packet) => { - if (packet.message.id === id) + if (packet.message.id === id && (filter === undefined || filter(packet))) { if (handleObj.timeout !== null) { @@ -192,20 +219,19 @@ export class Circuit timeout: setTimeout(this.resend.bind(this, packet.sequenceNumber), 1000) }; } - let size = packet.getSize(); - let dataToSend: Buffer = Buffer.allocUnsafe(size); + let dataToSend: Buffer = Buffer.allocUnsafe(packet.getSize()); 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 = ''; + /*let resend = ''; if (packet.packetFlags & PacketFlags.Resent) { resend = ' (resent)'; } console.log('--> ' + packet.message.name + resend); + */ }) } else @@ -235,11 +261,30 @@ export class Circuit this.sendMessage(msg, 0); } + expireReceivedPacket(sequenceNumber: number) + { + // Enough time has elapsed that we can forget about this packet + if (this.receivedPackets[sequenceNumber]) + { + delete this.receivedPackets[sequenceNumber]; + } + } + receivedPacket(bytes: Buffer) { const packet = new Packet(); packet.readFromBuffer(bytes, 0, this.ackReceived.bind(this), this.sendAck.bind(this)); - console.log('<--- ' + packet.message.name); + + if (this.receivedPackets[packet.sequenceNumber]) + { + clearTimeout(this.receivedPackets[packet.sequenceNumber]); + this.receivedPackets[packet.sequenceNumber] = setTimeout(this.expireReceivedPacket.bind(this, packet.sequenceNumber), 10000); + console.log('Ignoring duplicate packet: ' + packet.message.name); + return; + } + this.receivedPackets[packet.sequenceNumber] = setTimeout(this.expireReceivedPacket.bind(this, packet.sequenceNumber), 10000); + + //console.log('<--- ' + packet.message.name); if (packet.message.id === Message.PacketAck) { diff --git a/lib/classes/ClientEvents.ts b/lib/classes/ClientEvents.ts new file mode 100644 index 0000000..2328b5b --- /dev/null +++ b/lib/classes/ClientEvents.ts @@ -0,0 +1,11 @@ +import {LureEvent} from '../events/LureEvent'; +import {ChatEvent} from '../events/ChatEvent'; +import {TeleportEvent} from '../events/TeleportEvent'; +import {Subject} from 'rxjs/Subject'; + +export class ClientEvents +{ + onNearbyChat: Subject = new Subject(); + onLure: Subject = new Subject(); + onTeleportEvent: Subject = new Subject(); +} diff --git a/lib/classes/Comms.ts b/lib/classes/Comms.ts new file mode 100644 index 0000000..a8e08d4 --- /dev/null +++ b/lib/classes/Comms.ts @@ -0,0 +1,258 @@ +import {Circuit} from './Circuit'; +import {Agent} from './Agent'; +import {Packet} from './Packet'; +import {Message} from '../enums/Message'; +import {ChatFromSimulatorMessage} from './messages/ChatFromSimulator'; +import {ImprovedInstantMessageMessage} from './messages/ImprovedInstantMessage'; +import {ChatType} from '../enums/ChatType'; +import {Utils} from './Utils'; +import {ChatFromViewerMessage} from './messages/ChatFromViewer'; +import {PacketFlags} from '../enums/PacketFlags'; +import {ChatEvent} from '../events/ChatEvent'; +import {UUID} from './UUID'; +import {InstantMessageDialog} from '../enums/InstantMessageDialog'; +import {LureEvent} from '../events/LureEvent'; +import {AlertMessageMessage} from './messages/AlertMessage'; +import {ClientEvents} from './ClientEvents'; +import {Vector3} from './Vector3'; + +export class Comms +{ + private circuit: Circuit; + private agent: Agent; + private clientEvents: ClientEvents; + + constructor(circuit: Circuit, agent: Agent, clientEvents: ClientEvents) + { + this.clientEvents = clientEvents; + this.circuit = circuit; + this.agent = agent; + + this.circuit.subscribeToMessages([ + Message.ImprovedInstantMessage, + Message.ChatFromSimulator, + Message.AlertMessage + ], (packet: Packet) => + { + switch (packet.message.id) + { + case Message.ImprovedInstantMessage: + const im = packet.message as ImprovedInstantMessageMessage; + switch (im.MessageBlock.Dialog) + { + case InstantMessageDialog.MessageFromAgent: + break; + case InstantMessageDialog.MessageBox: + break; + case InstantMessageDialog.GroupInvitation: + break; + case InstantMessageDialog.InventoryOffered: + break; + case InstantMessageDialog.InventoryAccepted: + break; + case InstantMessageDialog.InventoryDeclined: + break; + case InstantMessageDialog.TaskInventoryOffered: + break; + case InstantMessageDialog.TaskInventoryAccepted: + break; + case InstantMessageDialog.TaskInventoryDeclined: + break; + case InstantMessageDialog.MessageFromObject: + break; + case InstantMessageDialog.BusyAutoResponse: + break; + case InstantMessageDialog.ConsoleAndChatHistory: + break; + case InstantMessageDialog.RequestTeleport: + const lureEvent = new LureEvent(); + + const extraData = Utils.BufferToStringSimple(im.MessageBlock.BinaryBucket).split('|'); + lureEvent.fromName = Utils.BufferToStringSimple(im.MessageBlock.FromAgentName); + lureEvent.lureMessage = Utils.BufferToStringSimple(im.MessageBlock.Message); + lureEvent.regionID = im.MessageBlock.RegionID; + lureEvent.position = im.MessageBlock.Position; + lureEvent.lureID = im.MessageBlock.ID; + lureEvent.gridX = parseInt(extraData[0], 10); + lureEvent.gridY = parseInt(extraData[1], 10); + this.clientEvents.onLure.next(lureEvent); + break; + case InstantMessageDialog.AcceptTeleport: + break; + case InstantMessageDialog.DenyTeleport: + break; + case InstantMessageDialog.RequestLure: + break; + case InstantMessageDialog.GotoUrl: + break; + case InstantMessageDialog.FromTaskAsAlert: + break; + case InstantMessageDialog.GroupNotice: + break; + case InstantMessageDialog.GroupNoticeInventoryAccepted: + break; + case InstantMessageDialog.GroupNoticeInventoryDeclined: + break; + case InstantMessageDialog.GroupInvitationAccept: + break; + case InstantMessageDialog.GroupInvitationDecline: + break; + case InstantMessageDialog.GroupNoticeRequested: + break; + case InstantMessageDialog.FriendshipOffered: + break; + case InstantMessageDialog.FriendshipAccepted: + break; + case InstantMessageDialog.FriendshipDeclined: + break; + case InstantMessageDialog.StartTyping: + break; + case InstantMessageDialog.StopTyping: + break; + + } + break; + + case Message.ChatFromSimulator: + + const chat = packet.message as ChatFromSimulatorMessage; + const event = new ChatEvent(); + event.fromName = Utils.BufferToStringSimple(chat.ChatData.FromName); + event.message = Utils.BufferToStringSimple(chat.ChatData.Message); + event.from = chat.ChatData.SourceID; + event.ownerID = chat.ChatData.OwnerID; + event.chatType = chat.ChatData.ChatType; + event.sourceType = chat.ChatData.SourceType; + event.audible = chat.ChatData.Audible; + event.position = chat.ChatData.Position; + this.clientEvents.onNearbyChat.next(event); + break; + + case Message.AlertMessage: + const alertm = packet.message as AlertMessageMessage; + + let alertMessage = Utils.BufferToStringSimple(alertm.AlertData.Message); + + console.log('Alert message: ' + alertMessage); + alertm.AlertInfo.forEach((info) => { + let alertInfoMessage = Utils.BufferToStringSimple(info.Message); + console.log('Alert info message: ' + alertInfoMessage); + }); + break; + } + }); + } + nearbyChat(message: string, type: ChatType, channel?: number) + { + if (channel === undefined) + { + channel = 0; + } + const cfv = new ChatFromViewerMessage(); + cfv.AgentData = { + AgentID: this.agent.agentID, + SessionID: this.circuit.sessionID + }; + cfv.ChatData = { + Message: Utils.StringToBuffer(message), + Type: type, + Channel: channel + }; + this.circuit.sendMessage(cfv, PacketFlags.Reliable); + } + say(message: string, channel?: number) + { + this.nearbyChat(message, ChatType.Normal, channel); + } + whisper(message: string, channel?: number) + { + this.nearbyChat(message, ChatType.Whisper, channel); + } + shout(message: string, channel?: number) + { + this.nearbyChat(message, ChatType.Shout, channel); + } + startTypingLocal() + { + const cfv = new ChatFromViewerMessage(); + cfv.AgentData = { + AgentID: this.agent.agentID, + SessionID: this.circuit.sessionID + }; + cfv.ChatData = { + Message: Buffer.allocUnsafe(0), + Type: ChatType.StartTyping, + Channel: 0 + }; + this.circuit.sendMessage(cfv, PacketFlags.Reliable); + } + stopTypingLocal() + { + const cfv = new ChatFromViewerMessage(); + cfv.AgentData = { + AgentID: this.agent.agentID, + SessionID: this.circuit.sessionID + }; + cfv.ChatData = { + Message: Buffer.allocUnsafe(0), + Type: ChatType.StopTyping, + Channel: 0 + }; + this.circuit.sendMessage(cfv, PacketFlags.Reliable); + } + typeMessage(message: string) + { + this.startTypingLocal(); + this.agent.startAnimations([new UUID('c541c47f-e0c0-058b-ad1a-d6ae3a4584d9')]).then(() => + { + // Average four characters per second i guess? + const timeToWait = (message.length / 5) * 1000; + setTimeout(() => + { + this.stopTypingLocal(); + this.agent.stopAnimations([new UUID('c541c47f-e0c0-058b-ad1a-d6ae3a4584d9')]).then(() => + { + this.say(message); + }); + }, timeToWait); + }); + } + shutdown() + { + + } + sendInstantMessage(to: UUID | string, message: string): Promise + { + const circuit = this.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); + } +} \ No newline at end of file diff --git a/lib/classes/EventQueueClient.ts b/lib/classes/EventQueueClient.ts new file mode 100644 index 0000000..fbe3203 --- /dev/null +++ b/lib/classes/EventQueueClient.ts @@ -0,0 +1,383 @@ +import {Caps} from './Caps'; +import * as LLSD from 'llsd'; +import * as request from 'request'; +import * as Long from 'long'; +import {IPAddress} from './IPAddress'; +import {TeleportEvent} from '../events/TeleportEvent'; +import {ClientEvents} from './ClientEvents'; +import {TeleportEventType} from '../enums/TeleportEventType'; + +export class EventQueueClient +{ + caps: Caps; + ack?: number; + done = false; + currentRequest: request.Request | null = null; + private clientEvents: ClientEvents; + + constructor(caps: Caps, clientEvents: ClientEvents) + { + this.clientEvents = clientEvents; + this.caps = caps; + this.Get(); + } + shutdown() + { + if (this.currentRequest !== null) + { + this.currentRequest.abort(); + } + this.done = true; + } + Get() + { + const req = { + 'ack': this.ack, + 'done': this.done + }; + this.capsRequestXML('EventQueueGet', req).then((data) => + { + if (data['events']) + { + data['events'].forEach((event: any) => + { + try + { + if (event['message']) + { + // noinspection TsLint + switch (event['message']) + { + case 'EnableSimulator': + + /* + { + "body": { + "SimulatorInfo": [ + { + "Handle": "AALoAAAECwA=", + "IP": "2FIqRA==", + "Port": 13029 + } + ] + }, + "message": "EnableSimulator" + } + */ + + break; + case 'ParcelProperties': + /* + { + "body": { + "AgeVerificationBlock": [ + { + + "RegionDenyAgeUnverified": true + } + ], + "MediaData": [ + { + "MediaDesc": "", + "MediaHeight": 0, + "MediaLoop": 0, + "MediaType": "text/html", + "MediaWidth": 0, + "ObscureMedia": 0, + "ObscureMusic": 0 + } + ], + "ParcelData": [ + { + "AABBMax": [ + 256, + 256, + 50 + ], + "AABBMin": [ + 0, + 0, + 0 + ], + "AnyAVSounds": true, + "Area": 65536, + "AuctionID": "AAAAAA==", + "AuthBuyerID": "00000000-0000-0000-0000-000000000000", + "Bitmap": "///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8=", + "Category": 0, + "ClaimDate": 1333505995, + "ClaimPrice": 0, + "Desc": "adoption parent furry parent teen twin cub neko pets adult elf vamp toddleedoo baby child panel brother sister numbers meshmerized gacha adoptions adopt family mesh skin shape camp ngi youthspot foster kids mall zoo train kid primbay\ndupli + city onlinker", + "GroupAVSounds": true, + "GroupID": "f2b75b49-8ebc-2a9c-f345-aa2f91adc908", + "GroupPrims": 18677, + "IsGroupOwned": true, + "LandingType": 2, + "LocalID": 15, + "MaxPrims": 30000, + "MediaAutoScale": 1, + "MediaID": "6bd35c06-2b24-a83e-03f6-f547c65c8556", + "MediaURL": "", + "MusicURL": "http://142.4.209.63:8071", + "Name": "Next Gen Inc. Adoption Agency on the :::: KiD GRiD :::", + "OtherCleanTime": 0, + "OtherCount": 4096, + "OtherPrims": 312, + "OwnerID": "f2b75b49-8ebc-2a9c-f345-aa2f91adc908", + "OwnerPrims": 3, + "ParcelFlags": "NiAUSw==", + "ParcelPrimBonus": 1, + "PassHours": 10, + "PassPrice": 10, + "PublicCount": 0, + "RegionDenyAnonymous": true, + "RegionDenyIdentified": true, + "RegionDenyTransacted": true, + "RegionPushOverride": true, + "RentPrice": 0, + "RequestResult": 0, + "SalePrice": 1, + "SeeAVs": true, + "SelectedPrims": 1, + "SelfCount": 0, + "SequenceID": 0, + "SimWideMaxPrims": 30000, + "SimWideTotalPrims": 18993, + "SnapSelection": true, + "SnapshotID": "09c4101a-9406-2501-b9b7-dbb60260fd7a", + "Status": 0, + "TotalPrims": 18993, + "UserLocation": [ + 131.48399353027344, + 171.41600036621094, + 21.544700622558594 + ], + "UserLookAt": [ + 0.0325143001973629, + -0.9994710087776184, + 0 + ] + } + ], + "RegionAllowAccessBlock": [ + { + "RegionAllowAccessOverride": true + } + ] + }, + "message": "ParcelProperties" + } + + */ + break; + case 'AgentGroupDataUpdate': + /* + { + "body": { + "AgentData": [ + { + "AgentID": "49cc9041-5c53-4c1c-8490-e6bb84cdbacd" + } + ], + "GroupData": [ + { + "AcceptNotices": true, + "Contribution": 0, + "GroupID": "06459c46-069f-4de1-c297-c966bd55ab91", + "GroupInsigniaID": "8dacb5c9-80bc-aae4-6a12-d792b6eb7dc4", + "GroupName": "Jez Ember Estates", + "GroupPowers": "AAAgAAQAAAA=" + }, + { + "AcceptNotices": true, + "Contribution": 0, + "GroupID": "539b5be0-bb18-d0ef-6c07-3326e0130aaf", + "GroupInsigniaID": "7d7d0b4a-bf5b-dc51-3869-5e0eaa6ad41d", + "GroupName": "**BOY BEARS MALL**", + "GroupPowers": "AAAIABgBAAA=" + } + ], + "NewGroupData": [ + { + "ListInProfile": true + }, + { + "ListInProfile": true + } + ] + }, + "message": "AgentGroupDataUpdate" + } + + */ + break; + case 'AgentStateUpdate': + /* + + { + "body": { + "can_modify_navmesh": true, + "has_modified_navmesh": true, + "preferences": { + "access_prefs": { + "max": "PG" + }, + "default_object_perm_masks": { + "Everyone": 0, + "Group": 0, + "NextOwner": 532480 + }, + "god_level": 0, + "hover_height": 0, + "language": "", + "language_is_public": true + } + }, + "message": "AgentStateUpdate" + } + */ + break; + case 'TeleportFailed': + { + const tpEvent = new TeleportEvent(); + tpEvent.message = event['body']['Info'][0]['Reason']; + tpEvent.eventType = TeleportEventType.TeleportFailed; + tpEvent.simIP = ''; + tpEvent.simPort = 0; + tpEvent.seedCapability = ''; + + this.clientEvents.onTeleportEvent.next(tpEvent); + break; + } + case 'TeleportFinish': + { + const info = event['body']['Info'][0]; + if (info['LocationID']) + { + info['LocationID'] = Buffer.from(info['LocationID'].toArray()).readUInt32LE(0); + + const regionHandleBuf = Buffer.from(info['RegionHandle'].toArray()); + info['RegionHandle'] = new Long(regionHandleBuf.readUInt32LE(0), regionHandleBuf.readUInt32LE(4), true); + + + info['SimIP'] = new IPAddress(Buffer.from(info['SimIP'].toArray()), 0).toString(); + + info['TeleportFlags'] = Buffer.from(info['TeleportFlags'].toArray()).readUInt32LE(0); + + const tpEvent = new TeleportEvent(); + tpEvent.message = ''; + tpEvent.eventType = TeleportEventType.TeleportCompleted; + tpEvent.simIP = info['SimIP']; + tpEvent.simPort = info['SimPort']; + tpEvent.seedCapability = info['SeedCapability']; + + this.clientEvents.onTeleportEvent.next(tpEvent); + } + + break; + } + default: + console.log('Unhandled event:'); + console.log(JSON.stringify(event, null, 4)); + } + } + } + catch (erro) + { + console.error('Error handling cap'); + console.error(erro); + } + }); + } + if (data['id']) + { + this.ack = data['id']; + } + else + { + this.ack = undefined; + } + if (!this.done) + { + this.Get(); + } + }).catch((err) => + { + // Wait 5 seconds before retrying + setTimeout(() => + { + if (!this.done) + { + this.Get(); + } + }, 5000); + }); + } + request(url: string, data: string, contentType: string): Promise + { + return new Promise((resolve, reject) => + { + this.currentRequest = request({ + 'headers': { + 'Content-Length': data.length, + 'Content-Type': contentType + }, + 'uri': url, + 'body': data, + 'rejectUnauthorized': false, + 'method': 'POST', + 'timeout': 1800000 // Super long timeout + }, (err, res, body) => + { + this.currentRequest = null; + if (err) + { + reject(err); + } + else + { + resolve(body); + } + }); + }); + } + + capsRequestXML(capability: string, data: any): Promise + { + return new Promise((resolve, reject) => + { + this.caps.getCapability(capability).then((url) => + { + const serializedData = LLSD.LLSD.formatXML(data); + this.request(url, serializedData, 'application/llsd+xml').then((body: string) => + { + try + { + if (body.indexOf('') !== -1) + { + const parsed = LLSD.LLSD.parseXML(body); + resolve(parsed); + } + else + { + throw new Error('Not an LLSD response'); + } + } + catch (error) + { + reject(error); + } + }).catch((err) => + { + reject(err); + }); + }).catch((err) => + { + reject(err); + }); + }); + } +} \ No newline at end of file diff --git a/lib/classes/IPAddress.ts b/lib/classes/IPAddress.ts index f35bd45..c03e4fe 100644 --- a/lib/classes/IPAddress.ts +++ b/lib/classes/IPAddress.ts @@ -8,7 +8,10 @@ export class IPAddress { return new IPAddress('0.0.0.0'); } - + public toString = (): string => + { + return this.ip.toString(); + }; constructor(buf?: Buffer | string, pos?: number) { if (buf !== undefined && buf instanceof Buffer) diff --git a/lib/classes/Inventory.ts b/lib/classes/Inventory.ts index e853f94..b5d8ada 100644 --- a/lib/classes/Inventory.ts +++ b/lib/classes/Inventory.ts @@ -1,4 +1,5 @@ import {UUID} from './UUID'; +import {ClientEvents} from './ClientEvents'; export class Inventory { @@ -27,4 +28,10 @@ export class Inventory } = { skeleton: [] }; + private clientEvents: ClientEvents; + + constructor(clientEvents: ClientEvents) + { + this.clientEvents = clientEvents; + } } diff --git a/lib/classes/LoginResponse.ts b/lib/classes/LoginResponse.ts index df3e6b4..c68dbba 100644 --- a/lib/classes/LoginResponse.ts +++ b/lib/classes/LoginResponse.ts @@ -4,6 +4,7 @@ import {Region} from './Region'; import {LoginFlags} from '../enums/LoginFlags'; import {Vector3} from './Vector3'; import Long = require('long'); +import {ClientEvents} from './ClientEvents'; export class LoginResponse { @@ -34,6 +35,7 @@ export class LoginResponse 'moonTextureID'?: UUID, } = {}; searchToken: string; + clientEvents: ClientEvents; private static toRegionHandle(x_global: number, y_global: number): Long { @@ -88,8 +90,9 @@ export class LoginResponse constructor(json: any) { - this.agent = new Agent(); - this.region = new Region(); + this.clientEvents = new ClientEvents(); + this.agent = new Agent(this.clientEvents); + this.region = new Region(this.agent, this.clientEvents); Object.keys(json).forEach((key: string) => { const val: any = json[key]; @@ -309,13 +312,12 @@ 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); break; case 'seed_capability': - this.region.circuit.seedCapability = String(val); + this.region.activateCaps(String(val)); break; case 'first_name': this.agent.firstName = String(val).replace(/"/g, ''); @@ -323,5 +325,6 @@ export class LoginResponse } }); + this.agent.setCurrentRegion(this.region); } } diff --git a/lib/classes/NameValue.ts b/lib/classes/NameValue.ts new file mode 100644 index 0000000..b996df4 --- /dev/null +++ b/lib/classes/NameValue.ts @@ -0,0 +1,7 @@ +export class NameValue +{ + type: string; + class: string; + sendTo: string; + value: string; +} diff --git a/lib/classes/Object.ts b/lib/classes/Object.ts new file mode 100644 index 0000000..d919d28 --- /dev/null +++ b/lib/classes/Object.ts @@ -0,0 +1,74 @@ +import {Vector3} from './Vector3'; +import {UUID} from './UUID'; +import {PCode} from '../enums/PCode'; +import {Quaternion} from './Quaternion'; +import {Tree} from '../enums/Tree'; +import {SoundFlags} from '../enums/SoundFlags'; +import {NameValue} from './NameValue'; + +export class GameObject +{ + ID: number; + State: number; + FullID: UUID; + CRC: number; + PCode: PCode; + Material: number; + ClickAction: number; + Scale: Vector3; + ObjectData: Buffer; + ParentID: number; + UpdateFlags: number; + Flags: number; + PathCurve: number; + ProfileCurve: number; + PathBegin: number; + PathEnd: number; + PathScaleX: number; + PathScaleY: number; + PathShearX: number; + PathShearY: number; + PathTwist: number; + PathTwistBegin: number; + PathRadiusOffset: number; + PathTaperX: number; + PathTaperY: number; + PathRevolutions: number; + PathSkew: number; + ProfileBegin: number; + ProfileEnd: number; + ProfileHollow: number; + TextureEntry: Buffer; + TextureAnim: Buffer; + Data: Buffer; + Text: string; + TextColor: Buffer; + MediaURL: string; + PSBlock: Buffer; + OwnerID: UUID; + JointType: number; + JointPivot: Vector3; + JointAxisOrAnchor: Vector3; + Position: Vector3; + Rotation: Quaternion; + AngularVelocity: Vector3; + TreeSpecies: Tree; + Sound: UUID; + SoundGain: number; + SoundFlags: SoundFlags; + SoundRadius: number; + IsAttachment: boolean; + NameValue: {[key: string]: NameValue}; + constructor() + { + this.Position = Vector3.getZero(); + this.Rotation = Quaternion.getIdentity(); + this.IsAttachment = false; + this.NameValue = {}; + this.AngularVelocity = Vector3.getZero(); + this.TreeSpecies = 0; + this.SoundFlags = 0; + this.SoundRadius = 1.0; + this.SoundGain = 1.0; + } +} diff --git a/lib/classes/ObjectStore.ts b/lib/classes/ObjectStore.ts new file mode 100644 index 0000000..2319c43 --- /dev/null +++ b/lib/classes/ObjectStore.ts @@ -0,0 +1,422 @@ +import {Circuit} from './Circuit'; +import {Packet} from './Packet'; +import {Message} from '../enums/Message'; +import {ObjectUpdateMessage} from './messages/ObjectUpdate'; +import {ObjectUpdateCachedMessage} from './messages/ObjectUpdateCached'; +import {ObjectUpdateCompressedMessage} from './messages/ObjectUpdateCompressed'; +import {ImprovedTerseObjectUpdateMessage} from './messages/ImprovedTerseObjectUpdate'; +import {MultipleObjectUpdateMessage} from './messages/MultipleObjectUpdate'; +import {RequestMultipleObjectsMessage} from './messages/RequestMultipleObjects'; +import {Agent} from './Agent'; +import {UUID} from './UUID'; +import {GameObject} from './Object'; +import {Quaternion} from './Quaternion'; +import {Vector3} from './Vector3'; +import {CompressedFlags} from '../enums/CompressedFlags'; +import {ExtraParamType} from '../enums/ExtraParamType'; +import {Utils} from './Utils'; +import {SoundFlags} from '../enums/SoundFlags'; +import {PCode} from '../enums/PCode'; +import {NameValue} from "./NameValue"; +import {ClientEvents} from "./ClientEvents"; + +export class ObjectStore +{ + private circuit: Circuit; + private agent: Agent; + private objects: {[key: number]: GameObject} = {}; + private objectsByUUID: {[key: string]: number} = {}; + private objectsByParent: {[key: number]: number[]} = {}; + private clientEvents: ClientEvents; + + constructor(circuit: Circuit, agent: Agent, clientEvents: ClientEvents) + { + this.clientEvents = clientEvents; + this.circuit = circuit; + this.agent = agent; + this.circuit.subscribeToMessages([ + Message.ObjectUpdate, + Message.ObjectUpdateCached, + Message.ObjectUpdateCompressed, + Message.ImprovedTerseObjectUpdate, + Message.MultipleObjectUpdate + ], (packet: Packet) => + { + switch (packet.message.id) + { + case Message.ObjectUpdate: + const objectUpdate = packet.message as ObjectUpdateMessage; + objectUpdate.ObjectData.forEach((objData) => + { + const localID = objData.ID; + const parentID = objData.ParentID; + let addToParentList = true; + + if (this.objects[localID]) + { + if (this.objects[localID].ParentID !== parentID && this.objectsByParent[parentID]) + { + const ind = this.objectsByParent[parentID].indexOf(localID); + if (ind !== -1) + { + this.objectsByParent[parentID].splice(ind, 1); + } + } + else + { + addToParentList = false; + } + } + else + { + this.objects[localID] = new GameObject(); + } + + const obj = this.objects[localID]; + obj.ID = objData.ID; + obj.State = objData.State; + obj.FullID = objData.FullID; + obj.CRC = objData.CRC; + obj.PCode = objData.PCode; + obj.Material = objData.Material; + obj.ClickAction = objData.ClickAction; + obj.Scale = objData.Scale; + obj.ObjectData = objData.ObjectData; // TODO: DECODE + obj.ParentID = objData.ParentID; + obj.Flags = objData.UpdateFlags; + obj.PathCurve = objData.PathCurve; + obj.ProfileCurve = objData.ProfileCurve; + obj.PathBegin = objData.PathBegin; + obj.PathEnd = objData.PathEnd; + obj.PathScaleX = objData.PathScaleX; + obj.PathScaleY = objData.PathScaleY; + obj.PathShearX = objData.PathShearX; + obj.PathShearY = objData.PathShearY; + obj.PathTwist = objData.PathTwist; + obj.PathTwistBegin = objData.PathTwistBegin; + obj.PathRadiusOffset = objData.PathRadiusOffset; + obj.PathTaperX = objData.PathTaperX; + obj.PathTaperY = objData.PathTaperY; + obj.PathRevolutions = objData.PathRevolutions; + obj.PathSkew = objData.PathSkew; + obj.ProfileBegin = objData.ProfileBegin; + obj.ProfileEnd = objData.ProfileEnd; + obj.ProfileHollow = objData.ProfileHollow; + obj.TextureEntry = objData.TextureEntry; // TODO: DECODE + obj.TextureAnim = objData.TextureAnim; + obj.Data = objData.Data; // TODO: DECODE + obj.Text = Utils.BufferToStringSimple(objData.Text); + obj.TextColor = objData.TextColor; // TODO: DECODE + obj.MediaURL = Utils.BufferToStringSimple(objData.MediaURL); + obj.PSBlock = objData.PSBlock; + obj.Sound = objData.Sound; + obj.OwnerID = objData.OwnerID; + obj.SoundGain = objData.Gain; + obj.SoundFlags = objData.Flags; + obj.SoundRadius = objData.Radius; + obj.JointType = objData.JointType; + obj.JointPivot = objData.JointPivot; + obj.JointAxisOrAnchor = objData.JointAxisOrAnchor; + + if (this.objects[localID].PCode === PCode.Avatar && this.objects[localID].FullID.toString() === this.agent.agentID.toString()) + { + this.agent.localID = localID; + } + + this.readExtraParams(objData.ExtraParams, 0, this.objects[localID]); + this.objects[localID].NameValue = this.parseNameValues(Utils.BufferToStringSimple(objData.NameValue)); + + this.objectsByUUID[objData.FullID.toString()] = localID; + if (!this.objectsByParent[parentID]) + { + this.objectsByParent[parentID] = []; + } + if (addToParentList) + { + this.objectsByParent[parentID].push(localID); + } + }); + break; + case Message.ObjectUpdateCached: + const objectUpdateCached = packet.message as ObjectUpdateCachedMessage; + const rmo = new RequestMultipleObjectsMessage(); + rmo.AgentData = { + AgentID: this.agent.agentID, + SessionID: this.circuit.sessionID + }; + rmo.ObjectData = []; + objectUpdateCached.ObjectData.forEach((obj) => + { + rmo.ObjectData.push({ + CacheMissType: 0, + ID: obj.ID + }); + }); + circuit.sendMessage(rmo, 0); + break; + case Message.ObjectUpdateCompressed: + { + const objectUpdateCompressed = packet.message as ObjectUpdateCompressedMessage; + objectUpdateCompressed.ObjectData.forEach((obj) => + { + const flags = obj.UpdateFlags; + const buf = obj.Data; + let pos = 0; + + const fullID = new UUID(buf, pos); + pos += 16; + const localID = buf.readUInt32LE(pos); + pos += 4; + const pcode = buf.readUInt8(pos++); + let newObj = false; + if (!this.objects[localID]) + { + newObj = true; + this.objects[localID] = new GameObject(); + } + const o = this.objects[localID]; + o.ID = localID; + this.objectsByUUID[fullID.toString()] = localID; + o.FullID = fullID; + o.Flags = flags; + o.PCode = pcode; + o.State = buf.readUInt8(pos++); + o.CRC = buf.readUInt32LE(pos); + pos = pos + 4; + o.Material = buf.readUInt8(pos++); + o.ClickAction = buf.readUInt8(pos++); + o.Scale = new Vector3(buf, pos, false); + pos = pos + 12; + o.Position = new Vector3(buf, pos, false); + pos = pos + 12; + o.Rotation = new Quaternion(buf, pos); + pos = pos + 12; + const compressedflags: CompressedFlags = buf.readUInt32LE(pos); + pos = pos + 4; + o.OwnerID = new UUID(buf, pos); + pos += 16; + + if (compressedflags & CompressedFlags.HasAngularVelocity) + { + o.AngularVelocity = new Vector3(buf, pos, false); + pos = pos + 12; + } + if (compressedflags & CompressedFlags.HasParent) + { + const newParentID = buf.readUInt32LE(pos); + pos += 4; + let add = true; + if (!newObj) + { + if (newParentID !== o.ParentID) + { + const index = this.objectsByParent[o.ParentID].indexOf(localID); + if (index !== -1) + { + this.objectsByParent[o.ParentID].splice(index, 1); + } + } + else + { + add = false; + } + } + if (add) + { + if (!this.objectsByParent[newParentID]) + { + this.objectsByParent[newParentID] = []; + } + this.objectsByParent[newParentID].push(localID); + } + o.ParentID = newParentID; + } + if (compressedflags & CompressedFlags.Tree) + { + o.TreeSpecies = buf.readUInt8(pos++); + } + else if (compressedflags & CompressedFlags.ScratchPad) + { + o.TreeSpecies = 0; + const scratchPadSize = buf.readUInt8(pos++); + // Ignore this data + pos = pos + scratchPadSize; + } + if (compressedflags & CompressedFlags.HasText) + { + // Read null terminated string + const result = Utils.BufferToString(buf, pos); + + pos += result.readLength; + o.Text = result.result; + o.TextColor = buf.slice(pos, pos + 4); + pos = pos + 4; + } + else + { + o.Text = ''; + } + if (compressedflags & CompressedFlags.MediaURL) + { + const result = Utils.BufferToString(buf, pos); + + pos += result.readLength; + o.MediaURL = result.result; + } + if (compressedflags & CompressedFlags.HasParticles) + { + // TODO: Particle system block + //console.log("HasParticles"); + pos += 86; + } + else + { + //console.log("HasNoParticles"); + } + + // Extra params + pos = this.readExtraParams(buf, pos, o); + + if (compressedflags & CompressedFlags.HasSound) + { + o.Sound = new UUID(buf, pos); + pos = pos + 16; + o.SoundGain = buf.readFloatLE(pos); + pos += 4; + o.SoundFlags = buf.readUInt8(pos++); + o.SoundRadius = buf.readFloatLE(pos); + pos = pos + 4; + } + if (compressedflags & CompressedFlags.HasNameValues) + { + const result = Utils.BufferToString(buf, pos); + o.NameValue = this.parseNameValues(result.result); + pos += result.readLength; + } + o.PathCurve = buf.readUInt8(pos++); + o.PathBegin = buf.readUInt16LE(pos); + pos = pos + 2; + o.PathEnd = buf.readUInt16LE(pos); + pos = pos + 2; + o.PathScaleX = buf.readUInt8(pos++); + o.PathScaleY = buf.readUInt8(pos++); + o.PathShearX = buf.readUInt8(pos++); + o.PathShearY = buf.readUInt8(pos++); + o.PathTwist = buf.readUInt8(pos++); + o.PathTwistBegin = buf.readUInt8(pos++); + o.PathRadiusOffset = buf.readUInt8(pos++); + o.PathTaperX = buf.readUInt8(pos++); + o.PathTaperY = buf.readUInt8(pos++); + o.PathRevolutions = buf.readUInt8(pos++); + o.PathSkew = buf.readUInt8(pos++); + o.ProfileCurve = buf.readUInt8(pos++); + o.ProfileBegin = buf.readUInt16LE(pos); + pos = pos + 2; + o.ProfileEnd = buf.readUInt16LE(pos); + pos = pos + 2; + o.ProfileHollow = buf.readUInt16LE(pos); + pos = pos + 2; + let textureEntryLength = buf.readUInt32LE(pos); + pos = pos + 4; + // TODO: Properly parse textureentry; + pos = pos + textureEntryLength; + + if (compressedflags & CompressedFlags.TextureAnimation) + { + // TODO: Properly parse textureAnim + pos = pos + 4; + } + + o.IsAttachment = (compressedflags & CompressedFlags.HasNameValues) !== 0 && o.ParentID !== 0; + + }); + + break; + } + case Message.ImprovedTerseObjectUpdate: + const objectUpdateTerse = packet.message as ImprovedTerseObjectUpdateMessage; + // TODO: ImprovedTerseObjectUPdate + break; + case Message.MultipleObjectUpdate: + const multipleObjectUpdate = packet.message as MultipleObjectUpdateMessage; + // TODO: multipleObjectUpdate + console.error('TODO: MultipleObjectUpdate'); + break; + } + }); + } + readExtraParams(buf: Buffer, pos: number, o: GameObject): number + { + if (pos >= buf.length) + { + return 0; + } + const extraParamCount = buf.readUInt8(pos++); + for (let k = 0; k < extraParamCount; k++) + { + const type: ExtraParamType = buf.readUInt16LE(pos); + pos = pos + 2; + const paramLength = buf.readUInt32LE(pos); + pos = pos + 4; + + // TODO: Read extra param data + pos += paramLength; + } + return pos; + } + getObjectsByParent(parentID: number): GameObject[] + { + const list = this.objectsByParent[parentID]; + if (list === undefined) + { + return []; + } + const result: GameObject[] = []; + list.forEach((localID) => + { + result.push(this.objects[localID]); + }); + return result; + } + parseNameValues(str: string): {[key: string]: NameValue} + { + const nv: {[key: string]: NameValue} = {}; + const lines = str.split('\n'); + lines.forEach((line) => + { + if (line.length > 0) + { + let kv = line.split(/[\t ]/); + if (kv.length > 5) + { + for(let x = 5; x < kv.length; x++) + { + kv[4] += ' ' + kv[x]; + } + kv = kv.slice(0, 5); + } + if (kv.length === 5) + { + const namevalue = new NameValue(); + namevalue.type = kv[1]; + namevalue.class = kv[2]; + namevalue.sendTo = kv[3]; + namevalue.value = kv[4]; + nv[kv[0]] = namevalue; + } + else + { + console.log("namevalue unexpected length: " + kv.length); + console.log(kv); + } + } + }); + return nv; + } + shutdown() + { + this.objects = {}; + this.objectsByUUID = {}; + this.objectsByParent = {}; + } +} diff --git a/lib/classes/Packet.ts b/lib/classes/Packet.ts index 9434ad3..3b65ca6 100644 --- a/lib/classes/Packet.ts +++ b/lib/classes/Packet.ts @@ -95,10 +95,22 @@ export class Packet { this.extraHeader = Buffer.allocUnsafe(0); } - + let appendedAcks = 0; if (this.packetFlags & PacketFlags.Zerocoded) { - buf = Zerocoder.Decode(buf, pos, buf.length - 1); + // Annoyingly, the AppendedAcks aren't zerocoded so we need to stop decode early + let tail = 0; + if (this.packetFlags & PacketFlags.Ack) + { + // Final byte in the packet contains the number of Acks + tail = 1; + appendedAcks = buf.readUInt8(buf.length - 1); + if (appendedAcks > 0) + { + tail += appendedAcks * 4; + } + } + buf = Zerocoder.Decode(buf, pos, buf.length - 1, tail); } let messageID = buf.readUInt8(pos); @@ -125,14 +137,11 @@ export class Packet const readLength = this.message.readFromBuffer(buf, pos); pos += readLength; - if (this.packetFlags & PacketFlags.Ack) { - // Final byte in the packet contains the number of Acks - const numAcks = buf.readUInt8(buf.length - 1); - for (let i = 0; i < numAcks; i++) + for (let i = 0; i < appendedAcks; i++) { - const ackID = buf.readUInt32LE(pos); + const ackID = buf.readUInt32BE(pos); ackReceived(ackID); pos += 4; } @@ -141,7 +150,7 @@ export class Packet } if (pos < buf.length) { - console.error('WARNING: Finished reading but we\'re not at the end of the packet'); + console.error('WARNING: Finished reading ' + nameFromID(messageID) + ' but we\'re not at the end of the packet (' + pos + ' < ' + buf.length + ', seq ' + this.sequenceNumber + ')'); } } } diff --git a/lib/classes/Quaternion.ts b/lib/classes/Quaternion.ts index e4a74fc..add9886 100644 --- a/lib/classes/Quaternion.ts +++ b/lib/classes/Quaternion.ts @@ -34,6 +34,6 @@ export class Quaternion extends quat const q: quat = this.normalize(); buf.writeFloatLE(q.x, pos); buf.writeFloatLE(q.y, pos + 4); - buf.writeFloatLE(q.z, pos + 4); + buf.writeFloatLE(q.z, pos + 8); } } diff --git a/lib/classes/Region.ts b/lib/classes/Region.ts index 4c2c99c..cad472b 100644 --- a/lib/classes/Region.ts +++ b/lib/classes/Region.ts @@ -1,13 +1,37 @@ import {Circuit} from './Circuit'; +import {ObjectStore} from './ObjectStore'; +import {Agent} from './Agent'; +import {Caps} from './Caps'; +import {Comms} from './Comms'; +import {ClientEvents} from './ClientEvents'; export class Region { xCoordinate: number; yCoordinate: number; circuit: Circuit; + objects: ObjectStore; + caps: Caps; + comms: Comms; + clientEvents: ClientEvents; - constructor() + constructor(agent: Agent, clientEvents: ClientEvents) { - this.circuit = new Circuit(); + this.clientEvents = clientEvents; + this.circuit = new Circuit(clientEvents); + this.objects = new ObjectStore(this.circuit, agent, clientEvents); + this.comms = new Comms(this.circuit, agent, clientEvents); + } + activateCaps(seedURL: string) + { + this.caps = new Caps(this, seedURL, this.clientEvents); + } + shutdown() + { + this.comms.shutdown(); + this.caps.shutdown(); + this.objects.shutdown(); + this.circuit.shutdown(); + } } diff --git a/lib/classes/UUID.ts b/lib/classes/UUID.ts index b57fad9..197c2e3 100644 --- a/lib/classes/UUID.ts +++ b/lib/classes/UUID.ts @@ -28,16 +28,25 @@ export class UUID + hexString.substr(16, 4) + '-' + hexString.substr(20, 12)); } + else + { + console.error('Can\'t accept UUIDs of type ' + typeof buf); + } } } public setUUID(val: string): boolean { - if (validator.isUUID(val, 4)) + const test = val.trim(); + if (validator.isUUID(test)) { - this.mUUID = val; + this.mUUID = test; return true; } + else + { + console.log('Invalid UUID: ' + test + ' (length ' + val.length + ')'); + } return false; } diff --git a/lib/classes/Utils.ts b/lib/classes/Utils.ts index dcd2b89..26843a5 100644 --- a/lib/classes/Utils.ts +++ b/lib/classes/Utils.ts @@ -1,7 +1,134 @@ +import * as Long from 'long'; +import {HTTPAssets} from "../enums/HTTPAssets"; + export class Utils { static StringToBuffer(str: string): Buffer { return Buffer.from(str + '\0', 'utf8'); } + static BufferToStringSimple(buf: Buffer, startPos?: number): string + { + if (buf.length === 0) + { + return ''; + } + if (buf[buf.length - 1] === 0) + { + return buf.slice(0, buf.length - 1).toString('utf8'); + } + else + { + return buf.toString('utf8'); + } + } + static BufferToString(buf: Buffer, startPos?: number): + { + readLength: number, + result: string + } + { + if (buf.length === 0) + { + return { + readLength: 0, + result: '' + }; + } + if (startPos === undefined) + { + startPos = 0; + } + + let foundNull = -1; + for (let x = startPos; x <= buf.length; x++) + { + if (buf[x] === 0) + { + foundNull = x; + break; + } + } + if (foundNull === -1) + { + console.error('BufferToString: Null terminator not found after ' + (buf.length - startPos) + ' bytes. Buffer length: ' + buf.length + ', startPos: ' + startPos); + foundNull = buf.length - 1; + } + return { + readLength: (foundNull - startPos) + 1, + result: buf.slice(startPos, foundNull).toString('utf8') + } + } + + static RegionCoordinatesToHandle(regionX: number, regionY: number): Long + { + regionX = Math.floor(regionX / 256) * 256; + regionY = Math.floor( regionY / 256) * 256; + return new Long(regionY, regionX); + } + + static HTTPAssetTypeToInventoryType(HTTPAssetType: string) + { + switch (HTTPAssetType) + { + case HTTPAssets.ASSET_TEXTURE: + return 'texture'; + case HTTPAssets.ASSET_SOUND: + return 'sound'; + case HTTPAssets.ASSET_ANIMATION: + return 'animation'; + case HTTPAssets.ASSET_GESTURE: + return 'gesture'; + case HTTPAssets.ASSET_LANDMARK: + return 'landmark'; + case HTTPAssets.ASSET_CALLINGCARD: + return 'callcard'; + case HTTPAssets.ASSET_SCRIPT: + return 'script'; + case HTTPAssets.ASSET_CLOTHING: + return 'wearable'; + case HTTPAssets.ASSET_OBJECT: + return 'object'; + case HTTPAssets.ASSET_NOTECARD: + return 'notecard'; + case HTTPAssets.ASSET_CATEGORY: + return 'category'; + case HTTPAssets.ASSET_LSL_TEXT: + return 'script'; + case HTTPAssets.ASSET_LSL_BYTECODE: + return 'script'; + case HTTPAssets.ASSET_BODYPART: + return 'wearable'; + case HTTPAssets.ASSET_MESH: + return 'mesh'; + default: + return ''; + } + } + + static UInt16ToFloat(val: number, lower: number, upper: number) + { + const ONE_OVER_U16_MAX = 1.0 / 65535; + let fval = val * ONE_OVER_U16_MAX; + const delta = upper - lower; + fval *= delta; + fval += lower; + + const maxError = delta * ONE_OVER_U16_MAX; + if (Math.abs(fval) < maxError) + { + fval = 0.0; + } + return fval; + } + static Base64EncodeString(str: string): string + { + const buff = new Buffer(str, 'utf8'); + return buff.toString('base64'); + } + static Base64DecodeString(str: string): string + { + const buff = new Buffer(str, 'base64'); + return buff.toString('utf8'); + } } \ No newline at end of file diff --git a/lib/classes/Vector3.ts b/lib/classes/Vector3.ts index 6e05775..b7881de 100644 --- a/lib/classes/Vector3.ts +++ b/lib/classes/Vector3.ts @@ -45,13 +45,13 @@ export class Vector3 extends vec3 { buf.writeDoubleLE(this.x, pos); buf.writeDoubleLE(this.y, pos + 8); - buf.writeDoubleLE(this.x, pos + 16); + buf.writeDoubleLE(this.z, pos + 16); } else { buf.writeFloatLE(this.x, pos); buf.writeFloatLE(this.y, pos + 4); - buf.writeFloatLE(this.x, pos + 8); + buf.writeFloatLE(this.z, pos + 8); } } } diff --git a/lib/classes/Vector4.ts b/lib/classes/Vector4.ts index 9402b9b..9ef3395 100644 --- a/lib/classes/Vector4.ts +++ b/lib/classes/Vector4.ts @@ -30,7 +30,7 @@ export class Vector4 extends vec4 { buf.writeFloatLE(this.x, pos); buf.writeFloatLE(this.y, pos + 4); - buf.writeFloatLE(this.x, pos + 8); + buf.writeFloatLE(this.z, pos + 8); buf.writeFloatLE(this.w, pos + 12); } } diff --git a/lib/classes/Wearable.ts b/lib/classes/Wearable.ts new file mode 100644 index 0000000..efd511a --- /dev/null +++ b/lib/classes/Wearable.ts @@ -0,0 +1,8 @@ +import {UUID} from "./UUID"; + +export class Wearable +{ + itemID: UUID; + assetID: UUID; + wearableType: number; +} \ No newline at end of file diff --git a/lib/classes/Zerocoder.ts b/lib/classes/Zerocoder.ts index 8f9ad26..fdd8450 100644 --- a/lib/classes/Zerocoder.ts +++ b/lib/classes/Zerocoder.ts @@ -54,7 +54,7 @@ export class Zerocoder } return newBuf; } - static Decode(buf: Buffer, start: number, end: number): Buffer + static Decode(buf: Buffer, start: number, end: number, tail: number): Buffer { // First, run through the data and calculate how many bytes have been compressed let bytes = 0; @@ -67,7 +67,7 @@ export class Zerocoder // Minus two bytes for the overhead bytes += buf.readUInt8(i) - 2; } - else if (buf[i] === 0) + else if (buf[i] === 0 && i <= (end - tail)) { zero = true; } @@ -88,7 +88,7 @@ export class Zerocoder newBuf[newBufIndex++] = 0; } } - else if (buf[i] === 0) + else if (buf[i] === 0 && i <= (end - tail)) { zero = true; } diff --git a/lib/classes/llsd.d.ts b/lib/classes/llsd.d.ts new file mode 100644 index 0000000..c4d800e --- /dev/null +++ b/lib/classes/llsd.d.ts @@ -0,0 +1 @@ +declare module 'llsd'; \ No newline at end of file diff --git a/lib/classes/messages/AgentAlertMessage.ts b/lib/classes/messages/AgentAlertMessage.ts index defb532..b0ad3d1 100644 --- a/lib/classes/messages/AgentAlertMessage.ts +++ b/lib/classes/messages/AgentAlertMessage.ts @@ -57,7 +57,7 @@ export class AgentAlertMessageMessage implements MessageBase }; newObjAlertData['Modal'] = (buf.readUInt8(pos++) === 1); varLength = buf.readUInt8(pos++); - newObjAlertData['Message'] = buf.slice(pos, pos + (varLength - 1)); + newObjAlertData['Message'] = buf.slice(pos, pos + varLength); pos += varLength; this.AlertData = newObjAlertData; return pos - startPos; diff --git a/lib/classes/messages/AgentAnimation.ts b/lib/classes/messages/AgentAnimation.ts index 9a43162..d3624d0 100644 --- a/lib/classes/messages/AgentAnimation.ts +++ b/lib/classes/messages/AgentAnimation.ts @@ -106,7 +106,7 @@ export class AgentAnimationMessage implements MessageBase TypeData: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjPhysicalAvatarEventList['TypeData'] = buf.slice(pos, pos + (varLength - 1)); + newObjPhysicalAvatarEventList['TypeData'] = buf.slice(pos, pos + varLength); pos += varLength; this.PhysicalAvatarEventList.push(newObjPhysicalAvatarEventList); } diff --git a/lib/classes/messages/AgentCachedTextureResponse.ts b/lib/classes/messages/AgentCachedTextureResponse.ts index b625762..008c665 100644 --- a/lib/classes/messages/AgentCachedTextureResponse.ts +++ b/lib/classes/messages/AgentCachedTextureResponse.ts @@ -97,7 +97,7 @@ export class AgentCachedTextureResponseMessage implements MessageBase pos += 16; newObjWearableData['TextureIndex'] = buf.readUInt8(pos++); varLength = buf.readUInt8(pos++); - newObjWearableData['HostName'] = buf.slice(pos, pos + (varLength - 1)); + newObjWearableData['HostName'] = buf.slice(pos, pos + varLength); pos += varLength; this.WearableData.push(newObjWearableData); } diff --git a/lib/classes/messages/AgentDataUpdate.ts b/lib/classes/messages/AgentDataUpdate.ts index acc740b..3dc92ea 100644 --- a/lib/classes/messages/AgentDataUpdate.ts +++ b/lib/classes/messages/AgentDataUpdate.ts @@ -77,20 +77,20 @@ export class AgentDataUpdateMessage implements MessageBase newObjAgentData['AgentID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjAgentData['FirstName'] = buf.slice(pos, pos + (varLength - 1)); + newObjAgentData['FirstName'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjAgentData['LastName'] = buf.slice(pos, pos + (varLength - 1)); + newObjAgentData['LastName'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjAgentData['GroupTitle'] = buf.slice(pos, pos + (varLength - 1)); + newObjAgentData['GroupTitle'] = buf.slice(pos, pos + varLength); 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.slice(pos, pos + (varLength - 1)); + newObjAgentData['GroupName'] = buf.slice(pos, pos + varLength); pos += varLength; this.AgentData = newObjAgentData; return pos - startPos; diff --git a/lib/classes/messages/AgentGroupDataUpdate.ts b/lib/classes/messages/AgentGroupDataUpdate.ts index 6f62ec7..ec17b33 100644 --- a/lib/classes/messages/AgentGroupDataUpdate.ts +++ b/lib/classes/messages/AgentGroupDataUpdate.ts @@ -107,7 +107,7 @@ export class AgentGroupDataUpdateMessage implements MessageBase newObjGroupData['Contribution'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjGroupData['GroupName'] = buf.slice(pos, pos + (varLength - 1)); + newObjGroupData['GroupName'] = buf.slice(pos, pos + varLength); pos += varLength; this.GroupData.push(newObjGroupData); } diff --git a/lib/classes/messages/AgentMovementComplete.ts b/lib/classes/messages/AgentMovementComplete.ts index 5aab136..bb40632 100644 --- a/lib/classes/messages/AgentMovementComplete.ts +++ b/lib/classes/messages/AgentMovementComplete.ts @@ -99,7 +99,7 @@ export class AgentMovementCompleteMessage implements MessageBase }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjSimData['ChannelVersion'] = buf.slice(pos, pos + (varLength - 1)); + newObjSimData['ChannelVersion'] = buf.slice(pos, pos + varLength); pos += varLength; this.SimData = newObjSimData; return pos - startPos; diff --git a/lib/classes/messages/AgentSetAppearance.ts b/lib/classes/messages/AgentSetAppearance.ts index 46e1b93..b69d0e1 100644 --- a/lib/classes/messages/AgentSetAppearance.ts +++ b/lib/classes/messages/AgentSetAppearance.ts @@ -113,7 +113,7 @@ export class AgentSetAppearanceMessage implements MessageBase }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjObjectData['TextureEntry'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['TextureEntry'] = buf.slice(pos, pos + varLength); pos += varLength; this.ObjectData = newObjObjectData; count = buf.readUInt8(pos++); diff --git a/lib/classes/messages/AgentThrottle.ts b/lib/classes/messages/AgentThrottle.ts index 6b12463..29f2014 100644 --- a/lib/classes/messages/AgentThrottle.ts +++ b/lib/classes/messages/AgentThrottle.ts @@ -73,7 +73,7 @@ export class AgentThrottleMessage implements MessageBase newObjThrottle['GenCounter'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjThrottle['Throttles'] = buf.slice(pos, pos + (varLength - 1)); + newObjThrottle['Throttles'] = buf.slice(pos, pos + varLength); pos += varLength; this.Throttle = newObjThrottle; return pos - startPos; diff --git a/lib/classes/messages/AlertMessage.ts b/lib/classes/messages/AlertMessage.ts index e2b51b5..7d4ef28 100644 --- a/lib/classes/messages/AlertMessage.ts +++ b/lib/classes/messages/AlertMessage.ts @@ -74,7 +74,7 @@ export class AlertMessageMessage implements MessageBase Message: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjAlertData['Message'] = buf.slice(pos, pos + (varLength - 1)); + newObjAlertData['Message'] = buf.slice(pos, pos + varLength); pos += varLength; this.AlertData = newObjAlertData; let count = buf.readUInt8(pos++); @@ -89,10 +89,10 @@ export class AlertMessageMessage implements MessageBase ExtraParams: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjAlertInfo['Message'] = buf.slice(pos, pos + (varLength - 1)); + newObjAlertInfo['Message'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjAlertInfo['ExtraParams'] = buf.slice(pos, pos + (varLength - 1)); + newObjAlertInfo['ExtraParams'] = buf.slice(pos, pos + varLength); pos += varLength; this.AlertInfo.push(newObjAlertInfo); } diff --git a/lib/classes/messages/AssetUploadRequest.ts b/lib/classes/messages/AssetUploadRequest.ts index 9e63bbb..eec2b55 100644 --- a/lib/classes/messages/AssetUploadRequest.ts +++ b/lib/classes/messages/AssetUploadRequest.ts @@ -63,7 +63,7 @@ export class AssetUploadRequestMessage implements MessageBase newObjAssetBlock['StoreLocal'] = (buf.readUInt8(pos++) === 1); varLength = buf.readUInt16LE(pos); pos += 2; - newObjAssetBlock['AssetData'] = buf.slice(pos, pos + (varLength - 1)); + newObjAssetBlock['AssetData'] = buf.slice(pos, pos + varLength); pos += varLength; this.AssetBlock = newObjAssetBlock; return pos - startPos; diff --git a/lib/classes/messages/AvatarAnimation.ts b/lib/classes/messages/AvatarAnimation.ts index a714063..e8eb4a5 100644 --- a/lib/classes/messages/AvatarAnimation.ts +++ b/lib/classes/messages/AvatarAnimation.ts @@ -124,7 +124,7 @@ export class AvatarAnimationMessage implements MessageBase TypeData: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjPhysicalAvatarEventList['TypeData'] = buf.slice(pos, pos + (varLength - 1)); + newObjPhysicalAvatarEventList['TypeData'] = buf.slice(pos, pos + varLength); pos += varLength; this.PhysicalAvatarEventList.push(newObjPhysicalAvatarEventList); } diff --git a/lib/classes/messages/AvatarAppearance.ts b/lib/classes/messages/AvatarAppearance.ts index 0efbe56..e381809 100644 --- a/lib/classes/messages/AvatarAppearance.ts +++ b/lib/classes/messages/AvatarAppearance.ts @@ -94,7 +94,7 @@ export class AvatarAppearanceMessage implements MessageBase }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjObjectData['TextureEntry'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['TextureEntry'] = buf.slice(pos, pos + varLength); 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 8c5f5d4..024b01e 100644 --- a/lib/classes/messages/AvatarClassifiedReply.ts +++ b/lib/classes/messages/AvatarClassifiedReply.ts @@ -85,7 +85,7 @@ export class AvatarClassifiedReplyMessage implements MessageBase newObjData['ClassifiedID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; this.Data.push(newObjData); } diff --git a/lib/classes/messages/AvatarGroupsReply.ts b/lib/classes/messages/AvatarGroupsReply.ts index cdb8cbe..63823b6 100644 --- a/lib/classes/messages/AvatarGroupsReply.ts +++ b/lib/classes/messages/AvatarGroupsReply.ts @@ -113,12 +113,12 @@ export class AvatarGroupsReplyMessage implements MessageBase pos += 8; newObjGroupData['AcceptNotices'] = (buf.readUInt8(pos++) === 1); varLength = buf.readUInt8(pos++); - newObjGroupData['GroupTitle'] = buf.slice(pos, pos + (varLength - 1)); + newObjGroupData['GroupTitle'] = buf.slice(pos, pos + varLength); pos += varLength; newObjGroupData['GroupID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjGroupData['GroupName'] = buf.slice(pos, pos + (varLength - 1)); + newObjGroupData['GroupName'] = buf.slice(pos, pos + varLength); 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 0239dae..dd624c2 100644 --- a/lib/classes/messages/AvatarInterestsReply.ts +++ b/lib/classes/messages/AvatarInterestsReply.ts @@ -83,15 +83,15 @@ export class AvatarInterestsReplyMessage implements MessageBase newObjPropertiesData['WantToMask'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjPropertiesData['WantToText'] = buf.slice(pos, pos + (varLength - 1)); + newObjPropertiesData['WantToText'] = buf.slice(pos, pos + varLength); pos += varLength; newObjPropertiesData['SkillsMask'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjPropertiesData['SkillsText'] = buf.slice(pos, pos + (varLength - 1)); + newObjPropertiesData['SkillsText'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjPropertiesData['LanguagesText'] = buf.slice(pos, pos + (varLength - 1)); + newObjPropertiesData['LanguagesText'] = buf.slice(pos, pos + varLength); pos += varLength; this.PropertiesData = newObjPropertiesData; return pos - startPos; diff --git a/lib/classes/messages/AvatarInterestsUpdate.ts b/lib/classes/messages/AvatarInterestsUpdate.ts index 26d12e7..cea6238 100644 --- a/lib/classes/messages/AvatarInterestsUpdate.ts +++ b/lib/classes/messages/AvatarInterestsUpdate.ts @@ -83,15 +83,15 @@ export class AvatarInterestsUpdateMessage implements MessageBase newObjPropertiesData['WantToMask'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjPropertiesData['WantToText'] = buf.slice(pos, pos + (varLength - 1)); + newObjPropertiesData['WantToText'] = buf.slice(pos, pos + varLength); pos += varLength; newObjPropertiesData['SkillsMask'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjPropertiesData['SkillsText'] = buf.slice(pos, pos + (varLength - 1)); + newObjPropertiesData['SkillsText'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjPropertiesData['LanguagesText'] = buf.slice(pos, pos + (varLength - 1)); + newObjPropertiesData['LanguagesText'] = buf.slice(pos, pos + varLength); pos += varLength; this.PropertiesData = newObjPropertiesData; return pos - startPos; diff --git a/lib/classes/messages/AvatarNotesReply.ts b/lib/classes/messages/AvatarNotesReply.ts index 8510390..feddbfc 100644 --- a/lib/classes/messages/AvatarNotesReply.ts +++ b/lib/classes/messages/AvatarNotesReply.ts @@ -61,7 +61,7 @@ export class AvatarNotesReplyMessage implements MessageBase pos += 16; varLength = buf.readUInt16LE(pos); pos += 2; - newObjData['Notes'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Notes'] = buf.slice(pos, pos + varLength); pos += varLength; this.Data = newObjData; return pos - startPos; diff --git a/lib/classes/messages/AvatarNotesUpdate.ts b/lib/classes/messages/AvatarNotesUpdate.ts index 0cee208..adb235c 100644 --- a/lib/classes/messages/AvatarNotesUpdate.ts +++ b/lib/classes/messages/AvatarNotesUpdate.ts @@ -68,7 +68,7 @@ export class AvatarNotesUpdateMessage implements MessageBase pos += 16; varLength = buf.readUInt16LE(pos); pos += 2; - newObjData['Notes'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Notes'] = buf.slice(pos, pos + varLength); pos += varLength; this.Data = newObjData; return pos - startPos; diff --git a/lib/classes/messages/AvatarPickerReply.ts b/lib/classes/messages/AvatarPickerReply.ts index 18d2ceb..cb52ede 100644 --- a/lib/classes/messages/AvatarPickerReply.ts +++ b/lib/classes/messages/AvatarPickerReply.ts @@ -91,10 +91,10 @@ export class AvatarPickerReplyMessage implements MessageBase newObjData['AvatarID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['FirstName'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['FirstName'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjData['LastName'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['LastName'] = buf.slice(pos, pos + varLength); pos += varLength; this.Data.push(newObjData); } diff --git a/lib/classes/messages/AvatarPickerRequest.ts b/lib/classes/messages/AvatarPickerRequest.ts index 5ab1f86..f9c5c24 100644 --- a/lib/classes/messages/AvatarPickerRequest.ts +++ b/lib/classes/messages/AvatarPickerRequest.ts @@ -66,7 +66,7 @@ export class AvatarPickerRequestMessage implements MessageBase Name: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; this.Data = newObjData; return pos - startPos; diff --git a/lib/classes/messages/AvatarPickerRequestBackend.ts b/lib/classes/messages/AvatarPickerRequestBackend.ts index 65bcee1..45e1f12 100644 --- a/lib/classes/messages/AvatarPickerRequestBackend.ts +++ b/lib/classes/messages/AvatarPickerRequestBackend.ts @@ -71,7 +71,7 @@ export class AvatarPickerRequestBackendMessage implements MessageBase Name: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; this.Data = newObjData; return pos - startPos; diff --git a/lib/classes/messages/AvatarPicksReply.ts b/lib/classes/messages/AvatarPicksReply.ts index 9dd580f..f6ac246 100644 --- a/lib/classes/messages/AvatarPicksReply.ts +++ b/lib/classes/messages/AvatarPicksReply.ts @@ -85,7 +85,7 @@ export class AvatarPicksReplyMessage implements MessageBase newObjData['PickID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['PickName'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['PickName'] = buf.slice(pos, pos + varLength); pos += varLength; this.Data.push(newObjData); } diff --git a/lib/classes/messages/AvatarPropertiesReply.ts b/lib/classes/messages/AvatarPropertiesReply.ts index ed323e7..4f3d068 100644 --- a/lib/classes/messages/AvatarPropertiesReply.ts +++ b/lib/classes/messages/AvatarPropertiesReply.ts @@ -111,19 +111,19 @@ export class AvatarPropertiesReplyMessage implements MessageBase pos += 16; varLength = buf.readUInt16LE(pos); pos += 2; - newObjPropertiesData['AboutText'] = buf.slice(pos, pos + (varLength - 1)); + newObjPropertiesData['AboutText'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjPropertiesData['FLAboutText'] = buf.slice(pos, pos + (varLength - 1)); + newObjPropertiesData['FLAboutText'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjPropertiesData['BornOn'] = buf.slice(pos, pos + (varLength - 1)); + newObjPropertiesData['BornOn'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjPropertiesData['ProfileURL'] = buf.slice(pos, pos + (varLength - 1)); + newObjPropertiesData['ProfileURL'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjPropertiesData['CharterMember'] = buf.slice(pos, pos + (varLength - 1)); + newObjPropertiesData['CharterMember'] = buf.slice(pos, pos + varLength); pos += varLength; newObjPropertiesData['Flags'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/AvatarPropertiesUpdate.ts b/lib/classes/messages/AvatarPropertiesUpdate.ts index a1184ad..7b392d2 100644 --- a/lib/classes/messages/AvatarPropertiesUpdate.ts +++ b/lib/classes/messages/AvatarPropertiesUpdate.ts @@ -95,15 +95,15 @@ export class AvatarPropertiesUpdateMessage implements MessageBase pos += 16; varLength = buf.readUInt16LE(pos); pos += 2; - newObjPropertiesData['AboutText'] = buf.slice(pos, pos + (varLength - 1)); + newObjPropertiesData['AboutText'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjPropertiesData['FLAboutText'] = buf.slice(pos, pos + (varLength - 1)); + newObjPropertiesData['FLAboutText'] = buf.slice(pos, pos + varLength); pos += varLength; newObjPropertiesData['AllowPublish'] = (buf.readUInt8(pos++) === 1); newObjPropertiesData['MaturePublish'] = (buf.readUInt8(pos++) === 1); varLength = buf.readUInt8(pos++); - newObjPropertiesData['ProfileURL'] = buf.slice(pos, pos + (varLength - 1)); + newObjPropertiesData['ProfileURL'] = buf.slice(pos, pos + varLength); pos += varLength; this.PropertiesData = newObjPropertiesData; return pos - startPos; diff --git a/lib/classes/messages/AvatarTextureUpdate.ts b/lib/classes/messages/AvatarTextureUpdate.ts index 2a7d0b3..d3eeca5 100644 --- a/lib/classes/messages/AvatarTextureUpdate.ts +++ b/lib/classes/messages/AvatarTextureUpdate.ts @@ -98,7 +98,7 @@ export class AvatarTextureUpdateMessage implements MessageBase pos += 16; newObjWearableData['TextureIndex'] = buf.readUInt8(pos++); varLength = buf.readUInt8(pos++); - newObjWearableData['HostName'] = buf.slice(pos, pos + (varLength - 1)); + newObjWearableData['HostName'] = buf.slice(pos, pos + varLength); pos += varLength; this.WearableData.push(newObjWearableData); } diff --git a/lib/classes/messages/BulkUpdateInventory.ts b/lib/classes/messages/BulkUpdateInventory.ts index e3ad664..16eacbf 100644 --- a/lib/classes/messages/BulkUpdateInventory.ts +++ b/lib/classes/messages/BulkUpdateInventory.ts @@ -168,7 +168,7 @@ export class BulkUpdateInventoryMessage implements MessageBase pos += 16; newObjFolderData['Type'] = buf.readInt8(pos++); varLength = buf.readUInt8(pos++); - newObjFolderData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjFolderData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; this.FolderData.push(newObjFolderData); } @@ -256,10 +256,10 @@ export class BulkUpdateInventoryMessage implements MessageBase newObjItemData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjItemData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjItemData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjItemData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjItemData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; newObjItemData['CreationDate'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/ChatFromSimulator.ts b/lib/classes/messages/ChatFromSimulator.ts index 82bcfd4..3bac422 100644 --- a/lib/classes/messages/ChatFromSimulator.ts +++ b/lib/classes/messages/ChatFromSimulator.ts @@ -74,7 +74,7 @@ export class ChatFromSimulatorMessage implements MessageBase Message: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjChatData['FromName'] = buf.slice(pos, pos + (varLength - 1)); + newObjChatData['FromName'] = buf.slice(pos, pos + varLength); 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.slice(pos, pos + (varLength - 1)); + newObjChatData['Message'] = buf.slice(pos, pos + varLength); pos += varLength; this.ChatData = newObjChatData; return pos - startPos; diff --git a/lib/classes/messages/ChatFromViewer.ts b/lib/classes/messages/ChatFromViewer.ts index e73bd35..c7b8306 100644 --- a/lib/classes/messages/ChatFromViewer.ts +++ b/lib/classes/messages/ChatFromViewer.ts @@ -70,7 +70,7 @@ export class ChatFromViewerMessage implements MessageBase }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjChatData['Message'] = buf.slice(pos, pos + (varLength - 1)); + newObjChatData['Message'] = buf.slice(pos, pos + varLength); 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 22f958e..b32f661 100644 --- a/lib/classes/messages/ChatPass.ts +++ b/lib/classes/messages/ChatPass.ts @@ -92,7 +92,7 @@ export class ChatPassMessage implements MessageBase newObjChatData['OwnerID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjChatData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjChatData['Name'] = buf.slice(pos, pos + varLength); 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.slice(pos, pos + (varLength - 1)); + newObjChatData['Message'] = buf.slice(pos, pos + varLength); pos += varLength; this.ChatData = newObjChatData; return pos - startPos; diff --git a/lib/classes/messages/ChildAgentUpdate.ts b/lib/classes/messages/ChildAgentUpdate.ts index be534c7..171fb34 100644 --- a/lib/classes/messages/ChildAgentUpdate.ts +++ b/lib/classes/messages/ChildAgentUpdate.ts @@ -297,7 +297,7 @@ export class ChildAgentUpdateMessage implements MessageBase newObjAgentData['Aspect'] = buf.readFloatLE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjAgentData['Throttles'] = buf.slice(pos, pos + (varLength - 1)); + newObjAgentData['Throttles'] = buf.slice(pos, pos + varLength); 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.slice(pos, pos + (varLength - 1)); + newObjAgentData['AgentTextures'] = buf.slice(pos, pos + varLength); pos += varLength; newObjAgentData['ActiveGroupID'] = new UUID(buf, pos); pos += 16; @@ -382,7 +382,7 @@ export class ChildAgentUpdateMessage implements MessageBase }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjNVPairData['NVPairs'] = buf.slice(pos, pos + (varLength - 1)); + newObjNVPairData['NVPairs'] = buf.slice(pos, pos + varLength); pos += varLength; this.NVPairData.push(newObjNVPairData); } @@ -436,7 +436,7 @@ export class ChildAgentUpdateMessage implements MessageBase InventoryHost: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjAgentInventoryHost['InventoryHost'] = buf.slice(pos, pos + (varLength - 1)); + newObjAgentInventoryHost['InventoryHost'] = buf.slice(pos, pos + varLength); pos += varLength; this.AgentInventoryHost.push(newObjAgentInventoryHost); } diff --git a/lib/classes/messages/ClassifiedInfoReply.ts b/lib/classes/messages/ClassifiedInfoReply.ts index 464c378..d0ce998 100644 --- a/lib/classes/messages/ClassifiedInfoReply.ts +++ b/lib/classes/messages/ClassifiedInfoReply.ts @@ -136,11 +136,11 @@ export class ClassifiedInfoReplyMessage implements MessageBase newObjData['Category'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjData['Desc'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Desc'] = buf.slice(pos, pos + varLength); 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.slice(pos, pos + (varLength - 1)); + newObjData['SimName'] = buf.slice(pos, pos + varLength); pos += varLength; newObjData['PosGlobal'] = new Vector3(buf, pos, true); pos += 24; varLength = buf.readUInt8(pos++); - newObjData['ParcelName'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['ParcelName'] = buf.slice(pos, pos + varLength); 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 2738dd7..9b7960e 100644 --- a/lib/classes/messages/ClassifiedInfoUpdate.ts +++ b/lib/classes/messages/ClassifiedInfoUpdate.ts @@ -110,11 +110,11 @@ export class ClassifiedInfoUpdateMessage implements MessageBase newObjData['Category'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjData['Desc'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Desc'] = buf.slice(pos, pos + varLength); 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 7ee8973..7d37d68 100644 --- a/lib/classes/messages/CopyInventoryItem.ts +++ b/lib/classes/messages/CopyInventoryItem.ts @@ -106,7 +106,7 @@ export class CopyInventoryItemMessage implements MessageBase newObjInventoryData['NewFolderID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjInventoryData['NewName'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryData['NewName'] = buf.slice(pos, pos + varLength); pos += varLength; this.InventoryData.push(newObjInventoryData); } diff --git a/lib/classes/messages/CreateGroupReply.ts b/lib/classes/messages/CreateGroupReply.ts index 1b823de..69976bf 100644 --- a/lib/classes/messages/CreateGroupReply.ts +++ b/lib/classes/messages/CreateGroupReply.ts @@ -64,7 +64,7 @@ export class CreateGroupReplyMessage implements MessageBase pos += 16; newObjReplyData['Success'] = (buf.readUInt8(pos++) === 1); varLength = buf.readUInt8(pos++); - newObjReplyData['Message'] = buf.slice(pos, pos + (varLength - 1)); + newObjReplyData['Message'] = buf.slice(pos, pos + varLength); pos += varLength; this.ReplyData = newObjReplyData; return pos - startPos; diff --git a/lib/classes/messages/CreateGroupRequest.ts b/lib/classes/messages/CreateGroupRequest.ts index 6c68345..4138a53 100644 --- a/lib/classes/messages/CreateGroupRequest.ts +++ b/lib/classes/messages/CreateGroupRequest.ts @@ -92,11 +92,11 @@ export class CreateGroupRequestMessage implements MessageBase MaturePublish: false }; varLength = buf.readUInt8(pos++); - newObjGroupData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjGroupData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjGroupData['Charter'] = buf.slice(pos, pos + (varLength - 1)); + newObjGroupData['Charter'] = buf.slice(pos, pos + varLength); 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 fe25fa8..43db175 100644 --- a/lib/classes/messages/CreateGroupRequestExtended.ts +++ b/lib/classes/messages/CreateGroupRequestExtended.ts @@ -99,11 +99,11 @@ export class CreateGroupRequestExtendedMessage implements MessageBase MaturePublish: false }; varLength = buf.readUInt8(pos++); - newObjGroupData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjGroupData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjGroupData['Charter'] = buf.slice(pos, pos + (varLength - 1)); + newObjGroupData['Charter'] = buf.slice(pos, pos + varLength); 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 fd70b4d..ddaf70a 100644 --- a/lib/classes/messages/CreateInventoryFolder.ts +++ b/lib/classes/messages/CreateInventoryFolder.ts @@ -78,7 +78,7 @@ export class CreateInventoryFolderMessage implements MessageBase pos += 16; newObjFolderData['Type'] = buf.readInt8(pos++); varLength = buf.readUInt8(pos++); - newObjFolderData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjFolderData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; this.FolderData = newObjFolderData; return pos - startPos; diff --git a/lib/classes/messages/CreateInventoryItem.ts b/lib/classes/messages/CreateInventoryItem.ts index d29c717..0452d56 100644 --- a/lib/classes/messages/CreateInventoryItem.ts +++ b/lib/classes/messages/CreateInventoryItem.ts @@ -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.slice(pos, pos + (varLength - 1)); + newObjInventoryBlock['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjInventoryBlock['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryBlock['Description'] = buf.slice(pos, pos + varLength); pos += varLength; this.InventoryBlock = newObjInventoryBlock; return pos - startPos; diff --git a/lib/classes/messages/CreateLandmarkForEvent.ts b/lib/classes/messages/CreateLandmarkForEvent.ts index efc85a2..9dc268f 100644 --- a/lib/classes/messages/CreateLandmarkForEvent.ts +++ b/lib/classes/messages/CreateLandmarkForEvent.ts @@ -79,7 +79,7 @@ export class CreateLandmarkForEventMessage implements MessageBase newObjInventoryBlock['FolderID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjInventoryBlock['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryBlock['Name'] = buf.slice(pos, pos + varLength); pos += varLength; this.InventoryBlock = newObjInventoryBlock; return pos - startPos; diff --git a/lib/classes/messages/CrossedRegion.ts b/lib/classes/messages/CrossedRegion.ts index 7603dbb..4527cbd 100644 --- a/lib/classes/messages/CrossedRegion.ts +++ b/lib/classes/messages/CrossedRegion.ts @@ -95,7 +95,7 @@ export class CrossedRegionMessage implements MessageBase pos += 8; varLength = buf.readUInt16LE(pos); pos += 2; - newObjRegionData['SeedCapability'] = buf.slice(pos, pos + (varLength - 1)); + newObjRegionData['SeedCapability'] = buf.slice(pos, pos + varLength); pos += varLength; this.RegionData = newObjRegionData; const newObjInfo: { diff --git a/lib/classes/messages/DirClassifiedQuery.ts b/lib/classes/messages/DirClassifiedQuery.ts index 434a270..6658ef6 100644 --- a/lib/classes/messages/DirClassifiedQuery.ts +++ b/lib/classes/messages/DirClassifiedQuery.ts @@ -81,7 +81,7 @@ export class DirClassifiedQueryMessage implements MessageBase newObjQueryData['QueryID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryData['QueryText'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryData['QueryText'] = buf.slice(pos, pos + varLength); pos += varLength; newObjQueryData['QueryFlags'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/DirClassifiedQueryBackend.ts b/lib/classes/messages/DirClassifiedQueryBackend.ts index a6f5fba..99526d3 100644 --- a/lib/classes/messages/DirClassifiedQueryBackend.ts +++ b/lib/classes/messages/DirClassifiedQueryBackend.ts @@ -83,7 +83,7 @@ export class DirClassifiedQueryBackendMessage implements MessageBase newObjQueryData['QueryID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryData['QueryText'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryData['QueryText'] = buf.slice(pos, pos + varLength); pos += varLength; newObjQueryData['QueryFlags'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/DirClassifiedReply.ts b/lib/classes/messages/DirClassifiedReply.ts index 27e66a9..d3d78bf 100644 --- a/lib/classes/messages/DirClassifiedReply.ts +++ b/lib/classes/messages/DirClassifiedReply.ts @@ -120,7 +120,7 @@ export class DirClassifiedReplyMessage implements MessageBase newObjQueryReplies['ClassifiedID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryReplies['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryReplies['Name'] = buf.slice(pos, pos + varLength); 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 8b36528..a2551ee 100644 --- a/lib/classes/messages/DirEventsReply.ts +++ b/lib/classes/messages/DirEventsReply.ts @@ -122,12 +122,12 @@ export class DirEventsReplyMessage implements MessageBase newObjQueryReplies['OwnerID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryReplies['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryReplies['Name'] = buf.slice(pos, pos + varLength); pos += varLength; newObjQueryReplies['EventID'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjQueryReplies['Date'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryReplies['Date'] = buf.slice(pos, pos + varLength); pos += varLength; newObjQueryReplies['UnixTime'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/DirFindQuery.ts b/lib/classes/messages/DirFindQuery.ts index 19976dc..cc1df1e 100644 --- a/lib/classes/messages/DirFindQuery.ts +++ b/lib/classes/messages/DirFindQuery.ts @@ -76,7 +76,7 @@ export class DirFindQueryMessage implements MessageBase newObjQueryData['QueryID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryData['QueryText'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryData['QueryText'] = buf.slice(pos, pos + varLength); pos += varLength; newObjQueryData['QueryFlags'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/DirFindQueryBackend.ts b/lib/classes/messages/DirFindQueryBackend.ts index 2e59967..9e0d64d 100644 --- a/lib/classes/messages/DirFindQueryBackend.ts +++ b/lib/classes/messages/DirFindQueryBackend.ts @@ -78,7 +78,7 @@ export class DirFindQueryBackendMessage implements MessageBase newObjQueryData['QueryID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryData['QueryText'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryData['QueryText'] = buf.slice(pos, pos + varLength); pos += varLength; newObjQueryData['QueryFlags'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/DirGroupsReply.ts b/lib/classes/messages/DirGroupsReply.ts index 91e69a3..f9b4ef2 100644 --- a/lib/classes/messages/DirGroupsReply.ts +++ b/lib/classes/messages/DirGroupsReply.ts @@ -101,7 +101,7 @@ export class DirGroupsReplyMessage implements MessageBase newObjQueryReplies['GroupID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryReplies['GroupName'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryReplies['GroupName'] = buf.slice(pos, pos + varLength); pos += varLength; newObjQueryReplies['Members'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/DirLandReply.ts b/lib/classes/messages/DirLandReply.ts index fbc62fb..3ab9975 100644 --- a/lib/classes/messages/DirLandReply.ts +++ b/lib/classes/messages/DirLandReply.ts @@ -109,7 +109,7 @@ export class DirLandReplyMessage implements MessageBase newObjQueryReplies['ParcelID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryReplies['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryReplies['Name'] = buf.slice(pos, pos + varLength); 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 78af95a..f58e11f 100644 --- a/lib/classes/messages/DirPeopleReply.ts +++ b/lib/classes/messages/DirPeopleReply.ts @@ -112,13 +112,13 @@ export class DirPeopleReplyMessage implements MessageBase newObjQueryReplies['AgentID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryReplies['FirstName'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryReplies['FirstName'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjQueryReplies['LastName'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryReplies['LastName'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjQueryReplies['Group'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryReplies['Group'] = buf.slice(pos, pos + varLength); 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 4054b74..d731031 100644 --- a/lib/classes/messages/DirPlacesQuery.ts +++ b/lib/classes/messages/DirPlacesQuery.ts @@ -86,13 +86,13 @@ export class DirPlacesQueryMessage implements MessageBase newObjQueryData['QueryID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryData['QueryText'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryData['QueryText'] = buf.slice(pos, pos + varLength); pos += varLength; newObjQueryData['QueryFlags'] = buf.readUInt32LE(pos); pos += 4; newObjQueryData['Category'] = buf.readInt8(pos++); varLength = buf.readUInt8(pos++); - newObjQueryData['SimName'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryData['SimName'] = buf.slice(pos, pos + varLength); pos += varLength; newObjQueryData['QueryStart'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/DirPlacesQueryBackend.ts b/lib/classes/messages/DirPlacesQueryBackend.ts index b9e9bc0..19ab870 100644 --- a/lib/classes/messages/DirPlacesQueryBackend.ts +++ b/lib/classes/messages/DirPlacesQueryBackend.ts @@ -88,13 +88,13 @@ export class DirPlacesQueryBackendMessage implements MessageBase newObjQueryData['QueryID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryData['QueryText'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryData['QueryText'] = buf.slice(pos, pos + varLength); pos += varLength; newObjQueryData['QueryFlags'] = buf.readUInt32LE(pos); pos += 4; newObjQueryData['Category'] = buf.readInt8(pos++); varLength = buf.readUInt8(pos++); - newObjQueryData['SimName'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryData['SimName'] = buf.slice(pos, pos + varLength); pos += varLength; newObjQueryData['EstateID'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/DirPlacesReply.ts b/lib/classes/messages/DirPlacesReply.ts index 2a55ed6..b5cf234 100644 --- a/lib/classes/messages/DirPlacesReply.ts +++ b/lib/classes/messages/DirPlacesReply.ts @@ -124,7 +124,7 @@ export class DirPlacesReplyMessage implements MessageBase newObjQueryReplies['ParcelID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryReplies['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryReplies['Name'] = buf.slice(pos, pos + varLength); 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 a363d85..936057a 100644 --- a/lib/classes/messages/DirPopularReply.ts +++ b/lib/classes/messages/DirPopularReply.ts @@ -96,7 +96,7 @@ export class DirPopularReplyMessage implements MessageBase newObjQueryReplies['ParcelID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryReplies['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryReplies['Name'] = buf.slice(pos, pos + varLength); pos += varLength; newObjQueryReplies['Dwell'] = buf.readFloatLE(pos); pos += 4; diff --git a/lib/classes/messages/EdgeDataPacket.ts b/lib/classes/messages/EdgeDataPacket.ts index 6b4eb8e..65068ac 100644 --- a/lib/classes/messages/EdgeDataPacket.ts +++ b/lib/classes/messages/EdgeDataPacket.ts @@ -50,7 +50,7 @@ export class EdgeDataPacketMessage implements MessageBase newObjEdgeData['Direction'] = buf.readUInt8(pos++); varLength = buf.readUInt16LE(pos); pos += 2; - newObjEdgeData['LayerData'] = buf.slice(pos, pos + (varLength - 1)); + newObjEdgeData['LayerData'] = buf.slice(pos, pos + varLength); pos += varLength; this.EdgeData = newObjEdgeData; return pos - startPos; diff --git a/lib/classes/messages/EmailMessageReply.ts b/lib/classes/messages/EmailMessageReply.ts index 743c002..7f4fb3b 100644 --- a/lib/classes/messages/EmailMessageReply.ts +++ b/lib/classes/messages/EmailMessageReply.ts @@ -79,17 +79,17 @@ export class EmailMessageReplyMessage implements MessageBase newObjDataBlock['Time'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjDataBlock['FromAddress'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataBlock['FromAddress'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjDataBlock['Subject'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataBlock['Subject'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjDataBlock['Data'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataBlock['Data'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjDataBlock['MailFilter'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataBlock['MailFilter'] = buf.slice(pos, pos + varLength); pos += varLength; this.DataBlock = newObjDataBlock; return pos - startPos; diff --git a/lib/classes/messages/EmailMessageRequest.ts b/lib/classes/messages/EmailMessageRequest.ts index bc0f651..ab998cd 100644 --- a/lib/classes/messages/EmailMessageRequest.ts +++ b/lib/classes/messages/EmailMessageRequest.ts @@ -52,10 +52,10 @@ export class EmailMessageRequestMessage implements MessageBase newObjDataBlock['ObjectID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjDataBlock['FromAddress'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataBlock['FromAddress'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjDataBlock['Subject'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataBlock['Subject'] = buf.slice(pos, pos + varLength); pos += varLength; this.DataBlock = newObjDataBlock; return pos - startPos; diff --git a/lib/classes/messages/Error.ts b/lib/classes/messages/Error.ts index 2c8e54d..59202f6 100644 --- a/lib/classes/messages/Error.ts +++ b/lib/classes/messages/Error.ts @@ -84,20 +84,20 @@ export class ErrorMessage implements MessageBase newObjData['Code'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjData['Token'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Token'] = buf.slice(pos, pos + varLength); pos += varLength; newObjData['ID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['System'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['System'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjData['Message'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Message'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjData['Data'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Data'] = buf.slice(pos, pos + varLength); pos += varLength; this.Data = newObjData; return pos - startPos; diff --git a/lib/classes/messages/EstateCovenantReply.ts b/lib/classes/messages/EstateCovenantReply.ts index 068ee9a..5fb7cc8 100644 --- a/lib/classes/messages/EstateCovenantReply.ts +++ b/lib/classes/messages/EstateCovenantReply.ts @@ -58,7 +58,7 @@ export class EstateCovenantReplyMessage implements MessageBase newObjData['CovenantTimestamp'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjData['EstateName'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['EstateName'] = buf.slice(pos, pos + varLength); 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 04d9351..7438f3f 100644 --- a/lib/classes/messages/EstateOwnerMessage.ts +++ b/lib/classes/messages/EstateOwnerMessage.ts @@ -92,7 +92,7 @@ export class EstateOwnerMessageMessage implements MessageBase Invoice: UUID.zero() }; varLength = buf.readUInt8(pos++); - newObjMethodData['Method'] = buf.slice(pos, pos + (varLength - 1)); + newObjMethodData['Method'] = buf.slice(pos, pos + varLength); pos += varLength; newObjMethodData['Invoice'] = new UUID(buf, pos); pos += 16; @@ -107,7 +107,7 @@ export class EstateOwnerMessageMessage implements MessageBase Parameter: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjParamList['Parameter'] = buf.slice(pos, pos + (varLength - 1)); + newObjParamList['Parameter'] = buf.slice(pos, pos + varLength); pos += varLength; this.ParamList.push(newObjParamList); } diff --git a/lib/classes/messages/EventGodDelete.ts b/lib/classes/messages/EventGodDelete.ts index 7f9c867..ed92389 100644 --- a/lib/classes/messages/EventGodDelete.ts +++ b/lib/classes/messages/EventGodDelete.ts @@ -89,7 +89,7 @@ export class EventGodDeleteMessage implements MessageBase newObjQueryData['QueryID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryData['QueryText'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryData['QueryText'] = buf.slice(pos, pos + varLength); pos += varLength; newObjQueryData['QueryFlags'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/EventInfoReply.ts b/lib/classes/messages/EventInfoReply.ts index 242d916..6cc1d19 100644 --- a/lib/classes/messages/EventInfoReply.ts +++ b/lib/classes/messages/EventInfoReply.ts @@ -121,20 +121,20 @@ export class EventInfoReplyMessage implements MessageBase newObjEventData['EventID'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjEventData['Creator'] = buf.slice(pos, pos + (varLength - 1)); + newObjEventData['Creator'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjEventData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjEventData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjEventData['Category'] = buf.slice(pos, pos + (varLength - 1)); + newObjEventData['Category'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjEventData['Desc'] = buf.slice(pos, pos + (varLength - 1)); + newObjEventData['Desc'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjEventData['Date'] = buf.slice(pos, pos + (varLength - 1)); + newObjEventData['Date'] = buf.slice(pos, pos + varLength); 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.slice(pos, pos + (varLength - 1)); + newObjEventData['SimName'] = buf.slice(pos, pos + varLength); 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 e24ab49..7a25140 100644 --- a/lib/classes/messages/FeatureDisabled.ts +++ b/lib/classes/messages/FeatureDisabled.ts @@ -49,7 +49,7 @@ export class FeatureDisabledMessage implements MessageBase TransactionID: UUID.zero() }; varLength = buf.readUInt8(pos++); - newObjFailureInfo['ErrorMessage'] = buf.slice(pos, pos + (varLength - 1)); + newObjFailureInfo['ErrorMessage'] = buf.slice(pos, pos + varLength); 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 e45edc2..e68da48 100644 --- a/lib/classes/messages/FetchInventoryReply.ts +++ b/lib/classes/messages/FetchInventoryReply.ts @@ -198,10 +198,10 @@ export class FetchInventoryReplyMessage implements MessageBase newObjInventoryData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjInventoryData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjInventoryData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; newObjInventoryData['CreationDate'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/GenericMessage.ts b/lib/classes/messages/GenericMessage.ts index d740105..303df87 100644 --- a/lib/classes/messages/GenericMessage.ts +++ b/lib/classes/messages/GenericMessage.ts @@ -92,7 +92,7 @@ export class GenericMessageMessage implements MessageBase Invoice: UUID.zero() }; varLength = buf.readUInt8(pos++); - newObjMethodData['Method'] = buf.slice(pos, pos + (varLength - 1)); + newObjMethodData['Method'] = buf.slice(pos, pos + varLength); pos += varLength; newObjMethodData['Invoice'] = new UUID(buf, pos); pos += 16; @@ -107,7 +107,7 @@ export class GenericMessageMessage implements MessageBase Parameter: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjParamList['Parameter'] = buf.slice(pos, pos + (varLength - 1)); + newObjParamList['Parameter'] = buf.slice(pos, pos + varLength); pos += varLength; this.ParamList.push(newObjParamList); } diff --git a/lib/classes/messages/GodKickUser.ts b/lib/classes/messages/GodKickUser.ts index 7ae9236..05a3729 100644 --- a/lib/classes/messages/GodKickUser.ts +++ b/lib/classes/messages/GodKickUser.ts @@ -69,7 +69,7 @@ export class GodKickUserMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjUserInfo['Reason'] = buf.slice(pos, pos + (varLength - 1)); + newObjUserInfo['Reason'] = buf.slice(pos, pos + varLength); pos += varLength; this.UserInfo = newObjUserInfo; return pos - startPos; diff --git a/lib/classes/messages/GodUpdateRegionInfo.ts b/lib/classes/messages/GodUpdateRegionInfo.ts index 6c98728..83aa741 100644 --- a/lib/classes/messages/GodUpdateRegionInfo.ts +++ b/lib/classes/messages/GodUpdateRegionInfo.ts @@ -107,7 +107,7 @@ export class GodUpdateRegionInfoMessage implements MessageBase RedirectGridY: 0 }; varLength = buf.readUInt8(pos++); - newObjRegionInfo['SimName'] = buf.slice(pos, pos + (varLength - 1)); + newObjRegionInfo['SimName'] = buf.slice(pos, pos + varLength); pos += varLength; newObjRegionInfo['EstateID'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/GodlikeMessage.ts b/lib/classes/messages/GodlikeMessage.ts index 6d68fc0..4b75b12 100644 --- a/lib/classes/messages/GodlikeMessage.ts +++ b/lib/classes/messages/GodlikeMessage.ts @@ -92,7 +92,7 @@ export class GodlikeMessageMessage implements MessageBase Invoice: UUID.zero() }; varLength = buf.readUInt8(pos++); - newObjMethodData['Method'] = buf.slice(pos, pos + (varLength - 1)); + newObjMethodData['Method'] = buf.slice(pos, pos + varLength); pos += varLength; newObjMethodData['Invoice'] = new UUID(buf, pos); pos += 16; @@ -107,7 +107,7 @@ export class GodlikeMessageMessage implements MessageBase Parameter: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjParamList['Parameter'] = buf.slice(pos, pos + (varLength - 1)); + newObjParamList['Parameter'] = buf.slice(pos, pos + varLength); pos += varLength; this.ParamList.push(newObjParamList); } diff --git a/lib/classes/messages/GroupAccountDetailsReply.ts b/lib/classes/messages/GroupAccountDetailsReply.ts index c23be0d..dd562ea 100644 --- a/lib/classes/messages/GroupAccountDetailsReply.ts +++ b/lib/classes/messages/GroupAccountDetailsReply.ts @@ -104,7 +104,7 @@ export class GroupAccountDetailsReplyMessage implements MessageBase newObjMoneyData['CurrentInterval'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjMoneyData['StartDate'] = buf.slice(pos, pos + (varLength - 1)); + newObjMoneyData['StartDate'] = buf.slice(pos, pos + varLength); pos += varLength; this.MoneyData = newObjMoneyData; const count = buf.readUInt8(pos++); @@ -119,7 +119,7 @@ export class GroupAccountDetailsReplyMessage implements MessageBase Amount: 0 }; varLength = buf.readUInt8(pos++); - newObjHistoryData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjHistoryData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; newObjHistoryData['Amount'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/GroupAccountSummaryReply.ts b/lib/classes/messages/GroupAccountSummaryReply.ts index 8e1ae75..321a72d 100644 --- a/lib/classes/messages/GroupAccountSummaryReply.ts +++ b/lib/classes/messages/GroupAccountSummaryReply.ts @@ -162,7 +162,7 @@ export class GroupAccountSummaryReplyMessage implements MessageBase newObjMoneyData['CurrentInterval'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjMoneyData['StartDate'] = buf.slice(pos, pos + (varLength - 1)); + newObjMoneyData['StartDate'] = buf.slice(pos, pos + varLength); 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.slice(pos, pos + (varLength - 1)); + newObjMoneyData['LastTaxDate'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjMoneyData['TaxDate'] = buf.slice(pos, pos + (varLength - 1)); + newObjMoneyData['TaxDate'] = buf.slice(pos, pos + varLength); pos += varLength; this.MoneyData = newObjMoneyData; return pos - startPos; diff --git a/lib/classes/messages/GroupAccountTransactionsReply.ts b/lib/classes/messages/GroupAccountTransactionsReply.ts index d002cb5..8f17a86 100644 --- a/lib/classes/messages/GroupAccountTransactionsReply.ts +++ b/lib/classes/messages/GroupAccountTransactionsReply.ts @@ -115,7 +115,7 @@ export class GroupAccountTransactionsReplyMessage implements MessageBase newObjMoneyData['CurrentInterval'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjMoneyData['StartDate'] = buf.slice(pos, pos + (varLength - 1)); + newObjMoneyData['StartDate'] = buf.slice(pos, pos + varLength); pos += varLength; this.MoneyData = newObjMoneyData; const count = buf.readUInt8(pos++); @@ -136,15 +136,15 @@ export class GroupAccountTransactionsReplyMessage implements MessageBase Amount: 0 }; varLength = buf.readUInt8(pos++); - newObjHistoryData['Time'] = buf.slice(pos, pos + (varLength - 1)); + newObjHistoryData['Time'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjHistoryData['User'] = buf.slice(pos, pos + (varLength - 1)); + newObjHistoryData['User'] = buf.slice(pos, pos + varLength); pos += varLength; newObjHistoryData['Type'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjHistoryData['Item'] = buf.slice(pos, pos + (varLength - 1)); + newObjHistoryData['Item'] = buf.slice(pos, pos + varLength); pos += varLength; newObjHistoryData['Amount'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/GroupActiveProposalItemReply.ts b/lib/classes/messages/GroupActiveProposalItemReply.ts index c04975c..bf73a13 100644 --- a/lib/classes/messages/GroupActiveProposalItemReply.ts +++ b/lib/classes/messages/GroupActiveProposalItemReply.ts @@ -150,24 +150,24 @@ export class GroupActiveProposalItemReplyMessage implements MessageBase newObjProposalData['VoteInitiator'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjProposalData['TerseDateID'] = buf.slice(pos, pos + (varLength - 1)); + newObjProposalData['TerseDateID'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjProposalData['StartDateTime'] = buf.slice(pos, pos + (varLength - 1)); + newObjProposalData['StartDateTime'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjProposalData['EndDateTime'] = buf.slice(pos, pos + (varLength - 1)); + newObjProposalData['EndDateTime'] = buf.slice(pos, pos + varLength); pos += varLength; newObjProposalData['AlreadyVoted'] = (buf.readUInt8(pos++) === 1); varLength = buf.readUInt8(pos++); - newObjProposalData['VoteCast'] = buf.slice(pos, pos + (varLength - 1)); + newObjProposalData['VoteCast'] = buf.slice(pos, pos + varLength); pos += varLength; newObjProposalData['Majority'] = buf.readFloatLE(pos); pos += 4; newObjProposalData['Quorum'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjProposalData['ProposalText'] = buf.slice(pos, pos + (varLength - 1)); + newObjProposalData['ProposalText'] = buf.slice(pos, pos + varLength); pos += varLength; this.ProposalData.push(newObjProposalData); } diff --git a/lib/classes/messages/GroupDataUpdate.ts b/lib/classes/messages/GroupDataUpdate.ts index 6a602c6..2076c13 100644 --- a/lib/classes/messages/GroupDataUpdate.ts +++ b/lib/classes/messages/GroupDataUpdate.ts @@ -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.slice(pos, pos + (varLength - 1)); + newObjAgentGroupData['GroupTitle'] = buf.slice(pos, pos + varLength); pos += varLength; this.AgentGroupData.push(newObjAgentGroupData); } diff --git a/lib/classes/messages/GroupMembersReply.ts b/lib/classes/messages/GroupMembersReply.ts index 23b412e..8f244c7 100644 --- a/lib/classes/messages/GroupMembersReply.ts +++ b/lib/classes/messages/GroupMembersReply.ts @@ -130,12 +130,12 @@ export class GroupMembersReplyMessage implements MessageBase newObjMemberData['Contribution'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjMemberData['OnlineStatus'] = buf.slice(pos, pos + (varLength - 1)); + newObjMemberData['OnlineStatus'] = buf.slice(pos, pos + varLength); pos += varLength; newObjMemberData['AgentPowers'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4)); pos += 8; varLength = buf.readUInt8(pos++); - newObjMemberData['Title'] = buf.slice(pos, pos + (varLength - 1)); + newObjMemberData['Title'] = buf.slice(pos, pos + varLength); 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 48f1829..ffbcc70 100644 --- a/lib/classes/messages/GroupNoticeAdd.ts +++ b/lib/classes/messages/GroupNoticeAdd.ts @@ -85,15 +85,15 @@ export class GroupNoticeAddMessage implements MessageBase pos += 16; newObjMessageBlock['Dialog'] = buf.readUInt8(pos++); varLength = buf.readUInt8(pos++); - newObjMessageBlock['FromAgentName'] = buf.slice(pos, pos + (varLength - 1)); + newObjMessageBlock['FromAgentName'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjMessageBlock['Message'] = buf.slice(pos, pos + (varLength - 1)); + newObjMessageBlock['Message'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjMessageBlock['BinaryBucket'] = buf.slice(pos, pos + (varLength - 1)); + newObjMessageBlock['BinaryBucket'] = buf.slice(pos, pos + varLength); pos += varLength; this.MessageBlock = newObjMessageBlock; return pos - startPos; diff --git a/lib/classes/messages/GroupNoticesListReply.ts b/lib/classes/messages/GroupNoticesListReply.ts index db536fc..b5ca5a5 100644 --- a/lib/classes/messages/GroupNoticesListReply.ts +++ b/lib/classes/messages/GroupNoticesListReply.ts @@ -109,11 +109,11 @@ export class GroupNoticesListReplyMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjData['FromName'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['FromName'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjData['Subject'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Subject'] = buf.slice(pos, pos + varLength); 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 61d5ade..af2f3f3 100644 --- a/lib/classes/messages/GroupProfileReply.ts +++ b/lib/classes/messages/GroupProfileReply.ts @@ -131,15 +131,15 @@ export class GroupProfileReplyMessage implements MessageBase newObjGroupData['GroupID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjGroupData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjGroupData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjGroupData['Charter'] = buf.slice(pos, pos + (varLength - 1)); + newObjGroupData['Charter'] = buf.slice(pos, pos + varLength); pos += varLength; newObjGroupData['ShowInList'] = (buf.readUInt8(pos++) === 1); varLength = buf.readUInt8(pos++); - newObjGroupData['MemberTitle'] = buf.slice(pos, pos + (varLength - 1)); + newObjGroupData['MemberTitle'] = buf.slice(pos, pos + varLength); 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 02aa183..797c1dd 100644 --- a/lib/classes/messages/GroupProposalBallot.ts +++ b/lib/classes/messages/GroupProposalBallot.ts @@ -73,7 +73,7 @@ export class GroupProposalBallotMessage implements MessageBase newObjProposalData['GroupID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjProposalData['VoteCast'] = buf.slice(pos, pos + (varLength - 1)); + newObjProposalData['VoteCast'] = buf.slice(pos, pos + varLength); pos += varLength; this.ProposalData = newObjProposalData; return pos - startPos; diff --git a/lib/classes/messages/GroupRoleDataReply.ts b/lib/classes/messages/GroupRoleDataReply.ts index 3b8c57e..cbce009 100644 --- a/lib/classes/messages/GroupRoleDataReply.ts +++ b/lib/classes/messages/GroupRoleDataReply.ts @@ -130,13 +130,13 @@ export class GroupRoleDataReplyMessage implements MessageBase newObjRoleData['RoleID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjRoleData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjRoleData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjRoleData['Title'] = buf.slice(pos, pos + (varLength - 1)); + newObjRoleData['Title'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjRoleData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjRoleData['Description'] = buf.slice(pos, pos + varLength); 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 64e821f..abaf906 100644 --- a/lib/classes/messages/GroupRoleUpdate.ts +++ b/lib/classes/messages/GroupRoleUpdate.ts @@ -116,13 +116,13 @@ export class GroupRoleUpdateMessage implements MessageBase newObjRoleData['RoleID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjRoleData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjRoleData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjRoleData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjRoleData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjRoleData['Title'] = buf.slice(pos, pos + (varLength - 1)); + newObjRoleData['Title'] = buf.slice(pos, pos + varLength); 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 234a786..574832c 100644 --- a/lib/classes/messages/GroupTitlesReply.ts +++ b/lib/classes/messages/GroupTitlesReply.ts @@ -94,7 +94,7 @@ export class GroupTitlesReplyMessage implements MessageBase Selected: false }; varLength = buf.readUInt8(pos++); - newObjGroupData['Title'] = buf.slice(pos, pos + (varLength - 1)); + newObjGroupData['Title'] = buf.slice(pos, pos + varLength); 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 f018224..d50550e 100644 --- a/lib/classes/messages/GroupVoteHistoryItemReply.ts +++ b/lib/classes/messages/GroupVoteHistoryItemReply.ts @@ -159,21 +159,21 @@ export class GroupVoteHistoryItemReplyMessage implements MessageBase newObjHistoryItemData['VoteID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjHistoryItemData['TerseDateID'] = buf.slice(pos, pos + (varLength - 1)); + newObjHistoryItemData['TerseDateID'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjHistoryItemData['StartDateTime'] = buf.slice(pos, pos + (varLength - 1)); + newObjHistoryItemData['StartDateTime'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjHistoryItemData['EndDateTime'] = buf.slice(pos, pos + (varLength - 1)); + newObjHistoryItemData['EndDateTime'] = buf.slice(pos, pos + varLength); pos += varLength; newObjHistoryItemData['VoteInitiator'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjHistoryItemData['VoteType'] = buf.slice(pos, pos + (varLength - 1)); + newObjHistoryItemData['VoteType'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjHistoryItemData['VoteResult'] = buf.slice(pos, pos + (varLength - 1)); + newObjHistoryItemData['VoteResult'] = buf.slice(pos, pos + varLength); 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.slice(pos, pos + (varLength - 1)); + newObjHistoryItemData['ProposalText'] = buf.slice(pos, pos + varLength); pos += varLength; this.HistoryItemData = newObjHistoryItemData; const count = buf.readUInt8(pos++); @@ -200,7 +200,7 @@ export class GroupVoteHistoryItemReplyMessage implements MessageBase newObjVoteItem['CandidateID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjVoteItem['VoteCast'] = buf.slice(pos, pos + (varLength - 1)); + newObjVoteItem['VoteCast'] = buf.slice(pos, pos + varLength); pos += varLength; newObjVoteItem['NumVotes'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/ImageData.ts b/lib/classes/messages/ImageData.ts index 5a04020..468dfa5 100644 --- a/lib/classes/messages/ImageData.ts +++ b/lib/classes/messages/ImageData.ts @@ -73,7 +73,7 @@ export class ImageDataMessage implements MessageBase }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjImageData['Data'] = buf.slice(pos, pos + (varLength - 1)); + newObjImageData['Data'] = buf.slice(pos, pos + varLength); pos += varLength; this.ImageData = newObjImageData; return pos - startPos; diff --git a/lib/classes/messages/ImagePacket.ts b/lib/classes/messages/ImagePacket.ts index a1c186c..096eb70 100644 --- a/lib/classes/messages/ImagePacket.ts +++ b/lib/classes/messages/ImagePacket.ts @@ -61,7 +61,7 @@ export class ImagePacketMessage implements MessageBase }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjImageData['Data'] = buf.slice(pos, pos + (varLength - 1)); + newObjImageData['Data'] = buf.slice(pos, pos + varLength); pos += varLength; this.ImageData = newObjImageData; return pos - startPos; diff --git a/lib/classes/messages/ImprovedInstantMessage.ts b/lib/classes/messages/ImprovedInstantMessage.ts index 483f3fa..421f5eb 100644 --- a/lib/classes/messages/ImprovedInstantMessage.ts +++ b/lib/classes/messages/ImprovedInstantMessage.ts @@ -136,15 +136,15 @@ export class ImprovedInstantMessageMessage implements MessageBase newObjMessageBlock['Timestamp'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjMessageBlock['FromAgentName'] = buf.slice(pos, pos + (varLength - 1)); + newObjMessageBlock['FromAgentName'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjMessageBlock['Message'] = buf.slice(pos, pos + (varLength - 1)); + newObjMessageBlock['Message'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjMessageBlock['BinaryBucket'] = buf.slice(pos, pos + (varLength - 1)); + newObjMessageBlock['BinaryBucket'] = buf.slice(pos, pos + varLength); pos += varLength; this.MessageBlock = newObjMessageBlock; const newObjEstateBlock: { diff --git a/lib/classes/messages/ImprovedTerseObjectUpdate.ts b/lib/classes/messages/ImprovedTerseObjectUpdate.ts index 7fcbb3e..7a1ba58 100644 --- a/lib/classes/messages/ImprovedTerseObjectUpdate.ts +++ b/lib/classes/messages/ImprovedTerseObjectUpdate.ts @@ -87,11 +87,11 @@ export class ImprovedTerseObjectUpdateMessage implements MessageBase TextureEntry: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjObjectData['Data'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['Data'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjObjectData['TextureEntry'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['TextureEntry'] = buf.slice(pos, pos + varLength); pos += varLength; this.ObjectData.push(newObjObjectData); } diff --git a/lib/classes/messages/InitiateDownload.ts b/lib/classes/messages/InitiateDownload.ts index 5b97b90..f16f195 100644 --- a/lib/classes/messages/InitiateDownload.ts +++ b/lib/classes/messages/InitiateDownload.ts @@ -58,10 +58,10 @@ export class InitiateDownloadMessage implements MessageBase ViewerFilename: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjFileData['SimFilename'] = buf.slice(pos, pos + (varLength - 1)); + newObjFileData['SimFilename'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjFileData['ViewerFilename'] = buf.slice(pos, pos + (varLength - 1)); + newObjFileData['ViewerFilename'] = buf.slice(pos, pos + varLength); pos += varLength; this.FileData = newObjFileData; return pos - startPos; diff --git a/lib/classes/messages/InternalScriptMail.ts b/lib/classes/messages/InternalScriptMail.ts index c416622..3bdb007 100644 --- a/lib/classes/messages/InternalScriptMail.ts +++ b/lib/classes/messages/InternalScriptMail.ts @@ -57,16 +57,16 @@ export class InternalScriptMailMessage implements MessageBase Body: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjDataBlock['From'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataBlock['From'] = buf.slice(pos, pos + varLength); pos += varLength; newObjDataBlock['To'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjDataBlock['Subject'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataBlock['Subject'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjDataBlock['Body'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataBlock['Body'] = buf.slice(pos, pos + varLength); pos += varLength; this.DataBlock = newObjDataBlock; return pos - startPos; diff --git a/lib/classes/messages/InventoryDescendents.ts b/lib/classes/messages/InventoryDescendents.ts index 8ce5ab5..b7b761d 100644 --- a/lib/classes/messages/InventoryDescendents.ts +++ b/lib/classes/messages/InventoryDescendents.ts @@ -186,7 +186,7 @@ export class InventoryDescendentsMessage implements MessageBase pos += 16; newObjFolderData['Type'] = buf.readInt8(pos++); varLength = buf.readUInt8(pos++); - newObjFolderData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjFolderData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; this.FolderData.push(newObjFolderData); } @@ -270,10 +270,10 @@ export class InventoryDescendentsMessage implements MessageBase newObjItemData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjItemData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjItemData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjItemData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjItemData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; newObjItemData['CreationDate'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/KickUser.ts b/lib/classes/messages/KickUser.ts index b4d6c24..5928a80 100644 --- a/lib/classes/messages/KickUser.ts +++ b/lib/classes/messages/KickUser.ts @@ -76,7 +76,7 @@ export class KickUserMessage implements MessageBase pos += 16; varLength = buf.readUInt16LE(pos); pos += 2; - newObjUserInfo['Reason'] = buf.slice(pos, pos + (varLength - 1)); + newObjUserInfo['Reason'] = buf.slice(pos, pos + varLength); pos += varLength; this.UserInfo = newObjUserInfo; return pos - startPos; diff --git a/lib/classes/messages/LandStatReply.ts b/lib/classes/messages/LandStatReply.ts index 39496de..0fc726e 100644 --- a/lib/classes/messages/LandStatReply.ts +++ b/lib/classes/messages/LandStatReply.ts @@ -133,10 +133,10 @@ export class LandStatReplyMessage implements MessageBase newObjReportData['Score'] = buf.readFloatLE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjReportData['TaskName'] = buf.slice(pos, pos + (varLength - 1)); + newObjReportData['TaskName'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjReportData['OwnerName'] = buf.slice(pos, pos + (varLength - 1)); + newObjReportData['OwnerName'] = buf.slice(pos, pos + varLength); pos += varLength; this.ReportData.push(newObjReportData); } diff --git a/lib/classes/messages/LandStatRequest.ts b/lib/classes/messages/LandStatRequest.ts index cd355c5..5d3270e 100644 --- a/lib/classes/messages/LandStatRequest.ts +++ b/lib/classes/messages/LandStatRequest.ts @@ -78,7 +78,7 @@ export class LandStatRequestMessage implements MessageBase newObjRequestData['RequestFlags'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjRequestData['Filter'] = buf.slice(pos, pos + (varLength - 1)); + newObjRequestData['Filter'] = buf.slice(pos, pos + varLength); pos += varLength; newObjRequestData['ParcelLocalID'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/LayerData.ts b/lib/classes/messages/LayerData.ts index 30841d2..d91f07c 100644 --- a/lib/classes/messages/LayerData.ts +++ b/lib/classes/messages/LayerData.ts @@ -51,7 +51,7 @@ export class LayerDataMessage implements MessageBase }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjLayerData['Data'] = buf.slice(pos, pos + (varLength - 1)); + newObjLayerData['Data'] = buf.slice(pos, pos + varLength); pos += varLength; this.LayerData = newObjLayerData; return pos - startPos; diff --git a/lib/classes/messages/LinkInventoryItem.ts b/lib/classes/messages/LinkInventoryItem.ts index 25b25d7..8d55d55 100644 --- a/lib/classes/messages/LinkInventoryItem.ts +++ b/lib/classes/messages/LinkInventoryItem.ts @@ -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.slice(pos, pos + (varLength - 1)); + newObjInventoryBlock['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjInventoryBlock['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryBlock['Description'] = buf.slice(pos, pos + varLength); pos += varLength; this.InventoryBlock = newObjInventoryBlock; return pos - startPos; diff --git a/lib/classes/messages/LiveHelpGroupReply.ts b/lib/classes/messages/LiveHelpGroupReply.ts index 69a07f6..96c0dde 100644 --- a/lib/classes/messages/LiveHelpGroupReply.ts +++ b/lib/classes/messages/LiveHelpGroupReply.ts @@ -53,7 +53,7 @@ export class LiveHelpGroupReplyMessage implements MessageBase newObjReplyData['GroupID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjReplyData['Selection'] = buf.slice(pos, pos + (varLength - 1)); + newObjReplyData['Selection'] = buf.slice(pos, pos + varLength); pos += varLength; this.ReplyData = newObjReplyData; return pos - startPos; diff --git a/lib/classes/messages/LoadURL.ts b/lib/classes/messages/LoadURL.ts index b664dda..0d1370f 100644 --- a/lib/classes/messages/LoadURL.ts +++ b/lib/classes/messages/LoadURL.ts @@ -65,7 +65,7 @@ export class LoadURLMessage implements MessageBase URL: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjData['ObjectName'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['ObjectName'] = buf.slice(pos, pos + varLength); 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.slice(pos, pos + (varLength - 1)); + newObjData['Message'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjData['URL'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['URL'] = buf.slice(pos, pos + varLength); pos += varLength; this.Data = newObjData; return pos - startPos; diff --git a/lib/classes/messages/LogDwellTime.ts b/lib/classes/messages/LogDwellTime.ts index 0cfd92e..f46f1ad 100644 --- a/lib/classes/messages/LogDwellTime.ts +++ b/lib/classes/messages/LogDwellTime.ts @@ -78,7 +78,7 @@ export class LogDwellTimeMessage implements MessageBase newObjDwellInfo['Duration'] = buf.readFloatLE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjDwellInfo['SimName'] = buf.slice(pos, pos + (varLength - 1)); + newObjDwellInfo['SimName'] = buf.slice(pos, pos + varLength); pos += varLength; newObjDwellInfo['RegionX'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/LogTextMessage.ts b/lib/classes/messages/LogTextMessage.ts index a7c1a9f..3078583 100644 --- a/lib/classes/messages/LogTextMessage.ts +++ b/lib/classes/messages/LogTextMessage.ts @@ -95,7 +95,7 @@ export class LogTextMessageMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjDataBlock['Message'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataBlock['Message'] = buf.slice(pos, pos + varLength); pos += varLength; this.DataBlock.push(newObjDataBlock); } diff --git a/lib/classes/messages/MapBlockReply.ts b/lib/classes/messages/MapBlockReply.ts index ac42fd7..eea119a 100644 --- a/lib/classes/messages/MapBlockReply.ts +++ b/lib/classes/messages/MapBlockReply.ts @@ -114,7 +114,7 @@ export class MapBlockReplyMessage implements MessageBase newObjData['Y'] = buf.readUInt16LE(pos); pos += 2; varLength = buf.readUInt8(pos++); - newObjData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Name'] = buf.slice(pos, pos + varLength); 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 f200c3f..e31e243 100644 --- a/lib/classes/messages/MapItemReply.ts +++ b/lib/classes/messages/MapItemReply.ts @@ -126,7 +126,7 @@ export class MapItemReplyMessage implements MessageBase newObjData['Extra2'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; this.Data.push(newObjData); } diff --git a/lib/classes/messages/MapNameRequest.ts b/lib/classes/messages/MapNameRequest.ts index 5ec7299..6d779c0 100644 --- a/lib/classes/messages/MapNameRequest.ts +++ b/lib/classes/messages/MapNameRequest.ts @@ -78,7 +78,7 @@ export class MapNameRequestMessage implements MessageBase Name: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjNameData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjNameData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; this.NameData = newObjNameData; return pos - startPos; diff --git a/lib/classes/messages/MoneyBalanceReply.ts b/lib/classes/messages/MoneyBalanceReply.ts index 0ed46a9..60543c7 100644 --- a/lib/classes/messages/MoneyBalanceReply.ts +++ b/lib/classes/messages/MoneyBalanceReply.ts @@ -101,7 +101,7 @@ export class MoneyBalanceReplyMessage implements MessageBase newObjMoneyData['SquareMetersCommitted'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjMoneyData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjMoneyData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; this.MoneyData = newObjMoneyData; const newObjTransactionInfo: { @@ -132,7 +132,7 @@ export class MoneyBalanceReplyMessage implements MessageBase newObjTransactionInfo['Amount'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjTransactionInfo['ItemDescription'] = buf.slice(pos, pos + (varLength - 1)); + newObjTransactionInfo['ItemDescription'] = buf.slice(pos, pos + varLength); pos += varLength; this.TransactionInfo = newObjTransactionInfo; return pos - startPos; diff --git a/lib/classes/messages/MoneyTransferBackend.ts b/lib/classes/messages/MoneyTransferBackend.ts index c5b2883..2f4c9bc 100644 --- a/lib/classes/messages/MoneyTransferBackend.ts +++ b/lib/classes/messages/MoneyTransferBackend.ts @@ -117,7 +117,7 @@ export class MoneyTransferBackendMessage implements MessageBase newObjMoneyData['GridY'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjMoneyData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjMoneyData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; this.MoneyData = newObjMoneyData; return pos - startPos; diff --git a/lib/classes/messages/MoneyTransferRequest.ts b/lib/classes/messages/MoneyTransferRequest.ts index 6fbe8cb..b6041fa 100644 --- a/lib/classes/messages/MoneyTransferRequest.ts +++ b/lib/classes/messages/MoneyTransferRequest.ts @@ -102,7 +102,7 @@ export class MoneyTransferRequestMessage implements MessageBase newObjMoneyData['TransactionType'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjMoneyData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjMoneyData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; this.MoneyData = newObjMoneyData; return pos - startPos; diff --git a/lib/classes/messages/MoveInventoryItem.ts b/lib/classes/messages/MoveInventoryItem.ts index 34f1729..f007f3a 100644 --- a/lib/classes/messages/MoveInventoryItem.ts +++ b/lib/classes/messages/MoveInventoryItem.ts @@ -97,7 +97,7 @@ export class MoveInventoryItemMessage implements MessageBase newObjInventoryData['FolderID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjInventoryData['NewName'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryData['NewName'] = buf.slice(pos, pos + varLength); pos += varLength; this.InventoryData.push(newObjInventoryData); } diff --git a/lib/classes/messages/MultipleObjectUpdate.ts b/lib/classes/messages/MultipleObjectUpdate.ts index 0c243d6..aa972c6 100644 --- a/lib/classes/messages/MultipleObjectUpdate.ts +++ b/lib/classes/messages/MultipleObjectUpdate.ts @@ -90,7 +90,7 @@ export class MultipleObjectUpdateMessage implements MessageBase pos += 4; newObjObjectData['Type'] = buf.readUInt8(pos++); varLength = buf.readUInt8(pos++); - newObjObjectData['Data'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['Data'] = buf.slice(pos, pos + varLength); pos += varLength; this.ObjectData.push(newObjObjectData); } diff --git a/lib/classes/messages/MuteListUpdate.ts b/lib/classes/messages/MuteListUpdate.ts index 343376f..b47960a 100644 --- a/lib/classes/messages/MuteListUpdate.ts +++ b/lib/classes/messages/MuteListUpdate.ts @@ -46,7 +46,7 @@ export class MuteListUpdateMessage implements MessageBase newObjMuteData['AgentID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjMuteData['Filename'] = buf.slice(pos, pos + (varLength - 1)); + newObjMuteData['Filename'] = buf.slice(pos, pos + varLength); pos += varLength; this.MuteData = newObjMuteData; return pos - startPos; diff --git a/lib/classes/messages/NameValuePair.ts b/lib/classes/messages/NameValuePair.ts index e3ad874..746ba6c 100644 --- a/lib/classes/messages/NameValuePair.ts +++ b/lib/classes/messages/NameValuePair.ts @@ -73,7 +73,7 @@ export class NameValuePairMessage implements MessageBase }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjNameValueData['NVPair'] = buf.slice(pos, pos + (varLength - 1)); + newObjNameValueData['NVPair'] = buf.slice(pos, pos + varLength); pos += varLength; this.NameValueData.push(newObjNameValueData); } diff --git a/lib/classes/messages/NeighborList.ts b/lib/classes/messages/NeighborList.ts index fc93f91..e601f9d 100644 --- a/lib/classes/messages/NeighborList.ts +++ b/lib/classes/messages/NeighborList.ts @@ -96,7 +96,7 @@ export class NeighborListMessage implements MessageBase newObjNeighborBlock['RegionID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjNeighborBlock['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjNeighborBlock['Name'] = buf.slice(pos, pos + varLength); 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 cdd359d..c93cf76 100644 --- a/lib/classes/messages/ObjectDescription.ts +++ b/lib/classes/messages/ObjectDescription.ts @@ -85,7 +85,7 @@ export class ObjectDescriptionMessage implements MessageBase newObjObjectData['LocalID'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjObjectData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; this.ObjectData.push(newObjObjectData); } diff --git a/lib/classes/messages/ObjectExtraParams.ts b/lib/classes/messages/ObjectExtraParams.ts index 91b9cda..2c1bae9 100644 --- a/lib/classes/messages/ObjectExtraParams.ts +++ b/lib/classes/messages/ObjectExtraParams.ts @@ -104,7 +104,7 @@ export class ObjectExtraParamsMessage implements MessageBase newObjObjectData['ParamSize'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjObjectData['ParamData'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['ParamData'] = buf.slice(pos, pos + varLength); pos += varLength; this.ObjectData.push(newObjObjectData); } diff --git a/lib/classes/messages/ObjectImage.ts b/lib/classes/messages/ObjectImage.ts index 2c59b71..9893d53 100644 --- a/lib/classes/messages/ObjectImage.ts +++ b/lib/classes/messages/ObjectImage.ts @@ -92,11 +92,11 @@ export class ObjectImageMessage implements MessageBase newObjObjectData['ObjectLocalID'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjObjectData['MediaURL'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['MediaURL'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjObjectData['TextureEntry'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['TextureEntry'] = buf.slice(pos, pos + varLength); pos += varLength; this.ObjectData.push(newObjObjectData); } diff --git a/lib/classes/messages/ObjectName.ts b/lib/classes/messages/ObjectName.ts index 51272b4..43e0a64 100644 --- a/lib/classes/messages/ObjectName.ts +++ b/lib/classes/messages/ObjectName.ts @@ -85,7 +85,7 @@ export class ObjectNameMessage implements MessageBase newObjObjectData['LocalID'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjObjectData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; this.ObjectData.push(newObjObjectData); } diff --git a/lib/classes/messages/ObjectProperties.ts b/lib/classes/messages/ObjectProperties.ts index 45e8886..62cfbe8 100644 --- a/lib/classes/messages/ObjectProperties.ts +++ b/lib/classes/messages/ObjectProperties.ts @@ -231,19 +231,19 @@ export class ObjectPropertiesMessage implements MessageBase newObjObjectData['LastOwnerID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjObjectData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['TouchName'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['TouchName'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['SitName'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['SitName'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['TextureID'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['TextureID'] = buf.slice(pos, pos + varLength); pos += varLength; this.ObjectData.push(newObjObjectData); } diff --git a/lib/classes/messages/ObjectPropertiesFamily.ts b/lib/classes/messages/ObjectPropertiesFamily.ts index dd59223..741ac3f 100644 --- a/lib/classes/messages/ObjectPropertiesFamily.ts +++ b/lib/classes/messages/ObjectPropertiesFamily.ts @@ -141,10 +141,10 @@ export class ObjectPropertiesFamilyMessage implements MessageBase newObjObjectData['LastOwnerID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjObjectData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; this.ObjectData = newObjObjectData; return pos - startPos; diff --git a/lib/classes/messages/ObjectUpdate.ts b/lib/classes/messages/ObjectUpdate.ts index 8965962..7938cb1 100644 --- a/lib/classes/messages/ObjectUpdate.ts +++ b/lib/classes/messages/ObjectUpdate.ts @@ -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.slice(pos, pos + (varLength - 1)); + newObjObjectData['ObjectData'] = buf.slice(pos, pos + varLength); 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.slice(pos, pos + (varLength - 1)); + newObjObjectData['TextureEntry'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['TextureAnim'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['TextureAnim'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjObjectData['NameValue'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['NameValue'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjObjectData['Data'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['Data'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['Text'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['Text'] = buf.slice(pos, pos + varLength); pos += varLength; newObjObjectData['TextColor'] = buf.slice(pos, pos + 4); pos += 4; varLength = buf.readUInt8(pos++); - newObjObjectData['MediaURL'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['MediaURL'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['PSBlock'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['PSBlock'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['ExtraParams'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['ExtraParams'] = buf.slice(pos, pos + varLength); 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 8d9baa2..eb83e03 100644 --- a/lib/classes/messages/ObjectUpdateCompressed.ts +++ b/lib/classes/messages/ObjectUpdateCompressed.ts @@ -89,7 +89,7 @@ export class ObjectUpdateCompressedMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjObjectData['Data'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['Data'] = buf.slice(pos, pos + varLength); pos += varLength; this.ObjectData.push(newObjObjectData); } diff --git a/lib/classes/messages/ParcelInfoReply.ts b/lib/classes/messages/ParcelInfoReply.ts index 01556d5..9cfc73f 100644 --- a/lib/classes/messages/ParcelInfoReply.ts +++ b/lib/classes/messages/ParcelInfoReply.ts @@ -127,10 +127,10 @@ export class ParcelInfoReplyMessage implements MessageBase newObjData['OwnerID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjData['Desc'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Desc'] = buf.slice(pos, pos + varLength); 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.slice(pos, pos + (varLength - 1)); + newObjData['SimName'] = buf.slice(pos, pos + varLength); 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 2e0fae3..8c7a2ff 100644 --- a/lib/classes/messages/ParcelMediaUpdate.ts +++ b/lib/classes/messages/ParcelMediaUpdate.ts @@ -66,7 +66,7 @@ export class ParcelMediaUpdateMessage implements MessageBase MediaAutoScale: 0 }; varLength = buf.readUInt8(pos++); - newObjDataBlock['MediaURL'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataBlock['MediaURL'] = buf.slice(pos, pos + varLength); pos += varLength; newObjDataBlock['MediaID'] = new UUID(buf, pos); pos += 16; @@ -86,10 +86,10 @@ export class ParcelMediaUpdateMessage implements MessageBase MediaLoop: 0 }; varLength = buf.readUInt8(pos++); - newObjDataBlockExtended['MediaType'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataBlockExtended['MediaType'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjDataBlockExtended['MediaDesc'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataBlockExtended['MediaDesc'] = buf.slice(pos, pos + varLength); pos += varLength; newObjDataBlockExtended['MediaWidth'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/ParcelOverlay.ts b/lib/classes/messages/ParcelOverlay.ts index 490c37d..b8106f2 100644 --- a/lib/classes/messages/ParcelOverlay.ts +++ b/lib/classes/messages/ParcelOverlay.ts @@ -47,7 +47,7 @@ export class ParcelOverlayMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjParcelData['Data'] = buf.slice(pos, pos + (varLength - 1)); + newObjParcelData['Data'] = buf.slice(pos, pos + varLength); pos += varLength; this.ParcelData = newObjParcelData; return pos - startPos; diff --git a/lib/classes/messages/ParcelProperties.ts b/lib/classes/messages/ParcelProperties.ts index f689e4e..efb4898 100644 --- a/lib/classes/messages/ParcelProperties.ts +++ b/lib/classes/messages/ParcelProperties.ts @@ -312,7 +312,7 @@ export class ParcelPropertiesMessage implements MessageBase pos += 12; varLength = buf.readUInt16LE(pos); pos += 2; - newObjParcelData['Bitmap'] = buf.slice(pos, pos + (varLength - 1)); + newObjParcelData['Bitmap'] = buf.slice(pos, pos + varLength); 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.slice(pos, pos + (varLength - 1)); + newObjParcelData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjParcelData['Desc'] = buf.slice(pos, pos + (varLength - 1)); + newObjParcelData['Desc'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjParcelData['MusicURL'] = buf.slice(pos, pos + (varLength - 1)); + newObjParcelData['MusicURL'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjParcelData['MediaURL'] = buf.slice(pos, pos + (varLength - 1)); + newObjParcelData['MediaURL'] = buf.slice(pos, pos + varLength); 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 45c6e4c..961c4f8 100644 --- a/lib/classes/messages/ParcelPropertiesUpdate.ts +++ b/lib/classes/messages/ParcelPropertiesUpdate.ts @@ -158,16 +158,16 @@ export class ParcelPropertiesUpdateMessage implements MessageBase newObjParcelData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjParcelData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjParcelData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjParcelData['Desc'] = buf.slice(pos, pos + (varLength - 1)); + newObjParcelData['Desc'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjParcelData['MusicURL'] = buf.slice(pos, pos + (varLength - 1)); + newObjParcelData['MusicURL'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjParcelData['MediaURL'] = buf.slice(pos, pos + (varLength - 1)); + newObjParcelData['MediaURL'] = buf.slice(pos, pos + varLength); 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 71a905c..5556f9b 100644 --- a/lib/classes/messages/ParcelRename.ts +++ b/lib/classes/messages/ParcelRename.ts @@ -65,7 +65,7 @@ export class ParcelRenameMessage implements MessageBase newObjParcelData['ParcelID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjParcelData['NewName'] = buf.slice(pos, pos + (varLength - 1)); + newObjParcelData['NewName'] = buf.slice(pos, pos + varLength); pos += varLength; this.ParcelData.push(newObjParcelData); } diff --git a/lib/classes/messages/PickInfoReply.ts b/lib/classes/messages/PickInfoReply.ts index a18b473..ac2d559 100644 --- a/lib/classes/messages/PickInfoReply.ts +++ b/lib/classes/messages/PickInfoReply.ts @@ -123,22 +123,22 @@ export class PickInfoReplyMessage implements MessageBase newObjData['ParcelID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjData['Desc'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Desc'] = buf.slice(pos, pos + varLength); pos += varLength; newObjData['SnapshotID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['User'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['User'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjData['OriginalName'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['OriginalName'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjData['SimName'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['SimName'] = buf.slice(pos, pos + varLength); 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 c8723b5..003cb0a 100644 --- a/lib/classes/messages/PickInfoUpdate.ts +++ b/lib/classes/messages/PickInfoUpdate.ts @@ -112,11 +112,11 @@ export class PickInfoUpdateMessage implements MessageBase newObjData['ParcelID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjData['Desc'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Desc'] = buf.slice(pos, pos + varLength); 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 80251ff..96c2b2a 100644 --- a/lib/classes/messages/PlacesQuery.ts +++ b/lib/classes/messages/PlacesQuery.ts @@ -94,13 +94,13 @@ export class PlacesQueryMessage implements MessageBase SimName: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjQueryData['QueryText'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryData['QueryText'] = buf.slice(pos, pos + varLength); pos += varLength; newObjQueryData['QueryFlags'] = buf.readUInt32LE(pos); pos += 4; newObjQueryData['Category'] = buf.readInt8(pos++); varLength = buf.readUInt8(pos++); - newObjQueryData['SimName'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryData['SimName'] = buf.slice(pos, pos + varLength); pos += varLength; this.QueryData = newObjQueryData; return pos - startPos; diff --git a/lib/classes/messages/PlacesReply.ts b/lib/classes/messages/PlacesReply.ts index 7315e8a..7d94d8e 100644 --- a/lib/classes/messages/PlacesReply.ts +++ b/lib/classes/messages/PlacesReply.ts @@ -154,10 +154,10 @@ export class PlacesReplyMessage implements MessageBase newObjQueryData['OwnerID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjQueryData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjQueryData['Desc'] = buf.slice(pos, pos + (varLength - 1)); + newObjQueryData['Desc'] = buf.slice(pos, pos + varLength); 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.slice(pos, pos + (varLength - 1)); + newObjQueryData['SimName'] = buf.slice(pos, pos + varLength); 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 2a81438..30bb77f 100644 --- a/lib/classes/messages/RegionHandshake.ts +++ b/lib/classes/messages/RegionHandshake.ts @@ -198,7 +198,7 @@ export class RegionHandshakeMessage implements MessageBase pos += 4; newObjRegionInfo['SimAccess'] = buf.readUInt8(pos++); varLength = buf.readUInt8(pos++); - newObjRegionInfo['SimName'] = buf.slice(pos, pos + (varLength - 1)); + newObjRegionInfo['SimName'] = buf.slice(pos, pos + varLength); pos += varLength; newObjRegionInfo['SimOwner'] = new UUID(buf, pos); pos += 16; @@ -268,13 +268,13 @@ export class RegionHandshakeMessage implements MessageBase newObjRegionInfo3['CPURatio'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjRegionInfo3['ColoName'] = buf.slice(pos, pos + (varLength - 1)); + newObjRegionInfo3['ColoName'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjRegionInfo3['ProductSKU'] = buf.slice(pos, pos + (varLength - 1)); + newObjRegionInfo3['ProductSKU'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjRegionInfo3['ProductName'] = buf.slice(pos, pos + (varLength - 1)); + newObjRegionInfo3['ProductName'] = buf.slice(pos, pos + varLength); 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 cd568b2..5caf393 100644 --- a/lib/classes/messages/RegionInfo.ts +++ b/lib/classes/messages/RegionInfo.ts @@ -163,7 +163,7 @@ export class RegionInfoMessage implements MessageBase SunHour: 0 }; varLength = buf.readUInt8(pos++); - newObjRegionInfo['SimName'] = buf.slice(pos, pos + (varLength - 1)); + newObjRegionInfo['SimName'] = buf.slice(pos, pos + varLength); pos += varLength; newObjRegionInfo['EstateID'] = buf.readUInt32LE(pos); pos += 4; @@ -207,10 +207,10 @@ export class RegionInfoMessage implements MessageBase HardMaxObjects: 0 }; varLength = buf.readUInt8(pos++); - newObjRegionInfo2['ProductSKU'] = buf.slice(pos, pos + (varLength - 1)); + newObjRegionInfo2['ProductSKU'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjRegionInfo2['ProductName'] = buf.slice(pos, pos + (varLength - 1)); + newObjRegionInfo2['ProductName'] = buf.slice(pos, pos + varLength); pos += varLength; newObjRegionInfo2['MaxAgents32'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/RegionPresenceResponse.ts b/lib/classes/messages/RegionPresenceResponse.ts index 0376d07..a689493 100644 --- a/lib/classes/messages/RegionPresenceResponse.ts +++ b/lib/classes/messages/RegionPresenceResponse.ts @@ -104,7 +104,7 @@ export class RegionPresenceResponseMessage implements MessageBase newObjRegionData['ValidUntil'] = buf.readDoubleLE(pos); pos += 8; varLength = buf.readUInt8(pos++); - newObjRegionData['Message'] = buf.slice(pos, pos + (varLength - 1)); + newObjRegionData['Message'] = buf.slice(pos, pos + varLength); pos += varLength; this.RegionData.push(newObjRegionData); } diff --git a/lib/classes/messages/RemoveMuteListEntry.ts b/lib/classes/messages/RemoveMuteListEntry.ts index aa9f14d..5826817 100644 --- a/lib/classes/messages/RemoveMuteListEntry.ts +++ b/lib/classes/messages/RemoveMuteListEntry.ts @@ -66,7 +66,7 @@ export class RemoveMuteListEntryMessage implements MessageBase newObjMuteData['MuteID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjMuteData['MuteName'] = buf.slice(pos, pos + (varLength - 1)); + newObjMuteData['MuteName'] = buf.slice(pos, pos + varLength); pos += varLength; this.MuteData = newObjMuteData; return pos - startPos; diff --git a/lib/classes/messages/RemoveNameValuePair.ts b/lib/classes/messages/RemoveNameValuePair.ts index c72e28e..7470006 100644 --- a/lib/classes/messages/RemoveNameValuePair.ts +++ b/lib/classes/messages/RemoveNameValuePair.ts @@ -73,7 +73,7 @@ export class RemoveNameValuePairMessage implements MessageBase }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjNameValueData['NVPair'] = buf.slice(pos, pos + (varLength - 1)); + newObjNameValueData['NVPair'] = buf.slice(pos, pos + varLength); pos += varLength; this.NameValueData.push(newObjNameValueData); } diff --git a/lib/classes/messages/ReplyTaskInventory.ts b/lib/classes/messages/ReplyTaskInventory.ts index 54c68e0..6319fba 100644 --- a/lib/classes/messages/ReplyTaskInventory.ts +++ b/lib/classes/messages/ReplyTaskInventory.ts @@ -53,7 +53,7 @@ export class ReplyTaskInventoryMessage implements MessageBase newObjInventoryData['Serial'] = buf.readInt16LE(pos); pos += 2; varLength = buf.readUInt8(pos++); - newObjInventoryData['Filename'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryData['Filename'] = buf.slice(pos, pos + varLength); pos += varLength; this.InventoryData = newObjInventoryData; return pos - startPos; diff --git a/lib/classes/messages/RequestXfer.ts b/lib/classes/messages/RequestXfer.ts index 4158187..585b763 100644 --- a/lib/classes/messages/RequestXfer.ts +++ b/lib/classes/messages/RequestXfer.ts @@ -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.slice(pos, pos + (varLength - 1)); + newObjXferID['Filename'] = buf.slice(pos, pos + varLength); 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 9fcc23e..8c53dd9 100644 --- a/lib/classes/messages/RezMultipleAttachmentsFromInv.ts +++ b/lib/classes/messages/RezMultipleAttachmentsFromInv.ts @@ -154,10 +154,10 @@ export class RezMultipleAttachmentsFromInvMessage implements MessageBase newObjObjectData['NextOwnerMask'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjObjectData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; this.ObjectData.push(newObjObjectData); } diff --git a/lib/classes/messages/RezObject.ts b/lib/classes/messages/RezObject.ts index fd1b30c..6bd61a9 100644 --- a/lib/classes/messages/RezObject.ts +++ b/lib/classes/messages/RezObject.ts @@ -276,10 +276,10 @@ export class RezObjectMessage implements MessageBase newObjInventoryData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjInventoryData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjInventoryData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; newObjInventoryData['CreationDate'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/RezRestoreToWorld.ts b/lib/classes/messages/RezRestoreToWorld.ts index 1859c32..cc32c85 100644 --- a/lib/classes/messages/RezRestoreToWorld.ts +++ b/lib/classes/messages/RezRestoreToWorld.ts @@ -186,10 +186,10 @@ export class RezRestoreToWorldMessage implements MessageBase newObjInventoryData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjInventoryData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjInventoryData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; newObjInventoryData['CreationDate'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/RezScript.ts b/lib/classes/messages/RezScript.ts index 9c62e16..cb11f17 100644 --- a/lib/classes/messages/RezScript.ts +++ b/lib/classes/messages/RezScript.ts @@ -211,10 +211,10 @@ export class RezScriptMessage implements MessageBase newObjInventoryBlock['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjInventoryBlock['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryBlock['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjInventoryBlock['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryBlock['Description'] = buf.slice(pos, pos + varLength); pos += varLength; newObjInventoryBlock['CreationDate'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/RezSingleAttachmentFromInv.ts b/lib/classes/messages/RezSingleAttachmentFromInv.ts index b6d7412..42ecdf8 100644 --- a/lib/classes/messages/RezSingleAttachmentFromInv.ts +++ b/lib/classes/messages/RezSingleAttachmentFromInv.ts @@ -112,10 +112,10 @@ export class RezSingleAttachmentFromInvMessage implements MessageBase newObjObjectData['NextOwnerMask'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjObjectData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjObjectData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjObjectData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; this.ObjectData = newObjObjectData; return pos - startPos; diff --git a/lib/classes/messages/RoutedMoneyBalanceReply.ts b/lib/classes/messages/RoutedMoneyBalanceReply.ts index b650c23..a0502fd 100644 --- a/lib/classes/messages/RoutedMoneyBalanceReply.ts +++ b/lib/classes/messages/RoutedMoneyBalanceReply.ts @@ -122,7 +122,7 @@ export class RoutedMoneyBalanceReplyMessage implements MessageBase newObjMoneyData['SquareMetersCommitted'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjMoneyData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjMoneyData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; this.MoneyData = newObjMoneyData; const newObjTransactionInfo: { @@ -153,7 +153,7 @@ export class RoutedMoneyBalanceReplyMessage implements MessageBase newObjTransactionInfo['Amount'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjTransactionInfo['ItemDescription'] = buf.slice(pos, pos + (varLength - 1)); + newObjTransactionInfo['ItemDescription'] = buf.slice(pos, pos + varLength); pos += varLength; this.TransactionInfo = newObjTransactionInfo; return pos - startPos; diff --git a/lib/classes/messages/RpcScriptReplyInbound.ts b/lib/classes/messages/RpcScriptReplyInbound.ts index e4c285a..07dda88 100644 --- a/lib/classes/messages/RpcScriptReplyInbound.ts +++ b/lib/classes/messages/RpcScriptReplyInbound.ts @@ -69,7 +69,7 @@ export class RpcScriptReplyInboundMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjDataBlock['StringValue'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataBlock['StringValue'] = buf.slice(pos, pos + varLength); pos += varLength; this.DataBlock = newObjDataBlock; return pos - startPos; diff --git a/lib/classes/messages/RpcScriptRequestInbound.ts b/lib/classes/messages/RpcScriptRequestInbound.ts index 60b1af0..728261c 100644 --- a/lib/classes/messages/RpcScriptRequestInbound.ts +++ b/lib/classes/messages/RpcScriptRequestInbound.ts @@ -89,7 +89,7 @@ export class RpcScriptRequestInboundMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjDataBlock['StringValue'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataBlock['StringValue'] = buf.slice(pos, pos + varLength); pos += varLength; this.DataBlock = newObjDataBlock; return pos - startPos; diff --git a/lib/classes/messages/RpcScriptRequestInboundForward.ts b/lib/classes/messages/RpcScriptRequestInboundForward.ts index 1d021ab..195b7cb 100644 --- a/lib/classes/messages/RpcScriptRequestInboundForward.ts +++ b/lib/classes/messages/RpcScriptRequestInboundForward.ts @@ -84,7 +84,7 @@ export class RpcScriptRequestInboundForwardMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjDataBlock['StringValue'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataBlock['StringValue'] = buf.slice(pos, pos + varLength); pos += varLength; this.DataBlock = newObjDataBlock; return pos - startPos; diff --git a/lib/classes/messages/ScriptDataReply.ts b/lib/classes/messages/ScriptDataReply.ts index 5c5ecc4..abe0905 100644 --- a/lib/classes/messages/ScriptDataReply.ts +++ b/lib/classes/messages/ScriptDataReply.ts @@ -69,7 +69,7 @@ export class ScriptDataReplyMessage implements MessageBase pos += 8; varLength = buf.readUInt16LE(pos); pos += 2; - newObjDataBlock['Reply'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataBlock['Reply'] = buf.slice(pos, pos + varLength); pos += varLength; this.DataBlock.push(newObjDataBlock); } diff --git a/lib/classes/messages/ScriptDataRequest.ts b/lib/classes/messages/ScriptDataRequest.ts index 3bad0be..31d1f4f 100644 --- a/lib/classes/messages/ScriptDataRequest.ts +++ b/lib/classes/messages/ScriptDataRequest.ts @@ -74,7 +74,7 @@ export class ScriptDataRequestMessage implements MessageBase newObjDataBlock['RequestType'] = buf.readInt8(pos++); varLength = buf.readUInt16LE(pos); pos += 2; - newObjDataBlock['Request'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataBlock['Request'] = buf.slice(pos, pos + varLength); pos += varLength; this.DataBlock.push(newObjDataBlock); } diff --git a/lib/classes/messages/ScriptDialog.ts b/lib/classes/messages/ScriptDialog.ts index 6b0d644..4803b70 100644 --- a/lib/classes/messages/ScriptDialog.ts +++ b/lib/classes/messages/ScriptDialog.ts @@ -106,17 +106,17 @@ export class ScriptDialogMessage implements MessageBase newObjData['ObjectID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['FirstName'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['FirstName'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjData['LastName'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['LastName'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjData['ObjectName'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['ObjectName'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjData['Message'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['Message'] = buf.slice(pos, pos + varLength); pos += varLength; newObjData['ChatChannel'] = buf.readInt32LE(pos); pos += 4; @@ -133,7 +133,7 @@ export class ScriptDialogMessage implements MessageBase ButtonLabel: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjButtons['ButtonLabel'] = buf.slice(pos, pos + (varLength - 1)); + newObjButtons['ButtonLabel'] = buf.slice(pos, pos + varLength); pos += varLength; this.Buttons.push(newObjButtons); } diff --git a/lib/classes/messages/ScriptDialogReply.ts b/lib/classes/messages/ScriptDialogReply.ts index 0bef066..e2ae822 100644 --- a/lib/classes/messages/ScriptDialogReply.ts +++ b/lib/classes/messages/ScriptDialogReply.ts @@ -80,7 +80,7 @@ export class ScriptDialogReplyMessage implements MessageBase newObjData['ButtonIndex'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjData['ButtonLabel'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['ButtonLabel'] = buf.slice(pos, pos + varLength); pos += varLength; this.Data = newObjData; return pos - startPos; diff --git a/lib/classes/messages/ScriptMailRegistration.ts b/lib/classes/messages/ScriptMailRegistration.ts index 45183e9..806db98 100644 --- a/lib/classes/messages/ScriptMailRegistration.ts +++ b/lib/classes/messages/ScriptMailRegistration.ts @@ -54,7 +54,7 @@ export class ScriptMailRegistrationMessage implements MessageBase Flags: 0 }; varLength = buf.readUInt8(pos++); - newObjDataBlock['TargetIP'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataBlock['TargetIP'] = buf.slice(pos, pos + varLength); pos += varLength; newObjDataBlock['TargetPort'] = buf.readUInt16LE(pos); pos += 2; diff --git a/lib/classes/messages/ScriptQuestion.ts b/lib/classes/messages/ScriptQuestion.ts index 8040c5c..a166b1a 100644 --- a/lib/classes/messages/ScriptQuestion.ts +++ b/lib/classes/messages/ScriptQuestion.ts @@ -69,10 +69,10 @@ export class ScriptQuestionMessage implements MessageBase newObjData['ItemID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['ObjectName'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['ObjectName'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjData['ObjectOwner'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['ObjectOwner'] = buf.slice(pos, pos + varLength); pos += varLength; newObjData['Questions'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/ScriptSensorReply.ts b/lib/classes/messages/ScriptSensorReply.ts index 80baaa0..4208fd3 100644 --- a/lib/classes/messages/ScriptSensorReply.ts +++ b/lib/classes/messages/ScriptSensorReply.ts @@ -125,7 +125,7 @@ export class ScriptSensorReplyMessage implements MessageBase newObjSensedData['Rotation'] = new Quaternion(buf, pos); pos += 12; varLength = buf.readUInt8(pos++); - newObjSensedData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjSensedData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; newObjSensedData['Type'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/ScriptSensorRequest.ts b/lib/classes/messages/ScriptSensorRequest.ts index 7517c69..9e9c8a9 100644 --- a/lib/classes/messages/ScriptSensorRequest.ts +++ b/lib/classes/messages/ScriptSensorRequest.ts @@ -103,7 +103,7 @@ export class ScriptSensorRequestMessage implements MessageBase newObjRequester['SearchDir'] = new Quaternion(buf, pos); pos += 12; varLength = buf.readUInt8(pos++); - newObjRequester['SearchName'] = buf.slice(pos, pos + (varLength - 1)); + newObjRequester['SearchName'] = buf.slice(pos, pos + varLength); pos += varLength; newObjRequester['Type'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/ScriptTeleportRequest.ts b/lib/classes/messages/ScriptTeleportRequest.ts index 6cc13ff..ff15a9e 100644 --- a/lib/classes/messages/ScriptTeleportRequest.ts +++ b/lib/classes/messages/ScriptTeleportRequest.ts @@ -55,10 +55,10 @@ export class ScriptTeleportRequestMessage implements MessageBase LookAt: Vector3.getZero() }; varLength = buf.readUInt8(pos++); - newObjData['ObjectName'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['ObjectName'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjData['SimName'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['SimName'] = buf.slice(pos, pos + varLength); 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 cb538c3..adf58ea 100644 --- a/lib/classes/messages/SendPostcard.ts +++ b/lib/classes/messages/SendPostcard.ts @@ -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.slice(pos, pos + (varLength - 1)); + newObjAgentData['To'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjAgentData['From'] = buf.slice(pos, pos + (varLength - 1)); + newObjAgentData['From'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjAgentData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjAgentData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjAgentData['Subject'] = buf.slice(pos, pos + (varLength - 1)); + newObjAgentData['Subject'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjAgentData['Msg'] = buf.slice(pos, pos + (varLength - 1)); + newObjAgentData['Msg'] = buf.slice(pos, pos + varLength); 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 2ee7d97..f044072 100644 --- a/lib/classes/messages/SendXferPacket.ts +++ b/lib/classes/messages/SendXferPacket.ts @@ -63,7 +63,7 @@ export class SendXferPacketMessage implements MessageBase }; varLength = buf.readUInt16LE(pos); pos += 2; - newObjDataPacket['Data'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataPacket['Data'] = buf.slice(pos, pos + varLength); pos += varLength; this.DataPacket = newObjDataPacket; return pos - startPos; diff --git a/lib/classes/messages/SetSimPresenceInDatabase.ts b/lib/classes/messages/SetSimPresenceInDatabase.ts index ee921df..117d3e5 100644 --- a/lib/classes/messages/SetSimPresenceInDatabase.ts +++ b/lib/classes/messages/SetSimPresenceInDatabase.ts @@ -77,7 +77,7 @@ export class SetSimPresenceInDatabaseMessage implements MessageBase newObjSimData['RegionID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjSimData['HostName'] = buf.slice(pos, pos + (varLength - 1)); + newObjSimData['HostName'] = buf.slice(pos, pos + varLength); 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.slice(pos, pos + (varLength - 1)); + newObjSimData['Status'] = buf.slice(pos, pos + varLength); pos += varLength; this.SimData = newObjSimData; return pos - startPos; diff --git a/lib/classes/messages/SetSimStatusInDatabase.ts b/lib/classes/messages/SetSimStatusInDatabase.ts index fdcfcfb..b328618 100644 --- a/lib/classes/messages/SetSimStatusInDatabase.ts +++ b/lib/classes/messages/SetSimStatusInDatabase.ts @@ -77,7 +77,7 @@ export class SetSimStatusInDatabaseMessage implements MessageBase newObjData['RegionID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjData['HostName'] = buf.slice(pos, pos + (varLength - 1)); + newObjData['HostName'] = buf.slice(pos, pos + varLength); 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.slice(pos, pos + (varLength - 1)); + newObjData['Status'] = buf.slice(pos, pos + varLength); pos += varLength; this.Data = newObjData; return pos - startPos; diff --git a/lib/classes/messages/SetStartLocationRequest.ts b/lib/classes/messages/SetStartLocationRequest.ts index 32b858d..196860e 100644 --- a/lib/classes/messages/SetStartLocationRequest.ts +++ b/lib/classes/messages/SetStartLocationRequest.ts @@ -75,7 +75,7 @@ export class SetStartLocationRequestMessage implements MessageBase LocationLookAt: Vector3.getZero() }; varLength = buf.readUInt8(pos++); - newObjStartLocationData['SimName'] = buf.slice(pos, pos + (varLength - 1)); + newObjStartLocationData['SimName'] = buf.slice(pos, pos + varLength); pos += varLength; newObjStartLocationData['LocationID'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/SimulatorPresentAtLocation.ts b/lib/classes/messages/SimulatorPresentAtLocation.ts index 58ef7fd..825b2c2 100644 --- a/lib/classes/messages/SimulatorPresentAtLocation.ts +++ b/lib/classes/messages/SimulatorPresentAtLocation.ts @@ -139,7 +139,7 @@ export class SimulatorPresentAtLocationMessage implements MessageBase ParentEstateID: 0 }; varLength = buf.readUInt8(pos++); - newObjSimulatorBlock['SimName'] = buf.slice(pos, pos + (varLength - 1)); + newObjSimulatorBlock['SimName'] = buf.slice(pos, pos + varLength); 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 b077457..a503950 100644 --- a/lib/classes/messages/SimulatorReady.ts +++ b/lib/classes/messages/SimulatorReady.ts @@ -71,7 +71,7 @@ export class SimulatorReadyMessage implements MessageBase ParentEstateID: 0 }; varLength = buf.readUInt8(pos++); - newObjSimulatorBlock['SimName'] = buf.slice(pos, pos + (varLength - 1)); + newObjSimulatorBlock['SimName'] = buf.slice(pos, pos + varLength); 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 4d11332..6280dfd 100644 --- a/lib/classes/messages/StartAuction.ts +++ b/lib/classes/messages/StartAuction.ts @@ -66,7 +66,7 @@ export class StartAuctionMessage implements MessageBase newObjParcelData['SnapshotID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjParcelData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjParcelData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; this.ParcelData = newObjParcelData; return pos - startPos; diff --git a/lib/classes/messages/StartGroupProposal.ts b/lib/classes/messages/StartGroupProposal.ts index 1caa716..dd58215 100644 --- a/lib/classes/messages/StartGroupProposal.ts +++ b/lib/classes/messages/StartGroupProposal.ts @@ -87,7 +87,7 @@ export class StartGroupProposalMessage implements MessageBase newObjProposalData['Duration'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjProposalData['ProposalText'] = buf.slice(pos, pos + (varLength - 1)); + newObjProposalData['ProposalText'] = buf.slice(pos, pos + varLength); pos += varLength; this.ProposalData = newObjProposalData; return pos - startPos; diff --git a/lib/classes/messages/StartLure.ts b/lib/classes/messages/StartLure.ts index 81ff0d6..20f3a4d 100644 --- a/lib/classes/messages/StartLure.ts +++ b/lib/classes/messages/StartLure.ts @@ -74,7 +74,7 @@ export class StartLureMessage implements MessageBase }; newObjInfo['LureType'] = buf.readUInt8(pos++); varLength = buf.readUInt8(pos++); - newObjInfo['Message'] = buf.slice(pos, pos + (varLength - 1)); + newObjInfo['Message'] = buf.slice(pos, pos + varLength); 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 1aacfe0..0453cf9 100644 --- a/lib/classes/messages/StateSave.ts +++ b/lib/classes/messages/StateSave.ts @@ -59,7 +59,7 @@ export class StateSaveMessage implements MessageBase Filename: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjDataBlock['Filename'] = buf.slice(pos, pos + (varLength - 1)); + newObjDataBlock['Filename'] = buf.slice(pos, pos + varLength); pos += varLength; this.DataBlock = newObjDataBlock; return pos - startPos; diff --git a/lib/classes/messages/SystemMessage.ts b/lib/classes/messages/SystemMessage.ts index 427382e..c3da410 100644 --- a/lib/classes/messages/SystemMessage.ts +++ b/lib/classes/messages/SystemMessage.ts @@ -70,7 +70,7 @@ export class SystemMessageMessage implements MessageBase Digest: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjMethodData['Method'] = buf.slice(pos, pos + (varLength - 1)); + newObjMethodData['Method'] = buf.slice(pos, pos + varLength); pos += varLength; newObjMethodData['Invoice'] = new UUID(buf, pos); pos += 16; @@ -87,7 +87,7 @@ export class SystemMessageMessage implements MessageBase Parameter: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjParamList['Parameter'] = buf.slice(pos, pos + (varLength - 1)); + newObjParamList['Parameter'] = buf.slice(pos, pos + varLength); pos += varLength; this.ParamList.push(newObjParamList); } diff --git a/lib/classes/messages/TelehubInfo.ts b/lib/classes/messages/TelehubInfo.ts index 73535b0..7eacc51 100644 --- a/lib/classes/messages/TelehubInfo.ts +++ b/lib/classes/messages/TelehubInfo.ts @@ -68,7 +68,7 @@ export class TelehubInfoMessage implements MessageBase newObjTelehubBlock['ObjectID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjTelehubBlock['ObjectName'] = buf.slice(pos, pos + (varLength - 1)); + newObjTelehubBlock['ObjectName'] = buf.slice(pos, pos + varLength); 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 db28f8b..eabe435 100644 --- a/lib/classes/messages/TeleportFailed.ts +++ b/lib/classes/messages/TeleportFailed.ts @@ -71,7 +71,7 @@ export class TeleportFailedMessage implements MessageBase newObjInfo['AgentID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjInfo['Reason'] = buf.slice(pos, pos + (varLength - 1)); + newObjInfo['Reason'] = buf.slice(pos, pos + varLength); pos += varLength; this.Info = newObjInfo; const count = buf.readUInt8(pos++); @@ -86,10 +86,10 @@ export class TeleportFailedMessage implements MessageBase ExtraParams: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); - newObjAlertInfo['Message'] = buf.slice(pos, pos + (varLength - 1)); + newObjAlertInfo['Message'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjAlertInfo['ExtraParams'] = buf.slice(pos, pos + (varLength - 1)); + newObjAlertInfo['ExtraParams'] = buf.slice(pos, pos + varLength); pos += varLength; this.AlertInfo.push(newObjAlertInfo); } diff --git a/lib/classes/messages/TeleportFinish.ts b/lib/classes/messages/TeleportFinish.ts index 5cb212f..de9205e 100644 --- a/lib/classes/messages/TeleportFinish.ts +++ b/lib/classes/messages/TeleportFinish.ts @@ -89,7 +89,7 @@ export class TeleportFinishMessage implements MessageBase pos += 8; varLength = buf.readUInt16LE(pos); pos += 2; - newObjInfo['SeedCapability'] = buf.slice(pos, pos + (varLength - 1)); + newObjInfo['SeedCapability'] = buf.slice(pos, pos + varLength); 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 7de5b68..4f9b0fe 100644 --- a/lib/classes/messages/TeleportProgress.ts +++ b/lib/classes/messages/TeleportProgress.ts @@ -59,7 +59,7 @@ export class TeleportProgressMessage implements MessageBase newObjInfo['TeleportFlags'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjInfo['Message'] = buf.slice(pos, pos + (varLength - 1)); + newObjInfo['Message'] = buf.slice(pos, pos + varLength); pos += varLength; this.Info = newObjInfo; return pos - startPos; diff --git a/lib/classes/messages/TransferInfo.ts b/lib/classes/messages/TransferInfo.ts index a3d1b45..6453468 100644 --- a/lib/classes/messages/TransferInfo.ts +++ b/lib/classes/messages/TransferInfo.ts @@ -76,7 +76,7 @@ export class TransferInfoMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjTransferInfo['Params'] = buf.slice(pos, pos + (varLength - 1)); + newObjTransferInfo['Params'] = buf.slice(pos, pos + varLength); pos += varLength; this.TransferInfo = newObjTransferInfo; return pos - startPos; diff --git a/lib/classes/messages/TransferPacket.ts b/lib/classes/messages/TransferPacket.ts index acffbfa..ce77668 100644 --- a/lib/classes/messages/TransferPacket.ts +++ b/lib/classes/messages/TransferPacket.ts @@ -69,7 +69,7 @@ export class TransferPacketMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjTransferData['Data'] = buf.slice(pos, pos + (varLength - 1)); + newObjTransferData['Data'] = buf.slice(pos, pos + varLength); pos += varLength; this.TransferData = newObjTransferData; return pos - startPos; diff --git a/lib/classes/messages/TransferRequest.ts b/lib/classes/messages/TransferRequest.ts index 523f666..620b195 100644 --- a/lib/classes/messages/TransferRequest.ts +++ b/lib/classes/messages/TransferRequest.ts @@ -69,7 +69,7 @@ export class TransferRequestMessage implements MessageBase pos += 4; varLength = buf.readUInt16LE(pos); pos += 2; - newObjTransferInfo['Params'] = buf.slice(pos, pos + (varLength - 1)); + newObjTransferInfo['Params'] = buf.slice(pos, pos + varLength); pos += varLength; this.TransferInfo = newObjTransferInfo; return pos - startPos; diff --git a/lib/classes/messages/UUIDGroupNameReply.ts b/lib/classes/messages/UUIDGroupNameReply.ts index 94e4cbd..1286255 100644 --- a/lib/classes/messages/UUIDGroupNameReply.ts +++ b/lib/classes/messages/UUIDGroupNameReply.ts @@ -65,7 +65,7 @@ export class UUIDGroupNameReplyMessage implements MessageBase newObjUUIDNameBlock['ID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjUUIDNameBlock['GroupName'] = buf.slice(pos, pos + (varLength - 1)); + newObjUUIDNameBlock['GroupName'] = buf.slice(pos, pos + varLength); pos += varLength; this.UUIDNameBlock.push(newObjUUIDNameBlock); } diff --git a/lib/classes/messages/UUIDNameReply.ts b/lib/classes/messages/UUIDNameReply.ts index 3a3d882..608a404 100644 --- a/lib/classes/messages/UUIDNameReply.ts +++ b/lib/classes/messages/UUIDNameReply.ts @@ -71,10 +71,10 @@ export class UUIDNameReplyMessage implements MessageBase newObjUUIDNameBlock['ID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjUUIDNameBlock['FirstName'] = buf.slice(pos, pos + (varLength - 1)); + newObjUUIDNameBlock['FirstName'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjUUIDNameBlock['LastName'] = buf.slice(pos, pos + (varLength - 1)); + newObjUUIDNameBlock['LastName'] = buf.slice(pos, pos + varLength); pos += varLength; this.UUIDNameBlock.push(newObjUUIDNameBlock); } diff --git a/lib/classes/messages/UpdateAttachment.ts b/lib/classes/messages/UpdateAttachment.ts index fef44aa..ff31e87 100644 --- a/lib/classes/messages/UpdateAttachment.ts +++ b/lib/classes/messages/UpdateAttachment.ts @@ -213,10 +213,10 @@ export class UpdateAttachmentMessage implements MessageBase newObjInventoryData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjInventoryData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjInventoryData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; newObjInventoryData['CreationDate'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/UpdateCreateInventoryItem.ts b/lib/classes/messages/UpdateCreateInventoryItem.ts index bf02815..2ade22c 100644 --- a/lib/classes/messages/UpdateCreateInventoryItem.ts +++ b/lib/classes/messages/UpdateCreateInventoryItem.ts @@ -217,10 +217,10 @@ export class UpdateCreateInventoryItemMessage implements MessageBase newObjInventoryData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjInventoryData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjInventoryData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; newObjInventoryData['CreationDate'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/UpdateGroupInfo.ts b/lib/classes/messages/UpdateGroupInfo.ts index c5cdc78..e6ee9b0 100644 --- a/lib/classes/messages/UpdateGroupInfo.ts +++ b/lib/classes/messages/UpdateGroupInfo.ts @@ -94,7 +94,7 @@ export class UpdateGroupInfoMessage implements MessageBase pos += 16; varLength = buf.readUInt16LE(pos); pos += 2; - newObjGroupData['Charter'] = buf.slice(pos, pos + (varLength - 1)); + newObjGroupData['Charter'] = buf.slice(pos, pos + varLength); 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 60ea872..c0416fa 100644 --- a/lib/classes/messages/UpdateInventoryFolder.ts +++ b/lib/classes/messages/UpdateInventoryFolder.ts @@ -97,7 +97,7 @@ export class UpdateInventoryFolderMessage implements MessageBase pos += 16; newObjFolderData['Type'] = buf.readInt8(pos++); varLength = buf.readUInt8(pos++); - newObjFolderData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjFolderData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; this.FolderData.push(newObjFolderData); } diff --git a/lib/classes/messages/UpdateInventoryItem.ts b/lib/classes/messages/UpdateInventoryItem.ts index 0b23f01..f6c6b37 100644 --- a/lib/classes/messages/UpdateInventoryItem.ts +++ b/lib/classes/messages/UpdateInventoryItem.ts @@ -219,10 +219,10 @@ export class UpdateInventoryItemMessage implements MessageBase newObjInventoryData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjInventoryData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjInventoryData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; newObjInventoryData['CreationDate'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/UpdateMuteListEntry.ts b/lib/classes/messages/UpdateMuteListEntry.ts index debebe2..ca78f91 100644 --- a/lib/classes/messages/UpdateMuteListEntry.ts +++ b/lib/classes/messages/UpdateMuteListEntry.ts @@ -76,7 +76,7 @@ export class UpdateMuteListEntryMessage implements MessageBase newObjMuteData['MuteID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjMuteData['MuteName'] = buf.slice(pos, pos + (varLength - 1)); + newObjMuteData['MuteName'] = buf.slice(pos, pos + varLength); pos += varLength; newObjMuteData['MuteType'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/UpdateParcel.ts b/lib/classes/messages/UpdateParcel.ts index 4f6908d..4bc0e31 100644 --- a/lib/classes/messages/UpdateParcel.ts +++ b/lib/classes/messages/UpdateParcel.ts @@ -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.slice(pos, pos + (varLength - 1)); + newObjParcelData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjParcelData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjParcelData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjParcelData['MusicURL'] = buf.slice(pos, pos + (varLength - 1)); + newObjParcelData['MusicURL'] = buf.slice(pos, pos + varLength); pos += varLength; newObjParcelData['RegionX'] = buf.readFloatLE(pos); pos += 4; diff --git a/lib/classes/messages/UpdateSimulator.ts b/lib/classes/messages/UpdateSimulator.ts index d8888fb..a3ab076 100644 --- a/lib/classes/messages/UpdateSimulator.ts +++ b/lib/classes/messages/UpdateSimulator.ts @@ -55,7 +55,7 @@ export class UpdateSimulatorMessage implements MessageBase newObjSimulatorInfo['RegionID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjSimulatorInfo['SimName'] = buf.slice(pos, pos + (varLength - 1)); + newObjSimulatorInfo['SimName'] = buf.slice(pos, pos + varLength); pos += varLength; newObjSimulatorInfo['EstateID'] = buf.readUInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/UpdateTaskInventory.ts b/lib/classes/messages/UpdateTaskInventory.ts index 8721b99..e58a830 100644 --- a/lib/classes/messages/UpdateTaskInventory.ts +++ b/lib/classes/messages/UpdateTaskInventory.ts @@ -204,10 +204,10 @@ export class UpdateTaskInventoryMessage implements MessageBase newObjInventoryData['SalePrice'] = buf.readInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjInventoryData['Name'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryData['Name'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjInventoryData['Description'] = buf.slice(pos, pos + (varLength - 1)); + newObjInventoryData['Description'] = buf.slice(pos, pos + varLength); pos += varLength; newObjInventoryData['CreationDate'] = buf.readInt32LE(pos); pos += 4; diff --git a/lib/classes/messages/UpdateUserInfo.ts b/lib/classes/messages/UpdateUserInfo.ts index 2cd8387..127d0f4 100644 --- a/lib/classes/messages/UpdateUserInfo.ts +++ b/lib/classes/messages/UpdateUserInfo.ts @@ -64,7 +64,7 @@ export class UpdateUserInfoMessage implements MessageBase }; newObjUserData['IMViaEMail'] = (buf.readUInt8(pos++) === 1); varLength = buf.readUInt8(pos++); - newObjUserData['DirectoryVisibility'] = buf.slice(pos, pos + (varLength - 1)); + newObjUserData['DirectoryVisibility'] = buf.slice(pos, pos + varLength); pos += varLength; this.UserData = newObjUserData; return pos - startPos; diff --git a/lib/classes/messages/UserInfoReply.ts b/lib/classes/messages/UserInfoReply.ts index 8a37ea6..fa1e2c7 100644 --- a/lib/classes/messages/UserInfoReply.ts +++ b/lib/classes/messages/UserInfoReply.ts @@ -64,11 +64,11 @@ export class UserInfoReplyMessage implements MessageBase }; newObjUserData['IMViaEMail'] = (buf.readUInt8(pos++) === 1); varLength = buf.readUInt8(pos++); - newObjUserData['DirectoryVisibility'] = buf.slice(pos, pos + (varLength - 1)); + newObjUserData['DirectoryVisibility'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjUserData['EMail'] = buf.slice(pos, pos + (varLength - 1)); + newObjUserData['EMail'] = buf.slice(pos, pos + varLength); pos += varLength; this.UserData = newObjUserData; return pos - startPos; diff --git a/lib/classes/messages/UserReport.ts b/lib/classes/messages/UserReport.ts index 9cc84f8..83934d0 100644 --- a/lib/classes/messages/UserReport.ts +++ b/lib/classes/messages/UserReport.ts @@ -127,19 +127,19 @@ export class UserReportMessage implements MessageBase newObjReportData['AbuserID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjReportData['AbuseRegionName'] = buf.slice(pos, pos + (varLength - 1)); + newObjReportData['AbuseRegionName'] = buf.slice(pos, pos + varLength); pos += varLength; newObjReportData['AbuseRegionID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjReportData['Summary'] = buf.slice(pos, pos + (varLength - 1)); + newObjReportData['Summary'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjReportData['Details'] = buf.slice(pos, pos + (varLength - 1)); + newObjReportData['Details'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjReportData['VersionString'] = buf.slice(pos, pos + (varLength - 1)); + newObjReportData['VersionString'] = buf.slice(pos, pos + varLength); pos += varLength; this.ReportData = newObjReportData; return pos - startPos; diff --git a/lib/classes/messages/UserReportInternal.ts b/lib/classes/messages/UserReportInternal.ts index 3971d22..72c65f5 100644 --- a/lib/classes/messages/UserReportInternal.ts +++ b/lib/classes/messages/UserReportInternal.ts @@ -144,19 +144,19 @@ export class UserReportInternalMessage implements MessageBase newObjReportData['AbuserID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjReportData['AbuseRegionName'] = buf.slice(pos, pos + (varLength - 1)); + newObjReportData['AbuseRegionName'] = buf.slice(pos, pos + varLength); pos += varLength; newObjReportData['AbuseRegionID'] = new UUID(buf, pos); pos += 16; varLength = buf.readUInt8(pos++); - newObjReportData['Summary'] = buf.slice(pos, pos + (varLength - 1)); + newObjReportData['Summary'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt16LE(pos); pos += 2; - newObjReportData['Details'] = buf.slice(pos, pos + (varLength - 1)); + newObjReportData['Details'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjReportData['VersionString'] = buf.slice(pos, pos + (varLength - 1)); + newObjReportData['VersionString'] = buf.slice(pos, pos + varLength); pos += varLength; this.ReportData = newObjReportData; return pos - startPos; diff --git a/lib/classes/messages/ViewerEffect.ts b/lib/classes/messages/ViewerEffect.ts index ce3fee9..690bede 100644 --- a/lib/classes/messages/ViewerEffect.ts +++ b/lib/classes/messages/ViewerEffect.ts @@ -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.slice(pos, pos + (varLength - 1)); + newObjEffect['TypeData'] = buf.slice(pos, pos + varLength); pos += varLength; this.Effect.push(newObjEffect); } diff --git a/lib/classes/messages/ViewerStats.ts b/lib/classes/messages/ViewerStats.ts index a289de3..02e83b6 100644 --- a/lib/classes/messages/ViewerStats.ts +++ b/lib/classes/messages/ViewerStats.ts @@ -196,13 +196,13 @@ export class ViewerStatsMessage implements MessageBase newObjAgentData['SysRAM'] = buf.readUInt32LE(pos); pos += 4; varLength = buf.readUInt8(pos++); - newObjAgentData['SysOS'] = buf.slice(pos, pos + (varLength - 1)); + newObjAgentData['SysOS'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjAgentData['SysCPU'] = buf.slice(pos, pos + (varLength - 1)); + newObjAgentData['SysCPU'] = buf.slice(pos, pos + varLength); pos += varLength; varLength = buf.readUInt8(pos++); - newObjAgentData['SysGPU'] = buf.slice(pos, pos + (varLength - 1)); + newObjAgentData['SysGPU'] = buf.slice(pos, pos + varLength); pos += varLength; this.AgentData = newObjAgentData; const newObjDownloadTotals: { diff --git a/lib/enums/AgentFlags.ts b/lib/enums/AgentFlags.ts new file mode 100644 index 0000000..4f95a47 --- /dev/null +++ b/lib/enums/AgentFlags.ts @@ -0,0 +1,4 @@ +export enum AgentFlags { + None = 0, + HideGroupTitle = 1 +} \ No newline at end of file diff --git a/lib/enums/AgentState.ts b/lib/enums/AgentState.ts new file mode 100644 index 0000000..620e731 --- /dev/null +++ b/lib/enums/AgentState.ts @@ -0,0 +1,5 @@ +export enum AgentState { + None = 0, + Typing = 4, + Editing = 16 +} \ No newline at end of file diff --git a/lib/enums/AssetType.ts b/lib/enums/AssetType.ts new file mode 100644 index 0000000..ce47c17 --- /dev/null +++ b/lib/enums/AssetType.ts @@ -0,0 +1,39 @@ +export enum AssetType +{ + Unknown = -1, + Texture = 0, + Sound = 1, + CallingCard = 2, + Landmark = 3, + Script = 4, + Clothing = 5, + Object = 6, + Notecard = 7, + Folder = 8, + RootFolder = 9, + LSLText = 10, + LSLBytecode = 11, + TextureTGA = 12, + Bodypart = 13, + TrashFolder = 14, + SnapshotFolder = 15, + LostAndFoundFolder = 16, + SoundWAV = 17, + ImageTGA = 18, + ImageJPEG = 19, + Animation = 20, + Gesture = 21, + Simstate = 22, + FavoriteFolder = 23, + Link = 24, + LinkFolder = 25, + EnsembleStart = 26, + EnsembleEnd = 45, + CurrentOutfitFolder = 46, + OutfitFolder = 47, + MyOutfitsFolder = 48, + Mesh = 49, + Inbox = 50, + Outbox = 51, + BasicRoot = 51 +} \ No newline at end of file diff --git a/lib/enums/AttachmentPoint.ts b/lib/enums/AttachmentPoint.ts new file mode 100644 index 0000000..ef8f812 --- /dev/null +++ b/lib/enums/AttachmentPoint.ts @@ -0,0 +1,44 @@ +export enum AttachmentPoint +{ + Default = 0, + Chest = 1, + Skull, + LeftShoulder, + RightShoulder, + LeftHand, + RightHand, + LeftFoot, + RightFoot, + Spine, + Pelvis, + Mouth, + Chin, + LeftEar, + RightEar, + LeftEyeball, + RightEyeball, + Nose, + RightUpperArm, + RightForearm, + LeftUpperArm, + LeftForearm, + RightHip, + RightUpperLeg, + RightLowerLeg, + LeftHip, + LeftUpperLeg, + LeftLowerLeg, + Stomach, + LeftPec, + RightPec, + HUDCenter2, + HUDTopRight, + HUDTop, + HUDTopLeft, + HUDCenter, + HUDBottomLeft, + HUDBottom, + HUDBottomRight, + Neck, + Root +} \ No newline at end of file diff --git a/lib/enums/BuiltInAnimations.ts b/lib/enums/BuiltInAnimations.ts new file mode 100644 index 0000000..47cd83f --- /dev/null +++ b/lib/enums/BuiltInAnimations.ts @@ -0,0 +1,138 @@ +export enum BuiltInAnimations +{ + AFRAID = '6b61c8e8-4747-0d75-12d7-e49ff207a4ca', + AIM_BAZOOKA_R = 'b5b4a67d-0aee-30d2-72cd-77b333e932ef', + AIM_BOW_L = '46bb4359-de38-4ed8-6a22-f1f52fe8f506', + AIM_HANDGUN_R = '3147d815-6338-b932-f011-16b56d9ac18b', + AIM_RIFLE_R = 'ea633413-8006-180a-c3ba-96dd1d756720', + ANGRY = '5747a48e-073e-c331-f6f3-7c2149613d3e', + AWAY = 'fd037134-85d4-f241-72c6-4f42164fedee', + BACKFLIP = 'c4ca6188-9127-4f31-0158-23c4e2f93304', + BELLY_LAUGH = '18b3a4b5-b463-bd48-e4b6-71eaac76c515', + BLOW_KISS = 'db84829b-462c-ee83-1e27-9bbee66bd624', + BORED = 'b906c4ba-703b-1940-32a3-0c7f7d791510', + BOW = '82e99230-c906-1403-4d9c-3889dd98daba', + BRUSH = '349a3801-54f9-bf2c-3bd0-1ac89772af01', + BUSY = 'efcf670c-2d18-8128-973a-034ebc806b67', + CLAP = '9b0c1c4e-8ac7-7969-1494-28c874c4f668', + COURTBOW = '9ba1c942-08be-e43a-fb29-16ad440efc50', + CROUCH = '201f3fdf-cb1f-dbec-201f-7333e328ae7c', + CROUCHWALK = '47f5f6fb-22e5-ae44-f871-73aaaf4a6022', + CRY = '92624d3e-1068-f1aa-a5ec-8244585193ed', + CUSTOMIZE = '038fcec9-5ebd-8a8e-0e2e-6e71a0a1ac53', + CUSTOMIZE_DONE = '6883a61a-b27b-5914-a61e-dda118a9ee2c', + DANCE1 = 'b68a3d7c-de9e-fc87-eec8-543d787e5b0d', + DANCE2 = '928cae18-e31d-76fd-9cc9-2f55160ff818', + DANCE3 = '30047778-10ea-1af7-6881-4db7a3a5a114', + DANCE4 = '951469f4-c7b2-c818-9dee-ad7eea8c30b7', + DANCE5 = '4bd69a1d-1114-a0b4-625f-84e0a5237155', + DANCE6 = 'cd28b69b-9c95-bb78-3f94-8d605ff1bb12', + DANCE7 = 'a54d8ee2-28bb-80a9-7f0c-7afbbe24a5d6', + DANCE8 = 'b0dc417c-1f11-af36-2e80-7e7489fa7cdc', + DEAD = '57abaae6-1d17-7b1b-5f98-6d11a6411276', + DRINK = '0f86e355-dd31-a61c-fdb0-3a96b9aad05f', + EMBARRASSED = '514af488-9051-044a-b3fc-d4dbf76377c6', + EXPRESS_AFRAID = 'aa2df84d-cf8f-7218-527b-424a52de766e', + EXPRESS_ANGER = '1a03b575-9634-b62a-5767-3a679e81f4de', + EXPRESS_BORED = '214aa6c1-ba6a-4578-f27c-ce7688f61d0d', + EXPRESS_CRY = 'd535471b-85bf-3b4d-a542-93bea4f59d33', + EXPRESS_DISDAIN = 'd4416ff1-09d3-300f-4183-1b68a19b9fc1', + EXPRESS_EMBARRASSED = '0b8c8211-d78c-33e8-fa28-c51a9594e424', + EXPRESS_FROWN = 'fee3df48-fa3d-1015-1e26-a205810e3001', + EXPRESS_KISS = '1e8d90cc-a84e-e135-884c-7c82c8b03a14', + EXPRESS_LAUGH = '62570842-0950-96f8-341c-809e65110823', + EXPRESS_OPEN_MOUTH = 'd63bc1f9-fc81-9625-a0c6-007176d82eb7', + EXPRESS_REPULSED = 'f76cda94-41d4-a229-2872-e0296e58afe1', + EXPRESS_SAD = 'eb6ebfb2-a4b3-a19c-d388-4dd5c03823f7', + EXPRESS_SHRUG = 'a351b1bc-cc94-aac2-7bea-a7e6ebad15ef', + EXPRESS_SMILE = 'b7c7c833-e3d3-c4e3-9fc0-131237446312', + EXPRESS_SURPRISE = '728646d9-cc79-08b2-32d6-937f0a835c24', + EXPRESS_TONGUE_OUT = '835965c6-7f2f-bda2-5deb-2478737f91bf', + EXPRESS_TOOTHSMILE = 'b92ec1a5-e7ce-a76b-2b05-bcdb9311417e', + EXPRESS_WINK = 'da020525-4d94-59d6-23d7-81fdebf33148', + EXPRESS_WORRY = '9c05e5c7-6f07-6ca4-ed5a-b230390c3950', + FALLDOWN = '666307d9-a860-572d-6fd4-c3ab8865c094', + FEMALE_WALK = 'f5fc7433-043d-e819-8298-f519a119b688', + FINGER_WAG = 'c1bc7f36-3ba0-d844-f93c-93be945d644f', + FIST_PUMP = '7db00ccd-f380-f3ee-439d-61968ec69c8a', + FLY = 'aec4610c-757f-bc4e-c092-c6e9caf18daf', + FLYSLOW = '2b5a38b2-5e00-3a97-a495-4c826bc443e6', + HELLO = '9b29cd61-c45b-5689-ded2-91756b8d76a9', + HOLD_BAZOOKA_R = 'ef62d355-c815-4816-2474-b1acc21094a6', + HOLD_BOW_L = '8b102617-bcba-037b-86c1-b76219f90c88', + HOLD_HANDGUN_R = 'efdc1727-8b8a-c800-4077-975fc27ee2f2', + HOLD_RIFLE_R = '3d94bad0-c55b-7dcc-8763-033c59405d33', + HOLD_THROW_R = '7570c7b5-1f22-56dd-56ef-a9168241bbb6', + HOVER = '4ae8016b-31b9-03bb-c401-b1ea941db41d', + HOVER_DOWN = '20f063ea-8306-2562-0b07-5c853b37b31e', + HOVER_UP = '62c5de58-cb33-5743-3d07-9e4cd4352864', + IMPATIENT = '5ea3991f-c293-392e-6860-91dfa01278a3', + JUMP = '2305bd75-1ca9-b03b-1faa-b176b8a8c49e', + JUMP_FOR_JOY = '709ea28e-1573-c023-8bf8-520c8bc637fa', + KISS_MY_BUTT = '19999406-3a3a-d58c-a2ac-d72e555dcf51', + LAND = '7a17b059-12b2-41b1-570a-186368b6aa6f', + LAUGH_SHORT = 'ca5b3f14-3194-7a2b-c894-aa699b718d1f', + MEDIUM_LAND = 'f4f00d6e-b9fe-9292-f4cb-0ae06ea58d57', + MOTORCYCLE_SIT = '08464f78-3a8e-2944-cba5-0c94aff3af29', + MUSCLE_BEACH = '315c3a41-a5f3-0ba4-27da-f893f769e69b', + NO = '5a977ed9-7f72-44e9-4c4c-6e913df8ae74', + NO_UNHAPPY = 'd83fa0e5-97ed-7eb2-e798-7bd006215cb4', + NYAH_NYAH = 'f061723d-0a18-754f-66ee-29a44795a32f', + ONETWO_PUNCH = 'eefc79be-daae-a239-8c04-890f5d23654a', + PEACE = 'b312b10e-65ab-a0a4-8b3c-1326ea8e3ed9', + POINT_ME = '17c024cc-eef2-f6a0-3527-9869876d7752', + POINT_YOU = 'ec952cca-61ef-aa3b-2789-4d1344f016de', + PRE_JUMP = '7a4e87fe-de39-6fcb-6223-024b00893244', + PUNCH_LEFT = 'f3300ad9-3462-1d07-2044-0fef80062da0', + PUNCH_RIGHT = 'c8e42d32-7310-6906-c903-cab5d4a34656', + REPULSED = '36f81a92-f076-5893-dc4b-7c3795e487cf', + ROUNDHOUSE_KICK = '49aea43b-5ac3-8a44-b595-96100af0beda', + RPS_COUNTDOWN = '35db4f7e-28c2-6679-cea9-3ee108f7fc7f', + RPS_PAPER = '0836b67f-7f7b-f37b-c00a-460dc1521f5a', + RPS_ROCK = '42dd95d5-0bc6-6392-f650-777304946c0f', + RPS_SCISSORS = '16803a9f-5140-e042-4d7b-d28ba247c325', + RUN = '05ddbff8-aaa9-92a1-2b74-8fe77a29b445', + SAD = '0eb702e2-cc5a-9a88-56a5-661a55c0676a', + SALUTE = 'cd7668a6-7011-d7e2-ead8-fc69eff1a104', + SHOOT_BOW_L = 'e04d450d-fdb5-0432-fd68-818aaf5935f8', + SHOUT = '6bd01860-4ebd-127a-bb3d-d1427e8e0c42', + SHRUG = '70ea714f-3a97-d742-1b01-590a8fcd1db5', + SIT = '1a5fe8ac-a804-8a5d-7cbd-56bd83184568', + SIT_FEMALE = 'b1709c8d-ecd3-54a1-4f28-d55ac0840782', + SIT_GENERIC = '245f3c54-f1c0-bf2e-811f-46d8eeb386e7', + SIT_GROUND = '1c7600d6-661f-b87b-efe2-d7421eb93c86', + SIT_GROUND_CONSTRAINED = '1a2bd58e-87ff-0df8-0b4c-53e047b0bb6e', + SIT_TO_STAND = 'a8dee56f-2eae-9e7a-05a2-6fb92b97e21e', + SLEEP = 'f2bed5f9-9d44-39af-b0cd-257b2a17fe40', + SMOKE_IDLE = 'd2f2ee58-8ad1-06c9-d8d3-3827ba31567a', + SMOKE_INHALE = '6802d553-49da-0778-9f85-1599a2266526', + SMOKE_THROW_DOWN = '0a9fb970-8b44-9114-d3a9-bf69cfe804d6', + SNAPSHOT = 'eae8905b-271a-99e2-4c0e-31106afd100c', + STAND = '2408fe9e-df1d-1d7d-f4ff-1384fa7b350f', + STANDUP = '3da1d753-028a-5446-24f3-9c9b856d9422', + STAND_1 = '15468e00-3400-bb66-cecc-646d7c14458e', + STAND_2 = '370f3a20-6ca6-9971-848c-9a01bc42ae3c', + STAND_3 = '42b46214-4b44-79ae-deb8-0df61424ff4b', + STAND_4 = 'f22fed8b-a5ed-2c93-64d5-bdd8b93c889f', + STRETCH = '80700431-74ec-a008-14f8-77575e73693f', + STRIDE = '1cb562b0-ba21-2202-efb3-30f82cdf9595', + SURF = '41426836-7437-7e89-025d-0aa4d10f1d69', + SURPRISE = '313b9881-4302-73c0-c7d0-0e7a36b6c224', + SWORD_STRIKE = '85428680-6bf9-3e64-b489-6f81087c24bd', + TALK = '5c682a95-6da4-a463-0bf6-0f5b7be129d1', + TANTRUM = '11000694-3f41-adc2-606b-eee1d66f3724', + THROW_R = 'aa134404-7dac-7aca-2cba-435f9db875ca', + TRYON_SHIRT = '83ff59fe-2346-f236-9009-4e3608af64c1', + TURNLEFT = '56e0ba0d-4a9f-7f27-6117-32f2ebbf6135', + TURNRIGHT = '2d6daa51-3192-6794-8e2e-a15f8338ec30', + TYPE = 'c541c47f-e0c0-058b-ad1a-d6ae3a4584d9', + WALK = '6ed24bd8-91aa-4b12-ccc7-c97c857ab4e0', + WHISPER = '7693f268-06c7-ea71-fa21-2b30d6533f8f', + WHISTLE = 'b1ed7982-c68e-a982-7561-52a88a5298c0', + WINK = '869ecdad-a44b-671e-3266-56aef2e3ac2e', + WINK_HOLLYWOOD = 'c0c4030f-c02b-49de-24ba-2331f43fe41c', + WORRY = '9f496bd2-589a-709f-16cc-69bf7df1d36c', + YES = '15dd911d-be82-2856-26db-27659b142875', + YES_HAPPY = 'b8c8b2a3-9008-1771-3bfc-90924955ab2d', + YOGA_FLOAT = '42ecd00b-9947-a97c-400a-bbc9174c7aeb' +} diff --git a/lib/enums/ChatAudible.ts b/lib/enums/ChatAudible.ts new file mode 100644 index 0000000..29e504a --- /dev/null +++ b/lib/enums/ChatAudible.ts @@ -0,0 +1,6 @@ +export enum ChatAudibleLevel +{ + Not = -1, + Barely = 0, + Fully = 1 +} \ No newline at end of file diff --git a/lib/enums/ChatSourceType.ts b/lib/enums/ChatSourceType.ts new file mode 100644 index 0000000..7982c1a --- /dev/null +++ b/lib/enums/ChatSourceType.ts @@ -0,0 +1,6 @@ +export enum ChatSourceType +{ + System = 0, + Agent = 1, + Object = 2 +} diff --git a/lib/enums/ChatType.ts b/lib/enums/ChatType.ts new file mode 100644 index 0000000..cd62106 --- /dev/null +++ b/lib/enums/ChatType.ts @@ -0,0 +1,13 @@ +export enum ChatType +{ + Whisper = 0, + Normal = 1, + Shout = 2, + Say = 3, + StartTyping = 4, + StopTyping = 5, + Debug = 6, + OwnerSay = 8, + RegionSayTo = 9, + RegionSay = 255, +} diff --git a/lib/enums/CompressedFlags.ts b/lib/enums/CompressedFlags.ts new file mode 100644 index 0000000..7e7b5f9 --- /dev/null +++ b/lib/enums/CompressedFlags.ts @@ -0,0 +1,14 @@ +export enum CompressedFlags +{ + None = 0x00, + ScratchPad = 0x01, + Tree = 0x02, + HasText = 0x04, + HasParticles = 0x08, + HasSound = 0x10, + HasParent = 0x20, + TextureAnimation = 0x40, + HasAngularVelocity = 0x80, + HasNameValues = 0x100, + MediaURL = 0x200 +} \ No newline at end of file diff --git a/lib/enums/ControlFlags.ts b/lib/enums/ControlFlags.ts new file mode 100644 index 0000000..9f801c1 --- /dev/null +++ b/lib/enums/ControlFlags.ts @@ -0,0 +1,36 @@ +export enum ControlFlags +{ + NONE = 0, + AGENT_CONTROL_AT_POS = 0x1 << 0, + AGENT_CONTROL_AT_NEG = 0x1 << 1, + AGENT_CONTROL_LEFT_POS = 0x1 << 2, + AGENT_CONTROL_LEFT_NEG = 0x1 << 3, + AGENT_CONTROL_UP_POS = 0x1 << 4, + AGENT_CONTROL_UP_NEG = 0x1 << 5, + AGENT_CONTROL_PITCH_POS = 0x1 << 6, + AGENT_CONTROL_PITCH_NEG = 0x1 << 7, + AGENT_CONTROL_YAW_POS = 0x1 << 8, + AGENT_CONTROL_YAW_NEG = 0x1 << 9, + AGENT_CONTROL_FAST_AT = 0x1 << 10, + AGENT_CONTROL_FAST_LEFT = 0x1 << 11, + AGENT_CONTROL_FAST_UP = 0x1 << 12, + AGENT_CONTROL_FLY = 0x1 << 13, + AGENT_CONTROL_STOP = 0x1 << 14, + AGENT_CONTROL_FINISH_ANIM = 0x1 << 15, + AGENT_CONTROL_STAND_UP = 0x1 << 16, + AGENT_CONTROL_SIT_ON_GROUND = 0x1 << 17, + AGENT_CONTROL_MOUSELOOK = 0x1 << 18, + AGENT_CONTROL_NUDGE_AT_POS = 0x1 << 19, + AGENT_CONTROL_NUDGE_AT_NEG = 0x1 << 20, + AGENT_CONTROL_NUDGE_LEFT_POS = 0x1 << 21, + AGENT_CONTROL_NUDGE_LEFT_NEG = 0x1 << 22, + AGENT_CONTROL_NUDGE_UP_POS = 0x1 << 23, + AGENT_CONTROL_NUDGE_UP_NEG = 0x1 << 24, + AGENT_CONTROL_TURN_LEFT = 0x1 << 25, + AGENT_CONTROL_TURN_RIGHT = 0x1 << 26, + AGENT_CONTROL_AWAY = 0x1 << 27, + AGENT_CONTROL_LBUTTON_DOWN = 0x1 << 28, + AGENT_CONTROL_LBUTTON_UP = 0x1 << 29, + AGENT_CONTROL_ML_LBUTTON_DOWN = 0x1 << 30, + AGENT_CONTROL_ML_LBUTTON_UP = 0x1 << 31 +} \ No newline at end of file diff --git a/lib/enums/ExtraParamType.ts b/lib/enums/ExtraParamType.ts new file mode 100644 index 0000000..2746ebe --- /dev/null +++ b/lib/enums/ExtraParamType.ts @@ -0,0 +1,8 @@ +export enum ExtraParamType +{ + Flexible = 0x10, + Light = 0x20, + Sculpt = 0x30, + LightImage = 0x40, + Mesh = 0x60 +} \ No newline at end of file diff --git a/lib/enums/GridItemType.ts b/lib/enums/GridItemType.ts new file mode 100644 index 0000000..3ced437 --- /dev/null +++ b/lib/enums/GridItemType.ts @@ -0,0 +1,12 @@ +export enum GridItemType +{ + Telehub = 1, + PgEvent = 2, + MatureEvent = 3, + Popular = 4, + AgentLocations = 6, + LandForSale = 7, + Classified = 8, + AdultEvent = 9, + AdultLandForSale = 10 +} \ No newline at end of file diff --git a/lib/enums/GridLayerType.ts b/lib/enums/GridLayerType.ts new file mode 100644 index 0000000..5849f18 --- /dev/null +++ b/lib/enums/GridLayerType.ts @@ -0,0 +1,6 @@ +export enum GridLayerType +{ + Objects = 0, + Terrain = 1, + LandForSale = 2 +} diff --git a/lib/enums/HTTPAssets.ts b/lib/enums/HTTPAssets.ts new file mode 100644 index 0000000..8870a77 --- /dev/null +++ b/lib/enums/HTTPAssets.ts @@ -0,0 +1,23 @@ +export enum HTTPAssets +{ + ASSET_TEXTURE = 'texture', + ASSET_SOUND = 'sound', + ASSET_ANIMATION = 'animatn', + ASSET_GESTURE = 'gesture', + ASSET_LANDMARK = 'landmark', + ASSET_CALLINGCARD = 'callcard', + ASSET_SCRIPT = 'script', + ASSET_CLOTHING = 'clothing', + ASSET_OBJECT = 'object', + ASSET_NOTECARD = 'notecard', + ASSET_CATEGORY = 'category', + ASSET_LSL_TEXT = 'lsltext', + ASSET_LSL_BYTECODE = 'lslbyte', + ASSET_BODYPART = 'bodypart', + ASSET_SIMSTATE = 'simstate', + ASSET_LINK = 'link', + ASSET_LINK_FOLDER = 'link_f', + ASSET_MESH = 'mesh', + ASSET_WIDGET = 'widget', + ASSET_PERSON = 'person' +} diff --git a/lib/enums/InstantMessageDialog.ts b/lib/enums/InstantMessageDialog.ts new file mode 100644 index 0000000..6cef2b8 --- /dev/null +++ b/lib/enums/InstantMessageDialog.ts @@ -0,0 +1,46 @@ +export enum InstantMessageDialog +{ + MessageFromAgent = 0, + MessageBox = 1, + MessageBoxCountdown = 2, + GroupInvitation = 3, + InventoryOffered = 4, + InventoryAccepted = 5, + InventoryDeclined = 6, + GroupVote = 7, + DeprecatedGroupMessage = 8, + TaskInventoryOffered = 9, + TaskInventoryAccepted = 10, + TaskInventoryDeclined = 11, + NewUserDefault = 12, + SessionAdd = 13, + SessionOfflineAdd = 14, + SessionGroupStart = 15, + SessionCardlessStart = 16, + SessionSend = 17, + SessionDrop = 18, + MessageFromObject = 19, + BusyAutoResponse = 20, + ConsoleAndChatHistory = 21, + RequestTeleport = 22, + AcceptTeleport = 23, + DenyTeleport = 24, + GodLikeRequestTeleport = 25, + RequestLure = 26, + DeprecatedGroupElection = 27, + GotoUrl = 28, + Session911Start = 29, + Lure911 = 30, + FromTaskAsAlert = 31, + GroupNotice = 32, + GroupNoticeInventoryAccepted = 33, + GroupNoticeInventoryDeclined = 34, + GroupInvitationAccept = 35, + GroupInvitationDecline = 36, + GroupNoticeRequested = 37, + FriendshipOffered = 38, + FriendshipAccepted = 39, + FriendshipDeclined = 40, + StartTyping = 41, + StopTyping = 42 +} \ No newline at end of file diff --git a/lib/enums/InventorySortOrder.ts b/lib/enums/InventorySortOrder.ts new file mode 100644 index 0000000..3224628 --- /dev/null +++ b/lib/enums/InventorySortOrder.ts @@ -0,0 +1,7 @@ +export enum InventorySortOrder +{ + ByName = 0, + ByDate = 1, + FoldersByName = 2, + SystemFoldersToTop = 4 +} \ No newline at end of file diff --git a/lib/enums/InventoryType.ts b/lib/enums/InventoryType.ts new file mode 100644 index 0000000..a2b9838 --- /dev/null +++ b/lib/enums/InventoryType.ts @@ -0,0 +1,27 @@ +export enum InventoryType +{ + Unknown = -1, + Texture = 0, + Sound = 1, + CallingCard = 2, + Landmark = 3, + Script = 4, + Clothing = 5, + Object = 6, + Notecard = 7, + Category = 8, + Folder = 8, + RootCategory = 9, + LSL = 10, + LSLBytecode = 11, + TextureTGA = 12, + Bodypart = 13, + Trash = 14, + Snapshot = 15, + LostAndFound = 16, + Attachment = 17, + Wearable = 18, + Animation = 19, + Gesture = 20, + Mesh = 22, +} \ No newline at end of file diff --git a/lib/enums/PCode.ts b/lib/enums/PCode.ts new file mode 100644 index 0000000..0d85a6f --- /dev/null +++ b/lib/enums/PCode.ts @@ -0,0 +1,10 @@ +export enum PCode +{ + None = 0, + Prim = 9, + Avatar = 47, + Grass = 95, + NewTree = 111, + ParticleSystem = 143, + Tree = 255 +} \ No newline at end of file diff --git a/lib/enums/RegionProtocolFlags.ts b/lib/enums/RegionProtocolFlags.ts new file mode 100644 index 0000000..11485e5 --- /dev/null +++ b/lib/enums/RegionProtocolFlags.ts @@ -0,0 +1,5 @@ +export enum RegionProtocolFlags { + None = 0, + AgentAppearanceService = 1, + SelfAppearanceSupport = 4 +} \ No newline at end of file diff --git a/lib/enums/SoundFlags.ts b/lib/enums/SoundFlags.ts new file mode 100644 index 0000000..fed846e --- /dev/null +++ b/lib/enums/SoundFlags.ts @@ -0,0 +1,10 @@ +export enum SoundFlags +{ + None = 0, + Loop = 0x01, + SyncMaster = 0x02, + SyncSlave = 0x04, + SyncPending = 0x08, + Queue = 0x10, + Stop = 0x20 +} diff --git a/lib/enums/TeleportEventType.ts b/lib/enums/TeleportEventType.ts new file mode 100644 index 0000000..eba91ef --- /dev/null +++ b/lib/enums/TeleportEventType.ts @@ -0,0 +1,7 @@ +export enum TeleportEventType +{ + TeleportStarted, + TeleportProgress, + TeleportCompleted, + TeleportFailed +} \ No newline at end of file diff --git a/lib/enums/TeleportFlags.ts b/lib/enums/TeleportFlags.ts new file mode 100644 index 0000000..c3280cc --- /dev/null +++ b/lib/enums/TeleportFlags.ts @@ -0,0 +1,23 @@ +export enum TeleportFlags +{ + Default = 0, + SetHomeToTarget = 1 << 0, + SetLastToTarget = 1 << 1, + ViaLure = 1 << 2, + ViaLandmark = 1 << 3, + ViaLocation = 1 << 4, + ViaHome = 1 << 5, + ViaTelehub = 1 << 6, + ViaLogin = 1 << 7, + ViaGodlikeLure = 1 << 8, + Godlike = 1 << 9, + NineOneOne = 1 << 10, + DisableCancel = 1 << 11, + ViaRegionID = 1 << 12, + IsFlying = 1 << 13, + ResetHome = 1 << 14, + ForceRedirect = 1 << 15, + FinishedViaLure = 1 << 26, + FinishedViaNewSim = 1 << 28, + FinishedViaSameSim = 1 << 29 +} diff --git a/lib/enums/TransferChannelType.ts b/lib/enums/TransferChannelType.ts new file mode 100644 index 0000000..7237d4c --- /dev/null +++ b/lib/enums/TransferChannelType.ts @@ -0,0 +1,7 @@ +export enum TransferChannelType +{ + Unknown = 0, + Misc = 1, + Asset = 2, + NumTypes = 3 +} diff --git a/lib/enums/TransferSourceTypes.ts b/lib/enums/TransferSourceTypes.ts new file mode 100644 index 0000000..10a9f7d --- /dev/null +++ b/lib/enums/TransferSourceTypes.ts @@ -0,0 +1,10 @@ +export enum TransferSourceType +{ + Unknown = 0, + File = 1, + Asset = 2, + SimInventoryItem = 3, + SimEstate = 4, + NumTypes = 5 +} + diff --git a/lib/enums/Tree.ts b/lib/enums/Tree.ts new file mode 100644 index 0000000..6573d3a --- /dev/null +++ b/lib/enums/Tree.ts @@ -0,0 +1,24 @@ +export enum Tree +{ + Pine1 = 0, + Oak, + TropicalBush1, + Palm1, + Dogwood, + TropicalBush2, + Palm2, + Cypress1, + Cypress2, + Pine2, + Plumeria, + WinterPine1, + WinterAspen, + WinterPine2, + Eucalyptus, + Fern, + Eelgrass, + SeaSword, + Kelp1, + BeachGrass1, + Kelp2 +} \ No newline at end of file diff --git a/lib/events/ChatEvent.ts b/lib/events/ChatEvent.ts new file mode 100644 index 0000000..ade8e9a --- /dev/null +++ b/lib/events/ChatEvent.ts @@ -0,0 +1,17 @@ +import {UUID} from '../classes/UUID'; +import {ChatAudibleLevel} from '../enums/ChatAudible'; +import {ChatType} from '../enums/ChatType'; +import {ChatSourceType} from '../enums/ChatSourceType'; +import {Vector3} from '../classes/Vector3'; + +export class ChatEvent +{ + from: UUID; + ownerID: UUID; + fromName: string; + chatType: ChatType; + sourceType: ChatSourceType; + audible: ChatAudibleLevel; + position: Vector3; + message: string; +} diff --git a/lib/events/LureEvent.ts b/lib/events/LureEvent.ts new file mode 100644 index 0000000..da97385 --- /dev/null +++ b/lib/events/LureEvent.ts @@ -0,0 +1,13 @@ +import {UUID} from '../classes/UUID'; +import {Vector3} from '../classes/Vector3'; + +export class LureEvent +{ + fromName: string; + lureMessage: string; + regionID: UUID; + position: Vector3; + gridX: number; + gridY: number; + lureID: UUID; +} \ No newline at end of file diff --git a/lib/events/MapInfoReply.ts b/lib/events/MapInfoReply.ts new file mode 100644 index 0000000..86ac0b3 --- /dev/null +++ b/lib/events/MapInfoReply.ts @@ -0,0 +1,12 @@ +import {UUID} from '../classes/UUID'; + +export class MapInfoReply +{ + name: string; + mapImage: UUID; + accessFlags: number; + avatars: { + X: number, + Y: number + }[] +} diff --git a/lib/events/TeleportEvent.ts b/lib/events/TeleportEvent.ts new file mode 100644 index 0000000..02e9076 --- /dev/null +++ b/lib/events/TeleportEvent.ts @@ -0,0 +1,10 @@ +import {TeleportEventType} from '../enums/TeleportEventType'; + +export class TeleportEvent +{ + eventType: TeleportEventType; + message: string; + simIP: string; + simPort: number; + seedCapability: string; +} \ No newline at end of file diff --git a/lib/index.ts b/lib/index.ts index 6f2e63d..56b819c 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -1,7 +1,19 @@ import {Bot} from './Bot'; import {LoginParameters} from './classes/LoginParameters'; +import {ClientEvents} from './classes/ClientEvents'; +import {BVH} from './classes/BVH'; + + +// Enums + +import {AssetType} from './enums/AssetType'; +import {HTTPAssets} from './enums/HTTPAssets'; export { Bot, - LoginParameters + LoginParameters, + AssetType, + HTTPAssets, + ClientEvents, + BVH }; diff --git a/package.json b/package.json index 934de24..631f9d1 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "scripts": { "prepublish": "npm run build", "build": "tsc --removeComments", + "run": "node -r source-map-support/register example/testBot.js", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", @@ -22,12 +23,15 @@ }, "dependencies": { "@types/long": "^3.0.32", + "@types/request": "^2.0.8", "@types/uuid": "^3.4.3", "@types/validator": "^6.3.0", "@types/xml": "^1.0.2", "@types/xmlrpc": "^1.3.3", "ipaddr.js": "^1.5.4", + "llsd": "git+https://github.com/CasperTech/llsd.git", "long": "^3.2.0", + "request": "^2.83.0", "rxjs": "^5.5.2", "source-map-support": "^0.5.0", "uuid": "^3.1.0", @@ -35,4 +39,4 @@ "xml": "^1.0.1", "xmlrpc": "^1.3.2" } -} +} \ No newline at end of file diff --git a/tools/writePacketClasses.js b/tools/writePacketClasses.js index cbe5112..2c01c4a 100644 --- a/tools/writePacketClasses.js +++ b/tools/writePacketClasses.js @@ -714,7 +714,7 @@ messages.forEach((message) => { console.error("INVALID VARIABLE LENGTH: " + param.size); } - classString += spaces + ' newObj' + block.name + '[\'' + param.name + '\'] = buf.slice(pos, pos + (varLength - 1));\n'; + classString += spaces + ' newObj' + block.name + '[\'' + param.name + '\'] = buf.slice(pos, pos + varLength);\n'; classString += spaces + ' pos += varLength;\n'; break; case 'LLVector4':