Browse Source

Worthless collection only used in 2 places.

mobile-class-refactor
MagicBot 1 year ago
parent
commit
2f8de2a919
  1. 2
      src/engine/net/client/handlers/OrderNPCMsgHandler.java
  2. 2
      src/engine/net/client/msg/ManageNPCMsg.java
  3. 33
      src/engine/objects/Mob.java

2
src/engine/net/client/handlers/OrderNPCMsgHandler.java

@ -541,7 +541,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { @@ -541,7 +541,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
} else if (orderNPCMsg.getObjectType() == GameObjectType.Mob.ordinal()) {
mob = Mob.getFromCacheDBID(orderNPCMsg.getNpcUUID());
mob = Mob.getMob(orderNPCMsg.getNpcUUID());
if (mob == null)
return true;

2
src/engine/net/client/msg/ManageNPCMsg.java

@ -557,7 +557,7 @@ public class ManageNPCMsg extends ClientNetMsg { @@ -557,7 +557,7 @@ public class ManageNPCMsg extends ClientNetMsg {
} else if (this.targetType == GameObjectType.Mob.ordinal()) {
mobA = Mob.getFromCacheDBID(this.targetID);
mobA = Mob.getMob(this.targetID);
if (mobA == null) {
Logger.error("Missing Mob of ID " + this.targetID);

33
src/engine/objects/Mob.java

@ -45,8 +45,6 @@ import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup; @@ -45,8 +45,6 @@ import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup;
public class Mob extends AbstractIntelligenceAgent {
private static final ReentrantReadWriteLock createLock = new ReentrantReadWriteLock();
private static final ConcurrentHashMap<Integer, Mob> mobMapByDBID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
// Variables NOT to be stored in db
private static int staticID = 0;
//mob specific
public final ConcurrentHashMap<Integer, Boolean> playerAgroMap = new ConcurrentHashMap<>();
@ -555,12 +553,6 @@ public class Mob extends AbstractIntelligenceAgent { @@ -555,12 +553,6 @@ public class Mob extends AbstractIntelligenceAgent {
return (Mob) DbManager.getFromCache(GameObjectType.Mob, id);
}
public static Mob getFromCacheDBID(int id) {
if (Mob.mobMapByDBID.containsKey(id))
return Mob.mobMapByDBID.get(id);
return null;
}
private static float getModifiedAmount(CharacterSkill skill) {
if (skill == null)
@ -1690,11 +1682,6 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1690,11 +1682,6 @@ public class Mob extends AbstractIntelligenceAgent {
if (ConfigManager.serverType.equals(ServerType.LOGINSERVER))
return;
// Add new object to collection
if (!this.isPet() && !isSiege)
Mob.mobMapByDBID.put(this.dbID, this);
try {
this.building = BuildingManager.getBuilding(this.buildingUUID);
} catch (Exception e) {
@ -1722,6 +1709,15 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1722,6 +1709,15 @@ public class Mob extends AbstractIntelligenceAgent {
this.spawnTime = 450;
}
// Load AI for guard dogs
if (this.contract != null && this.contract.getContractID() == 910) {
this.isPlayerGuard = true;
this.behaviourType = MobBehaviourType.GuardCaptain;
this.spawnTime = 900;
this.guardedCity = ZoneManager.getCityAtLocation(this.bindLoc);
}
if (this.building != null)
this.guild = this.building.getGuild();
else
@ -1742,11 +1738,6 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1742,11 +1738,6 @@ public class Mob extends AbstractIntelligenceAgent {
this.lastName = this.getContract().getName();
}
//store mobs by Database ID
if (!this.isPet() && !isSiege)
Mob.mobMapByDBID.put(this.dbID, this);
this.gridObjectType = GridObjectType.DYNAMIC;
this.healthMax = this.mobBase.getHealthMax();
this.manaMax = 0;
@ -1853,12 +1844,6 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1853,12 +1844,6 @@ public class Mob extends AbstractIntelligenceAgent {
mobBounds.setBounds(this.getLoc());
this.setBounds(mobBounds);
if (this.contract != null && this.contract.getContractID() == 910) {
this.isPlayerGuard = true;
this.behaviourType = MobBehaviourType.GuardCaptain;
this.spawnTime = 900;
this.guardedCity = ZoneManager.getCityAtLocation(this.bindLoc);
}
//assign 5 random patrol points for regular mobs
if (!(this.agentType.equals(AIAgentType.GUARD)) && !this.isPlayerGuard() && !this.isPet() && !this.isNecroPet() && !(this.agentType.equals(AIAgentType.PET)) && !(this.agentType.equals(AIAgentType.CHARMED))) {

Loading…
Cancel
Save