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

@@ -23,7 +23,7 @@ package net.server.channel;
import client.Character;
import config.YamlConfig;
import constants.game.GameConstants;
import constants.id.MapId;
import net.netty.ChannelServer;
import net.packet.Packet;
import net.server.PlayerStorage;
@@ -499,7 +499,7 @@ public final class Channel {
}
if (slot < range) {
int slotMapid = (isPartyDojo ? 925030000 : 925020000) + (100 * (fromStage + 1)) + slot;
int slotMapid = (isPartyDojo ? MapId.DOJO_PARTY_BASE : MapId.DOJO_SOLO_BASE) + (100 * (fromStage + 1)) + slot;
int dojoSlot = getDojoSlot(slotMapid);
if (party != null) {
@@ -574,7 +574,7 @@ public final class Channel {
final int slot = getDojoSlot(dojoMapId);
final int delta = (dojoMapId) % 100;
final int stage = (dojoMapId / 100) % 100;
final int dojoBaseMap = (dojoMapId >= 925030000) ? 925030000 : 925020000;
final int dojoBaseMap = (dojoMapId >= MapId.DOJO_PARTY_BASE) ? MapId.DOJO_PARTY_BASE : MapId.DOJO_SOLO_BASE;
for (int i = 0; i < 5; i++) { //only 32 stages, but 38 maps
if (stage + i > 38) {
@@ -605,7 +605,7 @@ public final class Channel {
}
this.dojoTask[slot] = TimerManager.getInstance().schedule(() -> {
final int delta = (dojoMapId) % 100;
final int dojoBaseMap = (slot < 5) ? 925030000 : 925020000;
final int dojoBaseMap = (slot < 5) ? MapId.DOJO_PARTY_BASE : MapId.DOJO_SOLO_BASE;
Party party = null;
for (int i = 0; i < 5; i++) { //only 32 stages, but 38 maps
@@ -613,9 +613,9 @@ public final class Channel {
break;
}
MapleMap dojoExit = getMapFactory().getMap(925020002);
MapleMap dojoExit = getMapFactory().getMap(MapId.DOJO_EXIT);
for (Character chr : getMapFactory().getMap(dojoBaseMap + (100 * (stage + i)) + delta).getAllPlayers()) {
if (GameConstants.isDojo(chr.getMap().getId())) {
if (MapId.isDojo(chr.getMap().getId())) {
chr.changeMap(dojoExit);
}
party = chr.getParty();

View File

@@ -29,6 +29,7 @@ import client.status.MonsterStatusEffect;
import config.YamlConfig;
import constants.game.GameConstants;
import constants.id.ItemId;
import constants.id.MapId;
import constants.id.MobId;
import constants.skills.*;
import net.AbstractPacketHandler;
@@ -734,7 +735,7 @@ public abstract class AbstractDealDamageHandler extends AbstractPacketHandler {
calcDmgMax = (long) Math.ceil(calcDmgMax * dmgBuff);
}
if (chr.getMapId() >= 914000000 && chr.getMapId() <= 914000500) {
if (chr.getMapId() >= MapId.ARAN_TUTORIAL_START && chr.getMapId() <= MapId.ARAN_TUTORIAL_MAX) {
calcDmgMax += 80000; // Aran Tutorial.
}

View File

@@ -26,6 +26,7 @@ import client.Client;
import client.inventory.InventoryType;
import client.inventory.manipulator.InventoryManipulator;
import constants.id.ItemId;
import constants.id.MapId;
import net.AbstractPacketHandler;
import net.packet.InPacket;
import server.Trade;
@@ -121,17 +122,17 @@ public final class ChangeMapHandler extends AbstractPacketHandler {
warp = true;
}
} else if (divi == 20100) {
if (targetid == 104000000) {
if (targetid == MapId.LITH_HARBOUR) {
c.sendPacket(PacketCreator.lockUI(false));
c.sendPacket(PacketCreator.disableUI(false));
warp = true;
}
} else if (divi == 9130401) { // Only allow warp if player is already in Intro map, or else = hack
if (targetid == 130000000 || targetid / 100 == 9130401) { // Cygnus introduction
if (targetid == MapId.EREVE || targetid / 100 == 9130401) { // Cygnus introduction
warp = true;
}
} else if (divi == 9140900) { // Aran Introduction
if (targetid == 914090011 || targetid == 914090012 || targetid == 914090013 || targetid == 140090000) {
if (targetid == MapId.ARAN_TUTO_2 || targetid == MapId.ARAN_TUTO_3 || targetid == MapId.ARAN_TUTO_4 || targetid == MapId.ARAN_INTRO) {
warp = true;
}
} else if (divi / 10 == 1020) { // Adventurer movie clip Intro
@@ -139,7 +140,7 @@ public final class ChangeMapHandler extends AbstractPacketHandler {
warp = true;
}
} else if (divi / 10 >= 980040 && divi / 10 <= 980045) {
if (targetid == 980040000) {
if (targetid == MapId.WITCH_TOWER_ENTRANCE) {
warp = true;
}
}
@@ -157,9 +158,9 @@ public final class ChangeMapHandler extends AbstractPacketHandler {
return;
}
if (chr.getMapId() == 109040004) {
if (chr.getMapId() == MapId.FITNESS_EVENT_LAST) {
chr.getFitness().resetTimes();
} else if (chr.getMapId() == 109030003 || chr.getMapId() == 109030103) {
} else if (chr.getMapId() == MapId.OLA_EVENT_LAST_1 || chr.getMapId() == MapId.OLA_EVENT_LAST_2) {
chr.getOla().resetTimes();
}

View File

@@ -25,6 +25,7 @@ import client.Character;
import client.*;
import config.YamlConfig;
import constants.game.GameConstants;
import constants.id.MapId;
import constants.skills.*;
import net.packet.InPacket;
import server.StatEffect;
@@ -62,7 +63,7 @@ public final class CloseRangeDamageHandler extends AbstractDealDamageHandler {
{
return;
}
if (GameConstants.isDojo(chr.getMap().getId()) && attack.numAttacked > 0) {
if (MapId.isDojo(chr.getMap().getId()) && attack.numAttacked > 0) {
chr.setDojoEnergy(chr.getDojoEnergy() + YamlConfig.config.server.DOJO_ENERGY_ATK);
c.sendPacket(PacketCreator.getEnergy("energy", chr.getDojoEnergy()));
}

View File

@@ -26,6 +26,7 @@ import client.Client;
import client.FamilyEntitlement;
import client.FamilyEntry;
import config.YamlConfig;
import constants.id.MapId;
import net.AbstractPacketHandler;
import net.packet.InPacket;
import net.server.coordinator.world.InviteCoordinator;
@@ -61,7 +62,7 @@ public final class FamilyUseHandler extends AbstractPacketHandler {
if (targetMap != null) {
if (type == FamilyEntitlement.FAMILY_REUINION) {
if (!FieldLimit.CANNOTMIGRATE.check(ownMap.getFieldLimit()) && !FieldLimit.CANNOTVIPROCK.check(targetMap.getFieldLimit())
&& (targetMap.getForcedReturnId() == 999999999 || targetMap.getId() < 100000000) && targetMap.getEventInstance() == null) {
&& (targetMap.getForcedReturnId() == MapId.NONE || MapId.isMapleIsland(targetMap.getId())) && targetMap.getEventInstance() == null) {
c.getPlayer().changeMap(victim.getMap(), victim.getMap().getPortal(0));
useEntitlement(entry, type);
@@ -71,7 +72,7 @@ public final class FamilyUseHandler extends AbstractPacketHandler {
}
} else {
if (!FieldLimit.CANNOTMIGRATE.check(targetMap.getFieldLimit()) && !FieldLimit.CANNOTVIPROCK.check(ownMap.getFieldLimit())
&& (ownMap.getForcedReturnId() == 999999999 || ownMap.getId() < 100000000) && ownMap.getEventInstance() == null) {
&& (ownMap.getForcedReturnId() == MapId.NONE || MapId.isMapleIsland(ownMap.getId())) && ownMap.getEventInstance() == null) {
if (InviteCoordinator.hasInvite(InviteType.FAMILY_SUMMON, victim.getId())) {
c.sendPacket(PacketCreator.sendFamilyMessage(74, 0));

View File

@@ -25,6 +25,7 @@ import client.Character;
import client.Client;
import config.YamlConfig;
import constants.game.GameConstants;
import constants.id.MapId;
import net.AbstractPacketHandler;
import net.packet.InPacket;
import net.server.Server;
@@ -216,7 +217,7 @@ public final class GuildOperationHandler extends AbstractPacketHandler {
Server.getInstance().changeRank(mc.getGuildId(), cid, newRank);
break;
case 0x0f:
if (mc.getGuildId() <= 0 || mc.getGuildRank() != 1 || mc.getMapId() != 200000301) {
if (mc.getGuildId() <= 0 || mc.getGuildRank() != 1 || mc.getMapId() != MapId.GUILD_HQ) {
System.out.println("[Hack] " + mc.getName() + " tried to change guild emblem without being the guild leader.");
return;
}

View File

@@ -24,7 +24,7 @@ package net.server.channel.handlers;
import client.Character;
import client.*;
import config.YamlConfig;
import constants.game.GameConstants;
import constants.id.MapId;
import constants.skills.Bishop;
import constants.skills.Evan;
import constants.skills.FPArchMage;
@@ -57,7 +57,7 @@ public final class MagicDamageHandler extends AbstractDealDamageHandler {
}
}
if (GameConstants.isDojo(chr.getMap().getId()) && attack.numAttacked > 0) {
if (MapId.isDojo(chr.getMap().getId()) && attack.numAttacked > 0) {
chr.setDojoEnergy(chr.getDojoEnergy() + +YamlConfig.config.server.DOJO_ENERGY_ATK);
c.sendPacket(PacketCreator.getEnergy("energy", chr.getDojoEnergy()));
}

View File

@@ -29,8 +29,8 @@ import client.inventory.Item;
import client.inventory.WeaponType;
import client.inventory.manipulator.InventoryManipulator;
import config.YamlConfig;
import constants.game.GameConstants;
import constants.id.ItemId;
import constants.id.MapId;
import constants.inventory.ItemConstants;
import constants.skills.*;
import net.packet.InPacket;
@@ -65,7 +65,7 @@ public final class RangedAttackHandler extends AbstractDealDamageHandler {
}
}
if (GameConstants.isDojo(chr.getMap().getId()) && attack.numAttacked > 0) {
if (MapId.isDojo(chr.getMap().getId()) && attack.numAttacked > 0) {
chr.setDojoEnergy(chr.getDojoEnergy() + YamlConfig.config.server.DOJO_ENERGY_ATK);
c.sendPacket(PacketCreator.getEnergy("energy", chr.getDojoEnergy()));
}

View File

@@ -30,7 +30,7 @@ import client.inventory.manipulator.InventoryManipulator;
import client.status.MonsterStatus;
import client.status.MonsterStatusEffect;
import config.YamlConfig;
import constants.game.GameConstants;
import constants.id.MapId;
import constants.inventory.ItemConstants;
import constants.skills.Aran;
import net.AbstractPacketHandler;
@@ -189,7 +189,7 @@ public final class TakeDamageHandler extends AbstractPacketHandler {
}
//in dojo player cannot use pot, so deadly attacks should be turned off as well
if (is_deadly && GameConstants.isDojo(chr.getMap().getId()) && !YamlConfig.config.server.USE_DEADLY_DOJO) {
if (is_deadly && MapId.isDojo(chr.getMap().getId()) && !YamlConfig.config.server.USE_DEADLY_DOJO) {
damage = 0;
mpattack = 0;
}
@@ -273,7 +273,7 @@ public final class TakeDamageHandler extends AbstractPacketHandler {
} else {
map.broadcastGMMessage(chr, PacketCreator.damagePlayer(damagefrom, monsteridfrom, chr.getId(), damage, fake, direction, is_pgmr, pgmr, is_pg, oid, pos_x, pos_y), false);
}
if (GameConstants.isDojo(map.getId())) {
if (MapId.isDojo(map.getId())) {
chr.setDojoEnergy(chr.getDojoEnergy() + YamlConfig.config.server.DOJO_ENERGY_DMG);
c.sendPacket(PacketCreator.getEnergy("energy", chr.getDojoEnergy()));
}

View File

@@ -34,6 +34,7 @@ import client.processor.stat.AssignSPProcessor;
import config.YamlConfig;
import constants.game.GameConstants;
import constants.id.ItemId;
import constants.id.MapId;
import constants.inventory.ItemConstants;
import net.AbstractPacketHandler;
import net.packet.InPacket;
@@ -106,7 +107,7 @@ public final class UseCashItemHandler extends AbstractPacketHandler {
int mapId = p.readInt();
if (itemId / 1000 >= 5041 || mapId / 100000000 == player.getMapId() / 100000000) { //check vip or same continent
MapleMap targetMap = c.getChannelServer().getMapFactory().getMap(mapId);
if (!FieldLimit.CANNOTVIPROCK.check(targetMap.getFieldLimit()) && (targetMap.getForcedReturnId() == 999999999 || mapId < 100000000)) {
if (!FieldLimit.CANNOTVIPROCK.check(targetMap.getFieldLimit()) && (targetMap.getForcedReturnId() == MapId.NONE || MapId.isMapleIsland(mapId))) {
player.forceChangeMap(targetMap, targetMap.getRandomPlayerSpawnpoint());
success = true;
} else {
@@ -121,7 +122,7 @@ public final class UseCashItemHandler extends AbstractPacketHandler {
if (victim != null) {
MapleMap targetMap = victim.getMap();
if (!FieldLimit.CANNOTVIPROCK.check(targetMap.getFieldLimit()) && (targetMap.getForcedReturnId() == 999999999 || targetMap.getId() < 100000000)) {
if (!FieldLimit.CANNOTVIPROCK.check(targetMap.getFieldLimit()) && (targetMap.getForcedReturnId() == MapId.NONE || MapId.isMapleIsland(targetMap.getId()))) {
if (!victim.isGM() || victim.gmLevel() <= player.gmLevel()) { // thanks Yoboes for noticing non-GM's being unreachable through rocks
player.forceChangeMap(targetMap, targetMap.findClosestPlayerSpawnpoint(victim.getPosition()));
success = true;

View File

@@ -22,6 +22,7 @@ package net.server.coordinator.matchchecker.listener;
import client.Character;
import config.YamlConfig;
import constants.game.GameConstants;
import constants.id.MapId;
import net.packet.Packet;
import net.server.Server;
import net.server.coordinator.matchchecker.AbstractMatchCheckerListener;
@@ -92,7 +93,7 @@ public class MatchCheckerGuildCreation implements MatchCheckerListenerRecipe {
broadcastGuildCreationDismiss(matchPlayers);
return;
}
if (leader.getMapId() != 200000301) {
if (leader.getMapId() != MapId.GUILD_HQ) {
leader.dropMessage(1, "You cannot establish the creation of a new Guild outside of the Guild Headquarters.");
broadcastGuildCreationDismiss(matchPlayers);
return;

View File

@@ -22,6 +22,7 @@ package net.server.coordinator.partysearch;
import client.Character;
import client.Job;
import config.YamlConfig;
import constants.id.MapId;
import net.server.audit.locks.MonitoredLockType;
import net.server.audit.locks.MonitoredReadLock;
import net.server.audit.locks.MonitoredReentrantReadWriteLock;
@@ -76,9 +77,9 @@ public class PartySearchCoordinator {
mapLinks.put(mapid, neighborMaps);
for (Data neighbordata : mapdata.getChildren()) {
int neighborid = DataTool.getInt(neighbordata, 999999999);
int neighborid = DataTool.getInt(neighbordata, MapId.NONE);
if (neighborid != 999999999) {
if (neighborid != MapId.NONE) {
neighborMaps.add(neighborid);
}
}