Dropped L2Spawn lastSpawnPoints.

This commit is contained in:
MobiusDev 2018-05-21 13:08:42 +00:00
parent 68a7ef1c65
commit dedec95e21
5 changed files with 18 additions and 55 deletions

View File

@ -119,7 +119,7 @@ public class L2NpcActionShift implements IActionShiftHandler
if (((L2Npc) target).getSpawn().isTerritoryBased()) if (((L2Npc) target).getSpawn().isTerritoryBased())
{ {
html.replace("%spawntype%", "Random"); html.replace("%spawntype%", "Random");
final Location spawnLoc = ((L2Npc) target).getSpawn().getLocation(target); final Location spawnLoc = ((L2Npc) target).getSpawn().getLocation();
html.replace("%spawn%", spawnLoc.getX() + " " + spawnLoc.getY() + " " + spawnLoc.getZ()); html.replace("%spawn%", spawnLoc.getX() + " " + spawnLoc.getY() + " " + spawnLoc.getZ());
} }
else else
@ -127,8 +127,8 @@ public class L2NpcActionShift implements IActionShiftHandler
html.replace("%spawntype%", "Fixed"); html.replace("%spawntype%", "Fixed");
html.replace("%spawn%", ((L2Npc) target).getSpawn().getX() + " " + ((L2Npc) target).getSpawn().getY() + " " + ((L2Npc) target).getSpawn().getZ()); html.replace("%spawn%", ((L2Npc) target).getSpawn().getX() + " " + ((L2Npc) target).getSpawn().getY() + " " + ((L2Npc) target).getSpawn().getZ());
} }
html.replace("%loc2d%", String.valueOf((int) target.calculateDistance(((L2Npc) target).getSpawn().getLocation(target), false, false))); html.replace("%loc2d%", String.valueOf((int) target.calculateDistance(((L2Npc) target).getSpawn().getLocation(), false, false)));
html.replace("%loc3d%", String.valueOf((int) target.calculateDistance(((L2Npc) target).getSpawn().getLocation(target), true, false))); html.replace("%loc3d%", String.valueOf((int) target.calculateDistance(((L2Npc) target).getSpawn().getLocation(), true, false)));
if (((L2Npc) target).getSpawn().getRespawnMinDelay() == 0) if (((L2Npc) target).getSpawn().getRespawnMinDelay() == 0)
{ {
html.replace("%resp%", "None"); html.replace("%resp%", "None");

View File

@ -351,7 +351,7 @@ public class L2AttackableAI extends L2CharacterAI
{ {
intention = AI_INTENTION_ACTIVE; intention = AI_INTENTION_ACTIVE;
} }
else if ((npc.getSpawn() != null) && !npc.isInsideRadius(npc.getSpawn().getLocation(npc), Config.MAX_DRIFT_RANGE + Config.MAX_DRIFT_RANGE, true, false)) else if ((npc.getSpawn() != null) && !npc.isInsideRadius(npc.getSpawn().getLocation(), Config.MAX_DRIFT_RANGE + Config.MAX_DRIFT_RANGE, true, false))
{ {
intention = AI_INTENTION_ACTIVE; intention = AI_INTENTION_ACTIVE;
} }
@ -721,9 +721,9 @@ public class L2AttackableAI extends L2CharacterAI
} }
} }
x1 = npc.getSpawn().getX(npc); x1 = npc.getSpawn().getX();
y1 = npc.getSpawn().getY(npc); y1 = npc.getSpawn().getY();
z1 = npc.getSpawn().getZ(npc); z1 = npc.getSpawn().getZ();
if (!npc.isInsideRadius(x1, y1, 0, range, false, false)) if (!npc.isInsideRadius(x1, y1, 0, range, false, false))
{ {

View File

@ -19,8 +19,6 @@ package com.l2jmobius.gameserver.model;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.util.Deque; import java.util.Deque;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level; import java.util.logging.Level;
@ -80,7 +78,6 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
private boolean _doRespawn = true; private boolean _doRespawn = true;
private static List<SpawnListener> _spawnListeners = new CopyOnWriteArrayList<>(); private static List<SpawnListener> _spawnListeners = new CopyOnWriteArrayList<>();
private final Deque<L2Npc> _spawnedNpcs = new ConcurrentLinkedDeque<>(); private final Deque<L2Npc> _spawnedNpcs = new ConcurrentLinkedDeque<>();
private Map<Integer, Location> _lastSpawnPoints;
private boolean _isNoRndWalk = false; // Is no random walk private boolean _isNoRndWalk = false; // Is no random walk
private int _spawnTemplateId = 0; private int _spawnTemplateId = 0;
@ -193,26 +190,15 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
return _location; return _location;
} }
public Location getLocation(L2Object obj) /**
{ * @return the X position of the spawn point.
return ((_lastSpawnPoints == null) || (obj == null) || !_lastSpawnPoints.containsKey(obj.getObjectId())) ? _location : _lastSpawnPoints.get(obj.getObjectId()); */
}
@Override @Override
public int getX() public int getX()
{ {
return _location.getX(); return _location.getX();
} }
/**
* @param obj object to check
* @return the X position of the last spawn point of given NPC.
*/
public int getX(L2Object obj)
{
return getLocation(obj).getX();
}
/** /**
* Set the X position of the spawn point. * Set the X position of the spawn point.
* @param x the x coordinate * @param x the x coordinate
@ -223,21 +209,15 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
_location.setX(x); _location.setX(x);
} }
/**
* @return the Y position of the spawn point.
*/
@Override @Override
public int getY() public int getY()
{ {
return _location.getY(); return _location.getY();
} }
/**
* @param obj object to check
* @return the Y position of the last spawn point of given NPC.
*/
public int getY(L2Object obj)
{
return getLocation(obj).getY();
}
/** /**
* Set the Y position of the spawn point. * Set the Y position of the spawn point.
* @param y the y coordinate * @param y the y coordinate
@ -248,21 +228,15 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
_location.setY(y); _location.setY(y);
} }
/**
* @return the Z position of the spawn point.
*/
@Override @Override
public int getZ() public int getZ()
{ {
return _location.getZ(); return _location.getZ();
} }
/**
* @param obj object to check
* @return the Z position of the last spawn point of given NPC.
*/
public int getZ(L2Object obj)
{
return getLocation(obj).getZ();
}
/** /**
* Set the Z position of the spawn point. * Set the Z position of the spawn point.
* @param z the z coordinate * @param z the z coordinate
@ -410,12 +384,6 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
// Remove this NPC from list of spawned // Remove this NPC from list of spawned
_spawnedNpcs.remove(oldNpc); _spawnedNpcs.remove(oldNpc);
// Remove spawn point for old NPC
if (_lastSpawnPoints != null)
{
_lastSpawnPoints.remove(oldNpc.getObjectId());
}
// Check if respawn is possible to prevent multiple respawning caused by lag // Check if respawn is possible to prevent multiple respawning caused by lag
if (_doRespawn && ((_scheduledCount + _currentCount) < _maximumCount)) if (_doRespawn && ((_scheduledCount + _currentCount) < _maximumCount))
{ {
@ -638,10 +606,6 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
notifyNpcSpawned(npc); notifyNpcSpawned(npc);
_spawnedNpcs.add(npc); _spawnedNpcs.add(npc);
if (_lastSpawnPoints != null)
{
_lastSpawnPoints.put(npc.getObjectId(), new Location(newlocx, newlocy, newlocz));
}
// Increase the current number of L2NpcInstance managed by this L2Spawn // Increase the current number of L2NpcInstance managed by this L2Spawn
_currentCount++; _currentCount++;
@ -719,7 +683,6 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
public void setSpawnTerritory(NpcSpawnTerritory territory) public void setSpawnTerritory(NpcSpawnTerritory territory)
{ {
_spawnTerritory = territory; _spawnTerritory = territory;
_lastSpawnPoints = new ConcurrentHashMap<>();
} }
public NpcSpawnTerritory getSpawnTerritory() public NpcSpawnTerritory getSpawnTerritory()

View File

@ -1665,7 +1665,7 @@ public class L2Attackable extends L2Npc
if (hasAI() && (getSpawn() != null)) if (hasAI() && (getSpawn() != null))
{ {
getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, getSpawn().getLocation(this)); getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, getSpawn().getLocation());
} }
} }

View File

@ -1742,7 +1742,7 @@ public class L2Npc extends L2Character
*/ */
public boolean staysInSpawnLoc() public boolean staysInSpawnLoc()
{ {
return ((getSpawn() != null) && (getSpawn().getX(this) == getX()) && (getSpawn().getY(this) == getY())); return ((getSpawn() != null) && (getSpawn().getX() == getX()) && (getSpawn().getY() == getY()));
} }
/** /**