Browse Source

Moving items out of constructor.

master
MagicBot 1 year ago
parent
commit
b21e9dc59e
  1. 15
      src/engine/objects/AbstractCharacter.java
  2. 2
      src/engine/objects/AbstractIntelligenceAgent.java
  3. 4
      src/engine/objects/Mob.java
  4. 6
      src/engine/objects/NPC.java
  5. 7
      src/engine/objects/PlayerCharacter.java

15
src/engine/objects/AbstractCharacter.java

@ -45,7 +45,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; @@ -45,7 +45,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
public abstract class AbstractCharacter extends AbstractWorldObject {
protected final CharacterItemManager charItemManager;
protected CharacterItemManager charItemManager;
private final ReentrantReadWriteLock healthLock = new ReentrantReadWriteLock();
public short level;
public AbstractWorldObject combatTarget;
@ -122,6 +122,15 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -122,6 +122,15 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
private boolean collided = false;
private byte aoecntr = 0;
public AbstractCharacter() {
super();
this.powers = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
this.initializeCharacter();
}
/**
* No Id Constructor
*/
@ -136,7 +145,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -136,7 +145,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
final short level,
final int exp,
final Vector3fImmutable bindLoc,
final Vector3fImmutable currentLoc,
final Vector3fImmutable faceDir,
final Guild guild,
final byte runningTrains
@ -154,7 +162,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -154,7 +162,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
this.exp = exp;
this.walkMode = true;
this.bindLoc = bindLoc;
;
this.faceDir = faceDir;
this.guild = guild;
this.runningTrains = runningTrains;
@ -162,8 +169,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -162,8 +169,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
this.initializeCharacter();
// Dangerous to use THIS in a constructor!!!
this.charItemManager = new CharacterItemManager(this);
}
/**

2
src/engine/objects/AbstractIntelligenceAgent.java

@ -46,7 +46,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { @@ -46,7 +46,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
Guild guild, byte runningTrains) {
super(firstName, lastName, statStrCurrent, statDexCurrent, statConCurrent,
statIntCurrent, statSpiCurrent, level, exp, bindLoc,
currentLoc, faceDir, guild,
faceDir, guild,
runningTrains);
}

4
src/engine/objects/Mob.java

@ -1928,6 +1928,10 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1928,6 +1928,10 @@ public class Mob extends AbstractIntelligenceAgent {
@Override
public void runAfterLoad() {
// Initialize inventory
this.charItemManager = new CharacterItemManager(this);
try {
if (this.equipmentSetID != 0)
this.equip = MobBase.loadEquipmentSet(this.equipmentSetID);

6
src/engine/objects/NPC.java

@ -88,7 +88,7 @@ public class NPC extends AbstractCharacter { @@ -88,7 +88,7 @@ public class NPC extends AbstractCharacter {
Vector3fImmutable currentLoc, Vector3fImmutable faceDir, short healthCurrent, short manaCurrent, short stamCurrent, Guild guild,
byte runningTrains, int npcType, boolean isMob, Building building, int contractID, Zone parent) {
super(name, "", statStrCurrent, statDexCurrent, statConCurrent, statIntCurrent, statSpiCurrent, level, exp,
bindLoc, currentLoc, faceDir, guild, runningTrains);
bindLoc, faceDir, guild, runningTrains);
this.loadID = npcType;
this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID);
@ -1049,6 +1049,10 @@ public class NPC extends AbstractCharacter { @@ -1049,6 +1049,10 @@ public class NPC extends AbstractCharacter {
if (wordCount(this.name) < 2 && this.contract != null)
this.name += " the " + this.contract.getName();
// Initialize inventory
this.charItemManager = new CharacterItemManager(this);
// Configure parent zone adding this NPC to the
// zone collection

7
src/engine/objects/PlayerCharacter.java

@ -188,7 +188,7 @@ public class PlayerCharacter extends AbstractCharacter { @@ -188,7 +188,7 @@ public class PlayerCharacter extends AbstractCharacter {
short spiMod, Guild guild, byte runningTrains, Account account, Race race, BaseClass baseClass, byte skinColor, byte hairColor,
byte beardColor, byte hairStyle, byte beardStyle) {
super(firstName, lastName, (short) 1, (short) 1, (short) 1, (short) 1, (short) 1, (short) 1, 0,
Vector3fImmutable.ZERO, Vector3fImmutable.ZERO, Vector3fImmutable.ZERO,
Vector3fImmutable.ZERO, Vector3fImmutable.ZERO,
guild, runningTrains);
this.runes = new ArrayList<>();
@ -4582,10 +4582,9 @@ public class PlayerCharacter extends AbstractCharacter { @@ -4582,10 +4582,9 @@ public class PlayerCharacter extends AbstractCharacter {
@Override
public void runAfterLoad() {
// Create player bounds object
// Init inventory
// if ((MBServer.getApp() instanceof engine.server.world.WorldServer))
// DbManager.GuildQueries.LOAD_GUILD_HISTORY_FOR_PLAYER(this);
this.charItemManager = new CharacterItemManager(this);
Bounds playerBounds = Bounds.borrow();
playerBounds.setBounds(this.getLoc());

Loading…
Cancel
Save