Skip to content

Commit

Permalink
Improvements to object resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
TomMettam committed Sep 9, 2024
1 parent 0b3070c commit 1c6a2fa
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 26 deletions.
4 changes: 4 additions & 0 deletions lib/classes/InventoryItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,10 @@ export class InventoryItem
{
inventoryItem.inventoryType = parseInt(prop, 10);
}
if ((prop = Utils.getFromXMLJS(result, 'Type')) !== undefined)
{
inventoryItem.type = parseInt(prop, 10);
}
if ((prop = Utils.getFromXMLJS(result, 'CreatorUUID')) !== undefined)
{
try
Expand Down
4 changes: 4 additions & 0 deletions lib/classes/ObjectResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export class ObjectResolver
}

const objArray = Array.from(objs.values());
for (const obj of objArray)
{
obj.resolveAttempts = (obj.resolveAttempts ?? 0) + 1;
}
try
{
await this.region.clientCommands.region.selectObjects(objArray);
Expand Down
1 change: 0 additions & 1 deletion lib/classes/ParticleSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ export class ParticleSystem
}
const systemBlock = Buffer.allocUnsafe(68);
let pos = 0;
console.log('FLAGS: ' + this.flags);
systemBlock.writeUInt32LE(this.crc, pos); pos = pos + 4;
systemBlock.writeUInt32LE(this.flags, pos); pos = pos + 4; // Flags is zero
systemBlock.writeUInt8(this.pattern, pos++);
Expand Down
15 changes: 0 additions & 15 deletions lib/classes/commands/RegionCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,21 +376,6 @@ export class RegionCommands extends CommandsBase
{

}
finally
{

for (const obj of objects)
{
if (!(obj instanceof GameObject))
{
continue;
}
if (obj.resolvedAt === undefined || obj.name === undefined)
{
obj.resolveAttempts++;
}
}
}
}
}

Expand Down
14 changes: 7 additions & 7 deletions lib/classes/public/GameObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1601,7 +1601,7 @@ export class GameObject implements IGameObjectData
}
}

private async getXML(xml: XMLNode, rootPrim: GameObject, linkNum: number, rootNode?: string): Promise<void>
private async getXML(xml: XMLNode, rootPrim: GameObject, linkNum: number, rootNode?: string, skipInventory = false): Promise<void>
{
const resolver = this.region?.resolver;
if (resolver)
Expand All @@ -1617,7 +1617,7 @@ export class GameObject implements IGameObjectData
Logger.Error(e);
}
}
if (!this.resolvedInventory)
if (!this.resolvedInventory && !skipInventory)
{
try
{
Expand Down Expand Up @@ -1889,25 +1889,25 @@ export class GameObject implements IGameObjectData
this.region.objects.populateChildren(this);
}

async exportXMLElement(rootNode?: string): Promise<XMLElement>
async exportXMLElement(rootNode?: string, skipInventory = false): Promise<XMLElement>
{
const document = builder.create('SceneObjectGroup');
let linkNum = 1;
await this.getXML(document, this, linkNum, rootNode);
await this.getXML(document, this, linkNum, rootNode, skipInventory);
if (this.children && this.children.length > 0)
{
const otherParts = document.ele('OtherParts');
for (const child of this.children)
{
await child.getXML(otherParts, this, ++linkNum, (rootNode !== undefined) ? 'Part' : undefined);
await child.getXML(otherParts, this, ++linkNum, (rootNode !== undefined) ? 'Part' : undefined, skipInventory);
}
}
return document;
}

async exportXML(rootNode?: string): Promise<string>
async exportXML(rootNode?: string, skipInventory = false): Promise<string>
{
return (await this.exportXMLElement(rootNode)).end({ pretty: true, allowEmpty: true });
return (await this.exportXMLElement(rootNode, skipInventory)).end({ pretty: true, allowEmpty: true });
}

public toJSON(): IGameObjectData
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@caspertech/node-metaverse",
"version": "0.7.24",
"version": "0.7.28",
"description": "A node.js interface for Second Life.",
"main": "dist/lib/index.js",
"types": "dist/lib/index.d.ts",
Expand Down

0 comments on commit 1c6a2fa

Please sign in to comment.