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

@@ -37,6 +37,7 @@ import config.YamlConfig;
import constants.game.ExpTable;
import constants.game.GameConstants;
import constants.id.ItemId;
import constants.id.MapId;
import constants.id.MobId;
import constants.inventory.ItemConstants;
import constants.skills.*;
@@ -405,10 +406,10 @@ public class Character extends AbstractCharacterObject {
//to fix the map 0 lol
for (int i = 0; i < 5; i++) {
ret.trockmaps.add(999999999);
ret.trockmaps.add(MapId.NONE);
}
for (int i = 0; i < 10; i++) {
ret.viptrockmaps.add(999999999);
ret.viptrockmaps.add(MapId.NONE);
}
return ret;
@@ -583,7 +584,8 @@ public class Character extends AbstractCharacterObject {
String prop = eim.getProperty("groomId");
if (prop != null) {
return (Integer.parseInt(prop) == id || eim.getIntProperty("brideId") == id) && (mapid == 680000110 || mapid == 680000210);
return (Integer.parseInt(prop) == id || eim.getIntProperty("brideId") == id) &&
(mapid == MapId.CHAPEL_WEDDING_ALTAR || mapid == MapId.CATHEDRAL_WEDDING_ALTAR);
}
}
@@ -594,7 +596,7 @@ public class Character extends AbstractCharacterObject {
int pts = 0;
if (dojoPoints < 17000) {
pts = 1 + ((mapid - 1) / 100 % 100) / 6;
if (!GameConstants.isDojoPartyArea(this.getMapId())) {
if (!MapId.isPartyDojo(this.getMapId())) {
pts++;
}
this.dojoPoints += pts;
@@ -1401,7 +1403,7 @@ public class Character extends AbstractCharacterObject {
// will actually enter the map given as parameter, regardless of being an eventmap or whatnot
canWarpCounter++;
eventChangedMap(999999999);
eventChangedMap(MapId.NONE);
EventInstanceManager mapEim = target.getEventInstance();
if (mapEim != null) {
@@ -1443,10 +1445,10 @@ public class Character extends AbstractCharacterObject {
if (mbs.getKey() == BuffStat.MAP_PROTECTION) {
byte value = (byte) mbs.getValue().value;
if (value == 1 && ((returnMapid == 211000000 && thisMapid != 200082300) || returnMapid == 193000000)) {
if (value == 1 && ((returnMapid == MapId.EL_NATH && thisMapid != MapId.ORBIS_TOWER_BOTTOM) || returnMapid == MapId.INTERNET_CAFE)) {
return true; //protection from cold
} else {
return value == 2 && (returnMapid == 230000000 || thisMapid == 200082300); //breathing underwater
return value == 2 && (returnMapid == MapId.AQUARIUM || thisMapid == MapId.ORBIS_TOWER_BOTTOM); //breathing underwater
}
}
}
@@ -1456,7 +1458,8 @@ public class Character extends AbstractCharacterObject {
}
for (Item it : this.getInventory(InventoryType.EQUIPPED).list()) {
if ((it.getFlag() & ItemConstants.COLD) == ItemConstants.COLD && ((returnMapid == 211000000 && thisMapid != 200082300) || returnMapid == 193000000)) {
if ((it.getFlag() & ItemConstants.COLD) == ItemConstants.COLD &&
((returnMapid == MapId.EL_NATH && thisMapid != MapId.ORBIS_TOWER_BOTTOM) || returnMapid == MapId.INTERNET_CAFE)) {
return true; //protection from cold
}
}
@@ -1951,7 +1954,7 @@ public class Character extends AbstractCharacterObject {
if (ItemId.isNxCard(mapitem.getItemId()) || mapitem.getMeso() > 0 || ii.isConsumeOnPickup(mapitem.getItemId()) || (hasSpaceInventory = InventoryManipulator.checkSpace(client, mapitem.getItemId(), mItem.getQuantity(), mItem.getOwner()))) {
int mapId = this.getMapId();
if ((mapId > 209000000 && mapId < 209000016) || (mapId >= 990000500 && mapId <= 990000502)) {//happyville trees and guild PQ
if ((MapId.isSelfLootableOnly(mapId))) {//happyville trees and guild PQ
if (!mapitem.isPlayerDrop() || mapitem.getDropper().getObjectId() == client.getPlayer().getObjectId()) {
if (mapitem.getMeso() > 0) {
if (!mpcs.isEmpty()) {
@@ -6209,7 +6212,7 @@ public class Character extends AbstractCharacterObject {
}
public boolean attemptCatchFish(int baitLevel) {
return YamlConfig.config.server.USE_FISHING_SYSTEM && GameConstants.isFishingArea(mapid) &&
return YamlConfig.config.server.USE_FISHING_SYSTEM && MapId.isFishingArea(mapid) &&
this.getPosition().getY() > 0 &&
ItemConstants.isFishingChair(chair.get()) &&
this.getWorldServer().registerFisherPlayer(this, baitLevel);
@@ -7127,7 +7130,7 @@ public class Character extends AbstractCharacterObject {
ret.map = mapManager.getMap(ret.mapid);
if (ret.map == null) {
ret.map = mapManager.getMap(100000000);
ret.map = mapManager.getMap(MapId.HENESYS);
}
Portal portal = ret.map.getPortal(ret.initialSpawnPoint);
if (portal == null) {
@@ -7175,11 +7178,11 @@ public class Character extends AbstractCharacterObject {
}
}
while (vip < 10) {
ret.viptrockmaps.add(999999999);
ret.viptrockmaps.add(MapId.NONE);
vip++;
}
while (reg < 5) {
ret.trockmaps.add(999999999);
ret.trockmaps.add(MapId.NONE);
reg++;
}
}
@@ -7585,7 +7588,7 @@ public class Character extends AbstractCharacterObject {
break;
}
}
if (possesed > 0 && !GameConstants.isDojo(getMapId())) {
if (possesed > 0 && !MapId.isDojo(getMapId())) {
message("You have used a safety charm, so your EXP points have not been decreased.");
InventoryManipulator.removeById(client, ItemConstants.getInventoryType(charmID[i]), charmID[i], 1, true, false);
usedSafetyCharm = true;
@@ -8410,7 +8413,7 @@ public class Character extends AbstractCharacterObject {
if (map == null || (cashshop != null && cashshop.isOpened())) {
ps.setInt(21, mapid);
} else {
if (map.getForcedReturnId() != 999999999) {
if (map.getForcedReturnId() != MapId.NONE) {
ps.setInt(21, map.getForcedReturnId());
} else {
ps.setInt(21, getHp() < 1 ? map.getReturnMapId() : map.getId());
@@ -8418,7 +8421,7 @@ public class Character extends AbstractCharacterObject {
}
ps.setInt(22, meso.get());
ps.setInt(23, hpMpApUsed);
if (map == null || map.getId() == 610020000 || map.getId() == 610020001) { // reset to first spawnpoint on those maps
if (map == null || map.getId() == MapId.CRIMSONWOOD_VALLEY_1 || map.getId() == MapId.CRIMSONWOOD_VALLEY_2) { // reset to first spawnpoint on those maps
ps.setInt(24, 0);
} else {
Portal closest = map.findClosestPlayerSpawnpoint(getPosition());
@@ -8613,7 +8616,7 @@ public class Character extends AbstractCharacterObject {
// Vip teleport rocks
try (PreparedStatement psVip = con.prepareStatement("INSERT INTO trocklocations(characterid, mapid, vip) VALUES (?, ?, 0)")) {
for (int i = 0; i < getTrockSize(); i++) {
if (trockmaps.get(i) != 999999999) {
if (trockmaps.get(i) != MapId.NONE) {
psVip.setInt(1, getId());
psVip.setInt(2, trockmaps.get(i));
psVip.addBatch();
@@ -8625,7 +8628,7 @@ public class Character extends AbstractCharacterObject {
// Regular teleport rocks
try (PreparedStatement psReg = con.prepareStatement("INSERT INTO trocklocations(characterid, mapid, vip) VALUES (?, ?, 1)")) {
for (int i = 0; i < getVipTrockSize(); i++) {
if (viptrockmaps.get(i) != 999999999) {
if (viptrockmaps.get(i) != MapId.NONE) {
psReg.setInt(1, getId());
psReg.setInt(2, viptrockmaps.get(i));
psReg.addBatch();
@@ -10246,7 +10249,7 @@ public class Character extends AbstractCharacterObject {
}
public int getTrockSize() {
int ret = trockmaps.indexOf(999999999);
int ret = trockmaps.indexOf(MapId.NONE);
if (ret == -1) {
ret = 5;
}
@@ -10257,12 +10260,12 @@ public class Character extends AbstractCharacterObject {
public void deleteFromTrocks(int map) {
trockmaps.remove(Integer.valueOf(map));
while (trockmaps.size() < 10) {
trockmaps.add(999999999);
trockmaps.add(MapId.NONE);
}
}
public void addTrockMap() {
int index = trockmaps.indexOf(999999999);
int index = trockmaps.indexOf(MapId.NONE);
if (index != -1) {
trockmaps.set(index, getMapId());
}
@@ -10274,7 +10277,7 @@ public class Character extends AbstractCharacterObject {
}
public int getVipTrockSize() {
int ret = viptrockmaps.indexOf(999999999);
int ret = viptrockmaps.indexOf(MapId.NONE);
if (ret == -1) {
ret = 10;
@@ -10286,12 +10289,12 @@ public class Character extends AbstractCharacterObject {
public void deleteFromVipTrocks(int map) {
viptrockmaps.remove(Integer.valueOf(map));
while (viptrockmaps.size() < 10) {
viptrockmaps.add(999999999);
viptrockmaps.add(MapId.NONE);
}
}
public void addVipTrockMap() {
int index = viptrockmaps.indexOf(999999999);
int index = viptrockmaps.indexOf(MapId.NONE);
if (index != -1) {
viptrockmaps.set(index, getMapId());
}

View File

@@ -24,6 +24,7 @@ package client;
import client.inventory.InventoryType;
import config.YamlConfig;
import constants.game.GameConstants;
import constants.id.MapId;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.timeout.IdleStateEvent;
@@ -930,7 +931,7 @@ public class Client extends ChannelInboundHandlerAdapter {
if (player.getMap() != null) {
int mapId = player.getMapId();
player.getMap().removePlayer(player);
if (GameConstants.isDojo(mapId)) {
if (MapId.isDojo(mapId)) {
this.getChannelServer().freeDojoSectionIfEmpty(mapId);
}
}

View File

@@ -31,6 +31,7 @@ import client.command.commands.gm3.*;
import client.command.commands.gm4.*;
import client.command.commands.gm5.*;
import client.command.commands.gm6.*;
import constants.id.MapId;
import tools.FilePrinter;
import tools.Pair;
@@ -87,7 +88,7 @@ public class CommandsExecutor {
}
private void handleInternal(Client client, String message) {
if (client.getPlayer().getMapId() == 300000012) {
if (client.getPlayer().getMapId() == MapId.JAIL) {
client.getPlayer().yellowMessage("You do not have permission to use commands while in jail.");
return;
}

View File

@@ -26,6 +26,7 @@ package client.command.commands.gm0;
import client.Character;
import client.Client;
import client.command.Command;
import constants.id.MapId;
import server.events.gm.Event;
import server.maps.FieldLimit;
@@ -44,7 +45,7 @@ public class JoinEventCommand extends Command {
if (event.getLimit() > 0) {
player.saveLocation("EVENT");
if (event.getMapId() == 109080000 || event.getMapId() == 109060001) {
if (event.getMapId() == MapId.EVENT_COCONUT_HARVEST || event.getMapId() == MapId.EVENT_SNOWBALL_ENTRANCE) {
player.setTeam(event.getLimit() % 2);
}

View File

@@ -97,7 +97,7 @@ public class GotoCommand extends Command {
}
}
HashMap<String, Integer> gotomaps;
Map<String, Integer> gotomaps;
if (player.isGM()) {
gotomaps = new HashMap<>(GameConstants.GOTO_AREAS); // distinct map registry for GM/users suggested thanks to Vcoc
gotomaps.putAll(GameConstants.GOTO_TOWNS); // thanks Halcyon (UltimateMors) for pointing out duplicates on listed entries functionality

View File

@@ -26,6 +26,7 @@ package client.command.commands.gm2;
import client.Character;
import client.Client;
import client.command.Command;
import constants.id.MapId;
import server.maps.MapleMap;
import server.maps.Portal;
@@ -57,10 +58,8 @@ public class JailCommand extends Command {
if (victim != null) {
victim.addJailExpirationTime(MINUTES.toMillis(minutesJailed));
int mapid = 300000012;
if (victim.getMapId() != mapid) { // those gone to jail won't be changing map anyway
MapleMap target = c.getChannelServer().getMapFactory().getMap(mapid);
if (victim.getMapId() != MapId.JAIL) { // those gone to jail won't be changing map anyway
MapleMap target = c.getChannelServer().getMapFactory().getMap(MapId.JAIL);
Portal targetPortal = target.getPortal(0);
victim.saveLocationOnWarp();
victim.changeMap(target, targetPortal);

View File

@@ -28,6 +28,7 @@ import client.Client;
import client.command.Command;
import client.inventory.Item;
import constants.id.ItemId;
import constants.id.MapId;
import java.awt.*;
@@ -39,7 +40,7 @@ public class SeedCommand extends Command {
@Override
public void execute(Client c, String[] params) {
Character player = c.getPlayer();
if (player.getMapId() != 910010000) {
if (player.getMapId() != MapId.HENESYS_PQ) {
player.yellowMessage("This command can only be used in HPQ.");
return;
}

View File

@@ -25,6 +25,7 @@ import client.creator.CharacterFactory;
import client.creator.CharacterFactoryRecipe;
import client.inventory.InventoryType;
import constants.id.ItemId;
import constants.id.MapId;
/**
* @author RonanLana
@@ -42,7 +43,7 @@ public class BeginnerCreator extends CharacterFactory {
}
public static int createCharacter(Client c, String name, int face, int hair, int skin, int top, int bottom, int shoes, int weapon, int gender) {
int status = createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.BEGINNER, 1, 10000, top, bottom, shoes, weapon));
int status = createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.BEGINNER, 1, MapId.MUSHROOM_TOWN, top, bottom, shoes, weapon));
return status;
}
}

View File

@@ -25,6 +25,7 @@ import client.creator.CharacterFactory;
import client.creator.CharacterFactoryRecipe;
import client.inventory.InventoryType;
import constants.id.ItemId;
import constants.id.MapId;
/**
* @author RonanLana
@@ -42,7 +43,7 @@ public class LegendCreator extends CharacterFactory {
}
public static int createCharacter(Client c, String name, int face, int hair, int skin, int top, int bottom, int shoes, int weapon, int gender) {
int status = createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.LEGEND, 1, 914000000, top, bottom, shoes, weapon));
int status = createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.LEGEND, 1, MapId.ARAN_TUTORIAL_START, top, bottom, shoes, weapon));
return status;
}
}

View File

@@ -25,6 +25,7 @@ import client.creator.CharacterFactory;
import client.creator.CharacterFactoryRecipe;
import client.inventory.InventoryType;
import constants.id.ItemId;
import constants.id.MapId;
/**
* @author RonanLana
@@ -42,7 +43,7 @@ public class NoblesseCreator extends CharacterFactory {
}
public static int createCharacter(Client c, String name, int face, int hair, int skin, int top, int bottom, int shoes, int weapon, int gender) {
int status = createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.NOBLESSE, 1, 130030000, top, bottom, shoes, weapon));
int status = createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.NOBLESSE, 1, MapId.STARTING_MAP_NOBLESSE, top, bottom, shoes, weapon));
return status;
}
}

View File

@@ -26,6 +26,7 @@ import client.creator.CharacterFactoryRecipe;
import client.inventory.InventoryType;
import client.inventory.Item;
import constants.id.ItemId;
import constants.id.MapId;
import server.ItemInformationProvider;
/**
@@ -71,6 +72,6 @@ public class BowmanCreator extends CharacterFactory {
}
public static int createCharacter(Client c, String name, int face, int hair, int skin, int gender, int improveSp) {
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.BOWMAN, 30, 100000000, equips[gender], equips[2 + gender], equips[4], weapons[0]));
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.BOWMAN, 30, MapId.HENESYS, equips[gender], equips[2 + gender], equips[4], weapons[0]));
}
}

View File

@@ -28,6 +28,7 @@ import client.creator.CharacterFactoryRecipe;
import client.inventory.InventoryType;
import client.inventory.Item;
import constants.id.ItemId;
import constants.id.MapId;
import constants.skills.Magician;
import server.ItemInformationProvider;
@@ -93,6 +94,6 @@ public class MagicianCreator extends CharacterFactory {
}
public static int createCharacter(Client c, String name, int face, int hair, int skin, int gender, int improveSp) {
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.MAGICIAN, 30, 101000000, equips[gender], equips[2 + gender], equips[4], weapons[0], gender, improveSp));
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.MAGICIAN, 30, MapId.ELLINIA, equips[gender], equips[2 + gender], equips[4], weapons[0], gender, improveSp));
}
}

View File

@@ -26,6 +26,7 @@ import client.creator.CharacterFactoryRecipe;
import client.inventory.InventoryType;
import client.inventory.Item;
import constants.id.ItemId;
import constants.id.MapId;
import server.ItemInformationProvider;
/**
@@ -74,6 +75,6 @@ public class PirateCreator extends CharacterFactory {
}
public static int createCharacter(Client c, String name, int face, int hair, int skin, int gender, int improveSp) {
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.PIRATE, 30, 120000000, equips[gender], equips[2 + gender], equips[4], weapons[0]));
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.PIRATE, 30, MapId.NAUTILUS_HARBOR, equips[gender], equips[2 + gender], equips[4], weapons[0]));
}
}

View File

@@ -26,6 +26,7 @@ import client.creator.CharacterFactoryRecipe;
import client.inventory.InventoryType;
import client.inventory.Item;
import constants.id.ItemId;
import constants.id.MapId;
import server.ItemInformationProvider;
/**
@@ -73,6 +74,6 @@ public class ThiefCreator extends CharacterFactory {
}
public static int createCharacter(Client c, String name, int face, int hair, int skin, int gender, int improveSp) {
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.THIEF, 30, 103000000, equips[gender], equips[2 + gender], equips[4], weapons[0]));
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.THIEF, 30, MapId.KERNING_CITY, equips[gender], equips[2 + gender], equips[4], weapons[0]));
}
}

View File

@@ -28,6 +28,7 @@ import client.creator.CharacterFactoryRecipe;
import client.inventory.InventoryType;
import client.inventory.Item;
import constants.id.ItemId;
import constants.id.MapId;
import constants.skills.Warrior;
import server.ItemInformationProvider;
@@ -93,6 +94,6 @@ public class WarriorCreator extends CharacterFactory {
}
public static int createCharacter(Client c, String name, int face, int hair, int skin, int gender, int improveSp) {
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.WARRIOR, 30, 102000000, equips[gender], equips[2 + gender], equips[4], weapons[0], gender, improveSp));
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.WARRIOR, 30, MapId.PERION, equips[gender], equips[2 + gender], equips[4], weapons[0], gender, improveSp));
}
}