Add BotOptionFlags.StoreMyAttachmentsOnly for ultra light-weight footprint

This commit is contained in:
Casper Warden
2017-12-14 02:18:50 +00:00
parent 60e300f052
commit ba121281dc
16 changed files with 96 additions and 17 deletions

View File

@@ -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++);