PlayerNPC patch + Wedding ring effects + Bypassable PIN/PIC + SP cap
Fixed an issue with delayed item pickups. Fixed ClearSlot command not removing rechargeables from inventory. Fixed Resurrection and Hyper Body animation effect not working for other players. Implemented bypassable PIN/PIC, applied on accounts after a successful authentication, remaining active while activity is detected for that account. Fixed anti-multiclient system not properly registering players logged in via all-chars-view. Fixed cases where players still could gain EXP from much higher-leveled mobs if they were on an event instance. Optimized scroll result method performance. Added a server flag for SP cap limit on the player's current job (missing amount are reobtained after changing jobs). PlayerNPCs now have overridable scripts. Fixed some mapobject issues with PlayerNPCs, potencially leading to disappearing from maps in certain circumstances. Fixed SpawnAllPnpcs command not properly spawning all PlayersNPCs. Added extra info on Abdula, now stating whether a book can be obtained from questline or not. Fixed marriage ring effects. Fixed some cases where marriage rings were being able to be sent out from the character owner. Fixed Duey allowing send untradeable items. New tool: MapleWorldmapChecker. It reads Map.wz XMLs, fetching mapids not properly referenced on the worldmap nodes.
This commit is contained in:
+132
-13
@@ -159,6 +159,8 @@ import server.life.MobSkillFactory;
|
||||
import server.maps.MapleMapItem;
|
||||
import net.server.audit.locks.MonitoredLockType;
|
||||
import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
|
||||
import server.movement.AbsoluteLifeMovement;
|
||||
import server.movement.LifeMovementFragment;
|
||||
|
||||
public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
private static final MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
@@ -804,10 +806,14 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
blockCashShop = !blockCashShop;
|
||||
}
|
||||
|
||||
public void setClient(MapleClient c) {
|
||||
this.client = c;
|
||||
}
|
||||
|
||||
public void newClient(MapleClient c) {
|
||||
this.loggedIn = true;
|
||||
c.setAccountName(this.client.getAccountName());//No null's for accountName
|
||||
this.client = c;
|
||||
this.setClient(c);
|
||||
this.map = c.getChannelServer().getMapFactory().getMap(getMapId());
|
||||
MaplePortal portal = map.findClosestPlayerSpawnpoint(getPosition());
|
||||
if (portal == null) {
|
||||
@@ -833,7 +839,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
announce(MaplePacketCreator.getGMEffect(0x10, (byte) 0));
|
||||
List<MapleBuffStat> dsstat = Collections.singletonList(MapleBuffStat.DARKSIGHT);
|
||||
getMap().broadcastGMMessage(this, MaplePacketCreator.cancelForeignBuff(id, dsstat), false);
|
||||
getMap().broadcastMessage(this, MaplePacketCreator.spawnPlayerMapObject(this), false);
|
||||
getMap().broadcastSpawnPlayerMapObjectMessage(this, this, false);
|
||||
|
||||
for(MapleSummon ms: this.getSummonsValues()) {
|
||||
getMap().broadcastNONGMMessage(this, MaplePacketCreator.spawnSummon(ms, false), false);
|
||||
@@ -842,9 +848,8 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
this.hidden = true;
|
||||
announce(MaplePacketCreator.getGMEffect(0x10, (byte) 1));
|
||||
if (!login) {
|
||||
getMap().broadcastMessage(this, MaplePacketCreator.removePlayerFromMap(getId()), false);
|
||||
getMap().broadcastNONGMMessage(this, MaplePacketCreator.removePlayerFromMap(getId()), false);
|
||||
}
|
||||
getMap().broadcastGMMessage(this, MaplePacketCreator.spawnPlayerMapObject(this), false);
|
||||
List<Pair<MapleBuffStat, Integer>> ldsstat = Collections.singletonList(new Pair<MapleBuffStat, Integer>(MapleBuffStat.DARKSIGHT, 0));
|
||||
getMap().broadcastGMMessage(this, MaplePacketCreator.giveForeignBuff(id, ldsstat), false);
|
||||
for (MapleMonster mon : this.getControlledMonsters()) {
|
||||
@@ -1034,8 +1039,15 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
if (newJob.getId() % 10 == 2) {
|
||||
spGain += 2;
|
||||
}
|
||||
|
||||
if (ServerConstants.USE_ENFORCE_JOB_SP_RANGE) {
|
||||
spGain = getChangedJobSp(newJob);
|
||||
}
|
||||
}
|
||||
|
||||
if (spGain > 0) {
|
||||
gainSp(spGain, GameConstants.getSkillBook(newJob.getId()), true);
|
||||
}
|
||||
gainSp(spGain, GameConstants.getSkillBook(newJob.getId()), true);
|
||||
|
||||
if (newJob.getId() % 10 > 1) {
|
||||
gainAp(5, true);
|
||||
@@ -1160,6 +1172,19 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
}
|
||||
|
||||
public void broadcastStance(int newStance) {
|
||||
setStance(newStance);
|
||||
broadcastStance();
|
||||
}
|
||||
|
||||
public void broadcastStance() {
|
||||
AbsoluteLifeMovement alm = new AbsoluteLifeMovement(0, getPosition(), 0, getStance());
|
||||
alm.setPixelsPerSecond(new Point(0, 0));
|
||||
List<LifeMovementFragment> moveUpdate = Collections.singletonList((LifeMovementFragment) alm);
|
||||
|
||||
map.broadcastMessage(this, MaplePacketCreator.movePlayer(id, moveUpdate), false);
|
||||
}
|
||||
|
||||
public MapleMap getWarpMap(int map) {
|
||||
MapleMap target;
|
||||
EventInstanceManager eim = getEventInstance();
|
||||
@@ -1743,7 +1768,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
|
||||
if (ob instanceof MapleMapItem) {
|
||||
MapleMapItem mapitem = (MapleMapItem) ob;
|
||||
if(Server.getInstance().getCurrentTime() - mapitem.getDropTime() < 900 || !mapitem.canBePickedBy(this)) {
|
||||
if (System.currentTimeMillis() - mapitem.getDropTime() < 900 || !mapitem.canBePickedBy(this)) {
|
||||
client.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
@@ -2585,7 +2610,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
|
||||
public void equipChanged() {
|
||||
getMap().broadcastMessage(this, MaplePacketCreator.updateCharLook(this), false);
|
||||
getMap().broadcastUpdateCharLookMessage(this, this);
|
||||
equipchanged = true;
|
||||
updateLocalStats();
|
||||
if (getMessenger() != null) {
|
||||
@@ -3939,8 +3964,14 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
extraRecInterval = effect.getMpRRate();
|
||||
}
|
||||
|
||||
stopExtraTask();
|
||||
startExtraTask(extraHpRec, extraMpRec, extraRecInterval); // HP & MP sharing the same task holder
|
||||
chrLock.lock();
|
||||
try {
|
||||
stopExtraTask();
|
||||
startExtraTask(extraHpRec, extraMpRec, extraRecInterval); // HP & MP sharing the same task holder
|
||||
} finally {
|
||||
chrLock.unlock();
|
||||
}
|
||||
|
||||
} else if (effect.isMapChair()) {
|
||||
startChairTask();
|
||||
}
|
||||
@@ -4504,6 +4535,18 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
return (inventory[MapleInventoryType.EQUIPPED.ordinal()].findById(itemid) != null);
|
||||
}
|
||||
|
||||
public boolean haveWeddingRing() {
|
||||
int rings[] = {1112806, 1112803, 1112807, 1112809};
|
||||
|
||||
for (int ringid : rings) {
|
||||
if (haveItemWithId(ringid, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getItemQuantity(int itemid, boolean checkEquipped) {
|
||||
int possesed = inventory[ItemConstants.getInventoryType(itemid).ordinal()].countById(itemid);
|
||||
if (checkEquipped) {
|
||||
@@ -5572,7 +5615,85 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
hpDecreaseTask.cancel(false);
|
||||
}
|
||||
}
|
||||
|
||||
private int getChangedJobSp(MapleJob newJob) {
|
||||
int curSp = getUsedSp(newJob) + getJobRemainingSp(newJob);
|
||||
int spGain = 0;
|
||||
int expectedSp = getJobLevelSp(level - 10, newJob, GameConstants.getJobBranch(newJob));
|
||||
if (curSp < expectedSp) {
|
||||
spGain += (expectedSp - curSp);
|
||||
}
|
||||
|
||||
return getSpGain(spGain, curSp, job);
|
||||
}
|
||||
|
||||
private int getUsedSp(MapleJob job) {
|
||||
int jobId = job.getId();
|
||||
int spUsed = 0;
|
||||
|
||||
for (Entry<Skill, SkillEntry> s : this.getSkills().entrySet()) {
|
||||
Skill skill = s.getKey();
|
||||
if (GameConstants.isInJobTree(skill.getId(), jobId) && !skill.isBeginnerSkill()) {
|
||||
spUsed += s.getValue().skillevel;
|
||||
}
|
||||
}
|
||||
|
||||
return spUsed;
|
||||
}
|
||||
|
||||
private int getJobLevelSp(int level, MapleJob job, int jobBranch) {
|
||||
if (getJobStyleInternal(job.getId(), (byte) 0x40) == MapleJob.MAGICIAN) {
|
||||
level += 2; // starts earlier, level 8
|
||||
}
|
||||
|
||||
return 3 * level + GameConstants.getChangeJobSpUpgrade(jobBranch);
|
||||
}
|
||||
|
||||
private int getJobMaxSp(MapleJob job) {
|
||||
int jobBranch = GameConstants.getJobBranch(job);
|
||||
int jobRange = GameConstants.getJobUpgradeLevelRange(jobBranch);
|
||||
return getJobLevelSp(jobRange, job, jobBranch);
|
||||
}
|
||||
|
||||
private int getJobRemainingSp(MapleJob job) {
|
||||
int skillBook = GameConstants.getSkillBook(job.getId());
|
||||
|
||||
int ret = 0;
|
||||
for (int i = 0; i <= skillBook; i++) {
|
||||
ret += this.getRemainingSp(i);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private int getSpGain(int spGain, MapleJob job) {
|
||||
int curSp = getUsedSp(job) + getJobRemainingSp(job);
|
||||
return getSpGain(spGain, curSp, job);
|
||||
}
|
||||
|
||||
private int getSpGain(int spGain, int curSp, MapleJob job) {
|
||||
int maxSp = getJobMaxSp(job);
|
||||
|
||||
spGain = Math.min(spGain, maxSp - curSp);
|
||||
int jobBranch = GameConstants.getJobBranch(job);
|
||||
return spGain;
|
||||
}
|
||||
|
||||
private void levelUpGainSp() {
|
||||
if (GameConstants.getJobBranch(job) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int spGain = 3;
|
||||
if (ServerConstants.USE_ENFORCE_JOB_SP_RANGE && !GameConstants.hasSPTable(job)) {
|
||||
spGain = getSpGain(spGain, job);
|
||||
}
|
||||
|
||||
if (spGain > 0) {
|
||||
gainSp(spGain, GameConstants.getSkillBook(job.getId()), true);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void levelUp(boolean takeexp) {
|
||||
Skill improvingMaxHP = null;
|
||||
Skill improvingMaxMP = null;
|
||||
@@ -5693,9 +5814,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
level = maxClassLevel; //To prevent levels past the maximum
|
||||
}
|
||||
|
||||
if (job.getId() % 1000 > 0) {
|
||||
gainSp(3, GameConstants.getSkillBook(job.getId()), true);
|
||||
}
|
||||
levelUpGainSp();
|
||||
|
||||
effLock.lock();
|
||||
statWlock.lock();
|
||||
@@ -8835,7 +8954,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
@Override
|
||||
public void sendSpawnData(MapleClient client) {
|
||||
if (!this.isHidden() || client.getPlayer().gmLevel() > 1) {
|
||||
client.announce(MaplePacketCreator.spawnPlayerMapObject(this));
|
||||
client.announce(MaplePacketCreator.spawnPlayerMapObject(client, this, false));
|
||||
|
||||
if(hasBuffFromSourceid(getJobMapChair(job))) {
|
||||
client.announce(MaplePacketCreator.giveForeignChairSkillEffect(id));
|
||||
|
||||
@@ -79,6 +79,7 @@ import server.quest.MapleQuest;
|
||||
|
||||
import net.server.audit.locks.MonitoredLockType;
|
||||
import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
|
||||
import net.server.coordinator.MapleLoginBypassCoordinator;
|
||||
|
||||
public class MapleClient {
|
||||
|
||||
@@ -473,6 +474,7 @@ public class MapleClient {
|
||||
}
|
||||
if (pin.equals(other)) {
|
||||
pinattempt = 0;
|
||||
MapleLoginBypassCoordinator.getInstance().registerLoginBypassEntry(getNibbleHWID(), accId, false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -499,7 +501,7 @@ public class MapleClient {
|
||||
}
|
||||
|
||||
public boolean checkPic(String other) {
|
||||
if(!ServerConstants.ENABLE_PIC) return true;
|
||||
if(!(ServerConstants.ENABLE_PIC && !canBypassPic())) return true;
|
||||
|
||||
picattempt++;
|
||||
if (picattempt > 5) {
|
||||
@@ -507,6 +509,7 @@ public class MapleClient {
|
||||
}
|
||||
if (pic.equals(other)) {
|
||||
picattempt = 0;
|
||||
MapleLoginBypassCoordinator.getInstance().registerLoginBypassEntry(getNibbleHWID(), accId, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -743,7 +746,7 @@ public class MapleClient {
|
||||
public int getAccID() {
|
||||
return accId;
|
||||
}
|
||||
|
||||
|
||||
public void updateLoginState(int newstate) {
|
||||
try {
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
@@ -1051,6 +1054,10 @@ public class MapleClient {
|
||||
public String getHWID() {
|
||||
return hwid;
|
||||
}
|
||||
|
||||
public void setHWID(String hwid) {
|
||||
this.hwid = hwid;
|
||||
}
|
||||
|
||||
public Set<String> getMacs() {
|
||||
return Collections.unmodifiableSet(macs);
|
||||
@@ -1232,8 +1239,8 @@ public class MapleClient {
|
||||
public void setCharacterSlots(byte slots) {
|
||||
characterSlots = slots;
|
||||
}
|
||||
|
||||
public synchronized boolean gainCharacterSlot() {
|
||||
|
||||
public synchronized boolean gainCharacterSlot() {
|
||||
if (characterSlots < 15) {
|
||||
Connection con = null;
|
||||
try {
|
||||
@@ -1462,4 +1469,16 @@ public class MapleClient {
|
||||
public void enableCSActions() {
|
||||
announce(MaplePacketCreator.enableCSUse(player));
|
||||
}
|
||||
|
||||
public String getNibbleHWID() {
|
||||
return (String) session.getAttribute(MapleClient.CLIENT_NIBBLEHWID);
|
||||
}
|
||||
|
||||
public boolean canBypassPin() {
|
||||
return MapleLoginBypassCoordinator.getInstance().canLoginBypass(getNibbleHWID(), accId, false);
|
||||
}
|
||||
|
||||
public boolean canBypassPic() {
|
||||
return MapleLoginBypassCoordinator.getInstance().canLoginBypass(getNibbleHWID(), accId, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,6 +180,7 @@ public class CommandsExecutor {
|
||||
addCommand("dex", StatDexCommand.class);
|
||||
addCommand("int", StatIntCommand.class);
|
||||
addCommand("luk", StatLukCommand.class);
|
||||
addCommand("enableauth", EnableAuthCommand.class);
|
||||
|
||||
commandsNameDesc.add(levelCommandsCursor);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,10 @@ import client.command.Command;
|
||||
import client.processor.BuybackProcessor;
|
||||
|
||||
public class BuyBackCommand extends Command {
|
||||
{
|
||||
setDescription("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(MapleClient c, String[] params) {
|
||||
if (params.length < 1) {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server, commands OdinMS-based
|
||||
Copyleft (L) 2016 - 2018 RonanLana
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
@Author: Arthur L - Refactored command content into modules
|
||||
*/
|
||||
package client.command.commands.gm0;
|
||||
|
||||
import client.command.Command;
|
||||
import client.MapleClient;
|
||||
import net.server.coordinator.MapleLoginBypassCoordinator;
|
||||
|
||||
public class EnableAuthCommand extends Command {
|
||||
{
|
||||
setDescription("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(MapleClient c, String[] params) {
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
MapleLoginBypassCoordinator.getInstance().unregisterLoginBypassEntry(c.getNibbleHWID(), c.getAccID());
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,31 +49,31 @@ public class ClearSlotCommand extends Command {
|
||||
Item tempItem = c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem((byte) i);
|
||||
if (tempItem == null)
|
||||
continue;
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.EQUIP, (byte) i, tempItem.getQuantity(), false, true);
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.EQUIP, (byte) i, tempItem.getQuantity(), false, false);
|
||||
}
|
||||
for (int i = 0; i < 101; i++) {
|
||||
Item tempItem = c.getPlayer().getInventory(MapleInventoryType.USE).getItem((byte) i);
|
||||
if (tempItem == null)
|
||||
continue;
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (byte) i, tempItem.getQuantity(), false, true);
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (byte) i, tempItem.getQuantity(), false, false);
|
||||
}
|
||||
for (int i = 0; i < 101; i++) {
|
||||
Item tempItem = c.getPlayer().getInventory(MapleInventoryType.ETC).getItem((byte) i);
|
||||
if (tempItem == null)
|
||||
continue;
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.ETC, (byte) i, tempItem.getQuantity(), false, true);
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.ETC, (byte) i, tempItem.getQuantity(), false, false);
|
||||
}
|
||||
for (int i = 0; i < 101; i++) {
|
||||
Item tempItem = c.getPlayer().getInventory(MapleInventoryType.SETUP).getItem((byte) i);
|
||||
if (tempItem == null)
|
||||
continue;
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.SETUP, (byte) i, tempItem.getQuantity(), false, true);
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.SETUP, (byte) i, tempItem.getQuantity(), false, false);
|
||||
}
|
||||
for (int i = 0; i < 101; i++) {
|
||||
Item tempItem = c.getPlayer().getInventory(MapleInventoryType.CASH).getItem((byte) i);
|
||||
if (tempItem == null)
|
||||
continue;
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.CASH, (byte) i, tempItem.getQuantity(), false, true);
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.CASH, (byte) i, tempItem.getQuantity(), false, false);
|
||||
}
|
||||
player.yellowMessage("All Slots Cleared.");
|
||||
break;
|
||||
@@ -82,7 +82,7 @@ public class ClearSlotCommand extends Command {
|
||||
Item tempItem = c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem((byte) i);
|
||||
if (tempItem == null)
|
||||
continue;
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.EQUIP, (byte) i, tempItem.getQuantity(), false, true);
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.EQUIP, (byte) i, tempItem.getQuantity(), false, false);
|
||||
}
|
||||
player.yellowMessage("Equipment Slot Cleared.");
|
||||
break;
|
||||
@@ -91,7 +91,7 @@ public class ClearSlotCommand extends Command {
|
||||
Item tempItem = c.getPlayer().getInventory(MapleInventoryType.USE).getItem((byte) i);
|
||||
if (tempItem == null)
|
||||
continue;
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (byte) i, tempItem.getQuantity(), false, true);
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (byte) i, tempItem.getQuantity(), false, false);
|
||||
}
|
||||
player.yellowMessage("Use Slot Cleared.");
|
||||
break;
|
||||
@@ -100,7 +100,7 @@ public class ClearSlotCommand extends Command {
|
||||
Item tempItem = c.getPlayer().getInventory(MapleInventoryType.SETUP).getItem((byte) i);
|
||||
if (tempItem == null)
|
||||
continue;
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.SETUP, (byte) i, tempItem.getQuantity(), false, true);
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.SETUP, (byte) i, tempItem.getQuantity(), false, false);
|
||||
}
|
||||
player.yellowMessage("Set-Up Slot Cleared.");
|
||||
break;
|
||||
@@ -109,7 +109,7 @@ public class ClearSlotCommand extends Command {
|
||||
Item tempItem = c.getPlayer().getInventory(MapleInventoryType.ETC).getItem((byte) i);
|
||||
if (tempItem == null)
|
||||
continue;
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.ETC, (byte) i, tempItem.getQuantity(), false, true);
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.ETC, (byte) i, tempItem.getQuantity(), false, false);
|
||||
}
|
||||
player.yellowMessage("ETC Slot Cleared.");
|
||||
break;
|
||||
@@ -118,7 +118,7 @@ public class ClearSlotCommand extends Command {
|
||||
Item tempItem = c.getPlayer().getInventory(MapleInventoryType.CASH).getItem((byte) i);
|
||||
if (tempItem == null)
|
||||
continue;
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.CASH, (byte) i, tempItem.getQuantity(), false, true);
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.CASH, (byte) i, tempItem.getQuantity(), false, false);
|
||||
}
|
||||
player.yellowMessage("Cash Slot Cleared.");
|
||||
break;
|
||||
|
||||
@@ -56,5 +56,6 @@ public class MaxSkillCommand extends Command {
|
||||
player.changeSkillLevel(skill, (byte) -1, -1, -1);
|
||||
}
|
||||
|
||||
player.yellowMessage("Skills maxed out.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,10 +31,12 @@ import provider.MapleDataProvider;
|
||||
import provider.MapleDataProviderFactory;
|
||||
import provider.MapleDataTool;
|
||||
import server.MapleItemInformationProvider;
|
||||
import server.quest.MapleQuest;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.Pair;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class SearchCommand extends Command {
|
||||
private static MapleData npcStringData;
|
||||
@@ -65,7 +67,7 @@ public class SearchCommand extends Command {
|
||||
long start = System.currentTimeMillis();//for the lulz
|
||||
MapleData data = null;
|
||||
if (!params[0].equalsIgnoreCase("ITEM")) {
|
||||
boolean mapSearch = false;
|
||||
int searchType = 0;
|
||||
|
||||
if (params[0].equalsIgnoreCase("NPC")) {
|
||||
data = npcStringData;
|
||||
@@ -75,21 +77,24 @@ public class SearchCommand extends Command {
|
||||
data = skillStringData;
|
||||
} else if (params[0].equalsIgnoreCase("MAP")) {
|
||||
data = mapStringData;
|
||||
mapSearch = true;
|
||||
searchType = 1;
|
||||
} else if (params[0].equalsIgnoreCase("QUEST")) {
|
||||
data = mapStringData;
|
||||
searchType = 2;
|
||||
} else {
|
||||
sb.append("#bInvalid search.\r\nSyntax: '!search [type] [name]', where [type] is MAP, NPC, ITEM, MOB, or SKILL.");
|
||||
sb.append("#bInvalid search.\r\nSyntax: '!search [type] [name]', where [type] is MAP, QUEST, NPC, ITEM, MOB, or SKILL.");
|
||||
}
|
||||
if (data != null) {
|
||||
String name;
|
||||
|
||||
if (!mapSearch) {
|
||||
if (searchType == 0) {
|
||||
for (MapleData searchData : data.getChildren()) {
|
||||
name = MapleDataTool.getString(searchData.getChildByPath("name"), "NO-NAME");
|
||||
if (name.toLowerCase().contains(search.toLowerCase())) {
|
||||
sb.append("#b").append(Integer.parseInt(searchData.getName())).append("#k - #r").append(name).append("\r\n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if (searchType == 1) {
|
||||
String mapName, streetName;
|
||||
|
||||
for (MapleData searchDataDir : data.getChildren()) {
|
||||
@@ -102,6 +107,16 @@ public class SearchCommand extends Command {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (MapleQuest mq : MapleQuest.getMatchedQuests(search)) {
|
||||
sb.append("#b").append(mq.getId()).append("#k - #r");
|
||||
|
||||
String parentName = mq.getParentName();
|
||||
if (!parentName.isEmpty()) {
|
||||
sb.append(parentName).append(" - ");
|
||||
}
|
||||
sb.append(mq.getName()).append("\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -28,7 +28,9 @@ import client.MapleClient;
|
||||
import client.MapleCharacter;
|
||||
import server.life.MapleMonster;
|
||||
import server.life.MapleNPC;
|
||||
import server.life.MaplePlayerNPC;
|
||||
import server.maps.MapleMapObject;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class WhereaMiCommand extends Command {
|
||||
{
|
||||
@@ -38,23 +40,54 @@ public class WhereaMiCommand extends Command {
|
||||
@Override
|
||||
public void execute(MapleClient c, String[] params) {
|
||||
MapleCharacter player = c.getPlayer();
|
||||
|
||||
HashSet<MapleCharacter> chars = new HashSet<>();
|
||||
HashSet<MapleNPC> npcs = new HashSet<>();
|
||||
HashSet<MaplePlayerNPC> playernpcs = new HashSet<>();
|
||||
HashSet<MapleMonster> mobs = new HashSet<>();
|
||||
|
||||
for (MapleMapObject mmo : player.getMap().getMapObjects()) {
|
||||
if (mmo instanceof MapleNPC) {
|
||||
MapleNPC npc = (MapleNPC) mmo;
|
||||
npcs.add(npc);
|
||||
} else if (mmo instanceof MapleCharacter) {
|
||||
MapleCharacter mc = (MapleCharacter) mmo;
|
||||
chars.add(mc);
|
||||
} else if (mmo instanceof MapleMonster) {
|
||||
MapleMonster mob = (MapleMonster) mmo;
|
||||
if (mob.isAlive()) {
|
||||
mobs.add(mob);
|
||||
}
|
||||
} else if (mmo instanceof MaplePlayerNPC) {
|
||||
MaplePlayerNPC npc = (MaplePlayerNPC) mmo;
|
||||
playernpcs.add(npc);
|
||||
}
|
||||
}
|
||||
|
||||
player.yellowMessage("Map ID: " + player.getMap().getId());
|
||||
|
||||
player.yellowMessage("Players on this map:");
|
||||
for (MapleMapObject mmo : player.getMap().getPlayers()) {
|
||||
MapleCharacter chr = (MapleCharacter) mmo;
|
||||
for (MapleCharacter chr : chars) {
|
||||
player.dropMessage(5, ">> " + chr.getName() + " - " + chr.getId() + " - Oid: " + chr.getObjectId());
|
||||
}
|
||||
player.yellowMessage("NPCs on this map:");
|
||||
for (MapleMapObject npcs : player.getMap().getMapObjects()) {
|
||||
if (npcs instanceof MapleNPC) {
|
||||
MapleNPC npc = (MapleNPC) npcs;
|
||||
|
||||
if (!playernpcs.isEmpty()) {
|
||||
player.yellowMessage("PlayerNPCs on this map:");
|
||||
for (MaplePlayerNPC pnpc : playernpcs) {
|
||||
player.dropMessage(5, ">> " + pnpc.getName() + " - Scriptid: " + pnpc.getScriptId() + " - Oid: " + pnpc.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
if (!npcs.isEmpty()) {
|
||||
player.yellowMessage("NPCs on this map:");
|
||||
for (MapleNPC npc : npcs) {
|
||||
player.dropMessage(5, ">> " + npc.getName() + " - " + npc.getId() + " - Oid: " + npc.getObjectId());
|
||||
}
|
||||
}
|
||||
player.yellowMessage("Monsters on this map:");
|
||||
for (MapleMapObject mobs : player.getMap().getMapObjects()) {
|
||||
if (mobs instanceof MapleMonster) {
|
||||
MapleMonster mob = (MapleMonster) mobs;
|
||||
|
||||
if (!mobs.isEmpty()) {
|
||||
player.yellowMessage("Monsters on this map:");
|
||||
for (MapleMonster mob : mobs) {
|
||||
if (mob.isAlive()) {
|
||||
player.dropMessage(5, ">> " + mob.getName() + " - " + mob.getId() + " - Oid: " + mob.getObjectId());
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ package client.command.commands.gm6;
|
||||
|
||||
import client.command.Command;
|
||||
import client.MapleClient;
|
||||
import client.MapleCharacter;
|
||||
import server.life.MaplePlayerNPC;
|
||||
|
||||
public class EraseAllPNpcsCommand extends Command {
|
||||
@@ -35,7 +34,6 @@ public class EraseAllPNpcsCommand extends Command {
|
||||
|
||||
@Override
|
||||
public void execute(MapleClient c, String[] params) {
|
||||
//MapleCharacter player = c.getPlayer();
|
||||
MaplePlayerNPC.removeAllPlayerNPC();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ public class Equip extends Item {
|
||||
int stat = 0;
|
||||
if(rnd >= limit) {
|
||||
rnd -= limit;
|
||||
stat = 1 + (int)Math.floor((-1 + Math.sqrt((8 * rnd) + 1)) / 2);
|
||||
stat = 1 + (int)Math.floor((-1 + Math.sqrt((8 * rnd) + 1)) / 2); // optimized randomizeStatUpgrade author: David A.
|
||||
}
|
||||
|
||||
return stat;
|
||||
|
||||
@@ -21,12 +21,7 @@ package client.processor;
|
||||
|
||||
import client.MapleClient;
|
||||
import client.MapleCharacter;
|
||||
import java.awt.Point;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import server.maps.MapleMap;
|
||||
import server.movement.AbsoluteLifeMovement;
|
||||
import server.movement.LifeMovementFragment;
|
||||
import tools.MaplePacketCreator;
|
||||
|
||||
/**
|
||||
@@ -74,16 +69,10 @@ public class BuybackProcessor {
|
||||
jobString = "beginner";
|
||||
}
|
||||
|
||||
chr.setStance(0);
|
||||
chr.healHpMp();
|
||||
chr.broadcastStance(chr.isFacingLeft() ? 5 : 4);
|
||||
|
||||
AbsoluteLifeMovement alm = new AbsoluteLifeMovement(0, chr.getPosition(), 0, 0);
|
||||
alm.setPixelsPerSecond(new Point(0, 0));
|
||||
List<LifeMovementFragment> moveUpdate = Collections.singletonList((LifeMovementFragment) alm);
|
||||
|
||||
MapleMap map = chr.getMap();
|
||||
map.broadcastMessage(chr, MaplePacketCreator.movePlayer(c.getPlayer().getId(), moveUpdate), false);
|
||||
|
||||
map.broadcastMessage(MaplePacketCreator.playSound("Buyback/" + jobString));
|
||||
map.broadcastMessage(MaplePacketCreator.earnTitleMessage(chr.getName() + " just bought back into the game!"));
|
||||
|
||||
|
||||
@@ -389,6 +389,11 @@ public class DueyProcessor {
|
||||
MapleInventoryType inv = MapleInventoryType.getByType(inventId);
|
||||
Item item = c.getPlayer().getInventory(inv).getItem(itemPos);
|
||||
if (item != null && c.getPlayer().getItemQuantity(item.getItemId(), false) >= amount) {
|
||||
if (item.isUntradeable()) {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_INCORRECT_REQUEST.getCode()));
|
||||
return;
|
||||
}
|
||||
|
||||
c.getPlayer().gainMeso(-finalcost, false);
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_SUCCESSFULLY_SENT.getCode()));
|
||||
|
||||
|
||||
@@ -121,6 +121,11 @@ public class StorageProcessor {
|
||||
MapleInventoryType invType = ItemConstants.getInventoryType(itemId);
|
||||
Item item = chr.getInventory(invType).getItem(slot).copy();
|
||||
if (item != null && item.getItemId() == itemId && (item.getQuantity() >= quantity || ItemConstants.isRechargeable(itemId))) {
|
||||
if (ItemConstants.isWeddingRing(itemId) || ItemConstants.isWeddingToken(itemId)) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
if (ItemConstants.isRechargeable(itemId)) {
|
||||
quantity = item.getQuantity();
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ public class GameConstants {
|
||||
private static final int[] MESO_RATE_GAIN = {1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105};
|
||||
private static final int[] EXP_RATE_GAIN = {1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610}; //fibonacci :3
|
||||
|
||||
private static final int[] jobUpgradeBlob = {1, 20, 60, 110, 190};
|
||||
private static final int[] jobUpgradeSpUp = {0, 1, 2, 3, 6};
|
||||
private final static Map<Integer, String> jobNames = new HashMap<>();
|
||||
private final static NumberFormat nfFormatter = new DecimalFormat("#,###,###,###");
|
||||
private final static NumberFormat nfParser = NumberFormat.getInstance(ServerConstants.USE_UNITPRICE_WITH_COMMA ? Locale.FRANCE : Locale.UK);
|
||||
@@ -152,6 +154,14 @@ public class GameConstants {
|
||||
return name;
|
||||
}
|
||||
|
||||
public static int getJobUpgradeLevelRange(int jobbranch) {
|
||||
return jobUpgradeBlob[jobbranch];
|
||||
}
|
||||
|
||||
public static int getChangeJobSpUpgrade(int jobbranch) {
|
||||
return jobUpgradeSpUp[jobbranch];
|
||||
}
|
||||
|
||||
public static boolean isHallOfFameMap(int mapid) {
|
||||
switch(mapid) {
|
||||
case 102000004: // warrior
|
||||
|
||||
@@ -27,9 +27,12 @@ public class ServerConstants {
|
||||
public static final long COUPON_INTERVAL = 60 * 60 * 1000; //60 minutes, 3600000.
|
||||
public static final long UPDATE_INTERVAL = 777; //Dictates the frequency on which the "centralized server time" is updated.
|
||||
|
||||
public static final boolean ENABLE_PIC = false; //Pick true/false to enable or disable Pic. Delete character needs this feature ENABLED.
|
||||
public static final boolean ENABLE_PIC = false; //Pick true/false to enable or disable Pic. Delete character required PIC available.
|
||||
public static final boolean ENABLE_PIN = false; //Pick true/false to enable or disable Pin.
|
||||
|
||||
public static final int BYPASS_PIC_EXPIRATION = 20; //Enables PIC bypass, which will remain active for that account by that client machine for N minutes. Set 0 to disable.
|
||||
public static final int BYPASS_PIN_EXPIRATION = 15; //Enables PIN bypass, which will remain active for that account by that client machine for N minutes. Set 0 to disable.
|
||||
|
||||
public static final boolean AUTOMATIC_REGISTER = true; //Automatically register players when they login with a nonexistent username.
|
||||
public static final boolean BCRYPT_MIGRATION = true; //Performs a migration from old SHA-1 and SHA-512 password to bcrypt.
|
||||
public static final boolean COLLECTIVE_CHARSLOT = false; //Available character slots are contabilized globally rather than per world server.
|
||||
@@ -79,6 +82,7 @@ public class ServerConstants {
|
||||
public static final boolean USE_ENFORCE_HPMP_SWAP = false; //Forces players to reuse stats (via AP Resetting) located on HP/MP pool only inside the HP/MP stats.
|
||||
public static final boolean USE_ENFORCE_MOB_LEVEL_RANGE = true; //Players N levels below the killed mob will gain no experience from defeating it.
|
||||
public static final boolean USE_ENFORCE_JOB_LEVEL_RANGE = false;//Caps the player level on the minimum required to advance their current jobs.
|
||||
public static final boolean USE_ENFORCE_JOB_SP_RANGE = true; //Caps the player SP level on the total obtainable by their current jobs. After changing jobs, missing SP will be retrieved.
|
||||
public static final boolean USE_ENFORCE_ITEM_SUGGESTION = false;//Forces the Owl of Minerva and the Cash Shop to always display the defined item array instead of those featured by the players.
|
||||
public static final boolean USE_ENFORCE_UNMERCHABLE_CASH = true;//Forces players to not sell CASH items via merchants.
|
||||
public static final boolean USE_ENFORCE_UNMERCHABLE_PET = true; //Forces players to not sell pets via merchants. (since non-named pets gets dirty name and other possible DB-related issues)
|
||||
|
||||
+39
-15
@@ -86,6 +86,7 @@ import constants.ItemConstants;
|
||||
import constants.GameConstants;
|
||||
import constants.ServerConstants;
|
||||
import server.CashShop.CashItemFactory;
|
||||
import server.MapleSkillbookInformationProvider;
|
||||
import server.TimerManager;
|
||||
import server.life.MaplePlayerNPCFactory;
|
||||
import server.quest.MapleQuest;
|
||||
@@ -329,7 +330,7 @@ public class Server {
|
||||
if(p == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
channelid++;
|
||||
World world = this.getWorld(worldid);
|
||||
Channel channel = new Channel(worldid, channelid, getCurrentTime());
|
||||
@@ -923,6 +924,8 @@ public class Server {
|
||||
|
||||
System.out.println("HeavenMS is now online.\r\n");
|
||||
online = true;
|
||||
|
||||
MapleSkillbookInformationProvider.getInstance();
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
@@ -1485,23 +1488,44 @@ public class Server {
|
||||
return new Pair<>(characterCount, wchars);
|
||||
}
|
||||
|
||||
public void loadAccountCharacters(MapleClient c) {
|
||||
Integer accId = c.getAccID();
|
||||
boolean firstAccountLogin;
|
||||
|
||||
public void loadAllAccountsCharactersView() {
|
||||
try {
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT id FROM accounts");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
int accountId = rs.getInt("id");
|
||||
if (isFirstAccountLogin(accountId)) {
|
||||
loadAccountCharactersView(accountId, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
rs.close();
|
||||
ps.close();
|
||||
con.close();
|
||||
} catch (SQLException se) {
|
||||
se.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isFirstAccountLogin(Integer accId) {
|
||||
lgnRLock.lock();
|
||||
try {
|
||||
firstAccountLogin = !accountChars.containsKey(accId);
|
||||
return !accountChars.containsKey(accId);
|
||||
} finally {
|
||||
lgnRLock.unlock();
|
||||
}
|
||||
|
||||
if(!firstAccountLogin) {
|
||||
}
|
||||
|
||||
public void loadAccountCharacters(MapleClient c) {
|
||||
Integer accId = c.getAccID();
|
||||
if (!isFirstAccountLogin(accId)) {
|
||||
Set<Integer> accWorlds = new HashSet<>();
|
||||
|
||||
lgnRLock.lock();
|
||||
try {
|
||||
for(Integer chrid : getAccountCharacterEntries(accId)) {
|
||||
for (Integer chrid : getAccountCharacterEntries(accId)) {
|
||||
accWorlds.add(worldChars.get(chrid));
|
||||
}
|
||||
} finally {
|
||||
@@ -1509,12 +1533,12 @@ public class Server {
|
||||
}
|
||||
|
||||
int gmLevel = 0;
|
||||
for(Integer aw : accWorlds) {
|
||||
for (Integer aw : accWorlds) {
|
||||
World wserv = this.getWorld(aw);
|
||||
|
||||
if (wserv != null) {
|
||||
for(MapleCharacter chr : wserv.getAllCharactersView()) {
|
||||
if(gmLevel < chr.gmLevel()) gmLevel = chr.gmLevel();
|
||||
for (MapleCharacter chr : wserv.getAllCharactersView()) {
|
||||
if (gmLevel < chr.gmLevel()) gmLevel = chr.gmLevel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1541,14 +1565,14 @@ public class Server {
|
||||
chars = new HashSet<>(5);
|
||||
}
|
||||
|
||||
for(int wid = fromWorldid; wid < wlist.size(); wid++) {
|
||||
for (int wid = fromWorldid; wid < wlist.size(); wid++) {
|
||||
World w = wlist.get(wid);
|
||||
List<MapleCharacter> wchars = accChars.get(wid);
|
||||
w.loadAccountCharactersView(accId, wchars);
|
||||
|
||||
for(MapleCharacter chr : wchars) {
|
||||
for (MapleCharacter chr : wchars) {
|
||||
int cid = chr.getId();
|
||||
if(gmLevel < chr.gmLevel()) gmLevel = chr.gmLevel();
|
||||
if (gmLevel < chr.gmLevel()) gmLevel = chr.gmLevel();
|
||||
|
||||
chars.add(cid);
|
||||
worldChars.put(cid, wid);
|
||||
|
||||
@@ -243,10 +243,14 @@ public final class CashOperationHandler extends AbstractMaplePacketHandler {
|
||||
if (item == null) {
|
||||
c.enableCSActions();
|
||||
return;
|
||||
} else if(c.getPlayer().getPetIndex(item.getPetId()) > -1) {
|
||||
} else if (c.getPlayer().getPetIndex(item.getPetId()) > -1) {
|
||||
chr.getClient().announce(MaplePacketCreator.serverNotice(1, "You cannot put the pet you currently equip into the Cash Shop inventory."));
|
||||
c.enableCSActions();
|
||||
return;
|
||||
} else if (ItemConstants.isWeddingRing(item.getItemId()) || ItemConstants.isWeddingToken(item.getItemId())) {
|
||||
chr.getClient().announce(MaplePacketCreator.serverNotice(1, "You cannot put relationship items into the Cash Shop inventory."));
|
||||
c.enableCSActions();
|
||||
return;
|
||||
}
|
||||
cs.addToInventory(item);
|
||||
mi.removeSlot(item.getPosition());
|
||||
|
||||
@@ -47,9 +47,8 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void respawnPlayer(MapleCharacter mc) {
|
||||
mc.getMap().broadcastMessage(mc, MaplePacketCreator.removePlayerFromMap(mc.getId()), false);
|
||||
mc.getMap().broadcastMessage(mc, MaplePacketCreator.spawnPlayerMapObject(mc), false);
|
||||
private void restancePlayer(MapleCharacter mc) {
|
||||
mc.broadcastStance();
|
||||
}
|
||||
|
||||
private class Invited {
|
||||
@@ -132,7 +131,7 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
|
||||
c.announce(MaplePacketCreator.showGuildInfo(mc));
|
||||
|
||||
c.getPlayer().dropMessage(1, "You have successfully created a Guild.");
|
||||
respawnPlayer(mc);
|
||||
restancePlayer(mc);
|
||||
break;
|
||||
case 0x05:
|
||||
if (mc.getGuildId() <= 0 || mc.getGuildRank() > 2) {
|
||||
@@ -192,7 +191,7 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
|
||||
if(allianceId > 0) Server.getInstance().getAlliance(allianceId).updateAlliancePackets(mc);
|
||||
|
||||
mc.saveGuildStatus(); // update database
|
||||
respawnPlayer(mc);
|
||||
restancePlayer(mc);
|
||||
break;
|
||||
case 0x07:
|
||||
allianceId = mc.getGuild().getAllianceId();
|
||||
@@ -211,7 +210,7 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
|
||||
|
||||
mc.getMGC().setGuildId(0);
|
||||
mc.saveGuildStatus();
|
||||
respawnPlayer(mc);
|
||||
restancePlayer(mc);
|
||||
break;
|
||||
case 0x08:
|
||||
allianceId = mc.getGuild().getAllianceId();
|
||||
@@ -271,7 +270,7 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
|
||||
}
|
||||
|
||||
mc.gainMeso(-ServerConstants.CHANGE_EMBLEM_COST, true, false, true);
|
||||
respawnPlayer(mc);
|
||||
restancePlayer(mc);
|
||||
break;
|
||||
case 0x10:
|
||||
if (mc.getGuildId() <= 0 || mc.getGuildRank() > 2) {
|
||||
|
||||
@@ -80,11 +80,12 @@ public final class NPCTalkHandler extends AbstractMaplePacketHandler {
|
||||
}
|
||||
} else if (obj instanceof MaplePlayerNPC) {
|
||||
MaplePlayerNPC pnpc = (MaplePlayerNPC) obj;
|
||||
NPCScriptManager nsm = NPCScriptManager.getInstance();
|
||||
|
||||
if(pnpc.getScriptId() < 9977777) {
|
||||
NPCScriptManager.getInstance().start(c, pnpc.getScriptId(), "rank_user", null);
|
||||
if (pnpc.getScriptId() < 9977777 && !nsm.isNpcScriptAvailable(c, "" + pnpc.getScriptId())) {
|
||||
nsm.start(c, pnpc.getScriptId(), "rank_user", null);
|
||||
} else {
|
||||
NPCScriptManager.getInstance().start(c, pnpc.getScriptId(), null);
|
||||
nsm.start(c, pnpc.getScriptId(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ import tools.MaplePacketCreator;
|
||||
import tools.data.input.SeekableLittleEndianAccessor;
|
||||
|
||||
public final class PetChatHandler extends AbstractMaplePacketHandler {
|
||||
|
||||
@Override
|
||||
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
||||
int petId = slea.readInt();
|
||||
slea.readInt();
|
||||
|
||||
@@ -83,22 +83,19 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
|
||||
final Server server = Server.getInstance();
|
||||
MapleCharacter player = c.getWorldServer().getPlayerStorage().getCharacterById(cid);
|
||||
boolean newcomer = false;
|
||||
|
||||
IoSession session = c.getSession();
|
||||
String remoteHwid;
|
||||
if (player == null) {
|
||||
IoSession session = c.getSession();
|
||||
|
||||
if (!server.validateCharacteridInTransition((InetSocketAddress) session.getRemoteAddress(), cid)) {
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ServerConstants.DETERRED_MULTICLIENT) {
|
||||
String remoteHwid = MapleSessionCoordinator.getInstance().getGameSessionHwid(session);
|
||||
if (remoteHwid == null) {
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
session.setAttribute(MapleClient.CLIENT_HWID, remoteHwid);
|
||||
remoteHwid = MapleSessionCoordinator.getInstance().getGameSessionHwid(session);
|
||||
if (remoteHwid == null) {
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -108,6 +105,7 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
remoteHwid = player.getClient().getHWID();
|
||||
c.setCharacterSlots((byte) player.getClient().getCharacterSlots());
|
||||
player.newClient(c);
|
||||
}
|
||||
@@ -116,6 +114,11 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
int hwidLen = remoteHwid.length();
|
||||
session.setAttribute(MapleClient.CLIENT_HWID, remoteHwid);
|
||||
session.setAttribute(MapleClient.CLIENT_NIBBLEHWID, remoteHwid.substring(hwidLen - 8, hwidLen));
|
||||
c.setHWID(remoteHwid);
|
||||
|
||||
c.setPlayer(player);
|
||||
c.setAccID(player.getAccountID());
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ import tools.data.input.SeekableLittleEndianAccessor;
|
||||
*/
|
||||
public final class QuestActionHandler extends AbstractMaplePacketHandler {
|
||||
|
||||
// credits to gabriel.sin
|
||||
// isNpcNearby credits to gabriel.sin
|
||||
private static boolean isNpcNearby(SeekableLittleEndianAccessor slea, MapleCharacter player, MapleQuest quest, int npcId) {
|
||||
Point playerP = null;
|
||||
|
||||
|
||||
@@ -107,8 +107,16 @@ public final class RingActionHandler extends AbstractMaplePacketHandler {
|
||||
source.dropMessage(1, "The player is already engaged!");
|
||||
source.announce(Wedding.OnMarriageResult((byte) 0));
|
||||
return;
|
||||
} else if (target.getGender() != 1) {
|
||||
source.dropMessage(1, "You may only propose to a girl!");
|
||||
} else if (target.haveWeddingRing()) {
|
||||
source.dropMessage(1, "The player already holds a marriage ring...");
|
||||
source.announce(Wedding.OnMarriageResult((byte) 0));
|
||||
return;
|
||||
} else if (source.haveWeddingRing()) {
|
||||
source.dropMessage(1, "You can't propose while holding a marriage ring!");
|
||||
source.announce(Wedding.OnMarriageResult((byte) 0));
|
||||
return;
|
||||
} else if (target.getGender() == source.getGender()) {
|
||||
source.dropMessage(1, "You may only propose to a " + (source.getGender() == 1 ? "male" : "female") + "!");
|
||||
source.announce(Wedding.OnMarriageResult((byte) 0));
|
||||
return;
|
||||
} else if (!MapleInventoryManipulator.checkSpace(c, newBoxId, 1, "")) {
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2018 RonanLana
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.server.coordinator;
|
||||
|
||||
import constants.ServerConstants;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleClient;
|
||||
import net.server.world.World;
|
||||
import net.server.Server;
|
||||
import tools.Pair;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class MapleLoginBypassCoordinator {
|
||||
|
||||
private final static MapleLoginBypassCoordinator instance = new MapleLoginBypassCoordinator();
|
||||
|
||||
public static MapleLoginBypassCoordinator getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private final ConcurrentHashMap<Pair<String, Integer>, Pair<Boolean, Long>> loginBypass = new ConcurrentHashMap<>(); // optimized PIN & PIC check
|
||||
|
||||
public boolean canLoginBypass(String nibbleHwid, int accId, boolean pic) {
|
||||
try {
|
||||
Pair<String, Integer> entry = new Pair<>(nibbleHwid, accId);
|
||||
Boolean p = loginBypass.get(entry).getLeft();
|
||||
|
||||
return !pic || p;
|
||||
} catch (NullPointerException npe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void registerLoginBypassEntry(String nibbleHwid, int accId, boolean pic) {
|
||||
long expireTime = (pic ? ServerConstants.BYPASS_PIC_EXPIRATION : ServerConstants.BYPASS_PIN_EXPIRATION);
|
||||
if (expireTime > 0) {
|
||||
Pair<String, Integer> entry = new Pair<>(nibbleHwid, accId);
|
||||
expireTime = Server.getInstance().getCurrentTime() + expireTime * 60 * 1000;
|
||||
try {
|
||||
pic |= loginBypass.get(entry).getLeft();
|
||||
expireTime = Math.max(loginBypass.get(entry).getRight(), expireTime);
|
||||
} catch (NullPointerException npe) {}
|
||||
|
||||
loginBypass.put(entry, new Pair<>(pic, expireTime));
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterLoginBypassEntry(String nibbleHwid, int accId) {
|
||||
Pair<String, Integer> entry = new Pair<>(nibbleHwid, accId);
|
||||
loginBypass.remove(entry);
|
||||
}
|
||||
|
||||
public void runUpdateLoginBypass() {
|
||||
if (!loginBypass.isEmpty()) {
|
||||
List<Pair<String, Integer>> toRemove = new LinkedList<>();
|
||||
Set<Integer> onlineAccounts = new HashSet<>();
|
||||
long timeNow = Server.getInstance().getCurrentTime();
|
||||
|
||||
for (World w : Server.getInstance().getWorlds()) {
|
||||
for (MapleCharacter chr : w.getPlayerStorage().getAllCharacters()) {
|
||||
MapleClient c = chr.getClient();
|
||||
if (c != null) {
|
||||
onlineAccounts.add(c.getAccID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Entry<Pair<String, Integer>, Pair<Boolean, Long>> e : loginBypass.entrySet()) {
|
||||
if (onlineAccounts.contains(e.getKey().getRight())) {
|
||||
long expireTime = timeNow + 2 * 60 * 1000;
|
||||
if (expireTime > e.getValue().getRight()) {
|
||||
loginBypass.replace(e.getKey(), new Pair<>(e.getValue().getLeft(), expireTime));
|
||||
}
|
||||
} else if (e.getValue().getRight() < timeNow) {
|
||||
toRemove.add(e.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
if (!toRemove.isEmpty()) {
|
||||
for (Pair<String, Integer> p : toRemove) {
|
||||
loginBypass.remove(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -290,17 +290,20 @@ public class MapleSessionCoordinator {
|
||||
lrh.remove(session);
|
||||
if (lrh.isEmpty()) {
|
||||
loginRemoteHosts.remove(remoteIp);
|
||||
|
||||
String nibbleHwid = (String) session.removeAttribute(MapleClient.CLIENT_NIBBLEHWID);
|
||||
if (nibbleHwid != null) {
|
||||
onlineRemoteHwids.remove(nibbleHwid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String nibbleHwid = (String) session.removeAttribute(MapleClient.CLIENT_NIBBLEHWID);
|
||||
if (nibbleHwid != null) {
|
||||
onlineRemoteHwids.remove(nibbleHwid);
|
||||
}
|
||||
}
|
||||
|
||||
public AntiMulticlientResult attemptLoginSession(IoSession session, String nibbleHwid, int accountId, boolean routineCheck) {
|
||||
if (!ServerConstants.DETERRED_MULTICLIENT) return AntiMulticlientResult.SUCCESS;
|
||||
if (!ServerConstants.DETERRED_MULTICLIENT) {
|
||||
session.setAttribute(MapleClient.CLIENT_NIBBLEHWID, nibbleHwid);
|
||||
return AntiMulticlientResult.SUCCESS;
|
||||
}
|
||||
|
||||
String remoteHost = getRemoteIp(session);
|
||||
Lock lock = getCoodinatorLock(remoteHost);
|
||||
@@ -368,11 +371,13 @@ public class MapleSessionCoordinator {
|
||||
}
|
||||
|
||||
public AntiMulticlientResult attemptGameSession(IoSession session, int accountId, String remoteHwid) {
|
||||
if (!ServerConstants.DETERRED_MULTICLIENT) return AntiMulticlientResult.SUCCESS;
|
||||
|
||||
String remoteHost = getRemoteIp(session);
|
||||
Lock lock = getCoodinatorLock(remoteHost);
|
||||
if (!ServerConstants.DETERRED_MULTICLIENT) {
|
||||
associateRemoteHostHwid(remoteHost, remoteHwid);
|
||||
return AntiMulticlientResult.SUCCESS;
|
||||
}
|
||||
|
||||
Lock lock = getCoodinatorLock(remoteHost);
|
||||
try {
|
||||
int tries = 0;
|
||||
while (true) {
|
||||
@@ -413,10 +418,7 @@ public class MapleSessionCoordinator {
|
||||
|
||||
// updated session CLIENT_HWID attribute will be set when the player log in the game
|
||||
onlineRemoteHwids.add(remoteHwid);
|
||||
|
||||
cachedHostHwids.put(remoteHost, remoteHwid);
|
||||
cachedHostTimeout.put(remoteHost, Server.getInstance().getCurrentTime() + 604800000); // 1 week-time entry
|
||||
|
||||
associateRemoteHostHwid(remoteHost, remoteHwid);
|
||||
associateHwidAccountIfAbsent(remoteHwid, accountId);
|
||||
|
||||
return AntiMulticlientResult.SUCCESS;
|
||||
@@ -456,6 +458,11 @@ public class MapleSessionCoordinator {
|
||||
return cachedHostHwids.get(remoteHost);
|
||||
}
|
||||
|
||||
private void associateRemoteHostHwid(String remoteHost, String remoteHwid) {
|
||||
cachedHostHwids.put(remoteHost, remoteHwid);
|
||||
cachedHostTimeout.put(remoteHost, Server.getInstance().getCurrentTime() + 604800000); // 1 week-time entry
|
||||
}
|
||||
|
||||
public void runUpdateHwidHistory() {
|
||||
try {
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
|
||||
@@ -64,7 +64,7 @@ public final class ViewAllCharHandler extends AbstractMaplePacketHandler {
|
||||
c.announce(MaplePacketCreator.showAllCharacter(charsSize, unk));
|
||||
|
||||
for (Pair<Integer, List<MapleCharacter>> wchars : worldChars) {
|
||||
c.announce(MaplePacketCreator.showAllCharacterInfo(wchars.getLeft(), wchars.getRight(), ServerConstants.ENABLE_PIC));
|
||||
c.announce(MaplePacketCreator.showAllCharacterInfo(wchars.getLeft(), wchars.getRight(), ServerConstants.ENABLE_PIC && !c.canBypassPic()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -6,19 +6,63 @@ import java.net.InetSocketAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import net.AbstractMaplePacketHandler;
|
||||
import net.server.Server;
|
||||
import net.server.coordinator.MapleSessionCoordinator;
|
||||
import net.server.world.World;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.Randomizer;
|
||||
import tools.data.input.SeekableLittleEndianAccessor;
|
||||
|
||||
public final class ViewAllCharRegisterPicHandler extends AbstractMaplePacketHandler {
|
||||
|
||||
private static int parseAntiMulticlientError(MapleSessionCoordinator.AntiMulticlientResult res) {
|
||||
switch (res) {
|
||||
case REMOTE_PROCESSING:
|
||||
return 10;
|
||||
|
||||
case REMOTE_LOGGEDIN:
|
||||
return 7;
|
||||
|
||||
case REMOTE_NO_MATCH:
|
||||
return 17;
|
||||
|
||||
case COORDINATOR_ERROR:
|
||||
return 8;
|
||||
|
||||
default:
|
||||
return 9;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
||||
slea.readByte();
|
||||
int charId = slea.readInt();
|
||||
slea.readInt(); // please don't let the client choose which world they should login
|
||||
|
||||
String mac = slea.readMapleAsciiString();
|
||||
String hwid = slea.readMapleAsciiString();
|
||||
|
||||
if (!hwid.matches("[0-9A-F]{12}_[0-9A-F]{8}")) {
|
||||
c.announce(MaplePacketCreator.getAfterLoginError(17));
|
||||
return;
|
||||
}
|
||||
|
||||
c.updateMacs(mac);
|
||||
c.updateHWID(hwid);
|
||||
|
||||
if (c.hasBannedMac() || c.hasBannedHWID()) {
|
||||
c.getSession().close(true);
|
||||
return;
|
||||
}
|
||||
|
||||
IoSession session = c.getSession();
|
||||
MapleSessionCoordinator.AntiMulticlientResult res = MapleSessionCoordinator.getInstance().attemptGameSession(session, c.getAccID(), hwid);
|
||||
if (res != MapleSessionCoordinator.AntiMulticlientResult.SUCCESS) {
|
||||
c.announce(MaplePacketCreator.getAfterLoginError(parseAntiMulticlientError(res)));
|
||||
return;
|
||||
}
|
||||
|
||||
Server server = Server.getInstance();
|
||||
if(!server.haveCharacterEntry(c.getAccID(), charId)) {
|
||||
c.getSession().close(true);
|
||||
@@ -35,14 +79,6 @@ public final class ViewAllCharRegisterPicHandler extends AbstractMaplePacketHand
|
||||
int channel = Randomizer.rand(1, server.getWorld(c.getWorld()).getChannelsSize());
|
||||
c.setChannel(channel);
|
||||
|
||||
String mac = slea.readMapleAsciiString();
|
||||
c.updateMacs(mac);
|
||||
if (c.hasBannedMac()) {
|
||||
c.getSession().close(true);
|
||||
return;
|
||||
}
|
||||
|
||||
slea.readMapleAsciiString();
|
||||
String pic = slea.readMapleAsciiString();
|
||||
c.setPic(pic);
|
||||
|
||||
|
||||
@@ -27,18 +27,62 @@ import java.net.InetSocketAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import net.AbstractMaplePacketHandler;
|
||||
import net.server.Server;
|
||||
import net.server.coordinator.MapleSessionCoordinator;
|
||||
import net.server.world.World;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.Randomizer;
|
||||
import tools.data.input.SeekableLittleEndianAccessor;
|
||||
|
||||
public final class ViewAllCharSelectedHandler extends AbstractMaplePacketHandler {
|
||||
|
||||
private static int parseAntiMulticlientError(MapleSessionCoordinator.AntiMulticlientResult res) {
|
||||
switch (res) {
|
||||
case REMOTE_PROCESSING:
|
||||
return 10;
|
||||
|
||||
case REMOTE_LOGGEDIN:
|
||||
return 7;
|
||||
|
||||
case REMOTE_NO_MATCH:
|
||||
return 17;
|
||||
|
||||
case COORDINATOR_ERROR:
|
||||
return 8;
|
||||
|
||||
default:
|
||||
return 9;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
||||
int charId = slea.readInt();
|
||||
slea.readInt(); // please don't let the client choose which world they should login
|
||||
|
||||
String macs = slea.readMapleAsciiString();
|
||||
String hwid = slea.readMapleAsciiString();
|
||||
|
||||
if (!hwid.matches("[0-9A-F]{12}_[0-9A-F]{8}")) {
|
||||
c.announce(MaplePacketCreator.getAfterLoginError(17));
|
||||
return;
|
||||
}
|
||||
|
||||
c.updateMacs(macs);
|
||||
c.updateHWID(hwid);
|
||||
|
||||
if (c.hasBannedMac() || c.hasBannedHWID()) {
|
||||
c.getSession().close(true);
|
||||
return;
|
||||
}
|
||||
|
||||
IoSession session = c.getSession();
|
||||
MapleSessionCoordinator.AntiMulticlientResult res = MapleSessionCoordinator.getInstance().attemptGameSession(session, c.getAccID(), hwid);
|
||||
if (res != MapleSessionCoordinator.AntiMulticlientResult.SUCCESS) {
|
||||
c.announce(MaplePacketCreator.getAfterLoginError(parseAntiMulticlientError(res)));
|
||||
return;
|
||||
}
|
||||
|
||||
Server server = Server.getInstance();
|
||||
if(!server.haveCharacterEntry(c.getAccID(), charId)) {
|
||||
c.getSession().close(true);
|
||||
@@ -53,13 +97,6 @@ public final class ViewAllCharSelectedHandler extends AbstractMaplePacketHandler
|
||||
return;
|
||||
}
|
||||
|
||||
String macs = slea.readMapleAsciiString();
|
||||
c.updateMacs(macs);
|
||||
if (c.hasBannedMac()) {
|
||||
c.getSession().close(true);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
int channel = Randomizer.rand(1, wserv.getChannelsSize());
|
||||
c.setChannel(channel);
|
||||
|
||||
@@ -11,9 +11,30 @@ import tools.Randomizer;
|
||||
import tools.data.input.SeekableLittleEndianAccessor;
|
||||
import client.MapleClient;
|
||||
import java.net.InetSocketAddress;
|
||||
import net.server.coordinator.MapleSessionCoordinator;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
|
||||
public class ViewAllCharSelectedWithPicHandler extends AbstractMaplePacketHandler {
|
||||
|
||||
private static int parseAntiMulticlientError(MapleSessionCoordinator.AntiMulticlientResult res) {
|
||||
switch (res) {
|
||||
case REMOTE_PROCESSING:
|
||||
return 10;
|
||||
|
||||
case REMOTE_LOGGEDIN:
|
||||
return 7;
|
||||
|
||||
case REMOTE_NO_MATCH:
|
||||
return 17;
|
||||
|
||||
case COORDINATOR_ERROR:
|
||||
return 8;
|
||||
|
||||
default:
|
||||
return 9;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
||||
|
||||
@@ -21,6 +42,29 @@ public class ViewAllCharSelectedWithPicHandler extends AbstractMaplePacketHandle
|
||||
int charId = slea.readInt();
|
||||
slea.readInt(); // please don't let the client choose which world they should login
|
||||
|
||||
String macs = slea.readMapleAsciiString();
|
||||
String hwid = slea.readMapleAsciiString();
|
||||
|
||||
if (!hwid.matches("[0-9A-F]{12}_[0-9A-F]{8}")) {
|
||||
c.announce(MaplePacketCreator.getAfterLoginError(17));
|
||||
return;
|
||||
}
|
||||
|
||||
c.updateMacs(macs);
|
||||
c.updateHWID(hwid);
|
||||
|
||||
if (c.hasBannedMac() || c.hasBannedHWID()) {
|
||||
c.getSession().close(true);
|
||||
return;
|
||||
}
|
||||
|
||||
IoSession session = c.getSession();
|
||||
MapleSessionCoordinator.AntiMulticlientResult res = MapleSessionCoordinator.getInstance().attemptGameSession(session, c.getAccID(), hwid);
|
||||
if (res != MapleSessionCoordinator.AntiMulticlientResult.SUCCESS) {
|
||||
c.announce(MaplePacketCreator.getAfterLoginError(parseAntiMulticlientError(res)));
|
||||
return;
|
||||
}
|
||||
|
||||
Server server = Server.getInstance();
|
||||
if(!server.haveCharacterEntry(c.getAccID(), charId)) {
|
||||
c.getSession().close(true);
|
||||
@@ -37,13 +81,6 @@ public class ViewAllCharSelectedWithPicHandler extends AbstractMaplePacketHandle
|
||||
int channel = Randomizer.rand(1, wserv.getChannelsSize());
|
||||
c.setChannel(channel);
|
||||
|
||||
String macs = slea.readMapleAsciiString();
|
||||
c.updateMacs(macs);
|
||||
if (c.hasBannedMac()) {
|
||||
c.getSession().close(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (c.checkPic(pic)) {
|
||||
String[] socket = server.getInetSocket(c.getWorld(), c.getChannel());
|
||||
if(socket == null) {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package net.server.worker;
|
||||
|
||||
import net.server.coordinator.MapleSessionCoordinator;
|
||||
import net.server.coordinator.MapleLoginBypassCoordinator;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -30,5 +31,6 @@ public class LoginStorageWorker implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
MapleSessionCoordinator.getInstance().runUpdateLoginHistory();
|
||||
MapleLoginBypassCoordinator.getInstance().runUpdateLoginBypass();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,6 +409,11 @@ public class World {
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<MapleCharacter> loadAndGetAllCharactersView() {
|
||||
Server.getInstance().loadAllAccountsCharactersView();
|
||||
return getAllCharactersView();
|
||||
}
|
||||
|
||||
public List<MapleCharacter> getAllCharactersView() { // sorted by accountid, charid
|
||||
List<MapleCharacter> chrList = new LinkedList<>();
|
||||
Map<Integer, SortedMap<Integer, MapleCharacter>> accChars;
|
||||
@@ -598,8 +603,7 @@ public class World {
|
||||
mc.saveGuildStatus();
|
||||
}
|
||||
if (bDifferentGuild) {
|
||||
mc.getMap().broadcastMessage(mc, MaplePacketCreator.removePlayerFromMap(cid), false);
|
||||
mc.getMap().broadcastMessage(mc, MaplePacketCreator.spawnPlayerMapObject(mc), false);
|
||||
mc.broadcastStance();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1063,4 +1063,8 @@ public class AbstractPlayerInteraction {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void npcTalk(int npcid, String message) {
|
||||
c.announce(MaplePacketCreator.getNPCTalk(npcid, (byte) 0, message, "00 00", (byte) 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@ import client.inventory.MaplePet;
|
||||
import constants.ItemConstants;
|
||||
import java.awt.Point;
|
||||
import java.util.Arrays;
|
||||
import server.MapleSkillbookInformationProvider;
|
||||
import server.MapleSkillbookInformationProvider.SkillBookEntry;
|
||||
import server.maps.MapleMapObject;
|
||||
import server.maps.MapleMapObjectType;
|
||||
|
||||
@@ -545,4 +547,9 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
||||
return MapleItemInformationProvider.getInstance().getWhoDrops(itemId).toArray();
|
||||
}
|
||||
|
||||
public String getSkillBookInfo(int itemid) {
|
||||
SkillBookEntry sbe = MapleSkillbookInformationProvider.getInstance().getSkillbookAvailability(itemid);
|
||||
return sbe != SkillBookEntry.UNAVAILABLE ? " Obtainable through #rquestline#k." : "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,6 +50,15 @@ public class NPCScriptManager extends AbstractScriptManager {
|
||||
private Map<MapleClient, NPCConversationManager> cms = new HashMap<>();
|
||||
private Map<MapleClient, Invocable> scripts = new HashMap<>();
|
||||
|
||||
public boolean isNpcScriptAvailable(MapleClient c, String fileName) {
|
||||
Invocable iv = null;
|
||||
if (fileName != null) {
|
||||
iv = getInvocable("npc/" + fileName + ".js", c);
|
||||
}
|
||||
|
||||
return iv != null;
|
||||
}
|
||||
|
||||
public boolean start(MapleClient c, int npc, MapleCharacter chr) {
|
||||
return start(c, npc, null, chr);
|
||||
}
|
||||
|
||||
@@ -379,13 +379,16 @@ public class CashShop {
|
||||
}
|
||||
|
||||
public Item findByCashId(int cashId) {
|
||||
boolean isRing = false;
|
||||
boolean isRing;
|
||||
Equip equip = null;
|
||||
for (Item item : getInventory()) {
|
||||
if (item.getInventoryType().equals(MapleInventoryType.EQUIP)) {
|
||||
equip = (Equip) item;
|
||||
isRing = equip.getRingId() > -1;
|
||||
} else {
|
||||
isRing = false;
|
||||
}
|
||||
|
||||
if ((item.getPetId() > -1 ? item.getPetId() : isRing ? equip.getRingId() : item.getCashId()) == cashId) {
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -641,21 +641,12 @@ public class MapleItemInformationProvider {
|
||||
return type[cat - 30];
|
||||
}
|
||||
|
||||
private static double testYourLuck() {
|
||||
double result = 100.0, rolled;
|
||||
int i, j = ServerConstants.SCROLL_CHANCE_RATE;
|
||||
|
||||
if(j < 1) j = 1;
|
||||
for(i = 0; i < j; i++) {
|
||||
rolled = Math.ceil(Math.random() * 100.0);
|
||||
if(result > rolled) result = rolled;
|
||||
}
|
||||
|
||||
return(result);
|
||||
private static double testYourLuck(double prop, int dices) { // revamped testYourLuck author: David A.
|
||||
return Math.pow(1.0 - prop, dices);
|
||||
}
|
||||
|
||||
public static boolean rollSuccessChance(double prop) {
|
||||
return(testYourLuck() <= prop && prop > 0.0);
|
||||
return Math.random() > testYourLuck(prop / 100.0, ServerConstants.SCROLL_CHANCE_RATE);
|
||||
}
|
||||
|
||||
private static short getMaximumShortMaxIfOverflow(int value1, int value2) {
|
||||
|
||||
@@ -0,0 +1,358 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2018 RonanLana
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import tools.DatabaseConnection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana
|
||||
*/
|
||||
public class MapleSkillbookInformationProvider {
|
||||
private final static MapleSkillbookInformationProvider instance = new MapleSkillbookInformationProvider();
|
||||
|
||||
public static MapleSkillbookInformationProvider getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
protected static Map<Integer, SkillBookEntry> foundSkillbooks = new HashMap<>();
|
||||
|
||||
public enum SkillBookEntry {
|
||||
UNAVAILABLE,
|
||||
QUEST,
|
||||
REACTOR,
|
||||
SCRIPT
|
||||
}
|
||||
|
||||
static String host = "jdbc:mysql://localhost:3306/heavenms";
|
||||
static String driver = "com.mysql.jdbc.Driver";
|
||||
static String username = "root";
|
||||
static String password = "";
|
||||
|
||||
static String wzPath = "wz";
|
||||
static String rootDirectory = ".";
|
||||
|
||||
static InputStreamReader fileReader = null;
|
||||
static BufferedReader bufferedReader = null;
|
||||
|
||||
static int initialStringLength = 50;
|
||||
|
||||
static int skillbookMinItemid = 2280000;
|
||||
static int skillbookMaxItemid = 2300000; // exclusively
|
||||
|
||||
static byte status = 0;
|
||||
static int questId = -1;
|
||||
static int isCompleteState = 0;
|
||||
|
||||
static int currentItemid = 0;
|
||||
static int currentCount = 0;
|
||||
|
||||
static {
|
||||
loadSkillbooks();
|
||||
}
|
||||
|
||||
private static String getName(String token) {
|
||||
int i, j;
|
||||
char[] dest;
|
||||
String d;
|
||||
|
||||
i = token.lastIndexOf("name");
|
||||
i = token.indexOf("\"", i) + 1; //lower bound of the string
|
||||
j = token.indexOf("\"", i); //upper bound
|
||||
|
||||
if(j < i) { //node value containing 'name' in it's scope, cheap fix since we don't deal with strings anyway
|
||||
System.out.println("[CRITICAL] Found this '" + token + "'");
|
||||
return "0";
|
||||
}
|
||||
|
||||
dest = new char[initialStringLength];
|
||||
token.getChars(i, j, dest, 0);
|
||||
|
||||
d = new String(dest);
|
||||
return(d.trim());
|
||||
}
|
||||
|
||||
private static String getValue(String token) {
|
||||
int i, j;
|
||||
char[] dest;
|
||||
String d;
|
||||
|
||||
i = token.lastIndexOf("value");
|
||||
i = token.indexOf("\"", i) + 1; //lower bound of the string
|
||||
j = token.indexOf("\"", i); //upper bound
|
||||
|
||||
dest = new char[initialStringLength];
|
||||
token.getChars(i, j, dest, 0);
|
||||
|
||||
d = new String(dest);
|
||||
return(d.trim());
|
||||
}
|
||||
|
||||
private static void forwardCursor(int st) {
|
||||
String line = null;
|
||||
|
||||
try {
|
||||
while(status >= st && (line = bufferedReader.readLine()) != null) {
|
||||
simpleToken(line);
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void simpleToken(String token) {
|
||||
if(token.contains("/imgdir")) {
|
||||
status -= 1;
|
||||
}
|
||||
else if(token.contains("imgdir")) {
|
||||
status += 1;
|
||||
}
|
||||
}
|
||||
|
||||
private static void inspectQuestItemList(int st) {
|
||||
String line = null;
|
||||
|
||||
try {
|
||||
while(status >= st && (line = bufferedReader.readLine()) != null) {
|
||||
readItemToken(line);
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSkillBook(int itemid) {
|
||||
return itemid >= skillbookMinItemid && itemid < skillbookMaxItemid;
|
||||
}
|
||||
|
||||
private static void processCurrentItem() {
|
||||
try {
|
||||
if(isSkillBook(currentItemid)) {
|
||||
if(currentCount > 0) {
|
||||
foundSkillbooks.put(currentItemid, SkillBookEntry.QUEST);
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
||||
private static void readItemToken(String token) {
|
||||
if(token.contains("/imgdir")) {
|
||||
status -= 1;
|
||||
|
||||
processCurrentItem();
|
||||
|
||||
currentItemid = 0;
|
||||
currentCount = 0;
|
||||
}
|
||||
else if(token.contains("imgdir")) {
|
||||
status += 1;
|
||||
}
|
||||
else {
|
||||
String d = getName(token);
|
||||
|
||||
if(d.equals("id")) {
|
||||
currentItemid = Integer.parseInt(getValue(token));
|
||||
} else if(d.equals("count")) {
|
||||
currentCount = Integer.parseInt(getValue(token));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void translateActToken(String token) {
|
||||
String d;
|
||||
int temp;
|
||||
|
||||
if(token.contains("/imgdir")) {
|
||||
status -= 1;
|
||||
}
|
||||
else if(token.contains("imgdir")) {
|
||||
if(status == 1) { //getting QuestId
|
||||
d = getName(token);
|
||||
questId = Integer.parseInt(d);
|
||||
}
|
||||
else if(status == 2) { //start/complete
|
||||
d = getName(token);
|
||||
isCompleteState = Integer.parseInt(d);
|
||||
}
|
||||
else if(status == 3) {
|
||||
d = getName(token);
|
||||
|
||||
if(d.contains("item")) {
|
||||
temp = status;
|
||||
inspectQuestItemList(temp);
|
||||
} else {
|
||||
forwardCursor(status);
|
||||
}
|
||||
}
|
||||
|
||||
status += 1;
|
||||
}
|
||||
}
|
||||
|
||||
private static void fetchSkillbooksFromQuests() {
|
||||
String line;
|
||||
try {
|
||||
fileReader = new InputStreamReader(new FileInputStream(wzPath + "/Quest.wz/Act.img.xml"), "UTF-8");
|
||||
bufferedReader = new BufferedReader(fileReader);
|
||||
|
||||
while((line = bufferedReader.readLine()) != null) {
|
||||
translateActToken(line);
|
||||
}
|
||||
|
||||
bufferedReader.close();
|
||||
fileReader.close();
|
||||
} catch(IOException ioe) {
|
||||
System.out.println("Failed to read Quest.wz file.");
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void fetchSkillbooksFromReactors() {
|
||||
Connection con = null;
|
||||
try {
|
||||
con = DatabaseConnection.getConnection();
|
||||
|
||||
PreparedStatement ps = con.prepareStatement("SELECT itemid FROM reactordrops WHERE itemid >= ? AND itemid < ?;");
|
||||
ps.setInt(1, skillbookMinItemid);
|
||||
ps.setInt(2, skillbookMaxItemid);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
if (rs.isBeforeFirst()) {
|
||||
while(rs.next()) {
|
||||
foundSkillbooks.put(rs.getInt("itemid"), SkillBookEntry.REACTOR);
|
||||
}
|
||||
}
|
||||
|
||||
rs.close();
|
||||
ps.close();
|
||||
|
||||
con.close();
|
||||
} catch (SQLException sqle) {
|
||||
sqle.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void listFiles(String directoryName, ArrayList<File> files) {
|
||||
File directory = new File(directoryName);
|
||||
|
||||
// get all the files from a directory
|
||||
File[] fList = directory.listFiles();
|
||||
for (File file : fList) {
|
||||
if (file.isFile()) {
|
||||
files.add(file);
|
||||
} else if (file.isDirectory()) {
|
||||
listFiles(file.getAbsolutePath(), files);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<File> listFilesFromDirectoryRecursively(String directory) {
|
||||
ArrayList<File> files = new ArrayList<>();
|
||||
listFiles(directory, files);
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
private static void filterScriptDirectorySearchMatchingData(String path) {
|
||||
for (File file : listFilesFromDirectoryRecursively(rootDirectory + "/" + path)) {
|
||||
if (file.getName().endsWith(".js")) {
|
||||
fileSearchMatchingData(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Set<Integer> foundMatchingDataOnFile(String fileContent) {
|
||||
Set<Integer> matches = new HashSet<>(4);
|
||||
|
||||
Matcher searchM = Pattern.compile("22(8|9)[0-9]{4}").matcher(fileContent);
|
||||
int idx = 0;
|
||||
while (searchM.find(idx)) {
|
||||
idx = searchM.end();
|
||||
matches.add(Integer.valueOf(fileContent.substring(searchM.start(), idx)));
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
static String readFileToString(File file, String encoding) throws IOException {
|
||||
Scanner scanner = new Scanner(file, encoding);
|
||||
String text = "";
|
||||
try {
|
||||
try {
|
||||
text = scanner.useDelimiter("\\A").next();
|
||||
} finally {
|
||||
scanner.close();
|
||||
}
|
||||
} catch (NoSuchElementException e) {}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
private static void fileSearchMatchingData(File file) {
|
||||
try {
|
||||
String fileContent = readFileToString(file, "UTF-8");
|
||||
|
||||
Set<Integer> books = foundMatchingDataOnFile(fileContent);
|
||||
for (Integer i : books) {
|
||||
foundSkillbooks.put(i, SkillBookEntry.SCRIPT);
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
System.out.println("Failed to read " + file.getName() + ".");
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void fetchSkillbooksFromScripts() {
|
||||
filterScriptDirectorySearchMatchingData("scripts");
|
||||
}
|
||||
|
||||
private static void loadSkillbooks() {
|
||||
fetchSkillbooksFromQuests();
|
||||
fetchSkillbooksFromReactors();
|
||||
fetchSkillbooksFromScripts();
|
||||
}
|
||||
|
||||
public SkillBookEntry getSkillbookAvailability(int itemid) {
|
||||
SkillBookEntry sbe = foundSkillbooks.get(itemid);
|
||||
return sbe != null ? sbe : SkillBookEntry.UNAVAILABLE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -753,10 +753,7 @@ public class MapleStatEffect {
|
||||
} else {
|
||||
if (isResurrection()) {
|
||||
hpchange = applyto.getCurrentMaxHp();
|
||||
applyto.setStance(0);
|
||||
|
||||
applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.removePlayerFromMap(applyto.getId()), false);
|
||||
applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.spawnPlayerMapObject(applyto), false);
|
||||
applyto.broadcastStance(applyto.isFacingLeft() ? 5 : 4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -895,9 +892,6 @@ public class MapleStatEffect {
|
||||
applyfrom.getMap().spawnMist(mist, getDuration(), mist.isPoisonMist(), false, mist.isRecoveryMist());
|
||||
} else if(isTimeLeap()) {
|
||||
applyto.removeAllCooldownsExcept(Buccaneer.TIME_LEAP, true);
|
||||
} else if(isHyperBody() && !primary) {
|
||||
applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.removePlayerFromMap(applyto.getId()), false);
|
||||
applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.spawnPlayerMapObject(applyto), false);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -445,8 +445,14 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
}
|
||||
|
||||
private int calcThresholdLevel(boolean isPqMob) {
|
||||
if(isPqMob || !ServerConstants.USE_ENFORCE_MOB_LEVEL_RANGE) {
|
||||
if(!ServerConstants.USE_ENFORCE_MOB_LEVEL_RANGE) {
|
||||
return 0;
|
||||
} else if (isPqMob) {
|
||||
double thresholdLevel = getLevel();
|
||||
thresholdLevel /= 32.55916838;
|
||||
thresholdLevel = Math.log(thresholdLevel) / 0.02058204546;
|
||||
|
||||
return (int) Math.ceil(thresholdLevel);
|
||||
} else {
|
||||
return getLevel() - (!isBoss() ? ServerConstants.MIN_UNDERLEVEL_TO_EXP_GAIN : 2 * ServerConstants.MIN_UNDERLEVEL_TO_EXP_GAIN);
|
||||
}
|
||||
|
||||
@@ -613,7 +613,14 @@ public class MaplePlayerNPC extends AbstractMapleMapObject {
|
||||
|
||||
public static void multicastSpawnPlayerNPC(int mapid, int world) {
|
||||
World wserv = Server.getInstance().getWorld(world);
|
||||
for(MapleCharacter mc : wserv.getAllCharactersView()) {
|
||||
if (wserv == null) return;
|
||||
|
||||
MapleClient c = new MapleClient(null, null, null); // mock client
|
||||
c.setWorld(world);
|
||||
c.setChannel(1);
|
||||
|
||||
for(MapleCharacter mc : wserv.loadAndGetAllCharactersView()) {
|
||||
mc.setClient(c);
|
||||
spawnPlayerNPC(mapid, mc);
|
||||
}
|
||||
}
|
||||
@@ -630,14 +637,12 @@ public class MaplePlayerNPC extends AbstractMapleMapObject {
|
||||
int world = rs.getInt("world"), map = rs.getInt("map");
|
||||
if(world >= wsize) continue;
|
||||
|
||||
World w = Server.getInstance().getWorld(world);
|
||||
for (Channel channel : w.getChannels()) {
|
||||
for (Channel channel : Server.getInstance().getChannelsFromWorld(world)) {
|
||||
MapleMap m = channel.getMapFactory().getMap(map);
|
||||
|
||||
for(MapleMapObject pnpcObj : m.getMapObjectsInRange(new Point(0, 0), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.PLAYER_NPC))) {
|
||||
MaplePlayerNPC pn = (MaplePlayerNPC) pnpcObj;
|
||||
|
||||
m.removeMapObject(pn);
|
||||
m.removeMapObject(pnpcObj);
|
||||
m.broadcastMessage(MaplePacketCreator.removeNPCController(pn.getObjectId()));
|
||||
m.broadcastMessage(MaplePacketCreator.removePlayerNPC(pn.getObjectId()));
|
||||
}
|
||||
|
||||
@@ -427,8 +427,9 @@ public class MapleMap {
|
||||
try {
|
||||
Integer curOid;
|
||||
|
||||
// clashes with playernpc on curOid >= 2147000000, developernpc uses >= 2147483000
|
||||
do {
|
||||
if ((curOid = runningOid.incrementAndGet()) < 0) { // clashes with playernpc on curOid >= 2147000000, developernpc uses >= 2147483000
|
||||
if ((curOid = runningOid.incrementAndGet()) >= 2147000000) {
|
||||
runningOid.set(curOid = 1000000001);
|
||||
}
|
||||
} while (mapobjects.containsKey(curOid));
|
||||
@@ -1610,9 +1611,6 @@ public class MapleMap {
|
||||
}
|
||||
|
||||
public boolean containsNPC(int npcid) {
|
||||
if (npcid == 9000066) {
|
||||
return true;
|
||||
}
|
||||
objectRLock.lock();
|
||||
try {
|
||||
for (MapleMapObject obj : mapobjects.values()) {
|
||||
@@ -2453,13 +2451,13 @@ public class MapleMap {
|
||||
chr.removeSandboxItems();
|
||||
|
||||
if (chr.isHidden()) {
|
||||
broadcastGMMessage(chr, MaplePacketCreator.spawnEnterPlayerMapObject(chr), false);
|
||||
broadcastGMSpawnPlayerMapObjectMessage(chr, chr, true);
|
||||
chr.announce(MaplePacketCreator.getGMEffect(0x10, (byte) 1));
|
||||
|
||||
List<Pair<MapleBuffStat, Integer>> dsstat = Collections.singletonList(new Pair<MapleBuffStat, Integer>(MapleBuffStat.DARKSIGHT, 0));
|
||||
broadcastGMMessage(chr, MaplePacketCreator.giveForeignBuff(chr.getId(), dsstat), false);
|
||||
} else {
|
||||
broadcastMessage(chr, MaplePacketCreator.spawnEnterPlayerMapObject(chr), false);
|
||||
broadcastSpawnPlayerMapObjectMessage(chr, chr, true);
|
||||
}
|
||||
|
||||
sendObjectPlacement(chr.getClient());
|
||||
@@ -2781,6 +2779,50 @@ public class MapleMap {
|
||||
}
|
||||
}
|
||||
|
||||
public void broadcastSpawnPlayerMapObjectMessage(MapleCharacter source, MapleCharacter player, boolean enteringField) {
|
||||
broadcastSpawnPlayerMapObjectMessage(source, player, enteringField, false);
|
||||
}
|
||||
|
||||
public void broadcastGMSpawnPlayerMapObjectMessage(MapleCharacter source, MapleCharacter player, boolean enteringField) {
|
||||
broadcastSpawnPlayerMapObjectMessage(source, player, enteringField, true);
|
||||
}
|
||||
|
||||
private void broadcastSpawnPlayerMapObjectMessage(MapleCharacter source, MapleCharacter player, boolean enteringField, boolean gmBroadcast) {
|
||||
chrRLock.lock();
|
||||
try {
|
||||
if (gmBroadcast) {
|
||||
for (MapleCharacter chr : characters) {
|
||||
if (chr.isGM()) {
|
||||
if (chr != source) {
|
||||
chr.announce(MaplePacketCreator.spawnPlayerMapObject(chr.getClient(), player, enteringField));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (MapleCharacter chr : characters) {
|
||||
if (chr != source) {
|
||||
chr.announce(MaplePacketCreator.spawnPlayerMapObject(chr.getClient(), player, enteringField));
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
chrRLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void broadcastUpdateCharLookMessage(MapleCharacter source, MapleCharacter player) {
|
||||
chrRLock.lock();
|
||||
try {
|
||||
for (MapleCharacter chr : characters) {
|
||||
if (chr != source) {
|
||||
chr.announce(MaplePacketCreator.updateCharLook(chr.getClient(), player));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
chrRLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void dropMessage(int type, String message) {
|
||||
broadcastStringMessage(type, message);
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ public class MapleQuest {
|
||||
private boolean autoStart;
|
||||
private boolean autoPreComplete, autoComplete;
|
||||
private boolean repeatable = false;
|
||||
private String name = "", parent = "";
|
||||
private final static MapleDataProvider questData = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Quest.wz"));
|
||||
private static MapleData questInfo;
|
||||
private static MapleData questAct;
|
||||
@@ -87,6 +88,9 @@ public class MapleQuest {
|
||||
if(questInfo != null) {
|
||||
MapleData reqInfo = questInfo.getChildByPath(String.valueOf(id));
|
||||
if(reqInfo != null) {
|
||||
name = MapleDataTool.getString("name", reqInfo, "");
|
||||
parent = MapleDataTool.getString("parent", reqInfo, "");
|
||||
|
||||
timeLimit = MapleDataTool.getInt("timeLimit", reqInfo, 0);
|
||||
timeLimit2 = MapleDataTool.getInt("timeLimit2", reqInfo, 0);
|
||||
autoStart = MapleDataTool.getInt("autoStart", reqInfo, 0) == 1;
|
||||
@@ -550,6 +554,27 @@ public class MapleQuest {
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getParentName() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public static List<MapleQuest> getMatchedQuests(String search) {
|
||||
List<MapleQuest> ret = new LinkedList<>();
|
||||
|
||||
search = search.toLowerCase();
|
||||
for (MapleQuest mq : quests.values()) {
|
||||
if (mq.name.toLowerCase().contains(search) || mq.parent.toLowerCase().contains(search)) {
|
||||
ret.add(mq);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void loadAllQuest() {
|
||||
questInfo = questData.getData("QuestInfo.img");
|
||||
questReq = questData.getData("Check.img");
|
||||
|
||||
@@ -713,13 +713,13 @@ public class MaplePacketCreator {
|
||||
mplew.write(0);
|
||||
|
||||
mplew.write(0); // IsQuietBan
|
||||
mplew.writeLong(0);//IsQuietBanTimeStamp
|
||||
mplew.writeLong(0); //CreationTimeStamp
|
||||
mplew.writeLong(0);//IsQuietBanTimeStamp
|
||||
mplew.writeLong(0); //CreationTimeStamp
|
||||
|
||||
mplew.writeInt(1); // 1: Remove the "Select the world you want to play in"
|
||||
|
||||
mplew.write(ServerConstants.ENABLE_PIN ? 0 : 1); // 0 = Pin-System Enabled, 1 = Disabled
|
||||
mplew.write(ServerConstants.ENABLE_PIC ? (c.getPic() == null ? 0 : 1) : 2); // 0 = Register PIC, 1 = Ask for PIC, 2 = Disabled
|
||||
|
||||
mplew.write(ServerConstants.ENABLE_PIN && !c.canBypassPin() ? 0 : 1); // 0 = Pin-System Enabled, 1 = Disabled
|
||||
mplew.write(ServerConstants.ENABLE_PIC && !c.canBypassPic() ? (c.getPic() == null ? 0 : 1) : 2); // 0 = Register PIC, 1 = Ask for PIC, 2 = Disabled
|
||||
|
||||
return mplew.getPacket();
|
||||
}
|
||||
@@ -889,7 +889,7 @@ public class MaplePacketCreator {
|
||||
addCharEntry(mplew, chr, false);
|
||||
}
|
||||
|
||||
mplew.write(ServerConstants.ENABLE_PIC ? (c.getPic() == null ? 0 : 1) : 2);
|
||||
mplew.write(ServerConstants.ENABLE_PIC && !c.canBypassPic() ? (c.getPic() == null ? 0 : 1) : 2);
|
||||
mplew.writeInt(ServerConstants.COLLECTIVE_CHARSLOT ? chars.size() + c.getAvailableCharacterSlots() : c.getCharacterSlots());
|
||||
return mplew.getPacket();
|
||||
}
|
||||
@@ -1049,7 +1049,7 @@ public class MaplePacketCreator {
|
||||
mplew.writeShort(chr.getHp());
|
||||
mplew.writeBool(false);
|
||||
mplew.writeLong(getTime(Server.getInstance().getCurrentTime()));
|
||||
mplew.writeInt(0);
|
||||
mplew.skip(5);
|
||||
return mplew.getPacket();
|
||||
}
|
||||
|
||||
@@ -1066,7 +1066,7 @@ public class MaplePacketCreator {
|
||||
mplew.writeInt(spawnPosition.x); // spawn position placement thanks to Arnah (Vertisy)
|
||||
mplew.writeInt(spawnPosition.y);
|
||||
mplew.writeLong(getTime(Server.getInstance().getCurrentTime()));
|
||||
mplew.writeInt(0);
|
||||
mplew.skip(5);
|
||||
return mplew.getPacket();
|
||||
}
|
||||
|
||||
@@ -1829,19 +1829,12 @@ public class MaplePacketCreator {
|
||||
/**
|
||||
* Gets a packet spawning a player as a mapobject to other clients.
|
||||
*
|
||||
* @param target The client receiving this packet.
|
||||
* @param chr The character to spawn to other clients.
|
||||
* @param enteringField Whether the character to spawn is not yet present in the map or already is.
|
||||
* @return The spawn player packet.
|
||||
*/
|
||||
|
||||
public static byte[] spawnPlayerMapObject(MapleCharacter chr) {
|
||||
return spawnPlayerMapObject(chr, false);
|
||||
}
|
||||
|
||||
public static byte[] spawnEnterPlayerMapObject(MapleCharacter chr) {
|
||||
return spawnPlayerMapObject(chr, true);
|
||||
}
|
||||
|
||||
private static byte[] spawnPlayerMapObject(MapleCharacter chr, boolean enteringField) {
|
||||
public static byte[] spawnPlayerMapObject(MapleClient target, MapleCharacter chr, boolean enteringField) {
|
||||
final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
|
||||
mplew.writeShort(SendOpcode.SPAWN_PLAYER.getValue());
|
||||
mplew.writeInt(chr.getId());
|
||||
@@ -2013,7 +2006,7 @@ public class MaplePacketCreator {
|
||||
}
|
||||
addRingLook(mplew, chr, true); // crush
|
||||
addRingLook(mplew, chr, false); // friendship
|
||||
addMarriageRingLook(mplew, chr);
|
||||
addMarriageRingLook(target, mplew, chr);
|
||||
encodeNewYearCardInfo(mplew, chr); // new year seems to crash sometimes...
|
||||
mplew.skip(2);
|
||||
mplew.write(chr.getTeam());//only needed in specific fields
|
||||
@@ -2137,17 +2130,23 @@ public class MaplePacketCreator {
|
||||
}
|
||||
}
|
||||
|
||||
private static void addMarriageRingLook(final MaplePacketLittleEndianWriter mplew, MapleCharacter chr) {
|
||||
private static void addMarriageRingLook(MapleClient target, final MaplePacketLittleEndianWriter mplew, MapleCharacter chr) {
|
||||
MapleRing ring = chr.getMarriageRing();
|
||||
|
||||
if (ring != null && !ring.equipped()) {
|
||||
if (ring == null || !ring.equipped()) {
|
||||
mplew.write(0);
|
||||
return;
|
||||
}
|
||||
mplew.writeBool(ring != null);
|
||||
if (ring != null) {
|
||||
mplew.writeInt(chr.getId());
|
||||
mplew.writeInt(ring.getPartnerChrId());
|
||||
} else {
|
||||
mplew.write(1);
|
||||
|
||||
MapleCharacter targetChr = target.getPlayer();
|
||||
if (targetChr != null && targetChr.getPartnerId() == chr.getId()) {
|
||||
mplew.writeInt(0); // 1a pessoa: ser 0 0 implica match...
|
||||
mplew.writeInt(0); // 3a pessoa: 1 2 2 1 funciona!
|
||||
} else {
|
||||
mplew.writeInt(chr.getId()); // 1a pessoa: ser 0 0 implica match...
|
||||
mplew.writeInt(ring.getPartnerChrId()); // 3a pessoa: 1 2 2 1 funciona!
|
||||
}
|
||||
|
||||
mplew.writeInt(ring.getItemId());
|
||||
}
|
||||
}
|
||||
@@ -2558,7 +2557,7 @@ public class MaplePacketCreator {
|
||||
return mplew.getPacket();
|
||||
}
|
||||
|
||||
public static byte[] updateCharLook(MapleCharacter chr) {
|
||||
public static byte[] updateCharLook(MapleClient target, MapleCharacter chr) {
|
||||
final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
|
||||
mplew.writeShort(SendOpcode.UPDATE_CHAR_LOOK.getValue());
|
||||
mplew.writeInt(chr.getId());
|
||||
@@ -2566,7 +2565,7 @@ public class MaplePacketCreator {
|
||||
addCharLook(mplew, chr, false);
|
||||
addRingLook(mplew, chr, true);
|
||||
addRingLook(mplew, chr, false);
|
||||
addMarriageRingLook(mplew, chr);
|
||||
addMarriageRingLook(target, mplew, chr);
|
||||
mplew.writeInt(0);
|
||||
return mplew.getPacket();
|
||||
}
|
||||
@@ -2913,6 +2912,7 @@ public class MaplePacketCreator {
|
||||
}
|
||||
|
||||
mplew.writeMapleAsciiString(q.getQuestData());
|
||||
mplew.skip(5);
|
||||
return mplew.getPacket();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user