Browse Source

Cleanup in pet minion

combat-2
MagicBot 1 year ago
parent
commit
d59f9857ce
  1. 2
      src/engine/gameManager/NPCManager.java
  2. 13
      src/engine/objects/Mob.java

2
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)) { if (abstractCharacter.getObjectType().equals(Enum.GameObjectType.Mob) && ((Mob) abstractCharacter).behaviourType.equals(Enum.MobBehaviourType.SiegeEngine)) {
Mob siegeMobile = (Mob) abstractCharacter; Mob siegeMobile = (Mob) abstractCharacter;
buildingSlot = siegeMobile.guardCaptain.siegeMinionMap.size() + 1; buildingSlot = siegeMobile.guardCaptain.siegeMinionMap.size() + 2;
} }
if (buildingSlot == -1) if (buildingSlot == -1)

13
src/engine/objects/Mob.java

@ -33,7 +33,6 @@ import org.pmw.tinylog.Logger;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -44,7 +43,6 @@ import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup;
public class Mob extends AbstractIntelligenceAgent { public class Mob extends AbstractIntelligenceAgent {
private static final ReentrantReadWriteLock createLock = new ReentrantReadWriteLock();
private static int staticID = 0; private static int staticID = 0;
//mob specific //mob specific
public final ConcurrentHashMap<Integer, Boolean> playerAgroMap = new ConcurrentHashMap<>(); public final ConcurrentHashMap<Integer, Boolean> playerAgroMap = new ConcurrentHashMap<>();
@ -535,14 +533,14 @@ public class Mob extends AbstractIntelligenceAgent {
return siegeMinion; return siegeMinion;
} }
public static Mob createPetMinion(int loadID, Zone parent, PlayerCharacter petOwner, short level) { public static synchronized Mob createPetMinion(int loadID, Zone parent, PlayerCharacter petOwner, short level) {
Mob petMinion = new Mob();
if (petOwner == null) if (petOwner == null)
return null; return null;
createLock.writeLock().lock(); Mob petMinion = new Mob();
petMinion.currentID = (--Mob.staticID);
petMinion.level = (short) (level + 20); petMinion.level = (short) (level + 20);
petMinion.loadID = loadID; petMinion.loadID = loadID;
@ -556,11 +554,12 @@ public class Mob extends AbstractIntelligenceAgent {
petMinion.behaviourType = MobBehaviourType.Pet1; petMinion.behaviourType = MobBehaviourType.Pet1;
petMinion.firstName = ""; petMinion.firstName = "";
petMinion.lastName = ""; petMinion.lastName = "";
petMinion.despawned = false; petMinion.despawned = false;
petMinion.runAfterLoad(); petMinion.runAfterLoad();
DbManager.addToCache(petMinion); DbManager.addToCache(petMinion);
createLock.writeLock().unlock();
petMinion.setLoc(petMinion.bindLoc); petMinion.setLoc(petMinion.bindLoc);
return petMinion; return petMinion;
} }
public static Mob getMob(int id) { public static Mob getMob(int id) {

Loading…
Cancel
Save