From 221ae0a58b09cad6482595e66fcc2298626b4492 Mon Sep 17 00:00:00 2001 From: byronhb Date: Mon, 10 Nov 2025 21:14:28 -0600 Subject: [PATCH] Fixes for /mob, /npc, and /equipset commands. --- src/engine/db/handlers/dbNPCHandler.java | 8 ++++++-- src/engine/objects/Mob.java | 12 +++++++++++- src/engine/objects/NPC.java | 5 +++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/engine/db/handlers/dbNPCHandler.java b/src/engine/db/handlers/dbNPCHandler.java index 51b20246..af98e96e 100644 --- a/src/engine/db/handlers/dbNPCHandler.java +++ b/src/engine/db/handlers/dbNPCHandler.java @@ -243,8 +243,12 @@ public class dbNPCHandler extends dbHandlerBase { public boolean UPDATE_EQUIPSET(NPC npc, int equipSetID) { + // Column name must match what NPC/Mob loaders read ("equipmentSet"). + // Using the wrong column here causes the update to fail silently and + // dev command to report "Unable to find Equipset" despite a valid ID. + try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_npc` SET `equipsetID`=? WHERE `UID`=?")) { + PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_npc` SET `equipmentSet`=? WHERE `UID`=?")) { preparedStatement.setInt(1, equipSetID); preparedStatement.setLong(2, npc.getObjectUUID()); @@ -467,4 +471,4 @@ public class dbNPCHandler extends dbHandlerBase { return false; } } -} +} \ No newline at end of file diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 70602b02..d7b578d1 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -541,8 +541,18 @@ public class Mob extends AbstractIntelligenceAgent { mobWithoutID.parentZone = parent; mobWithoutID.parentZoneID = parent.getObjectUUID(); - // NPC in a Building derives position from slot + // Ensure spawn coordinates are persisted for DB insert + // statLat/statAlt/statLon represent local (zone-relative) spawn + // coordinates used by the DB handler when creating the mob row. + if (spawn != null && parent != null) { + // Convert world coordinates to zone-local spawn coordinates + Vector3fImmutable localSpawn = spawn.subtract(parent.getLoc()); + mobWithoutID.statLat = localSpawn.x; + mobWithoutID.statAlt = localSpawn.y; + mobWithoutID.statLon = localSpawn.z; + } + // NPC in a Building derives position from slot if (mobWithoutID.building != null) mobWithoutID.bindLoc = Vector3fImmutable.ZERO; diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 1e6d2f83..ae3092de 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -470,7 +470,8 @@ public class NPC extends AbstractCharacter { newNPC.bindLoc = Vector3fImmutable.ZERO; newNPC.parentZoneUUID = parent.getObjectUUID(); - newNPC.guildUUID = guild.getObjectUUID(); + // guild may be null when spawning via ./npc; default to 0 + newNPC.guildUUID = (guild != null) ? guild.getObjectUUID() : 0; if (building == null) newNPC.buildingUUID = 0; @@ -1347,4 +1348,4 @@ public class NPC extends AbstractCharacter { } } -} +} \ No newline at end of file