diff --git a/src/engine/db/handlers/dbMobHandler.java b/src/engine/db/handlers/dbMobHandler.java index 29a7f266..aac5b418 100644 --- a/src/engine/db/handlers/dbMobHandler.java +++ b/src/engine/db/handlers/dbMobHandler.java @@ -35,24 +35,24 @@ public class dbMobHandler extends dbHandlerBase { try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("CALL `mob_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) { - preparedStatement.setLong(1, toAdd.getParentZoneUUID()); - preparedStatement.setInt(2, toAdd.getMobBaseID()); - preparedStatement.setInt(3, toAdd.getGuildUUID()); - preparedStatement.setFloat(4, toAdd.getSpawnX()); - preparedStatement.setFloat(5, toAdd.getSpawnY()); - preparedStatement.setFloat(6, toAdd.getSpawnZ()); + preparedStatement.setLong(1, toAdd.parentZoneUUID); + preparedStatement.setInt(2, toAdd.loadID); + preparedStatement.setInt(3, toAdd.guildUUID); + preparedStatement.setFloat(4, toAdd.bindLoc.x); + preparedStatement.setFloat(5, toAdd.bindLoc.y); + preparedStatement.setFloat(6, toAdd.bindLoc.z); preparedStatement.setInt(7, 0); - preparedStatement.setFloat(8, toAdd.getSpawnRadius()); - preparedStatement.setInt(9, toAdd.getTrueSpawnTime()); + preparedStatement.setFloat(8, toAdd.spawnRadius); + preparedStatement.setInt(9, toAdd.spawnTime); if (toAdd.getContract() != null) - preparedStatement.setInt(10, toAdd.getContract().getContractID()); + preparedStatement.setInt(10, toAdd.contractUUID); else preparedStatement.setInt(10, 0); - preparedStatement.setInt(11, toAdd.getBuildingID()); - preparedStatement.setInt(12, toAdd.getLevel()); - preparedStatement.setString(13, toAdd.getFirstName()); + preparedStatement.setInt(11, toAdd.buildingUUID); + preparedStatement.setInt(12, toAdd.level); + preparedStatement.setString(13, toAdd.firstName); ResultSet rs = preparedStatement.executeQuery(); diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index a897aa78..960540b8 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -52,8 +52,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject { public int contractUUID; public Contract contract; - protected String firstName; - protected String lastName; + public String firstName; + public String lastName; protected short statStrCurrent; protected short statDexCurrent; protected short statConCurrent; diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 02fec22b..d78f7eaa 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -78,10 +78,10 @@ public class Mob extends AbstractIntelligenceAgent { public long stopPatrolTime = 0; public City guardedCity; protected int dbID; //the database ID - protected int loadID; - protected float spawnRadius; + public int loadID; + public float spawnRadius; //used by static mobs - protected int parentZoneUUID; + public int parentZoneUUID; protected float statLat; protected float statLon; protected float statAlt; @@ -472,6 +472,7 @@ public class Mob extends AbstractIntelligenceAgent { Mob mobile = new Mob(); mobile.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; mobile.loadID = loadID; + mobile.level = (short) level; if (guild.isEmptyGuild()) mobile.guildUUID = 0; @@ -480,32 +481,21 @@ public class Mob extends AbstractIntelligenceAgent { mobile.parentZoneUUID = parent.getObjectUUID(); mobile.buildingUUID = building.getObjectUUID(); - mobile.firstName = pirateName; - mobile.bindLoc = spawn; - - - Mob mobWithoutID = new Mob(pirateName, "", (short) 0, (short) 0, (short) 0, (short) 0, (short) 0, (short) 1, 0, false, false, false, spawn, spawn, Vector3fImmutable.ZERO, (short) 1, (short) 1, (short) 1, guild, (byte) 0, loadID, isMob, parent, building, contractID); - - if (mobWithoutID.mobBase == null) - return null; - - mobWithoutID.level = (short) level; - // Parent zone is required by dbhandler. Can likely - // refactor that out and just use the id. + if (mobile.buildingUUID != 0) + mobile.bindLoc = Vector3fImmutable.ZERO; + else + mobile.bindLoc = spawn; - mobWithoutID.parentZone = parent; - mobWithoutID.parentZoneUUID = parent.getObjectUUID(); + mobile.firstName = pirateName; - // NPC in a Building derives position from slot + mobile.contractUUID = contractID; - if (mobWithoutID.building != null) - mobWithoutID.bindLoc = Vector3fImmutable.ZERO; Mob mob; try { - mob = DbManager.MobQueries.ADD_MOB(mobWithoutID); + mob = DbManager.MobQueries.ADD_MOB(mobile); mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks()); } catch (Exception e) {