Read NPC building owners once instead of per building at boot

Building.runAfterLoad ran GET_UID_ENUM for every building (~47k queries).
One query now reads the NPC owner IDs before the building load; runtime
loads also check the NPC cache. City load reads ownerIsNPC before NPCs
are cached, so a pass after the NPC load would not work.

Value changes: none. ownerIsNPC is still true exactly when the owner's
object.type is 'npc' (dev DB: 388 buildings, 24 owners).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
MagicBotandClaude Opus 5.5 committed 2026-10-26 19:16:53 -04:00
1 parent 015d536337
commit 35f1738ee4
4 files changed
+27 -8

No files matched your search

+3 -8
View File
@@ -1027,15 +1027,10 @@ public class Building extends AbstractWorldObject {
}
}
// Submit upgrade job if building is currently set to rank.
// City load reads ownerIsNPC before NPCs are cached, so boot uses the owner set read ahead of buildings.
try {
DbObjectType objectType = DbManager.BuildingQueries.GET_UID_ENUM(this.ownerUUID);
this.ownerIsNPC = (objectType == DbObjectType.NPC);
} catch (Exception e) {
this.ownerIsNPC = false;
Logger.error("Failed to find Object Type for owner " + this.ownerUUID + " Location " + this.getLoc().toString());
}
this.ownerIsNPC = BuildingManager._npcBuildingOwners.contains(this.ownerUUID)
|| DbManager.inCache(GameObjectType.NPC, this.ownerUUID);
// Reference friend and condemn lists from BuildingManager