forked from MagicBane/Server
Minions now use copyonwrite collection. Slot agnostic.
This commit is contained in:
@@ -39,6 +39,7 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
@@ -121,8 +122,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
private byte aoecntr = 0;
|
||||
|
||||
public int hidden = 0; // current rank of hide/sneak/invis
|
||||
|
||||
public final ConcurrentHashMap<Mob, Integer> siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
public CopyOnWriteArrayList<Integer> minions = new CopyOnWriteArrayList();
|
||||
|
||||
public AbstractCharacter() {
|
||||
super();
|
||||
|
||||
@@ -26,7 +26,6 @@ import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.msg.PetMsg;
|
||||
import engine.net.client.msg.PlaceAssetMsg;
|
||||
import engine.powers.RuneSkillAdjustEntry;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.joda.time.DateTime;
|
||||
import org.pmw.tinylog.Logger;
|
||||
@@ -489,8 +488,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
minionMobile.setLoc(minionMobile.bindLoc);
|
||||
minionMobile.despawn();
|
||||
|
||||
int slot = guardCaptain.siegeMinionMap.size() + 1;
|
||||
guardCaptain.siegeMinionMap.put(minionMobile, slot);
|
||||
guardCaptain.minions.add(minionMobile.getObjectUUID());
|
||||
|
||||
return minionMobile;
|
||||
}
|
||||
@@ -520,8 +518,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
siegeMinion.setLoc(siegeMinion.bindLoc);
|
||||
siegeMinion.despawn();
|
||||
|
||||
int slot = artyCaptain.siegeMinionMap.size() + 1;
|
||||
artyCaptain.siegeMinionMap.put(siegeMinion, slot);
|
||||
artyCaptain.minions.add(siegeMinion.getObjectUUID());
|
||||
|
||||
return siegeMinion;
|
||||
}
|
||||
@@ -1783,10 +1780,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
this.weaponPower = weaponPower;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<Mob, Integer> getSiegeMinionMap() {
|
||||
return siegeMinionMap;
|
||||
}
|
||||
|
||||
public DateTime getUpgradeDateTime() {
|
||||
|
||||
lock.readLock().lock();
|
||||
|
||||
@@ -640,28 +640,31 @@ public class NPC extends AbstractCharacter {
|
||||
|
||||
public void removeMinions() {
|
||||
|
||||
for (Mob toRemove : this.siegeMinionMap.keySet()) {
|
||||
|
||||
for (Integer minionUUID : this.minions) {
|
||||
|
||||
Mob minionMob = Mob.getMob(minionUUID);
|
||||
|
||||
try {
|
||||
toRemove.clearEffects();
|
||||
minionMob.clearEffects();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.getMessage());
|
||||
}
|
||||
|
||||
if (toRemove.getParentZone() != null)
|
||||
toRemove.getParentZone().zoneMobSet.remove(toRemove);
|
||||
if (minionMob.getParentZone() != null)
|
||||
minionMob.getParentZone().zoneMobSet.remove(minionMob);
|
||||
|
||||
WorldGrid.RemoveWorldObject(toRemove);
|
||||
DbManager.removeFromCache(toRemove);
|
||||
WorldGrid.RemoveWorldObject(minionMob);
|
||||
DbManager.removeFromCache(minionMob);
|
||||
|
||||
|
||||
PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain;
|
||||
PlayerCharacter petOwner = (PlayerCharacter) minionMob.guardCaptain;
|
||||
|
||||
if (petOwner != null) {
|
||||
|
||||
petOwner.setPet(null);
|
||||
|
||||
toRemove.guardCaptain = null;
|
||||
minionMob.guardCaptain = null;
|
||||
|
||||
PetMsg petMsg = new PetMsg(5, null);
|
||||
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
|
||||
@@ -669,6 +672,7 @@ public class NPC extends AbstractCharacter {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user