Rename MaplePortal

This commit is contained in:
P0nk
2021-09-09 22:36:45 +02:00
parent 667bc69eb1
commit 7f4760ba1a
19 changed files with 69 additions and 69 deletions

View File

@@ -802,7 +802,7 @@ public class Character extends AbstractCharacterObject {
c.setAccountName(this.client.getAccountName());//No null's for accountName c.setAccountName(this.client.getAccountName());//No null's for accountName
this.setClient(c); this.setClient(c);
this.map = c.getChannelServer().getMapFactory().getMap(getMapId()); this.map = c.getChannelServer().getMapFactory().getMap(getMapId());
MaplePortal portal = map.findClosestPlayerSpawnpoint(getPosition()); Portal portal = map.findClosestPlayerSpawnpoint(getPosition());
if (portal == null) { if (portal == null) {
portal = map.getPortal(0); portal = map.getPortal(0);
} }
@@ -1292,7 +1292,7 @@ public class Character extends AbstractCharacterObject {
} }
MapleMap map_ = getWarpMap(mapid); MapleMap map_ = getWarpMap(mapid);
MaplePortal portal_ = map_.getPortal(portal); Portal portal_ = map_.getPortal(portal);
changeMap(map_, portal_ != null ? portal_ : map_.getRandomPlayerSpawnpoint()); changeMap(map_, portal_ != null ? portal_ : map_.getRandomPlayerSpawnpoint());
setBanishPlayerData(banMap, banSp, banTime); setBanishPlayerData(banMap, banSp, banTime);
@@ -1337,7 +1337,7 @@ public class Character extends AbstractCharacterObject {
changeMap(warpMap, warpMap.getPortal(portal)); changeMap(warpMap, warpMap.getPortal(portal));
} }
public void changeMap(int map, MaplePortal portal) { public void changeMap(int map, Portal portal) {
MapleMap warpMap; MapleMap warpMap;
EventInstanceManager eim = getEventInstance(); EventInstanceManager eim = getEventInstance();
@@ -1358,7 +1358,7 @@ public class Character extends AbstractCharacterObject {
changeMap(to, to.getPortal(portal)); changeMap(to, to.getPortal(portal));
} }
public void changeMap(final MapleMap target, MaplePortal pto) { public void changeMap(final MapleMap target, Portal pto) {
canWarpCounter++; canWarpCounter++;
eventChangedMap(target.getId()); // player can be dropped from an event here, hence the new warping target. eventChangedMap(target.getId()); // player can be dropped from an event here, hence the new warping target.
@@ -1393,7 +1393,7 @@ public class Character extends AbstractCharacterObject {
eventAfterChangedMap(this.getMapId()); eventAfterChangedMap(this.getMapId());
} }
public void forceChangeMap(final MapleMap target, MaplePortal pto) { public void forceChangeMap(final MapleMap target, Portal pto) {
// will actually enter the map given as parameter, regardless of being an eventmap or whatnot // will actually enter the map given as parameter, regardless of being an eventmap or whatnot
canWarpCounter++; canWarpCounter++;
@@ -7120,7 +7120,7 @@ public class Character extends AbstractCharacterObject {
if (ret.map == null) { if (ret.map == null) {
ret.map = mapManager.getMap(100000000); ret.map = mapManager.getMap(100000000);
} }
MaplePortal portal = ret.map.getPortal(ret.initialSpawnPoint); Portal portal = ret.map.getPortal(ret.initialSpawnPoint);
if (portal == null) { if (portal == null) {
portal = ret.map.getPortal(0); portal = ret.map.getPortal(0);
ret.initialSpawnPoint = 0; ret.initialSpawnPoint = 0;
@@ -8145,7 +8145,7 @@ public class Character extends AbstractCharacterObject {
} }
public void saveLocationOnWarp() { // suggestion to remember the map before warp command thanks to Lei public void saveLocationOnWarp() { // suggestion to remember the map before warp command thanks to Lei
MaplePortal closest = map.findClosestPortal(getPosition()); Portal closest = map.findClosestPortal(getPosition());
int curMapid = getMapId(); int curMapid = getMapId();
for (int i = 0; i < savedLocations.length; i++) { for (int i = 0; i < savedLocations.length; i++) {
@@ -8156,7 +8156,7 @@ public class Character extends AbstractCharacterObject {
} }
public void saveLocation(String type) { public void saveLocation(String type) {
MaplePortal closest = map.findClosestPortal(getPosition()); Portal closest = map.findClosestPortal(getPosition());
savedLocations[SavedLocationType.fromString(type).ordinal()] = new SavedLocation(getMapId(), closest != null ? closest.getId() : 0); savedLocations[SavedLocationType.fromString(type).ordinal()] = new SavedLocation(getMapId(), closest != null ? closest.getId() : 0);
} }
@@ -8412,7 +8412,7 @@ public class Character extends AbstractCharacterObject {
if (map == null || map.getId() == 610020000 || map.getId() == 610020001) { // reset to first spawnpoint on those maps if (map == null || map.getId() == 610020000 || map.getId() == 610020001) { // reset to first spawnpoint on those maps
ps.setInt(24, 0); ps.setInt(24, 0);
} else { } else {
MaplePortal closest = map.findClosestPlayerSpawnpoint(getPosition()); Portal closest = map.findClosestPlayerSpawnpoint(getPosition());
if (closest != null) { if (closest != null) {
ps.setInt(24, closest.getId()); ps.setInt(24, closest.getId());
} else { } else {

View File

@@ -108,7 +108,7 @@ public class GotoCommand extends Command {
MapleMap target = c.getChannelServer().getMapFactory().getMap(gotomaps.get(params[0])); MapleMap target = c.getChannelServer().getMapFactory().getMap(gotomaps.get(params[0]));
// expedition issue with this command detected thanks to Masterrulax // expedition issue with this command detected thanks to Masterrulax
MaplePortal targetPortal = target.getRandomPlayerSpawnpoint(); Portal targetPortal = target.getRandomPlayerSpawnpoint();
player.saveLocationOnWarp(); player.saveLocationOnWarp();
player.changeMap(target, targetPortal); player.changeMap(target, targetPortal);
} else { } else {

View File

@@ -27,7 +27,7 @@ import client.Character;
import client.Client; import client.Client;
import client.command.Command; import client.command.Command;
import server.maps.MapleMap; import server.maps.MapleMap;
import server.maps.MaplePortal; import server.maps.Portal;
public class JailCommand extends Command { public class JailCommand extends Command {
{ {
@@ -59,7 +59,7 @@ public class JailCommand extends Command {
if (victim.getMapId() != mapid) { // those gone to jail won't be changing map anyway if (victim.getMapId() != mapid) { // those gone to jail won't be changing map anyway
MapleMap target = c.getChannelServer().getMapFactory().getMap(mapid); MapleMap target = c.getChannelServer().getMapFactory().getMap(mapid);
MaplePortal targetPortal = target.getPortal(0); Portal targetPortal = target.getPortal(0);
victim.saveLocationOnWarp(); victim.saveLocationOnWarp();
victim.changeMap(target, targetPortal); victim.changeMap(target, targetPortal);
player.message(victim.getName() + " was jailed for " + minutesJailed + " minutes."); player.message(victim.getName() + " was jailed for " + minutesJailed + " minutes.");

View File

@@ -32,8 +32,8 @@ import server.life.Monster;
import server.life.SpawnPoint; import server.life.SpawnPoint;
import server.maps.MapObject; import server.maps.MapObject;
import server.maps.MapObjectType; import server.maps.MapObjectType;
import server.maps.MaplePortal;
import server.maps.MapleReactor; import server.maps.MapleReactor;
import server.maps.Portal;
import java.awt.*; import java.awt.*;
import java.util.Arrays; import java.util.Arrays;
@@ -80,7 +80,7 @@ public class DebugCommand extends Command {
break; break;
case "portal": case "portal":
MaplePortal portal = player.getMap().findClosestPortal(player.getPosition()); Portal portal = player.getMap().findClosestPortal(player.getPosition());
if (portal != null) if (portal != null)
player.dropMessage(6, "Closest portal: " + portal.getId() + " '" + portal.getName() + "' Type: " + portal.getType() + " --> toMap: " + portal.getTargetMapId() + " scriptname: '" + portal.getScriptName() + "' state: " + (portal.getPortalState() ? 1 : 0) + "."); player.dropMessage(6, "Closest portal: " + portal.getId() + " '" + portal.getName() + "' Type: " + portal.getType() + " --> toMap: " + portal.getTargetMapId() + " scriptname: '" + portal.getScriptName() + "' state: " + (portal.getPortalState() ? 1 : 0) + ".");
else player.dropMessage(6, "There is no portal on this map."); else player.dropMessage(6, "There is no portal on this map.");

View File

@@ -29,7 +29,7 @@ import net.AbstractPacketHandler;
import net.packet.InPacket; import net.packet.InPacket;
import server.MapleTrade; import server.MapleTrade;
import server.maps.MapleMap; import server.maps.MapleMap;
import server.maps.MaplePortal; import server.maps.Portal;
import tools.FilePrinter; import tools.FilePrinter;
import tools.PacketCreator; import tools.PacketCreator;
@@ -78,7 +78,7 @@ public final class ChangeMapHandler extends AbstractPacketHandler {
p.readByte(); // 1 = from dying 0 = regular portals p.readByte(); // 1 = from dying 0 = regular portals
int targetid = p.readInt(); int targetid = p.readInt();
String startwp = p.readString(); String startwp = p.readString();
MaplePortal portal = chr.getMap().getPortal(startwp); Portal portal = chr.getMap().getPortal(startwp);
p.readByte(); p.readByte();
boolean wheel = p.readByte() > 0; boolean wheel = p.readByte() > 0;

View File

@@ -26,7 +26,7 @@ import net.AbstractPacketHandler;
import net.packet.InPacket; import net.packet.InPacket;
import server.MapleTrade; import server.MapleTrade;
import server.MapleTrade.TradeResult; import server.MapleTrade.TradeResult;
import server.maps.MaplePortal; import server.maps.Portal;
import tools.PacketCreator; import tools.PacketCreator;
public final class ChangeMapSpecialHandler extends AbstractPacketHandler { public final class ChangeMapSpecialHandler extends AbstractPacketHandler {
@@ -35,7 +35,7 @@ public final class ChangeMapSpecialHandler extends AbstractPacketHandler {
p.readByte(); p.readByte();
String startwp = p.readString(); String startwp = p.readString();
p.readShort(); p.readShort();
MaplePortal portal = c.getPlayer().getMap().getPortal(startwp); Portal portal = c.getPlayer().getMap().getPortal(startwp);
if (portal == null || c.getPlayer().portalDelay() > currentServerTime() || c.getPlayer().getBlockedPortals().contains(portal.getScriptName())) { if (portal == null || c.getPlayer().portalDelay() > currentServerTime() || c.getPlayer().getBlockedPortals().contains(portal.getScriptName())) {
c.sendPacket(PacketCreator.enableActions()); c.sendPacket(PacketCreator.enableActions());
return; return;

View File

@@ -29,8 +29,8 @@ import net.AbstractPacketHandler;
import net.packet.InPacket; import net.packet.InPacket;
import server.maps.MapObject; import server.maps.MapObject;
import server.maps.MapObjectType; import server.maps.MapObjectType;
import server.maps.MaplePortal;
import server.maps.PlayerShop; import server.maps.PlayerShop;
import server.maps.Portal;
import tools.PacketCreator; import tools.PacketCreator;
import java.awt.*; import java.awt.*;
@@ -63,7 +63,7 @@ public final class HiredMerchantRequest extends AbstractPacketHandler {
} }
Point cpos = chr.getPosition(); Point cpos = chr.getPosition();
MaplePortal portal = chr.getMap().findClosestTeleportPortal(cpos); Portal portal = chr.getMap().findClosestTeleportPortal(cpos);
if (portal != null && portal.getPosition().distance(cpos) < 120.0) { if (portal != null && portal.getPosition().distance(cpos) < 120.0) {
chr.sendPacket(PacketCreator.getMiniRoomError(10)); chr.sendPacket(PacketCreator.getMiniRoomError(10));
return; return;

View File

@@ -814,7 +814,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
} }
Point cpos = chr.getPosition(); Point cpos = chr.getPosition();
MaplePortal portal = chr.getMap().findClosestTeleportPortal(cpos); Portal portal = chr.getMap().findClosestTeleportPortal(cpos);
if (portal != null && portal.getPosition().distance(cpos) < 120.0) { if (portal != null && portal.getPosition().distance(cpos) < 120.0) {
chr.sendPacket(PacketCreator.getMiniRoomError(10)); chr.sendPacket(PacketCreator.getMiniRoomError(10));
return false; return false;

View File

@@ -46,8 +46,8 @@ import server.life.Monster;
import server.life.NPC; import server.life.NPC;
import server.maps.MapManager; import server.maps.MapManager;
import server.maps.MapleMap; import server.maps.MapleMap;
import server.maps.MaplePortal;
import server.maps.MapleReactor; import server.maps.MapleReactor;
import server.maps.Portal;
import tools.PacketCreator; import tools.PacketCreator;
import tools.Pair; import tools.Pair;
@@ -1277,7 +1277,7 @@ public class EventInstanceManager {
thisStage--; //stages counts from ONE, scripts from ZERO thisStage--; //stages counts from ONE, scripts from ZERO
MapleMap nextStage = getMapInstance(thisMapId); MapleMap nextStage = getMapInstance(thisMapId);
MaplePortal portal = nextStage.getPortal("next00"); Portal portal = nextStage.getPortal("next00");
if (portal != null) { if (portal != null) {
portal.setScriptName(eventFamily + thisStage); portal.setScriptName(eventFamily + thisStage);
} }
@@ -1288,7 +1288,7 @@ public class EventInstanceManager {
thisStage--; //stages counts from ONE, scripts from ZERO thisStage--; //stages counts from ONE, scripts from ZERO
MapleMap nextStage = getMapInstance(thisMapId); MapleMap nextStage = getMapInstance(thisMapId);
MaplePortal portal = nextStage.getPortal(portalName); Portal portal = nextStage.getPortal(portalName);
if (portal != null) { if (portal != null) {
portal.setScriptName(scriptName); portal.setScriptName(scriptName);
} }

View File

@@ -24,7 +24,7 @@ package scripting.portal;
import client.Client; import client.Client;
import scripting.AbstractPlayerInteraction; import scripting.AbstractPlayerInteraction;
import scripting.map.MapScriptManager; import scripting.map.MapScriptManager;
import server.maps.MaplePortal; import server.maps.Portal;
import tools.DatabaseConnection; import tools.DatabaseConnection;
import tools.PacketCreator; import tools.PacketCreator;
@@ -34,14 +34,14 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
public class PortalPlayerInteraction extends AbstractPlayerInteraction { public class PortalPlayerInteraction extends AbstractPlayerInteraction {
private final MaplePortal portal; private final Portal portal;
public PortalPlayerInteraction(Client c, MaplePortal portal) { public PortalPlayerInteraction(Client c, Portal portal) {
super(c); super(c);
this.portal = portal; this.portal = portal;
} }
public MaplePortal getPortal() { public Portal getPortal() {
return portal; return portal;
} }

View File

@@ -25,7 +25,7 @@ import client.Client;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import scripting.AbstractScriptManager; import scripting.AbstractScriptManager;
import server.maps.MaplePortal; import server.maps.Portal;
import javax.script.Invocable; import javax.script.Invocable;
import javax.script.ScriptEngine; import javax.script.ScriptEngine;
@@ -64,7 +64,7 @@ public class PortalScriptManager extends AbstractScriptManager {
return script; return script;
} }
public boolean executePortalScript(MaplePortal portal, Client c) { public boolean executePortalScript(Portal portal, Client c) {
try { try {
PortalScript script = getPortalScript(portal.getScriptName()); PortalScript script = getPortalScript(portal.getScriptName());
if (script != null) { if (script != null) {

View File

@@ -908,7 +908,7 @@ public class MapleStatEffect {
if (moveTo != -1) { if (moveTo != -1) {
if (moveTo != applyto.getMapId()) { if (moveTo != applyto.getMapId()) {
MapleMap target; MapleMap target;
MaplePortal pt; Portal pt;
if (moveTo == 999999999) { if (moveTo == 999999999) {
if (sourceid != 2030100) { if (sourceid != 2030100) {

View File

@@ -37,7 +37,7 @@ import java.util.Collection;
public class Door { public class Door {
private int ownerId; private int ownerId;
private MapleMap town; private MapleMap town;
private MaplePortal townPortal; private Portal townPortal;
private final MapleMap target; private final MapleMap target;
private Pair<String, Integer> posStatus = null; private Pair<String, Integer> posStatus = null;
private long deployTime; private long deployTime;
@@ -81,7 +81,7 @@ public class Door {
public void updateDoorPortal(Character owner) { public void updateDoorPortal(Character owner) {
int slot = owner.fetchDoorSlot(); int slot = owner.fetchDoorSlot();
MaplePortal nextTownPortal = getTownDoorPortal(slot); Portal nextTownPortal = getTownDoorPortal(slot);
if (nextTownPortal != null) { if (nextTownPortal != null) {
townPortal = nextTownPortal; townPortal = nextTownPortal;
areaDoor.update(nextTownPortal.getId(), nextTownPortal.getPosition()); areaDoor.update(nextTownPortal.getId(), nextTownPortal.getPosition());
@@ -141,7 +141,7 @@ public class Door {
} }
} }
private MaplePortal getTownDoorPortal(int doorid) { private Portal getTownDoorPortal(int doorid) {
return town.getDoorPortal(doorid); return town.getDoorPortal(doorid);
} }
@@ -161,7 +161,7 @@ public class Door {
return town; return town;
} }
public MaplePortal getTownPortal() { public Portal getTownPortal() {
return townPortal; return townPortal;
} }

View File

@@ -32,7 +32,7 @@ import tools.PacketCreator;
import java.awt.*; import java.awt.*;
public class GenericPortal implements MaplePortal { public class GenericPortal implements Portal {
private String name; private String name;
private String target; private String target;
private Point position; private Point position;
@@ -144,7 +144,7 @@ public class GenericPortal implements MaplePortal {
Character chr = c.getPlayer(); Character chr = c.getPlayer();
if (!(chr.getChalkboard() != null && GameConstants.isFreeMarketRoom(getTargetMapId()))) { if (!(chr.getChalkboard() != null && GameConstants.isFreeMarketRoom(getTargetMapId()))) {
MapleMap to = chr.getEventInstance() == null ? c.getChannelServer().getMapFactory().getMap(getTargetMapId()) : chr.getEventInstance().getMapInstance(getTargetMapId()); MapleMap to = chr.getEventInstance() == null ? c.getChannelServer().getMapFactory().getMap(getTargetMapId()) : chr.getEventInstance().getMapInstance(getTargetMapId());
MaplePortal pto = to.getPortal(getTarget()); Portal pto = to.getPortal(getTarget());
if (pto == null) {// fallback for missing portals - no real life case anymore - interesting for not implemented areas if (pto == null) {// fallback for missing portals - no real life case anymore - interesting for not implemented areas
pto = to.getPortal(0); pto = to.getPortal(0);
} }

View File

@@ -28,7 +28,7 @@ import java.util.concurrent.ScheduledFuture;
public class MapMonitor { public class MapMonitor {
private ScheduledFuture<?> monitorSchedule; private ScheduledFuture<?> monitorSchedule;
private MapleMap map; private MapleMap map;
private MaplePortal portal; private Portal portal;
public MapMonitor(final MapleMap map, String portal) { public MapMonitor(final MapleMap map, String portal) {
this.map = map; this.map = map;
@@ -49,7 +49,7 @@ public class MapMonitor {
map.killAllMonsters(); map.killAllMonsters();
map.clearDrops(); map.clearDrops();
if (portal != null) { if (portal != null) {
portal.setPortalStatus(MaplePortal.OPEN); portal.setPortalStatus(Portal.OPEN);
} }
map.resetReactors(); map.resetReactors();

View File

@@ -23,6 +23,6 @@ package server.maps;
public class MapPortal extends GenericPortal { public class MapPortal extends GenericPortal {
public MapPortal() { public MapPortal() {
super(MaplePortal.MAP_PORTAL); super(Portal.MAP_PORTAL);
} }
} }

View File

@@ -90,7 +90,7 @@ public class MapleMap {
private final AtomicInteger droppedItemCount = new AtomicInteger(0); private final AtomicInteger droppedItemCount = new AtomicInteger(0);
private final Collection<Character> characters = new LinkedHashSet<>(); private final Collection<Character> characters = new LinkedHashSet<>();
private final Map<Integer, Set<Integer>> mapParty = new LinkedHashMap<>(); private final Map<Integer, Set<Integer>> mapParty = new LinkedHashMap<>();
private final Map<Integer, MaplePortal> portals = new HashMap<>(); private final Map<Integer, Portal> portals = new HashMap<>();
private final Map<Integer, Integer> backgroundTypes = new HashMap<>(); private final Map<Integer, Integer> backgroundTypes = new HashMap<>();
private final Map<String, Integer> environment = new LinkedHashMap<>(); private final Map<String, Integer> environment = new LinkedHashMap<>();
private final Map<MapItem, Long> droppedItems = new LinkedHashMap<>(); private final Map<MapItem, Long> droppedItems = new LinkedHashMap<>();
@@ -596,7 +596,7 @@ public class MapleMap {
} }
public Pair<String, Integer> getDoorPositionStatus(Point pos) { public Pair<String, Integer> getDoorPositionStatus(Point pos) {
MaplePortal portal = findClosestPlayerSpawnpoint(pos); Portal portal = findClosestPlayerSpawnpoint(pos);
double angle = getAngle(portal.getPosition(), pos); double angle = getAngle(portal.getPosition(), pos);
double distn = pos.distanceSq(portal.getPosition()); double distn = pos.distanceSq(portal.getPosition());
@@ -2051,8 +2051,8 @@ public class MapleMap {
}, chr -> chr.getMapId() == door.getFrom().getId()); }, chr -> chr.getMapId() == door.getFrom().getId());
} }
public MaplePortal getDoorPortal(int doorid) { public Portal getDoorPortal(int doorid) {
MaplePortal doorPortal = portals.get(0x80 + doorid); Portal doorPortal = portals.get(0x80 + doorid);
if (doorPortal == null) { if (doorPortal == null) {
FilePrinter.printError(FilePrinter.EXCEPTION, "[Door] " + mapName + "(" + mapid + ") does not contain door portalid " + doorid); FilePrinter.printError(FilePrinter.EXCEPTION, "[Door] " + mapName + "(" + mapid + ") does not contain door portalid " + doorid);
return portals.get(0x80); return portals.get(0x80);
@@ -2584,23 +2584,23 @@ public class MapleMap {
Server.getInstance().registerAnnouncePlayerDiseases(c); Server.getInstance().registerAnnouncePlayerDiseases(c);
} }
public MaplePortal getRandomPlayerSpawnpoint() { public Portal getRandomPlayerSpawnpoint() {
List<MaplePortal> spawnPoints = new ArrayList<>(); List<Portal> spawnPoints = new ArrayList<>();
for (MaplePortal portal : portals.values()) { for (Portal portal : portals.values()) {
if (portal.getType() >= 0 && portal.getType() <= 1 && portal.getTargetMapId() == 999999999) { if (portal.getType() >= 0 && portal.getType() <= 1 && portal.getTargetMapId() == 999999999) {
spawnPoints.add(portal); spawnPoints.add(portal);
} }
} }
MaplePortal portal = spawnPoints.get(new Random().nextInt(spawnPoints.size())); Portal portal = spawnPoints.get(new Random().nextInt(spawnPoints.size()));
return portal != null ? portal : getPortal(0); return portal != null ? portal : getPortal(0);
} }
public MaplePortal findClosestTeleportPortal(Point from) { public Portal findClosestTeleportPortal(Point from) {
MaplePortal closest = null; Portal closest = null;
double shortestDistance = Double.POSITIVE_INFINITY; double shortestDistance = Double.POSITIVE_INFINITY;
for (MaplePortal portal : portals.values()) { for (Portal portal : portals.values()) {
double distance = portal.getPosition().distanceSq(from); double distance = portal.getPosition().distanceSq(from);
if (portal.getType() == MaplePortal.TELEPORT_PORTAL && distance < shortestDistance && portal.getTargetMapId() != 999999999) { if (portal.getType() == Portal.TELEPORT_PORTAL && distance < shortestDistance && portal.getTargetMapId() != 999999999) {
closest = portal; closest = portal;
shortestDistance = distance; shortestDistance = distance;
} }
@@ -2608,10 +2608,10 @@ public class MapleMap {
return closest; return closest;
} }
public MaplePortal findClosestPlayerSpawnpoint(Point from) { public Portal findClosestPlayerSpawnpoint(Point from) {
MaplePortal closest = null; Portal closest = null;
double shortestDistance = Double.POSITIVE_INFINITY; double shortestDistance = Double.POSITIVE_INFINITY;
for (MaplePortal portal : portals.values()) { for (Portal portal : portals.values()) {
double distance = portal.getPosition().distanceSq(from); double distance = portal.getPosition().distanceSq(from);
if (portal.getType() >= 0 && portal.getType() <= 1 && distance < shortestDistance && portal.getTargetMapId() == 999999999) { if (portal.getType() >= 0 && portal.getType() <= 1 && distance < shortestDistance && portal.getTargetMapId() == 999999999) {
closest = portal; closest = portal;
@@ -2621,10 +2621,10 @@ public class MapleMap {
return closest; return closest;
} }
public MaplePortal findClosestPortal(Point from) { public Portal findClosestPortal(Point from) {
MaplePortal closest = null; Portal closest = null;
double shortestDistance = Double.POSITIVE_INFINITY; double shortestDistance = Double.POSITIVE_INFINITY;
for (MaplePortal portal : portals.values()) { for (Portal portal : portals.values()) {
double distance = portal.getPosition().distanceSq(from); double distance = portal.getPosition().distanceSq(from);
if (distance < shortestDistance) { if (distance < shortestDistance) {
closest = portal; closest = portal;
@@ -2634,8 +2634,8 @@ public class MapleMap {
return closest; return closest;
} }
public MaplePortal findMarketPortal() { public Portal findMarketPortal() {
for (MaplePortal portal : portals.values()) { for (Portal portal : portals.values()) {
String ptScript = portal.getScriptName(); String ptScript = portal.getScriptName();
if (ptScript != null && ptScript.contains("market")) { if (ptScript != null && ptScript.contains("market")) {
return portal; return portal;
@@ -2645,7 +2645,7 @@ public class MapleMap {
} }
/* /*
public Collection<MaplePortal> getPortals() { public Collection<Portal> getPortals() {
return Collections.unmodifiableCollection(portals.values()); return Collections.unmodifiableCollection(portals.values());
} }
*/ */
@@ -3008,12 +3008,12 @@ public class MapleMap {
} }
} }
public void addPortal(MaplePortal myPortal) { public void addPortal(Portal myPortal) {
portals.put(myPortal.getId(), myPortal); portals.put(myPortal.getId(), myPortal);
} }
public MaplePortal getPortal(String portalname) { public Portal getPortal(String portalname) {
for (MaplePortal port : portals.values()) { for (Portal port : portals.values()) {
if (port.getName().equals(portalname)) { if (port.getName().equals(portalname)) {
return port; return port;
} }
@@ -3021,7 +3021,7 @@ public class MapleMap {
return null; return null;
} }
public MaplePortal getPortal(int portalid) { public Portal getPortal(int portalid) {
return portals.get(portalid); return portals.get(portalid);
} }

View File

@@ -33,9 +33,9 @@ public class MaplePortalFactory {
nextDoorPortal = 0x80; nextDoorPortal = 0x80;
} }
public MaplePortal makePortal(int type, Data portal) { public Portal makePortal(int type, Data portal) {
GenericPortal ret = null; GenericPortal ret = null;
if (type == MaplePortal.MAP_PORTAL) { if (type == Portal.MAP_PORTAL) {
ret = new MapPortal(); ret = new MapPortal();
} else { } else {
ret = new GenericPortal(type); ret = new GenericPortal(type);
@@ -56,7 +56,7 @@ public class MaplePortalFactory {
script = null; script = null;
} }
myPortal.setScriptName(script); myPortal.setScriptName(script);
if (myPortal.getType() == MaplePortal.DOOR_PORTAL) { if (myPortal.getType() == Portal.DOOR_PORTAL) {
myPortal.setId(nextDoorPortal); myPortal.setId(nextDoorPortal);
nextDoorPortal++; nextDoorPortal++;
} else { } else {

View File

@@ -25,7 +25,7 @@ import client.Client;
import java.awt.*; import java.awt.*;
public interface MaplePortal { public interface Portal {
int TELEPORT_PORTAL = 1; int TELEPORT_PORTAL = 1;
int MAP_PORTAL = 2; int MAP_PORTAL = 2;
int DOOR_PORTAL = 6; int DOOR_PORTAL = 6;