diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 07553a4d..98549265 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -340,7 +340,7 @@ public enum NPCManager { if (abstractCharacter.getObjectType().equals(Enum.GameObjectType.Mob) && ((Mob) abstractCharacter).behaviourType.equals(Enum.MobBehaviourType.SiegeEngine)) { Mob siegeMobile = (Mob) abstractCharacter; - buildingSlot = siegeMobile.guardCaptain.siegeMinionMap.size() + 1; + buildingSlot = siegeMobile.guardCaptain.siegeMinionMap.size() + 2; } if (buildingSlot == -1) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index eb08b78a..8d6c0736 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -33,7 +33,6 @@ import org.pmw.tinylog.Logger; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; @@ -44,7 +43,6 @@ import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup; public class Mob extends AbstractIntelligenceAgent { - private static final ReentrantReadWriteLock createLock = new ReentrantReadWriteLock(); private static int staticID = 0; //mob specific public final ConcurrentHashMap playerAgroMap = new ConcurrentHashMap<>(); @@ -535,14 +533,14 @@ public class Mob extends AbstractIntelligenceAgent { return siegeMinion; } - public static Mob createPetMinion(int loadID, Zone parent, PlayerCharacter petOwner, short level) { - - Mob petMinion = new Mob(); + public static synchronized Mob createPetMinion(int loadID, Zone parent, PlayerCharacter petOwner, short level) { if (petOwner == null) return null; - createLock.writeLock().lock(); + Mob petMinion = new Mob(); + + petMinion.currentID = (--Mob.staticID); petMinion.level = (short) (level + 20); petMinion.loadID = loadID; @@ -556,11 +554,12 @@ public class Mob extends AbstractIntelligenceAgent { petMinion.behaviourType = MobBehaviourType.Pet1; petMinion.firstName = ""; petMinion.lastName = ""; + petMinion.despawned = false; petMinion.runAfterLoad(); DbManager.addToCache(petMinion); - createLock.writeLock().unlock(); petMinion.setLoc(petMinion.bindLoc); + return petMinion; } public static Mob getMob(int id) {