Refactor towards new constructor.

This commit is contained in:
2023-08-25 12:11:50 -04:00
parent 573cc531bf
commit 24639b62c0
3 changed files with 26 additions and 36 deletions
+12 -12
View File
@@ -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();
+2 -2
View File
@@ -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;
+12 -22
View File
@@ -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();
if (mobile.buildingUUID != 0)
mobile.bindLoc = Vector3fImmutable.ZERO;
else
mobile.bindLoc = spawn;
mobile.firstName = pirateName;
mobile.bindLoc = spawn;
mobile.contractUUID = contractID;
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.
mobWithoutID.parentZone = parent;
mobWithoutID.parentZoneUUID = parent.getObjectUUID();
// NPC in a Building derives position from slot
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) {