Store door objects in regions.
This commit is contained in:
parent
a8a6584d64
commit
031006131b
@ -17,12 +17,10 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -33,9 +31,10 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
@ -52,7 +51,6 @@ public class DoorData implements IXmlReader
|
||||
private final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -64,7 +62,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/DoorData.xml");
|
||||
}
|
||||
|
||||
@ -72,7 +69,7 @@ public class DoorData implements IXmlReader
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "door", doorNode -> spawnDoor(parseDoor(doorNode))));
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " Door Templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public StatSet parseDoor(Node doorNode)
|
||||
@ -151,7 +148,7 @@ public class DoorData implements IXmlReader
|
||||
// Register the door
|
||||
_templates.put(door.getId(), set);
|
||||
_doors.put(door.getId(), door);
|
||||
_regions.computeIfAbsent(MapRegionManager.getInstance().getMapRegionLocId(door), key -> new ArrayList<>()).add(door);
|
||||
|
||||
return door;
|
||||
}
|
||||
|
||||
@ -213,27 +210,31 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instance, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instance
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, Instance instance, boolean doubleFaceCheck)
|
||||
{
|
||||
final Collection<DoorInstance> allDoors = (instance != null) ? instance.getDoors() : _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
if (allDoors == null)
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instance == null)
|
||||
{
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
@ -17,12 +17,10 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -33,9 +31,10 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
@ -52,7 +51,6 @@ public class DoorData implements IXmlReader
|
||||
private final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -64,7 +62,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/DoorData.xml");
|
||||
}
|
||||
|
||||
@ -72,7 +69,7 @@ public class DoorData implements IXmlReader
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "door", doorNode -> spawnDoor(parseDoor(doorNode))));
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " Door Templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public StatSet parseDoor(Node doorNode)
|
||||
@ -151,7 +148,7 @@ public class DoorData implements IXmlReader
|
||||
// Register the door
|
||||
_templates.put(door.getId(), set);
|
||||
_doors.put(door.getId(), door);
|
||||
_regions.computeIfAbsent(MapRegionManager.getInstance().getMapRegionLocId(door), key -> new ArrayList<>()).add(door);
|
||||
|
||||
return door;
|
||||
}
|
||||
|
||||
@ -213,27 +210,31 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instance, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instance
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, Instance instance, boolean doubleFaceCheck)
|
||||
{
|
||||
final Collection<DoorInstance> allDoors = (instance != null) ? instance.getDoors() : _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
if (allDoors == null)
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instance == null)
|
||||
{
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
@ -17,12 +17,10 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -33,9 +31,10 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
@ -52,7 +51,6 @@ public class DoorData implements IXmlReader
|
||||
private final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -64,7 +62,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/DoorData.xml");
|
||||
}
|
||||
|
||||
@ -72,7 +69,7 @@ public class DoorData implements IXmlReader
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "door", doorNode -> spawnDoor(parseDoor(doorNode))));
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " Door Templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public StatSet parseDoor(Node doorNode)
|
||||
@ -151,7 +148,7 @@ public class DoorData implements IXmlReader
|
||||
// Register the door
|
||||
_templates.put(door.getId(), set);
|
||||
_doors.put(door.getId(), door);
|
||||
_regions.computeIfAbsent(MapRegionManager.getInstance().getMapRegionLocId(door), key -> new ArrayList<>()).add(door);
|
||||
|
||||
return door;
|
||||
}
|
||||
|
||||
@ -213,27 +210,31 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instance, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instance
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, Instance instance, boolean doubleFaceCheck)
|
||||
{
|
||||
final Collection<DoorInstance> allDoors = (instance != null) ? instance.getDoors() : _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
if (allDoors == null)
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instance == null)
|
||||
{
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
@ -17,12 +17,10 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -33,9 +31,10 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
@ -52,7 +51,6 @@ public class DoorData implements IXmlReader
|
||||
private final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -64,7 +62,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/DoorData.xml");
|
||||
}
|
||||
|
||||
@ -72,7 +69,7 @@ public class DoorData implements IXmlReader
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "door", doorNode -> spawnDoor(parseDoor(doorNode))));
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " Door Templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public StatSet parseDoor(Node doorNode)
|
||||
@ -151,7 +148,7 @@ public class DoorData implements IXmlReader
|
||||
// Register the door
|
||||
_templates.put(door.getId(), set);
|
||||
_doors.put(door.getId(), door);
|
||||
_regions.computeIfAbsent(MapRegionManager.getInstance().getMapRegionLocId(door), key -> new ArrayList<>()).add(door);
|
||||
|
||||
return door;
|
||||
}
|
||||
|
||||
@ -213,27 +210,31 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instance, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instance
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, Instance instance, boolean doubleFaceCheck)
|
||||
{
|
||||
final Collection<DoorInstance> allDoors = (instance != null) ? instance.getDoors() : _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
if (allDoors == null)
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instance == null)
|
||||
{
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
@ -17,12 +17,10 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -33,9 +31,10 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
@ -52,7 +51,6 @@ public class DoorData implements IXmlReader
|
||||
private final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -64,7 +62,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/DoorData.xml");
|
||||
}
|
||||
|
||||
@ -72,7 +69,7 @@ public class DoorData implements IXmlReader
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "door", doorNode -> spawnDoor(parseDoor(doorNode))));
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " Door Templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public StatSet parseDoor(Node doorNode)
|
||||
@ -151,7 +148,7 @@ public class DoorData implements IXmlReader
|
||||
// Register the door
|
||||
_templates.put(door.getId(), set);
|
||||
_doors.put(door.getId(), door);
|
||||
_regions.computeIfAbsent(MapRegionManager.getInstance().getMapRegionLocId(door), key -> new ArrayList<>()).add(door);
|
||||
|
||||
return door;
|
||||
}
|
||||
|
||||
@ -213,27 +210,31 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instance, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instance
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, Instance instance, boolean doubleFaceCheck)
|
||||
{
|
||||
final Collection<DoorInstance> allDoors = (instance != null) ? instance.getDoors() : _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
if (allDoors == null)
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instance == null)
|
||||
{
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
@ -17,12 +17,10 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -33,9 +31,10 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
@ -52,7 +51,6 @@ public class DoorData implements IXmlReader
|
||||
private final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -64,7 +62,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/DoorData.xml");
|
||||
}
|
||||
|
||||
@ -72,7 +69,7 @@ public class DoorData implements IXmlReader
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "door", doorNode -> spawnDoor(parseDoor(doorNode))));
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " Door Templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public StatSet parseDoor(Node doorNode)
|
||||
@ -151,7 +148,7 @@ public class DoorData implements IXmlReader
|
||||
// Register the door
|
||||
_templates.put(door.getId(), set);
|
||||
_doors.put(door.getId(), door);
|
||||
_regions.computeIfAbsent(MapRegionManager.getInstance().getMapRegionLocId(door), key -> new ArrayList<>()).add(door);
|
||||
|
||||
return door;
|
||||
}
|
||||
|
||||
@ -213,27 +210,31 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instance, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instance
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, Instance instance, boolean doubleFaceCheck)
|
||||
{
|
||||
final Collection<DoorInstance> allDoors = (instance != null) ? instance.getDoors() : _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
if (allDoors == null)
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instance == null)
|
||||
{
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
@ -17,12 +17,10 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -33,9 +31,10 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
@ -52,7 +51,6 @@ public class DoorData implements IXmlReader
|
||||
private final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -64,7 +62,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/DoorData.xml");
|
||||
}
|
||||
|
||||
@ -72,7 +69,7 @@ public class DoorData implements IXmlReader
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "door", doorNode -> spawnDoor(parseDoor(doorNode))));
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " Door Templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public StatSet parseDoor(Node doorNode)
|
||||
@ -151,7 +148,7 @@ public class DoorData implements IXmlReader
|
||||
// Register the door
|
||||
_templates.put(door.getId(), set);
|
||||
_doors.put(door.getId(), door);
|
||||
_regions.computeIfAbsent(MapRegionManager.getInstance().getMapRegionLocId(door), key -> new ArrayList<>()).add(door);
|
||||
|
||||
return door;
|
||||
}
|
||||
|
||||
@ -213,27 +210,31 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instance, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instance
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, Instance instance, boolean doubleFaceCheck)
|
||||
{
|
||||
final Collection<DoorInstance> allDoors = (instance != null) ? instance.getDoors() : _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
if (allDoors == null)
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instance == null)
|
||||
{
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
@ -17,12 +17,10 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -33,9 +31,10 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
@ -52,7 +51,6 @@ public class DoorData implements IXmlReader
|
||||
private final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -64,7 +62,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/DoorData.xml");
|
||||
}
|
||||
|
||||
@ -72,7 +69,7 @@ public class DoorData implements IXmlReader
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "door", doorNode -> spawnDoor(parseDoor(doorNode))));
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " Door Templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public StatSet parseDoor(Node doorNode)
|
||||
@ -151,7 +148,7 @@ public class DoorData implements IXmlReader
|
||||
// Register the door
|
||||
_templates.put(door.getId(), set);
|
||||
_doors.put(door.getId(), door);
|
||||
_regions.computeIfAbsent(MapRegionManager.getInstance().getMapRegionLocId(door), key -> new ArrayList<>()).add(door);
|
||||
|
||||
return door;
|
||||
}
|
||||
|
||||
@ -213,27 +210,31 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instance, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instance
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, Instance instance, boolean doubleFaceCheck)
|
||||
{
|
||||
final Collection<DoorInstance> allDoors = (instance != null) ? instance.getDoors() : _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
if (allDoors == null)
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instance == null)
|
||||
{
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
@ -17,12 +17,10 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -33,9 +31,10 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
@ -52,7 +51,6 @@ public class DoorData implements IXmlReader
|
||||
private final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -64,7 +62,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/DoorData.xml");
|
||||
}
|
||||
|
||||
@ -72,7 +69,7 @@ public class DoorData implements IXmlReader
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "door", doorNode -> spawnDoor(parseDoor(doorNode))));
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " Door Templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public StatSet parseDoor(Node doorNode)
|
||||
@ -151,7 +148,7 @@ public class DoorData implements IXmlReader
|
||||
// Register the door
|
||||
_templates.put(door.getId(), set);
|
||||
_doors.put(door.getId(), door);
|
||||
_regions.computeIfAbsent(MapRegionManager.getInstance().getMapRegionLocId(door), key -> new ArrayList<>()).add(door);
|
||||
|
||||
return door;
|
||||
}
|
||||
|
||||
@ -213,27 +210,31 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instance, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instance
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, Instance instance, boolean doubleFaceCheck)
|
||||
{
|
||||
final Collection<DoorInstance> allDoors = (instance != null) ? instance.getDoors() : _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
if (allDoors == null)
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instance == null)
|
||||
{
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
@ -17,12 +17,10 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -33,9 +31,10 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
@ -52,7 +51,6 @@ public class DoorData implements IXmlReader
|
||||
private final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -64,7 +62,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/DoorData.xml");
|
||||
}
|
||||
|
||||
@ -72,7 +69,7 @@ public class DoorData implements IXmlReader
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "door", doorNode -> spawnDoor(parseDoor(doorNode))));
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " Door Templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public StatSet parseDoor(Node doorNode)
|
||||
@ -151,7 +148,7 @@ public class DoorData implements IXmlReader
|
||||
// Register the door
|
||||
_templates.put(door.getId(), set);
|
||||
_doors.put(door.getId(), door);
|
||||
_regions.computeIfAbsent(MapRegionManager.getInstance().getMapRegionLocId(door), key -> new ArrayList<>()).add(door);
|
||||
|
||||
return door;
|
||||
}
|
||||
|
||||
@ -213,27 +210,31 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instance, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instance
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, Instance instance, boolean doubleFaceCheck)
|
||||
{
|
||||
final Collection<DoorInstance> allDoors = (instance != null) ? instance.getDoors() : _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
if (allDoors == null)
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instance == null)
|
||||
{
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
@ -31,6 +31,8 @@ import org.l2jmobius.gameserver.instancemanager.ClanHallManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.CreatureTemplate;
|
||||
import org.l2jmobius.gameserver.model.residences.ClanHall;
|
||||
@ -239,22 +241,15 @@ public class DoorData implements IXmlReader
|
||||
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz)
|
||||
{
|
||||
int region;
|
||||
try
|
||||
{
|
||||
region = MapRegionData.getInstance().getMapRegion(x, y);
|
||||
}
|
||||
catch (Exception e)
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
final Collection<DoorInstance> doors = region != null ? region.getDoors() : null;
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : DOORS.values())
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
if (doorInst.getMapRegion() != region)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (doorInst.getXMax() == 0)
|
||||
{
|
||||
continue;
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
@ -29,6 +30,7 @@ import org.l2jmobius.gameserver.ai.SiegeGuardAI;
|
||||
import org.l2jmobius.gameserver.data.sql.SpawnTable;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
|
||||
import org.l2jmobius.gameserver.model.spawn.Spawn;
|
||||
import org.l2jmobius.gameserver.model.zone.ZoneManager;
|
||||
@ -42,6 +44,7 @@ public class WorldRegion
|
||||
private static final Logger LOGGER = Logger.getLogger(WorldRegion.class.getName());
|
||||
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@ -315,6 +318,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -342,6 +353,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -377,6 +396,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return "(" + _regionX + ", " + _regionY + ")";
|
||||
|
@ -31,6 +31,8 @@ import org.l2jmobius.gameserver.instancemanager.ClanHallManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.CreatureTemplate;
|
||||
import org.l2jmobius.gameserver.model.residences.ClanHall;
|
||||
@ -239,22 +241,15 @@ public class DoorData implements IXmlReader
|
||||
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz)
|
||||
{
|
||||
int region;
|
||||
try
|
||||
{
|
||||
region = MapRegionData.getInstance().getMapRegion(x, y);
|
||||
}
|
||||
catch (Exception e)
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
final Collection<DoorInstance> doors = region != null ? region.getDoors() : null;
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : DOORS.values())
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
if (doorInst.getMapRegion() != region)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (doorInst.getXMax() == 0)
|
||||
{
|
||||
continue;
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
@ -29,6 +30,7 @@ import org.l2jmobius.gameserver.ai.SiegeGuardAI;
|
||||
import org.l2jmobius.gameserver.data.sql.SpawnTable;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
|
||||
import org.l2jmobius.gameserver.model.spawn.Spawn;
|
||||
import org.l2jmobius.gameserver.model.zone.ZoneManager;
|
||||
@ -42,6 +44,7 @@ public class WorldRegion
|
||||
private static final Logger LOGGER = Logger.getLogger(WorldRegion.class.getName());
|
||||
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@ -315,6 +318,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -342,6 +353,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -377,6 +396,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return "(" + _regionX + ", " + _regionY + ")";
|
||||
|
@ -17,11 +17,9 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@ -31,11 +29,13 @@ import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
|
||||
/**
|
||||
* Loads doors.
|
||||
@ -46,7 +46,6 @@ public class DoorData implements IXmlReader
|
||||
private static final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -58,7 +57,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/Doors.xml");
|
||||
}
|
||||
|
||||
@ -88,7 +86,7 @@ public class DoorData implements IXmlReader
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " door templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public void insertCollisionData(StatSet set)
|
||||
@ -125,7 +123,7 @@ public class DoorData implements IXmlReader
|
||||
final DoorInstance door = new DoorInstance(template);
|
||||
door.setCurrentHp(door.getMaxHp());
|
||||
door.spawnMe(template.getX(), template.getY(), template.getZ());
|
||||
putDoor(door, MapRegionManager.getInstance().getMapRegionLocId(door));
|
||||
_doors.put(door.getId(), door);
|
||||
}
|
||||
|
||||
public StatSet getDoorTemplate(int doorId)
|
||||
@ -138,17 +136,6 @@ public class DoorData implements IXmlReader
|
||||
return _doors.get(doorId);
|
||||
}
|
||||
|
||||
public void putDoor(DoorInstance door, int region)
|
||||
{
|
||||
_doors.put(door.getId(), door);
|
||||
|
||||
if (!_regions.containsKey(region))
|
||||
{
|
||||
_regions.put(region, new ArrayList<>());
|
||||
}
|
||||
_regions.get(region).add(door);
|
||||
}
|
||||
|
||||
public static void addDoorGroup(String groupName, int doorId)
|
||||
{
|
||||
Set<Integer> set = _groups.get(groupName);
|
||||
@ -180,36 +167,39 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instanceId, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instanceId
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, int instanceId, boolean doubleFaceCheck)
|
||||
{
|
||||
Collection<DoorInstance> allDoors;
|
||||
if ((instanceId > 0) && (InstanceManager.getInstance().getInstance(instanceId) != null))
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instanceId < 1)
|
||||
{
|
||||
allDoors = InstanceManager.getInstance().getInstance(instanceId).getDoors();
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
allDoors = _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
final Instance instance = InstanceManager.getInstance().getInstance(instanceId);
|
||||
if (instance != null)
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (allDoors == null)
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
@ -17,11 +17,9 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@ -31,11 +29,13 @@ import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
|
||||
/**
|
||||
* Loads doors.
|
||||
@ -46,7 +46,6 @@ public class DoorData implements IXmlReader
|
||||
private static final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -58,7 +57,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/Doors.xml");
|
||||
}
|
||||
|
||||
@ -88,7 +86,7 @@ public class DoorData implements IXmlReader
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " door templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public void insertCollisionData(StatSet set)
|
||||
@ -125,7 +123,7 @@ public class DoorData implements IXmlReader
|
||||
final DoorInstance door = new DoorInstance(template);
|
||||
door.setCurrentHp(door.getMaxHp());
|
||||
door.spawnMe(template.getX(), template.getY(), template.getZ());
|
||||
putDoor(door, MapRegionManager.getInstance().getMapRegionLocId(door));
|
||||
_doors.put(door.getId(), door);
|
||||
}
|
||||
|
||||
public StatSet getDoorTemplate(int doorId)
|
||||
@ -138,17 +136,6 @@ public class DoorData implements IXmlReader
|
||||
return _doors.get(doorId);
|
||||
}
|
||||
|
||||
public void putDoor(DoorInstance door, int region)
|
||||
{
|
||||
_doors.put(door.getId(), door);
|
||||
|
||||
if (!_regions.containsKey(region))
|
||||
{
|
||||
_regions.put(region, new ArrayList<>());
|
||||
}
|
||||
_regions.get(region).add(door);
|
||||
}
|
||||
|
||||
public static void addDoorGroup(String groupName, int doorId)
|
||||
{
|
||||
Set<Integer> set = _groups.get(groupName);
|
||||
@ -180,36 +167,39 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instanceId, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instanceId
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, int instanceId, boolean doubleFaceCheck)
|
||||
{
|
||||
Collection<DoorInstance> allDoors;
|
||||
if ((instanceId > 0) && (InstanceManager.getInstance().getInstance(instanceId) != null))
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instanceId < 1)
|
||||
{
|
||||
allDoors = InstanceManager.getInstance().getInstance(instanceId).getDoors();
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
allDoors = _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
final Instance instance = InstanceManager.getInstance().getInstance(instanceId);
|
||||
if (instance != null)
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (allDoors == null)
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
@ -17,12 +17,10 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -33,9 +31,10 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
@ -52,7 +51,6 @@ public class DoorData implements IXmlReader
|
||||
private final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -64,7 +62,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/DoorData.xml");
|
||||
}
|
||||
|
||||
@ -72,7 +69,7 @@ public class DoorData implements IXmlReader
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "door", doorNode -> spawnDoor(parseDoor(doorNode))));
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " Door Templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public StatSet parseDoor(Node doorNode)
|
||||
@ -151,7 +148,7 @@ public class DoorData implements IXmlReader
|
||||
// Register the door
|
||||
_templates.put(door.getId(), set);
|
||||
_doors.put(door.getId(), door);
|
||||
_regions.computeIfAbsent(MapRegionManager.getInstance().getMapRegionLocId(door), key -> new ArrayList<>()).add(door);
|
||||
|
||||
return door;
|
||||
}
|
||||
|
||||
@ -213,27 +210,31 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instance, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instance
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, Instance instance, boolean doubleFaceCheck)
|
||||
{
|
||||
final Collection<DoorInstance> allDoors = (instance != null) ? instance.getDoors() : _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
if (allDoors == null)
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instance == null)
|
||||
{
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
@ -17,12 +17,10 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -33,9 +31,10 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
@ -52,7 +51,6 @@ public class DoorData implements IXmlReader
|
||||
private final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -64,7 +62,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/DoorData.xml");
|
||||
}
|
||||
|
||||
@ -72,7 +69,7 @@ public class DoorData implements IXmlReader
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "door", doorNode -> spawnDoor(parseDoor(doorNode))));
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " Door Templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public StatSet parseDoor(Node doorNode)
|
||||
@ -151,7 +148,7 @@ public class DoorData implements IXmlReader
|
||||
// Register the door
|
||||
_templates.put(door.getId(), set);
|
||||
_doors.put(door.getId(), door);
|
||||
_regions.computeIfAbsent(MapRegionManager.getInstance().getMapRegionLocId(door), key -> new ArrayList<>()).add(door);
|
||||
|
||||
return door;
|
||||
}
|
||||
|
||||
@ -213,27 +210,31 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instance, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instance
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, Instance instance, boolean doubleFaceCheck)
|
||||
{
|
||||
final Collection<DoorInstance> allDoors = (instance != null) ? instance.getDoors() : _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
if (allDoors == null)
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instance == null)
|
||||
{
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
@ -17,12 +17,10 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -33,9 +31,10 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
@ -52,7 +51,6 @@ public class DoorData implements IXmlReader
|
||||
private final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -64,7 +62,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/DoorData.xml");
|
||||
}
|
||||
|
||||
@ -72,7 +69,7 @@ public class DoorData implements IXmlReader
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "door", doorNode -> spawnDoor(parseDoor(doorNode))));
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " Door Templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public StatSet parseDoor(Node doorNode)
|
||||
@ -151,7 +148,7 @@ public class DoorData implements IXmlReader
|
||||
// Register the door
|
||||
_templates.put(door.getId(), set);
|
||||
_doors.put(door.getId(), door);
|
||||
_regions.computeIfAbsent(MapRegionManager.getInstance().getMapRegionLocId(door), key -> new ArrayList<>()).add(door);
|
||||
|
||||
return door;
|
||||
}
|
||||
|
||||
@ -213,27 +210,31 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instance, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instance
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, Instance instance, boolean doubleFaceCheck)
|
||||
{
|
||||
final Collection<DoorInstance> allDoors = (instance != null) ? instance.getDoors() : _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
if (allDoors == null)
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instance == null)
|
||||
{
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
@ -17,12 +17,10 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -33,9 +31,10 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
@ -52,7 +51,6 @@ public class DoorData implements IXmlReader
|
||||
private final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -64,7 +62,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/DoorData.xml");
|
||||
}
|
||||
|
||||
@ -72,7 +69,7 @@ public class DoorData implements IXmlReader
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "door", doorNode -> spawnDoor(parseDoor(doorNode))));
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " Door Templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public StatSet parseDoor(Node doorNode)
|
||||
@ -151,7 +148,7 @@ public class DoorData implements IXmlReader
|
||||
// Register the door
|
||||
_templates.put(door.getId(), set);
|
||||
_doors.put(door.getId(), door);
|
||||
_regions.computeIfAbsent(MapRegionManager.getInstance().getMapRegionLocId(door), key -> new ArrayList<>()).add(door);
|
||||
|
||||
return door;
|
||||
}
|
||||
|
||||
@ -213,27 +210,31 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instance, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instance
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, Instance instance, boolean doubleFaceCheck)
|
||||
{
|
||||
final Collection<DoorInstance> allDoors = (instance != null) ? instance.getDoors() : _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
if (allDoors == null)
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instance == null)
|
||||
{
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
@ -17,12 +17,10 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -33,9 +31,10 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
@ -52,7 +51,6 @@ public class DoorData implements IXmlReader
|
||||
private final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -64,7 +62,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/DoorData.xml");
|
||||
}
|
||||
|
||||
@ -72,7 +69,7 @@ public class DoorData implements IXmlReader
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "door", doorNode -> spawnDoor(parseDoor(doorNode))));
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " Door Templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public StatSet parseDoor(Node doorNode)
|
||||
@ -151,7 +148,7 @@ public class DoorData implements IXmlReader
|
||||
// Register the door
|
||||
_templates.put(door.getId(), set);
|
||||
_doors.put(door.getId(), door);
|
||||
_regions.computeIfAbsent(MapRegionManager.getInstance().getMapRegionLocId(door), key -> new ArrayList<>()).add(door);
|
||||
|
||||
return door;
|
||||
}
|
||||
|
||||
@ -213,27 +210,31 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instance, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instance
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, Instance instance, boolean doubleFaceCheck)
|
||||
{
|
||||
final Collection<DoorInstance> allDoors = (instance != null) ? instance.getDoors() : _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
if (allDoors == null)
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instance == null)
|
||||
{
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
@ -17,12 +17,10 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -33,9 +31,10 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
@ -52,7 +51,6 @@ public class DoorData implements IXmlReader
|
||||
private final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -64,7 +62,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/DoorData.xml");
|
||||
}
|
||||
|
||||
@ -72,7 +69,7 @@ public class DoorData implements IXmlReader
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "door", doorNode -> spawnDoor(parseDoor(doorNode))));
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " Door Templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public StatSet parseDoor(Node doorNode)
|
||||
@ -151,7 +148,7 @@ public class DoorData implements IXmlReader
|
||||
// Register the door
|
||||
_templates.put(door.getId(), set);
|
||||
_doors.put(door.getId(), door);
|
||||
_regions.computeIfAbsent(MapRegionManager.getInstance().getMapRegionLocId(door), key -> new ArrayList<>()).add(door);
|
||||
|
||||
return door;
|
||||
}
|
||||
|
||||
@ -213,27 +210,31 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instance, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instance
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, Instance instance, boolean doubleFaceCheck)
|
||||
{
|
||||
final Collection<DoorInstance> allDoors = (instance != null) ? instance.getDoors() : _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
if (allDoors == null)
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instance == null)
|
||||
{
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
@ -17,12 +17,10 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -33,9 +31,10 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
@ -52,7 +51,6 @@ public class DoorData implements IXmlReader
|
||||
private final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -64,7 +62,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/DoorData.xml");
|
||||
}
|
||||
|
||||
@ -72,7 +69,7 @@ public class DoorData implements IXmlReader
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "door", doorNode -> spawnDoor(parseDoor(doorNode))));
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " Door Templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public StatSet parseDoor(Node doorNode)
|
||||
@ -151,7 +148,7 @@ public class DoorData implements IXmlReader
|
||||
// Register the door
|
||||
_templates.put(door.getId(), set);
|
||||
_doors.put(door.getId(), door);
|
||||
_regions.computeIfAbsent(MapRegionManager.getInstance().getMapRegionLocId(door), key -> new ArrayList<>()).add(door);
|
||||
|
||||
return door;
|
||||
}
|
||||
|
||||
@ -213,27 +210,31 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instance, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instance
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, Instance instance, boolean doubleFaceCheck)
|
||||
{
|
||||
final Collection<DoorInstance> allDoors = (instance != null) ? instance.getDoors() : _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
if (allDoors == null)
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instance == null)
|
||||
{
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
@ -17,12 +17,10 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -33,9 +31,10 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
@ -52,7 +51,6 @@ public class DoorData implements IXmlReader
|
||||
private final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -64,7 +62,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/DoorData.xml");
|
||||
}
|
||||
|
||||
@ -72,7 +69,7 @@ public class DoorData implements IXmlReader
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "door", doorNode -> spawnDoor(parseDoor(doorNode))));
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " Door Templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public StatSet parseDoor(Node doorNode)
|
||||
@ -151,7 +148,7 @@ public class DoorData implements IXmlReader
|
||||
// Register the door
|
||||
_templates.put(door.getId(), set);
|
||||
_doors.put(door.getId(), door);
|
||||
_regions.computeIfAbsent(MapRegionManager.getInstance().getMapRegionLocId(door), key -> new ArrayList<>()).add(door);
|
||||
|
||||
return door;
|
||||
}
|
||||
|
||||
@ -213,27 +210,31 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instance, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instance
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, Instance instance, boolean doubleFaceCheck)
|
||||
{
|
||||
final Collection<DoorInstance> allDoors = (instance != null) ? instance.getDoors() : _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
if (allDoors == null)
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instance == null)
|
||||
{
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
@ -17,12 +17,10 @@
|
||||
package org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -33,9 +31,10 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldRegion;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.DoorTemplate;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
@ -52,7 +51,6 @@ public class DoorData implements IXmlReader
|
||||
private final Map<String, Set<Integer>> _groups = new HashMap<>();
|
||||
private final Map<Integer, DoorInstance> _doors = new HashMap<>();
|
||||
private final Map<Integer, StatSet> _templates = new HashMap<>();
|
||||
private final Map<Integer, List<DoorInstance>> _regions = new HashMap<>();
|
||||
|
||||
protected DoorData()
|
||||
{
|
||||
@ -64,7 +62,6 @@ public class DoorData implements IXmlReader
|
||||
{
|
||||
_doors.clear();
|
||||
_groups.clear();
|
||||
_regions.clear();
|
||||
parseDatapackFile("data/DoorData.xml");
|
||||
}
|
||||
|
||||
@ -72,7 +69,7 @@ public class DoorData implements IXmlReader
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "door", doorNode -> spawnDoor(parseDoor(doorNode))));
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " Door Templates for " + _regions.size() + " regions.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _doors.size() + " doors.");
|
||||
}
|
||||
|
||||
public StatSet parseDoor(Node doorNode)
|
||||
@ -151,7 +148,7 @@ public class DoorData implements IXmlReader
|
||||
// Register the door
|
||||
_templates.put(door.getId(), set);
|
||||
_doors.put(door.getId(), door);
|
||||
_regions.computeIfAbsent(MapRegionManager.getInstance().getMapRegionLocId(door), key -> new ArrayList<>()).add(door);
|
||||
|
||||
return door;
|
||||
}
|
||||
|
||||
@ -213,27 +210,31 @@ public class DoorData implements IXmlReader
|
||||
return checkIfDoorsBetween(x, y, z, tx, ty, tz, instance, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GodKratos: TODO: remove GeoData checks from door table and convert door nodes to Geo zones
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param tx
|
||||
* @param ty
|
||||
* @param tz
|
||||
* @param instance
|
||||
* @param doubleFaceCheck
|
||||
* @return {@code boolean}
|
||||
*/
|
||||
public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, Instance instance, boolean doubleFaceCheck)
|
||||
{
|
||||
final Collection<DoorInstance> allDoors = (instance != null) ? instance.getDoors() : _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
|
||||
if (allDoors == null)
|
||||
final Collection<DoorInstance> doors;
|
||||
if (instance == null)
|
||||
{
|
||||
final WorldRegion region = World.getInstance().getRegion(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
doors = region.getDoors();
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doors = instance.getDoors();
|
||||
}
|
||||
if ((doors == null) || doors.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DoorInstance doorInst : allDoors)
|
||||
for (DoorInstance doorInst : doors)
|
||||
{
|
||||
// check dead and open
|
||||
if (doorInst.isDead() || doorInst.isOpen() || !doorInst.checkCollision() || (doorInst.getX(0) == 0))
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@ -23,6 +24,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
|
||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||
|
||||
@ -30,6 +32,8 @@ public class WorldRegion
|
||||
{
|
||||
/** List containing visible objects in this world region. */
|
||||
private final UnboundArrayList<WorldObject> _visibleObjects = new UnboundArrayList<>();
|
||||
/** List containing doors in this world region. */
|
||||
private final List<DoorInstance> _doors = new ArrayList<>(1);
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
@ -230,6 +234,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.addIfAbsent(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
_surroundingRegions[i].addDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@ -255,6 +267,14 @@ public class WorldRegion
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object.isDoor())
|
||||
{
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
removeDoor((DoorInstance) object);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
@ -266,6 +286,24 @@ public class WorldRegion
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
||||
public synchronized void addDoor(DoorInstance door)
|
||||
{
|
||||
if (!_doors.contains(door))
|
||||
{
|
||||
_doors.add(door);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeDoor(DoorInstance door)
|
||||
{
|
||||
_doors.remove(door);
|
||||
}
|
||||
|
||||
public List<DoorInstance> getDoors()
|
||||
{
|
||||
return _doors;
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
Loading…
Reference in New Issue
Block a user