Turn map id magic numbers into constants

This commit is contained in:
P0nk
2021-11-07 14:26:34 +01:00
parent c022c3595f
commit b15a7e61d4
51 changed files with 615 additions and 341 deletions

View File

@@ -21,6 +21,7 @@ package server.maps;
import client.Character;
import client.Client;
import constants.id.MapId;
import net.server.audit.locks.MonitoredLockType;
import net.server.audit.locks.MonitoredReadLock;
import net.server.audit.locks.MonitoredReentrantReadWriteLock;
@@ -128,7 +129,7 @@ public class DoorObject extends AbstractMapObject {
if (from.getId() == chr.getMapId()) {
Party party = chr.getParty();
if (party != null && (ownerId == chr.getId() || party.getMemberById(ownerId) != null)) {
client.sendPacket(PacketCreator.partyPortal(999999999, 999999999, new Point(-1, -1)));
client.sendPacket(PacketCreator.partyPortal(MapId.NONE, MapId.NONE, new Point(-1, -1)));
}
client.sendPacket(PacketCreator.removeDoor(ownerId, inTown()));
}
@@ -136,7 +137,7 @@ public class DoorObject extends AbstractMapObject {
public void sendDestroyData(Client client, boolean partyUpdate) {
if (client != null && from.getId() == client.getPlayer().getMapId()) {
client.sendPacket(PacketCreator.partyPortal(999999999, 999999999, new Point(-1, -1)));
client.sendPacket(PacketCreator.partyPortal(MapId.NONE, MapId.NONE, new Point(-1, -1)));
client.sendPacket(PacketCreator.removeDoor(ownerId, inTown()));
}
}

View File

@@ -24,6 +24,7 @@ package server.maps;
import client.Character;
import client.Client;
import constants.game.GameConstants;
import constants.id.MapId;
import net.server.audit.locks.MonitoredLockType;
import net.server.audit.locks.MonitoredReentrantLock;
import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
@@ -140,7 +141,7 @@ public class GenericPortal implements Portal {
} catch (NullPointerException npe) {
npe.printStackTrace();
}
} else if (getTargetMapId() != 999999999) {
} else if (getTargetMapId() != MapId.NONE) {
Character chr = c.getPlayer();
if (!(chr.getChalkboard() != null && GameConstants.isFreeMarketRoom(getTargetMapId()))) {
MapleMap to = chr.getEventInstance() == null ? c.getChannelServer().getMapFactory().getMap(getTargetMapId()) : chr.getEventInstance().getMapInstance(getTargetMapId());

View File

@@ -21,6 +21,7 @@
*/
package server.maps;
import constants.id.MapId;
import provider.Data;
import provider.DataProvider;
import provider.DataProviderFactory;
@@ -309,7 +310,7 @@ public class MapFactory {
map.setTown(DataTool.getIntConvert("town", infoData, 0) != 0);
map.setHPDec(DataTool.getIntConvert("decHP", infoData, 0));
map.setHPDecProtect(DataTool.getIntConvert("protectItem", infoData, 0));
map.setForcedReturnMap(DataTool.getInt(infoData.getChildByPath("forcedReturn"), 999999999));
map.setForcedReturnMap(DataTool.getInt(infoData.getChildByPath("forcedReturn"), MapId.NONE));
map.setBoat(mapData.getChildByPath("shipObj") != null);
map.setTimeLimit(DataTool.getIntConvert("timeLimit", infoData, -1));
map.setFieldType(DataTool.getIntConvert("fieldType", infoData, 0));
@@ -381,15 +382,15 @@ public class MapFactory {
StringBuilder builder = new StringBuilder();
if (mapid < 100000000) {
builder.append("maple");
} else if (mapid >= 100000000 && mapid < 200000000) {
} else if (mapid >= 100000000 && mapid < MapId.ORBIS) {
builder.append("victoria");
} else if (mapid >= 200000000 && mapid < 300000000) {
} else if (mapid >= MapId.ORBIS && mapid < MapId.ELLIN_FOREST) {
builder.append("ossyria");
} else if (mapid >= 300000000 && mapid < 400000000) {
} else if (mapid >= MapId.ELLIN_FOREST && mapid < 400000000) {
builder.append("elin");
} else if (mapid >= 540000000 && mapid < 560000000) {
} else if (mapid >= MapId.SINGAPORE && mapid < 560000000) {
builder.append("singapore");
} else if (mapid >= 600000000 && mapid < 620000000) {
} else if (mapid >= MapId.NEW_LEAF_CITY && mapid < 620000000) {
builder.append("MasteriaGL");
} else if (mapid >= 677000000 && mapid < 677100000) {
builder.append("Episode1GL");
@@ -403,7 +404,7 @@ public class MapFactory {
builder.append("HalloweenGL");
} else if (mapid >= 683000000 && mapid < 684000000) {
builder.append("event");
} else if (mapid >= 800000000 && mapid < 900000000) {
} else if (mapid >= MapId.MUSHROOM_SHRINE && mapid < 900000000) {
if ((mapid >= 889100000 && mapid < 889200000)) {
builder.append("etc");
} else {

View File

@@ -33,6 +33,7 @@ import client.status.MonsterStatus;
import client.status.MonsterStatusEffect;
import config.YamlConfig;
import constants.game.GameConstants;
import constants.id.MapId;
import constants.id.MobId;
import constants.inventory.ItemConstants;
import net.packet.Packet;
@@ -120,7 +121,7 @@ public class MapleMap {
private String streetName;
private MapEffect mapEffect = null;
private boolean everlast = false;
private int forcedReturnMap = 999999999;
private int forcedReturnMap = MapId.NONE;
private int timeLimit;
private long mapTimer;
private int decHP = 0;
@@ -264,7 +265,7 @@ public class MapleMap {
}
public MapleMap getReturnMap() {
if (returnMapId == 999999999) {
if (returnMapId == MapId.NONE) {
return this;
}
return getChannelServer().getMapFactory().getMap(returnMapId);
@@ -2388,7 +2389,7 @@ public class MapleMap {
}
}
if (onUserEnter.length() != 0) {
if (onUserEnter.equals("cygnusTest") && (mapid < 913040000 || mapid > 913040006)) {
if (onUserEnter.equals("cygnusTest") && !MapId.isCygnusIntro(mapid)) {
chr.saveLocation("INTRO");
}
@@ -2399,52 +2400,52 @@ public class MapleMap {
chr.cancelBuffStats(BuffStat.MONSTER_RIDING);
}
if (mapid == 200090060) { // To Rien
if (mapid == MapId.FROM_LITH_TO_RIEN) { // To Rien
int travelTime = getWorldServer().getTransportationTime((int) MINUTES.toMillis(1));
chr.sendPacket(PacketCreator.getClock(travelTime / 1000));
TimerManager.getInstance().schedule(() -> {
if (chr.getMapId() == 200090060) {
chr.changeMap(140020300, 0);
if (chr.getMapId() == MapId.FROM_LITH_TO_RIEN) {
chr.changeMap(MapId.DANGEROUS_FOREST, 0);
}
}, travelTime);
} else if (mapid == 200090070) { // To Lith Harbor
} else if (mapid == MapId.FROM_RIEN_TO_LITH) { // To Lith Harbor
int travelTime = getWorldServer().getTransportationTime((int) MINUTES.toMillis(1));
chr.sendPacket(PacketCreator.getClock(travelTime / 1000));
TimerManager.getInstance().schedule(() -> {
if (chr.getMapId() == 200090070) {
chr.changeMap(104000000, 3);
if (chr.getMapId() == MapId.FROM_RIEN_TO_LITH) {
chr.changeMap(MapId.LITH_HARBOUR, 3);
}
}, travelTime);
} else if (mapid == 200090030) { // To Ereve (SkyFerry)
} else if (mapid == MapId.FROM_ELLINIA_TO_EREVE) { // To Ereve (SkyFerry)
int travelTime = getWorldServer().getTransportationTime((int) MINUTES.toMillis(2));
chr.sendPacket(PacketCreator.getClock(travelTime / 1000));
TimerManager.getInstance().schedule(() -> {
if (chr.getMapId() == 200090030) {
chr.changeMap(130000210, 0);
if (chr.getMapId() == MapId.FROM_ELLINIA_TO_EREVE) {
chr.changeMap(MapId.SKY_FERRY, 0);
}
}, travelTime);
} else if (mapid == 200090031) { // To Victoria Island (SkyFerry)
} else if (mapid == MapId.FROM_EREVE_TO_ELLINIA) { // To Victoria Island (SkyFerry)
int travelTime = getWorldServer().getTransportationTime((int) MINUTES.toMillis(2));
chr.sendPacket(PacketCreator.getClock(travelTime / 1000));
TimerManager.getInstance().schedule(() -> {
if (chr.getMapId() == 200090031) {
chr.changeMap(101000400, 0);
if (chr.getMapId() == MapId.FROM_EREVE_TO_ELLINIA) {
chr.changeMap(MapId.ELLINIA_SKY_FERRY, 0);
}
}, travelTime);
} else if (mapid == 200090021) { // To Orbis (SkyFerry)
} else if (mapid == MapId.FROM_EREVE_TO_ORBIS) { // To Orbis (SkyFerry)
int travelTime = getWorldServer().getTransportationTime((int) MINUTES.toMillis(8));
chr.sendPacket(PacketCreator.getClock(travelTime / 1000));
TimerManager.getInstance().schedule(() -> {
if (chr.getMapId() == 200090021) {
chr.changeMap(200000161, 0);
if (chr.getMapId() == MapId.FROM_EREVE_TO_ORBIS) {
chr.changeMap(MapId.ORBIS_STATION, 0);
}
}, travelTime);
} else if (mapid == 200090020) { // To Ereve From Orbis (SkyFerry)
} else if (mapid == MapId.FROM_ORBIS_TO_EREVE) { // To Ereve From Orbis (SkyFerry)
int travelTime = getWorldServer().getTransportationTime((int) MINUTES.toMillis(8));
chr.sendPacket(PacketCreator.getClock(travelTime / 1000));
TimerManager.getInstance().schedule(() -> {
if (chr.getMapId() == 200090020) {
chr.changeMap(130000210, 0);
if (chr.getMapId() == MapId.FROM_ORBIS_TO_EREVE) {
chr.changeMap(MapId.SKY_FERRY, 0);
}
}, travelTime);
} else if (MiniDungeonInfo.isDungeonMap(mapid)) {
@@ -2550,7 +2551,7 @@ public class MapleMap {
mapEffect.sendStartData(chr.getClient());
}
chr.sendPacket(PacketCreator.resetForcedStats());
if (mapid == 914000200 || mapid == 914000210 || mapid == 914000220) {
if (MapId.isGodlyStatMap(mapid)) {
chr.sendPacket(PacketCreator.aranGodlyStats());
}
if (chr.getEventInstance() != null && chr.getEventInstance().isTimerStarted()) {
@@ -2564,7 +2565,7 @@ public class MapleMap {
chr.sendPacket(PacketCreator.getClock((int) (chr.getOla().getTimeLeft() / 1000)));
}
if (mapid == 109060000) {
if (mapid == MapId.EVENT_SNOWBALL) {
chr.sendPacket(PacketCreator.rollSnowBall(true, 0, null, null));
}
@@ -2591,7 +2592,7 @@ public class MapleMap {
public Portal getRandomPlayerSpawnpoint() {
List<Portal> spawnPoints = new ArrayList<>();
for (Portal portal : portals.values()) {
if (portal.getType() >= 0 && portal.getType() <= 1 && portal.getTargetMapId() == 999999999) {
if (portal.getType() >= 0 && portal.getType() <= 1 && portal.getTargetMapId() == MapId.NONE) {
spawnPoints.add(portal);
}
}
@@ -2604,7 +2605,7 @@ public class MapleMap {
double shortestDistance = Double.POSITIVE_INFINITY;
for (Portal portal : portals.values()) {
double distance = portal.getPosition().distanceSq(from);
if (portal.getType() == Portal.TELEPORT_PORTAL && distance < shortestDistance && portal.getTargetMapId() != 999999999) {
if (portal.getType() == Portal.TELEPORT_PORTAL && distance < shortestDistance && portal.getTargetMapId() != MapId.NONE) {
closest = portal;
shortestDistance = distance;
}
@@ -2617,7 +2618,7 @@ public class MapleMap {
double shortestDistance = Double.POSITIVE_INFINITY;
for (Portal portal : portals.values()) {
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() == MapId.NONE) {
closest = portal;
shortestDistance = distance;
}
@@ -3895,20 +3896,21 @@ public class MapleMap {
}
public void startEvent(final Character chr) {
if (this.mapid == 109080000 && getCoconut() == null) {
if (this.mapid == MapId.EVENT_COCONUT_HARVEST && getCoconut() == null) {
setCoconut(new Coconut(this));
coconut.startEvent();
} else if (this.mapid == 109040000) {
} else if (this.mapid == MapId.EVENT_PHYSICAL_FITNESS) {
chr.setFitness(new Fitness(chr));
chr.getFitness().startFitness();
} else if (this.mapid == 109030101 || this.mapid == 109030201 || this.mapid == 109030301 || this.mapid == 109030401) {
} else if (this.mapid == MapId.EVENT_OLA_OLA_1 || this.mapid == MapId.EVENT_OLA_OLA_2 ||
this.mapid == MapId.EVENT_OLA_OLA_3 || this.mapid == MapId.EVENT_OLA_OLA_4) {
chr.setOla(new Ola(chr));
chr.getOla().startOla();
} else if (this.mapid == 109020001 && getOx() == null) {
} else if (this.mapid == MapId.EVENT_OX_QUIZ && getOx() == null) {
setOx(new OxQuiz(this));
getOx().sendQuestion();
setOxQuiz(true);
} else if (this.mapid == 109060000 && getSnowball(chr.getTeam()) == null) {
} else if (this.mapid == MapId.EVENT_SNOWBALL && getSnowball(chr.getTeam()) == null) {
setSnowball(0, new Snowball(0, this));
setSnowball(1, new Snowball(1, this));
getSnowball(chr.getTeam()).startEvent();
@@ -3930,13 +3932,13 @@ public class MapleMap {
public String getEventNPC() {
StringBuilder sb = new StringBuilder();
sb.append("Talk to ");
if (mapid == 60000) {
if (mapid == MapId.SOUTHPERRY) {
sb.append("Paul!");
} else if (mapid == 104000000) {
} else if (mapid == MapId.LITH_HARBOUR) {
sb.append("Jean!");
} else if (mapid == 200000000) {
} else if (mapid == MapId.ORBIS) {
sb.append("Martin!");
} else if (mapid == 220000000) {
} else if (mapid == MapId.LUDIBRIUM) {
sb.append("Tony!");
} else {
return null;
@@ -3945,15 +3947,16 @@ public class MapleMap {
}
public boolean hasEventNPC() {
return this.mapid == 60000 || this.mapid == 104000000 || this.mapid == 200000000 || this.mapid == 220000000;
return this.mapid == 60000 || this.mapid == MapId.LITH_HARBOUR || this.mapid == MapId.ORBIS || this.mapid == MapId.LUDIBRIUM;
}
public boolean isStartingEventMap() {
return this.mapid == 109040000 || this.mapid == 109020001 || this.mapid == 109010000 || this.mapid == 109030001 || this.mapid == 109030101;
return this.mapid == MapId.EVENT_PHYSICAL_FITNESS || this.mapid == MapId.EVENT_OX_QUIZ ||
this.mapid == MapId.EVENT_FIND_THE_JEWEL || this.mapid == MapId.EVENT_OLA_OLA_0 || this.mapid == MapId.EVENT_OLA_OLA_1;
}
public boolean isEventMap() {
return this.mapid >= 109010000 && this.mapid < 109050000 || this.mapid > 109050001 && this.mapid <= 109090000;
return this.mapid >= MapId.EVENT_FIND_THE_JEWEL && this.mapid < MapId.EVENT_WINNER || this.mapid > MapId.EVENT_EXIT && this.mapid <= 109090000;
}
public void setTimeMob(int id, String msg) {

View File

@@ -21,6 +21,8 @@
*/
package server.maps;
import constants.id.MapId;
/**
* @author Alan (SharpAceX)
*/
@@ -29,18 +31,18 @@ public enum MiniDungeonInfo {
//http://bbb.hidden-street.net/search_finder/mini%20dungeon
CAVE_OF_MUSHROOMS(105050100, 105050101, 30),
GOLEM_CASTLE_RUINS(105040304, 105040320, 34),
HILL_OF_SANDSTORMS(260020600, 260020630, 30),
HENESYS_PIG_FARM(100020000, 100020100, 30),
DRAKES_BLUE_CAVE(105090311, 105090320, 30),
DRUMMER_BUNNYS_LAIR(221023400, 221023401, 30),
THE_ROUND_TABLE_OF_KENTARUS(240020500, 240020512, 30),
THE_RESTORING_MEMORY(240040511, 240040800, 19),
NEWT_SECURED_ZONE(240040520, 240040900, 19),
PILLAGE_OF_TREASURE_ISLAND(251010402, 251010410, 30),
CRITICAL_ERROR(261020300, 261020301, 30),
LONGEST_RIDE_ON_BYEBYE_STATION(551030000, 551030001, 19);
CAVE_OF_MUSHROOMS(MapId.ANT_TUNNEL_2, MapId.CAVE_OF_MUSHROOMS_BASE, 30), // Horny Mushroom, Zombie Mushroom
GOLEM_CASTLE_RUINS(MapId.SLEEPY_DUNGEON_4, MapId.GOLEMS_CASTLE_RUINS_BASE, 34), // Stone Golem, Mixed Golem
HILL_OF_SANDSTORMS(MapId.SAHEL_2, MapId.HILL_OF_SANDSTORMS_BASE, 30), // Sand Rat
HENESYS_PIG_FARM(MapId.RAIN_FOREST_EAST_OF_HENESYS, MapId.HENESYS_PIG_FARM_BASE, 30), // Pig, Ribbon Pig
DRAKES_BLUE_CAVE(MapId.COLD_CRADLE, MapId.DRAKES_BLUE_CAVE_BASE, 30), // Dark Drake
DRUMMER_BUNNYS_LAIR(MapId.EOS_TOWER_76TH_TO_90TH_FLOOR, MapId.DRUMMER_BUNNYS_LAIR_BASE, 30), // Drumming Bunny
THE_ROUND_TABLE_OF_KENTARUS(MapId.BATTLEFIELD_OF_FIRE_AND_WATER, MapId.ROUND_TABLE_OF_KENTAURUS_BASE, 30), // Blue/Red/Black Kentaurus
THE_RESTORING_MEMORY(MapId.DRAGON_NEST_LEFT_BEHIND, MapId.RESTORING_MEMORY_BASE, 19), // Skelegon, Skelosaurus
NEWT_SECURED_ZONE(MapId.DESTROYED_DRAGON_NEST, MapId.NEWT_SECURED_ZONE_BASE, 19), // Jr. Newtie, Transforming Jr. Newtie
PILLAGE_OF_TREASURE_ISLAND(MapId.RED_NOSE_PIRATE_DEN_2, MapId.PILLAGE_OF_TREASURE_ISLAND_BASE, 30), // Captain
CRITICAL_ERROR(MapId.LAB_AREA_C1, MapId.CRITICAL_ERROR_BASE, 30), // Roid
LONGEST_RIDE_ON_BYEBYE_STATION(MapId.FANTASY_THEME_PARK_3, MapId.LONGEST_RIDE_ON_BYEBYE_STATION, 19); // Froscola, Jester Scarlion
private final int baseId;
private final int dungeonId;

View File

@@ -22,16 +22,16 @@
package server.maps;
public class SavedLocation {
private int mapid = 102000000;
private final int mapId;
private final int portal;
public SavedLocation(int mapid, int portal) {
this.mapid = mapid;
public SavedLocation(int mapId, int portal) {
this.mapId = mapId;
this.portal = portal;
}
public int getMapId() {
return mapid;
return mapId;
}
public int getPortal() {