Add BotOptionFlags.StoreMyAttachmentsOnly for ultra light-weight footprint
This commit is contained in:
4
dist/classes/ObjectStoreFull.d.ts
vendored
4
dist/classes/ObjectStoreFull.d.ts
vendored
@@ -6,6 +6,7 @@ import { ClientEvents } from './ClientEvents';
|
||||
import { IObjectStore } from './interfaces/IObjectStore';
|
||||
import { GameObjectFull } from './GameObjectFull';
|
||||
import { IGameObject } from './interfaces/IGameObject';
|
||||
import { BotOptionFlags } from '../enums/BotOptionFlags';
|
||||
export declare class ObjectStoreFull implements IObjectStore {
|
||||
private circuit;
|
||||
private agent;
|
||||
@@ -13,7 +14,8 @@ export declare class ObjectStoreFull implements IObjectStore {
|
||||
private objectsByUUID;
|
||||
private objectsByParent;
|
||||
private clientEvents;
|
||||
constructor(circuit: Circuit, agent: Agent, clientEvents: ClientEvents);
|
||||
private options;
|
||||
constructor(circuit: Circuit, agent: Agent, clientEvents: ClientEvents, options: BotOptionFlags);
|
||||
deleteObject(objectID: number): void;
|
||||
readExtraParams(buf: Buffer, pos: number, o: GameObjectFull): number;
|
||||
getObjectsByParent(parentID: number): IGameObject[];
|
||||
|
||||
16
dist/classes/ObjectStoreFull.js
vendored
16
dist/classes/ObjectStoreFull.js
vendored
@@ -10,11 +10,13 @@ const Utils_1 = require("./Utils");
|
||||
const PCode_1 = require("../enums/PCode");
|
||||
const NameValue_1 = require("./NameValue");
|
||||
const GameObjectFull_1 = require("./GameObjectFull");
|
||||
const BotOptionFlags_1 = require("../enums/BotOptionFlags");
|
||||
class ObjectStoreFull {
|
||||
constructor(circuit, agent, clientEvents) {
|
||||
constructor(circuit, agent, clientEvents, options) {
|
||||
this.objects = {};
|
||||
this.objectsByUUID = {};
|
||||
this.objectsByParent = {};
|
||||
this.options = options;
|
||||
this.clientEvents = clientEvents;
|
||||
this.circuit = circuit;
|
||||
this.agent = agent;
|
||||
@@ -104,6 +106,12 @@ class ObjectStoreFull {
|
||||
if (addToParentList) {
|
||||
this.objectsByParent[parentID].push(localID);
|
||||
}
|
||||
if (this.options & BotOptionFlags_1.BotOptionFlags.StoreMyAttachmentsOnly) {
|
||||
if (this.agent.localID !== 0 && obj.ParentID !== this.agent.localID) {
|
||||
this.deleteObject(localID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
break;
|
||||
case Message_1.Message.ObjectUpdateCached:
|
||||
@@ -187,6 +195,12 @@ class ObjectStoreFull {
|
||||
}
|
||||
o.ParentID = newParentID;
|
||||
}
|
||||
if (newObj && this.options & BotOptionFlags_1.BotOptionFlags.StoreMyAttachmentsOnly) {
|
||||
if (this.agent.localID !== 0 && o.ParentID !== this.agent.localID) {
|
||||
this.deleteObject(localID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (compressedflags & CompressedFlags_1.CompressedFlags.Tree) {
|
||||
o.TreeSpecies = buf.readUInt8(pos++);
|
||||
}
|
||||
|
||||
2
dist/classes/ObjectStoreFull.js.map
vendored
2
dist/classes/ObjectStoreFull.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/classes/ObjectStoreLite.d.ts
vendored
4
dist/classes/ObjectStoreLite.d.ts
vendored
@@ -5,6 +5,7 @@ import { ClientEvents } from './ClientEvents';
|
||||
import { IObjectStore } from './interfaces/IObjectStore';
|
||||
import { GameObjectLite } from './GameObjectLite';
|
||||
import { NameValue } from './NameValue';
|
||||
import { BotOptionFlags } from '../enums/BotOptionFlags';
|
||||
export declare class ObjectStoreLite implements IObjectStore {
|
||||
private circuit;
|
||||
private agent;
|
||||
@@ -12,7 +13,8 @@ export declare class ObjectStoreLite implements IObjectStore {
|
||||
private objectsByUUID;
|
||||
private objectsByParent;
|
||||
private clientEvents;
|
||||
constructor(circuit: Circuit, agent: Agent, clientEvents: ClientEvents);
|
||||
private options;
|
||||
constructor(circuit: Circuit, agent: Agent, clientEvents: ClientEvents, options: BotOptionFlags);
|
||||
deleteObject(objectID: number): void;
|
||||
readExtraParams(buf: Buffer, pos: number, o: GameObjectLite): number;
|
||||
getObjectsByParent(parentID: number): GameObjectLite[];
|
||||
|
||||
16
dist/classes/ObjectStoreLite.js
vendored
16
dist/classes/ObjectStoreLite.js
vendored
@@ -8,11 +8,13 @@ const Utils_1 = require("./Utils");
|
||||
const PCode_1 = require("../enums/PCode");
|
||||
const GameObjectLite_1 = require("./GameObjectLite");
|
||||
const NameValue_1 = require("./NameValue");
|
||||
const BotOptionFlags_1 = require("../enums/BotOptionFlags");
|
||||
class ObjectStoreLite {
|
||||
constructor(circuit, agent, clientEvents) {
|
||||
constructor(circuit, agent, clientEvents, options) {
|
||||
this.objects = {};
|
||||
this.objectsByUUID = {};
|
||||
this.objectsByParent = {};
|
||||
this.options = options;
|
||||
this.clientEvents = clientEvents;
|
||||
this.circuit = circuit;
|
||||
this.agent = agent;
|
||||
@@ -61,6 +63,12 @@ class ObjectStoreLite {
|
||||
if (addToParentList) {
|
||||
this.objectsByParent[parentID].push(localID);
|
||||
}
|
||||
if (this.options & BotOptionFlags_1.BotOptionFlags.StoreMyAttachmentsOnly) {
|
||||
if (this.agent.localID !== 0 && obj.ParentID !== this.agent.localID) {
|
||||
this.deleteObject(localID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
break;
|
||||
case Message_1.Message.ObjectUpdateCached:
|
||||
@@ -137,6 +145,12 @@ class ObjectStoreLite {
|
||||
}
|
||||
o.ParentID = newParentID;
|
||||
}
|
||||
if (newObj && this.options & BotOptionFlags_1.BotOptionFlags.StoreMyAttachmentsOnly) {
|
||||
if (this.agent.localID !== 0 && o.ParentID !== this.agent.localID) {
|
||||
this.deleteObject(localID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (compressedflags & CompressedFlags_1.CompressedFlags.Tree) {
|
||||
pos++;
|
||||
}
|
||||
|
||||
2
dist/classes/ObjectStoreLite.js.map
vendored
2
dist/classes/ObjectStoreLite.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/classes/Region.js
vendored
4
dist/classes/Region.js
vendored
@@ -12,10 +12,10 @@ class Region {
|
||||
this.clientEvents = clientEvents;
|
||||
this.circuit = new Circuit_1.Circuit(clientEvents);
|
||||
if (options & BotOptionFlags_1.BotOptionFlags.LiteObjectStore) {
|
||||
this.objects = new ObjectStoreLite_1.ObjectStoreLite(this.circuit, agent, clientEvents);
|
||||
this.objects = new ObjectStoreLite_1.ObjectStoreLite(this.circuit, agent, clientEvents, options);
|
||||
}
|
||||
else {
|
||||
this.objects = new ObjectStoreFull_1.ObjectStoreFull(this.circuit, agent, clientEvents);
|
||||
this.objects = new ObjectStoreFull_1.ObjectStoreFull(this.circuit, agent, clientEvents, options);
|
||||
}
|
||||
this.comms = new Comms_1.Comms(this.circuit, agent, clientEvents);
|
||||
}
|
||||
|
||||
2
dist/classes/Region.js.map
vendored
2
dist/classes/Region.js.map
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"Region.js","sourceRoot":"","sources":["../../lib/classes/Region.ts"],"names":[],"mappings":";;AAAA,uCAAkC;AAElC,iCAA4B;AAC5B,mCAA8B;AAG9B,uDAAkD;AAClD,4DAAuD;AACvD,uDAAkD;AAElD;IAWI,YAAY,KAAY,EAAE,YAA0B,EAAE,OAAuB;QAEzE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,IAAI,iBAAO,CAAC,YAAY,CAAC,CAAC;QACzC,EAAE,CAAC,CAAC,OAAO,GAAG,+BAAc,CAAC,eAAe,CAAC,CAC7C,CAAC;YACG,IAAI,CAAC,OAAO,GAAG,IAAI,iCAAe,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;QAC1E,CAAC;QACD,IAAI,CACJ,CAAC;YACG,IAAI,CAAC,OAAO,GAAG,IAAI,iCAAe,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;QAC1E,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,aAAK,CAAC,IAAI,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,KAAK,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC;IACD,YAAY,CAAC,OAAe;QAExB,IAAI,CAAC,IAAI,GAAG,IAAI,WAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3D,CAAC;IACD,QAAQ;QAEJ,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACrB,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;IAE5B,CAAC;CACJ;AAtCD,wBAsCC"}
|
||||
1
dist/enums/BotOptionFlags.d.ts
vendored
1
dist/enums/BotOptionFlags.d.ts
vendored
@@ -1,4 +1,5 @@
|
||||
export declare enum BotOptionFlags {
|
||||
None = 0,
|
||||
LiteObjectStore = 1,
|
||||
StoreMyAttachmentsOnly = 2,
|
||||
}
|
||||
|
||||
1
dist/enums/BotOptionFlags.js
vendored
1
dist/enums/BotOptionFlags.js
vendored
@@ -4,5 +4,6 @@ var BotOptionFlags;
|
||||
(function (BotOptionFlags) {
|
||||
BotOptionFlags[BotOptionFlags["None"] = 0] = "None";
|
||||
BotOptionFlags[BotOptionFlags["LiteObjectStore"] = 1] = "LiteObjectStore";
|
||||
BotOptionFlags[BotOptionFlags["StoreMyAttachmentsOnly"] = 2] = "StoreMyAttachmentsOnly";
|
||||
})(BotOptionFlags = exports.BotOptionFlags || (exports.BotOptionFlags = {}));
|
||||
//# sourceMappingURL=BotOptionFlags.js.map
|
||||
2
dist/enums/BotOptionFlags.js.map
vendored
2
dist/enums/BotOptionFlags.js.map
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"BotOptionFlags.js","sourceRoot":"","sources":["../../lib/enums/BotOptionFlags.ts"],"names":[],"mappings":";;AAAA,IAAY,cAIX;AAJD,WAAY,cAAc;IAEtB,mDAAQ,CAAA;IACR,yEAAmB,CAAA;AACvB,CAAC,EAJW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAIzB"}
|
||||
{"version":3,"file":"BotOptionFlags.js","sourceRoot":"","sources":["../../lib/enums/BotOptionFlags.ts"],"names":[],"mappings":";;AAAA,IAAY,cAKX;AALD,WAAY,cAAc;IAEtB,mDAAQ,CAAA;IACR,yEAAmB,CAAA;IACnB,uFAA0B,CAAA;AAC9B,CAAC,EALW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAKzB"}
|
||||
@@ -13,7 +13,7 @@ loginParameters.start = "last";
|
||||
// If you don't intend to use the object store (i.e you have no interest in inworld objects, textures, etc,
|
||||
// using ObjectStoreLite will drastically reduce the footprint
|
||||
//
|
||||
const options = nmv.BotOptionFlags.LiteObjectStore;
|
||||
const options = nmv.BotOptionFlags.LiteObjectStore | nmv.BotOptionFlags.StoreMyAttachmentsOnly;
|
||||
|
||||
const bot = new nmv.Bot(loginParameters, options);
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import {KillObjectMessage} from './messages/KillObject';
|
||||
import {IObjectStore} from './interfaces/IObjectStore';
|
||||
import {GameObjectFull} from './GameObjectFull';
|
||||
import {IGameObject} from './interfaces/IGameObject';
|
||||
import {BotOptionFlags} from '../enums/BotOptionFlags';
|
||||
|
||||
export class ObjectStoreFull implements IObjectStore
|
||||
{
|
||||
@@ -30,9 +31,11 @@ export class ObjectStoreFull implements IObjectStore
|
||||
private objectsByUUID: { [key: string]: number } = {};
|
||||
private objectsByParent: { [key: number]: number[] } = {};
|
||||
private clientEvents: ClientEvents;
|
||||
private options: BotOptionFlags;
|
||||
|
||||
constructor(circuit: Circuit, agent: Agent, clientEvents: ClientEvents)
|
||||
constructor(circuit: Circuit, agent: Agent, clientEvents: ClientEvents, options: BotOptionFlags)
|
||||
{
|
||||
this.options = options;
|
||||
this.clientEvents = clientEvents;
|
||||
this.circuit = circuit;
|
||||
this.agent = agent;
|
||||
@@ -138,6 +141,16 @@ export class ObjectStoreFull implements IObjectStore
|
||||
{
|
||||
this.objectsByParent[parentID].push(localID);
|
||||
}
|
||||
|
||||
if (this.options & BotOptionFlags.StoreMyAttachmentsOnly)
|
||||
{
|
||||
if (this.agent.localID !== 0 && obj.ParentID !== this.agent.localID)
|
||||
{
|
||||
// Drop object
|
||||
this.deleteObject(localID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
break;
|
||||
case Message.ObjectUpdateCached:
|
||||
@@ -234,6 +247,15 @@ export class ObjectStoreFull implements IObjectStore
|
||||
}
|
||||
o.ParentID = newParentID;
|
||||
}
|
||||
if (newObj && this.options & BotOptionFlags.StoreMyAttachmentsOnly)
|
||||
{
|
||||
if (this.agent.localID !== 0 && o.ParentID !== this.agent.localID)
|
||||
{
|
||||
// Drop object
|
||||
this.deleteObject(localID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (compressedflags & CompressedFlags.Tree)
|
||||
{
|
||||
o.TreeSpecies = buf.readUInt8(pos++);
|
||||
|
||||
@@ -18,6 +18,7 @@ import {KillObjectMessage} from './messages/KillObject';
|
||||
import {IObjectStore} from './interfaces/IObjectStore';
|
||||
import {GameObjectLite} from './GameObjectLite';
|
||||
import {NameValue} from './NameValue';
|
||||
import {BotOptionFlags} from '../enums/BotOptionFlags';
|
||||
|
||||
export class ObjectStoreLite implements IObjectStore
|
||||
{
|
||||
@@ -27,9 +28,11 @@ export class ObjectStoreLite implements IObjectStore
|
||||
private objectsByUUID: { [key: string]: number } = {};
|
||||
private objectsByParent: { [key: number]: number[] } = {};
|
||||
private clientEvents: ClientEvents;
|
||||
private options: BotOptionFlags;
|
||||
|
||||
constructor(circuit: Circuit, agent: Agent, clientEvents: ClientEvents)
|
||||
constructor(circuit: Circuit, agent: Agent, clientEvents: ClientEvents, options: BotOptionFlags)
|
||||
{
|
||||
this.options = options;
|
||||
this.clientEvents = clientEvents;
|
||||
this.circuit = circuit;
|
||||
this.agent = agent;
|
||||
@@ -94,6 +97,16 @@ export class ObjectStoreLite implements IObjectStore
|
||||
{
|
||||
this.objectsByParent[parentID].push(localID);
|
||||
}
|
||||
|
||||
if (this.options & BotOptionFlags.StoreMyAttachmentsOnly)
|
||||
{
|
||||
if (this.agent.localID !== 0 && obj.ParentID !== this.agent.localID)
|
||||
{
|
||||
// Drop object
|
||||
this.deleteObject(localID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
break;
|
||||
case Message.ObjectUpdateCached:
|
||||
@@ -189,6 +202,15 @@ export class ObjectStoreLite implements IObjectStore
|
||||
}
|
||||
o.ParentID = newParentID;
|
||||
}
|
||||
if (newObj && this.options & BotOptionFlags.StoreMyAttachmentsOnly)
|
||||
{
|
||||
if (this.agent.localID !== 0 && o.ParentID !== this.agent.localID)
|
||||
{
|
||||
// Drop object
|
||||
this.deleteObject(localID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (compressedflags & CompressedFlags.Tree)
|
||||
{
|
||||
pos++;
|
||||
|
||||
@@ -26,11 +26,11 @@ export class Region
|
||||
this.circuit = new Circuit(clientEvents);
|
||||
if (options & BotOptionFlags.LiteObjectStore)
|
||||
{
|
||||
this.objects = new ObjectStoreLite(this.circuit, agent, clientEvents);
|
||||
this.objects = new ObjectStoreLite(this.circuit, agent, clientEvents, options);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.objects = new ObjectStoreFull(this.circuit, agent, clientEvents);
|
||||
this.objects = new ObjectStoreFull(this.circuit, agent, clientEvents, options);
|
||||
}
|
||||
this.comms = new Comms(this.circuit, agent, clientEvents);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export enum BotOptionFlags
|
||||
{
|
||||
None = 0,
|
||||
LiteObjectStore = 1
|
||||
}
|
||||
LiteObjectStore = 1,
|
||||
StoreMyAttachmentsOnly = 2
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user