Cash Shop patch + new features
Cash shop fix, new item sorting features, minor patches.
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
/build/
|
||||||
|
/dist/
|
||||||
10
README.txt
10
README.txt
@@ -4,6 +4,14 @@ Freelance developer: Ronan C. P. Lana
|
|||||||
|
|
||||||
Credits about are to be given to the original MapleSolaxia staff and other colaborators, as some minor
|
Credits about are to be given to the original MapleSolaxia staff and other colaborators, as some minor
|
||||||
changes/patches on the game were applied by me.
|
changes/patches on the game were applied by me.
|
||||||
|
|
||||||
|
This is a NetBeans 8.0.2 Project. This means that it's easier to install the project via "NetBeans' import
|
||||||
|
new project using existing code". Once installed, build this project on your machine and run the server using
|
||||||
|
the "launch.bat" application.
|
||||||
|
|
||||||
|
|
||||||
|
Note that the project uses the IP 25.15.163.31. Therefore, change the IP wherever it applies to run properly
|
||||||
|
the program. Eventually, I will change the settings on this repository to run at localhost (127.0.0.1).
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
@@ -11,4 +19,4 @@ To run it in Windows 10:
|
|||||||
- Install everything normally;
|
- Install everything normally;
|
||||||
- WampServer 2.0 -> change port 80 at "httpd.conf" to another, as it clashes with a Windows
|
- WampServer 2.0 -> change port 80 at "httpd.conf" to another, as it clashes with a Windows
|
||||||
default port.
|
default port.
|
||||||
- Run MapleStory client using these: "Windows XP (SP2)" & "16-bit color mode";
|
- Run MapleStory client using these: "Windows XP (SP2)" & "(8 or 16)-bit color mode";
|
||||||
@@ -76,8 +76,15 @@ Correcao de bug que nao retirava corretamente recursos de projeteis.
|
|||||||
Movimentação no ranking agora é contabilizado corretamente.
|
Movimentação no ranking agora é contabilizado corretamente.
|
||||||
|
|
||||||
11 Dezembro 2015,
|
11 Dezembro 2015,
|
||||||
Corrigi bug que nao permitia ao tentar aceitar quest remotamente (lightbulb).
|
Correcao de bug que nao permitia ao tentar aceitar quest remotamente (lightbulb).
|
||||||
|
|
||||||
26 --- 29 Dezembro 2015,
|
26 --- 29 Dezembro 2015,
|
||||||
Correcao de movimentacao no Ranking, a cada atualizacao do sistema.
|
Correcao de movimentacao no Ranking, a cada atualizacao do sistema.
|
||||||
Implementacao e aprimoramento das funcionalidades de ItemSort e SlotMerger do inventario.
|
Implementacao e aprimoramento das funcionalidades de ItemSort e SlotMerger do inventario.
|
||||||
|
Correcao de bug em scripts que fazia o jogador ficar preso num mapa de transicao (barco, por ex.).
|
||||||
|
|
||||||
|
01 Janeiro 2016,
|
||||||
|
Correcao de bug, onde o sistema nao contabilizava corretamente queda de HP em determinados mapas.
|
||||||
|
|
||||||
|
03 Janeiro 2016,
|
||||||
|
Correcao de bug, onde clientes podiam congelar apos acessar o Cash Shop.
|
||||||
@@ -3,7 +3,25 @@
|
|||||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||||
<group>
|
<group>
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/src/net/server/RankingWorker.java</file>
|
<file>file:/C:/Nexon/MapleSolaxia/src/net/server/world/World.java</file>
|
||||||
|
<file>file:/C:/Nexon/MapleSolaxia/src/server/MapleStatEffect.java</file>
|
||||||
|
<file>file:/C:/Nexon/MapleSolaxia/src/net/MapleServerHandler.java</file>
|
||||||
|
<file>file:/C:/Nexon/MapleSolaxia/src/client/MapleClient.java</file>
|
||||||
|
<file>file:/C:/Nexon/MapleSolaxia/src/net/server/PlayerStorage.java</file>
|
||||||
|
<file>file:/C:/Nexon/MapleSolaxia/src/client/command/Commands.java</file>
|
||||||
|
<file>file:/C:/Nexon/MapleSolaxia/src/client/MapleCharacter.java</file>
|
||||||
|
<file>file:/C:/Nexon/MapleSolaxia/src/net/server/channel/handlers/ChangeMapSpecialHandler.java</file>
|
||||||
|
<file>file:/C:/Nexon/MapleSolaxia/src/tools/MaplePacketCreator.java</file>
|
||||||
|
<file>file:/C:/Nexon/MapleSolaxia/src/net/server/channel/handlers/EnterMTSHandler.java</file>
|
||||||
|
<file>file:/C:/Nexon/MapleSolaxia/src/net/server/channel/Channel.java</file>
|
||||||
|
<file>file:/C:/Nexon/MapleSolaxia/src/net/server/channel/handlers/EnterCashShopHandler.java</file>
|
||||||
|
<file>file:/C:/Nexon/MapleSolaxia/src/net/server/channel/handlers/ChangeMapHandler.java</file>
|
||||||
|
<file>file:/C:/Nexon/MapleSolaxia/src/net/server/channel/handlers/StorageHandler.java</file>
|
||||||
|
<file>file:/C:/Nexon/MapleSolaxia/src/net/server/channel/handlers/PlayerLoggedinHandler.java</file>
|
||||||
|
<file>file:/C:/Nexon/MapleSolaxia/src/net/PacketProcessor.java</file>
|
||||||
|
<file>file:/C:/Nexon/MapleSolaxia/src/net/server/channel/handlers/ChangeChannelHandler.java</file>
|
||||||
|
<file>file:/C:/Nexon/MapleSolaxia/src/constants/ServerConstants.java</file>
|
||||||
|
<file>file:/C:/Nexon/MapleSolaxia/src/server/maps/MapleMap.java</file>
|
||||||
</group>
|
</group>
|
||||||
</open-files>
|
</open-files>
|
||||||
</project-private>
|
</project-private>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ var Orbis_Station;
|
|||||||
var Ludibrium_Station;
|
var Ludibrium_Station;
|
||||||
|
|
||||||
//Time Setting is in millisecond
|
//Time Setting is in millisecond
|
||||||
var closeTime = 60 * 1000; //The time to close the gate
|
var closeTime = 50 * 1000; //The time to close the gate
|
||||||
var beginTime = 60 * 1000; //The time to begin the ride
|
var beginTime = 60 * 1000; //The time to begin the ride
|
||||||
var rideTime = 60 * 1000; //The time that require move to destination
|
var rideTime = 60 * 1000; //The time that require move to destination
|
||||||
|
|
||||||
|
|||||||
@@ -2971,7 +2971,7 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
|||||||
|
|
||||||
public static MapleCharacter loadCharFromDB(int charid, MapleClient client, boolean channelserver) throws SQLException {
|
public static MapleCharacter loadCharFromDB(int charid, MapleClient client, boolean channelserver) throws SQLException {
|
||||||
try {
|
try {
|
||||||
MapleCharacter ret = new MapleCharacter();
|
MapleCharacter ret = new MapleCharacter();
|
||||||
ret.client = client;
|
ret.client = client;
|
||||||
ret.id = charid;
|
ret.id = charid;
|
||||||
Connection con = DatabaseConnection.getConnection();
|
Connection con = DatabaseConnection.getConnection();
|
||||||
@@ -3857,6 +3857,7 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
|||||||
ps.executeBatch();
|
ps.executeBatch();
|
||||||
}
|
}
|
||||||
} catch (SQLException se) {
|
} catch (SQLException se) {
|
||||||
|
se.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3871,6 +3872,7 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
|||||||
ps.execute();
|
ps.execute();
|
||||||
}
|
}
|
||||||
} catch (SQLException se) {
|
} catch (SQLException se) {
|
||||||
|
se.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3959,6 +3961,7 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
|||||||
con.setAutoCommit(true);
|
con.setAutoCommit(true);
|
||||||
con.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
|
con.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4216,7 +4219,7 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
|||||||
con.commit();
|
con.commit();
|
||||||
con.setAutoCommit(true);
|
con.setAutoCommit(true);
|
||||||
|
|
||||||
if (cashshop != null) {
|
if (cashshop != null) {
|
||||||
cashshop.save(con);
|
cashshop.save(con);
|
||||||
}
|
}
|
||||||
if (storage != null) {
|
if (storage != null) {
|
||||||
|
|||||||
@@ -506,6 +506,7 @@ public class MapleClient {
|
|||||||
rs.close();
|
rs.close();
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (loginok == 0) {
|
if (loginok == 0) {
|
||||||
@@ -755,12 +756,12 @@ public class MapleClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final void disconnect(boolean shutdown, boolean cashshop) {//once per MapleClient instance
|
public final void disconnect(boolean shutdown, boolean cashshop) {//once per MapleClient instance
|
||||||
if (disconnecting) {
|
if (disconnecting) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
disconnecting = true;
|
disconnecting = true;
|
||||||
if (player != null && player.isLoggedin() && player.getClient() != null) {
|
if (player != null && player.isLoggedin() && player.getClient() != null) {
|
||||||
MapleMap map = player.getMap();
|
MapleMap map = player.getMap();
|
||||||
final MapleParty party = player.getParty();
|
final MapleParty party = player.getParty();
|
||||||
final int idz = player.getId();
|
final int idz = player.getId();
|
||||||
final int messengerid = player.getMessenger() == null ? 0 : player.getMessenger().getId();
|
final int messengerid = player.getMessenger() == null ? 0 : player.getMessenger().getId();
|
||||||
@@ -771,13 +772,17 @@ public class MapleClient {
|
|||||||
final MapleGuildCharacter chrg = player.getMGC();
|
final MapleGuildCharacter chrg = player.getMGC();
|
||||||
final MapleGuild guild = player.getGuild();
|
final MapleGuild guild = player.getGuild();
|
||||||
|
|
||||||
removePlayer();
|
|
||||||
player.saveCooldowns();
|
|
||||||
player.saveToDB();
|
|
||||||
if (channel == -1 || shutdown) {
|
if (channel == -1 || shutdown) {
|
||||||
|
removePlayer();
|
||||||
|
player.saveCooldowns();
|
||||||
|
player.saveToDB();
|
||||||
|
|
||||||
player = null;
|
player = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removePlayer();
|
||||||
|
|
||||||
final World worlda = getWorldServer();
|
final World worlda = getWorldServer();
|
||||||
try {
|
try {
|
||||||
if (!cashshop) {
|
if (!cashshop) {
|
||||||
@@ -854,7 +859,10 @@ public class MapleClient {
|
|||||||
}
|
}
|
||||||
player.logOff();
|
player.logOff();
|
||||||
}
|
}
|
||||||
player = null;
|
|
||||||
|
player.saveCooldowns();
|
||||||
|
player.saveToDB();
|
||||||
|
player = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!serverTransition && isLoggedIn()) {
|
if (!serverTransition && isLoggedIn()) {
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public final class MonsterBook {
|
|||||||
c.announce(MaplePacketCreator.addCard(false, cardid, 1));
|
c.announce(MaplePacketCreator.addCard(false, cardid, 1));
|
||||||
c.announce(MaplePacketCreator.showGainCard());
|
c.announce(MaplePacketCreator.showGainCard());
|
||||||
calculateLevel();
|
calculateLevel();
|
||||||
|
|
||||||
c.getPlayer().saveToDB();
|
c.getPlayer().saveToDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ public class ServerConstants {
|
|||||||
public static final boolean USE_FAMILY_SYSTEM = false;
|
public static final boolean USE_FAMILY_SYSTEM = false;
|
||||||
public static final boolean USE_DUEY = true;
|
public static final boolean USE_DUEY = true;
|
||||||
public static final boolean USE_ITEM_SORT = true;
|
public static final boolean USE_ITEM_SORT = true;
|
||||||
|
public static final boolean USE_ITEM_SORT_BY_NAME = false; //item sorting based on name rather than id.
|
||||||
public static final boolean USE_PARTY_SEARCH = false;
|
public static final boolean USE_PARTY_SEARCH = false;
|
||||||
public static final boolean USE_AUTOBAN = false; //commands the server to detect infractors automatically.
|
public static final boolean USE_AUTOBAN = false; //commands the server to detect infractors automatically.
|
||||||
public static final boolean USE_ANOTHER_AUTOASSIGN = true; //based on distributing AP accordingly with higher secondary stat on equipments.
|
public static final boolean USE_ANOTHER_AUTOASSIGN = true; //based on distributing AP accordingly with higher secondary stat on equipments.
|
||||||
|
|||||||
@@ -60,7 +60,9 @@ public class MapleServerHandler extends IoHandlerAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
|
public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
|
||||||
if (cause instanceof IOException || cause instanceof ClassCastException) {
|
System.out.println("disconnect by exception");
|
||||||
|
|
||||||
|
if (cause instanceof IOException || cause instanceof ClassCastException) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MapleClient mc = (MapleClient) session.getAttribute(MapleClient.CLIENT_KEY);
|
MapleClient mc = (MapleClient) session.getAttribute(MapleClient.CLIENT_KEY);
|
||||||
@@ -107,7 +109,7 @@ public class MapleServerHandler extends IoHandlerAdapter {
|
|||||||
try {
|
try {
|
||||||
boolean inCashShop = false;
|
boolean inCashShop = false;
|
||||||
if (client.getPlayer() != null) {
|
if (client.getPlayer() != null) {
|
||||||
inCashShop = client.getPlayer().getCashShop().isOpened();
|
inCashShop = client.getPlayer().getCashShop().isOpened();
|
||||||
}
|
}
|
||||||
client.disconnect(false, inCashShop);
|
client.disconnect(false, inCashShop);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
|||||||
@@ -595,6 +595,7 @@ public class Server implements Runnable {
|
|||||||
try {
|
try {
|
||||||
instance.finalize();//FUU I CAN AND IT'S FREE
|
instance.finalize();//FUU I CAN AND IT'S FREE
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
instance = null;
|
instance = null;
|
||||||
System.gc();
|
System.gc();
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler {
|
|||||||
default:
|
default:
|
||||||
c.getPlayer().dropMessage("Feature not available");
|
c.getPlayer().dropMessage("Feature not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
alliance.saveToDB();
|
alliance.saveToDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public final class CashOperationHandler extends AbstractMaplePacketHandler {
|
|||||||
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
||||||
MapleCharacter chr = c.getPlayer();
|
MapleCharacter chr = c.getPlayer();
|
||||||
CashShop cs = chr.getCashShop();
|
CashShop cs = chr.getCashShop();
|
||||||
|
|
||||||
if (!cs.isOpened()) {
|
if (!cs.isOpened()) {
|
||||||
c.announce(MaplePacketCreator.enableActions());
|
c.announce(MaplePacketCreator.enableActions());
|
||||||
return;
|
return;
|
||||||
@@ -98,6 +99,7 @@ public final class CashOperationHandler extends AbstractMaplePacketHandler {
|
|||||||
try {
|
try {
|
||||||
chr.sendNote(recipient.get("name"), chr.getName() + " has sent you a gift! Go check out the Cash Shop.", (byte) 0); //fame or not
|
chr.sendNote(recipient.get("name"), chr.getName() + " has sent you a gift! Go check out the Cash Shop.", (byte) 0); //fame or not
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
MapleCharacter receiver = c.getChannelServer().getPlayerStorage().getCharacterByName(recipient.get("name"));
|
MapleCharacter receiver = c.getChannelServer().getPlayerStorage().getCharacterByName(recipient.get("name"));
|
||||||
if (receiver != null) receiver.showNote();
|
if (receiver != null) receiver.showNote();
|
||||||
@@ -283,6 +285,7 @@ public final class CashOperationHandler extends AbstractMaplePacketHandler {
|
|||||||
try {
|
try {
|
||||||
chr.sendNote(partner.getName(), text, (byte) 1);
|
chr.sendNote(partner.getName(), text, (byte) 1);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
partner.showNote();
|
partner.showNote();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public final class ChangeMapHandler extends AbstractMaplePacketHandler {
|
|||||||
}
|
}
|
||||||
if (slea.available() == 0) { //Cash Shop :)
|
if (slea.available() == 0) { //Cash Shop :)
|
||||||
if(!chr.getCashShop().isOpened()) {
|
if(!chr.getCashShop().isOpened()) {
|
||||||
c.disconnect(false, false);
|
c.disconnect(false, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String[] socket = c.getChannelServer().getIP().split(":");
|
String[] socket = c.getChannelServer().getIP().split(":");
|
||||||
@@ -62,7 +62,7 @@ public final class ChangeMapHandler extends AbstractMaplePacketHandler {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(chr.getCashShop().isOpened()) {
|
if(chr.getCashShop().isOpened()) {
|
||||||
c.disconnect(false, false);
|
c.disconnect(false, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -38,21 +38,25 @@ public class EnterCashShopHandler extends AbstractMaplePacketHandler {
|
|||||||
try {
|
try {
|
||||||
MapleCharacter mc = c.getPlayer();
|
MapleCharacter mc = c.getPlayer();
|
||||||
|
|
||||||
if (mc.getCashShop().isOpened()) return;
|
if (mc.getCashShop().isOpened()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Server.getInstance().getPlayerBuffStorage().addBuffsToStorage(mc.getId(), mc.getAllBuffs());
|
Server.getInstance().getPlayerBuffStorage().addBuffsToStorage(mc.getId(), mc.getAllBuffs());
|
||||||
mc.cancelBuffEffects();
|
mc.cancelBuffEffects();
|
||||||
mc.cancelExpirationTask();
|
mc.cancelExpirationTask();
|
||||||
c.announce(MaplePacketCreator.openCashShop(c, false));
|
|
||||||
mc.saveToDB();
|
c.announce(MaplePacketCreator.openCashShop(c, false));
|
||||||
mc.getCashShop().open(true);
|
c.announce(MaplePacketCreator.showCashInventory(c));
|
||||||
mc.getMap().removePlayer(mc);
|
c.announce(MaplePacketCreator.showGifts(mc.getCashShop().loadGifts()));
|
||||||
c.getChannelServer().removePlayer(mc);
|
c.announce(MaplePacketCreator.showWishList(mc, false));
|
||||||
|
c.announce(MaplePacketCreator.showCash(mc));
|
||||||
c.announce(MaplePacketCreator.showCashInventory(c));
|
|
||||||
c.announce(MaplePacketCreator.showGifts(mc.getCashShop().loadGifts()));
|
|
||||||
c.announce(MaplePacketCreator.showWishList(mc, false));
|
c.getChannelServer().removePlayer(mc);
|
||||||
c.announce(MaplePacketCreator.showCash(mc));
|
mc.getMap().removePlayer(mc);
|
||||||
|
mc.getCashShop().open(true);
|
||||||
|
mc.saveToDB();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,10 +60,12 @@ public final class EnterMTSHandler extends AbstractMaplePacketHandler {
|
|||||||
Server.getInstance().getPlayerBuffStorage().addBuffsToStorage(chr.getId(), chr.getAllBuffs());
|
Server.getInstance().getPlayerBuffStorage().addBuffsToStorage(chr.getId(), chr.getAllBuffs());
|
||||||
chr.cancelExpirationTask();
|
chr.cancelExpirationTask();
|
||||||
chr.saveToDB();
|
chr.saveToDB();
|
||||||
|
System.out.println("STRANGE SAVE TO DB");
|
||||||
chr.getMap().removePlayer(c.getPlayer());
|
chr.getMap().removePlayer(c.getPlayer());
|
||||||
try {
|
try {
|
||||||
c.announce(MaplePacketCreator.openCashShop(c, true));
|
c.announce(MaplePacketCreator.openCashShop(c, true));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
chr.getCashShop().open(true);// xD
|
chr.getCashShop().open(true);// xD
|
||||||
c.announce(MaplePacketCreator.enableCSUse());
|
c.announce(MaplePacketCreator.enableCSUse());
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
package net.server.channel.handlers;
|
package net.server.channel.handlers;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import constants.ServerConstants;
|
import constants.ServerConstants;
|
||||||
@@ -32,35 +31,181 @@ import tools.data.input.SeekableLittleEndianAccessor;
|
|||||||
import client.MapleCharacter;
|
import client.MapleCharacter;
|
||||||
import client.MapleClient;
|
import client.MapleClient;
|
||||||
import client.inventory.Item;
|
import client.inventory.Item;
|
||||||
|
import client.inventory.Equip;
|
||||||
import client.inventory.MapleInventory;
|
import client.inventory.MapleInventory;
|
||||||
import client.inventory.MapleInventoryType;
|
import client.inventory.MapleInventoryType;
|
||||||
import client.inventory.ModifyInventory;
|
import client.inventory.ModifyInventory;
|
||||||
|
import server.MapleItemInformationProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BubblesDev
|
* @author BubblesDev
|
||||||
*/
|
*/
|
||||||
public final class ItemIdSortHandler extends AbstractMaplePacketHandler {
|
|
||||||
|
|
||||||
|
class PairedQuicksort {
|
||||||
|
/* by RonanLana */
|
||||||
|
|
||||||
|
private int i = 0;
|
||||||
|
private int j = 0;
|
||||||
|
private final ArrayList<Integer> intersect;
|
||||||
|
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||||
|
|
||||||
|
private void PartitionByItemId(int Esq, int Dir, ArrayList<Item> A) {
|
||||||
|
Item x, w;
|
||||||
|
|
||||||
|
i = Esq;
|
||||||
|
j = Dir;
|
||||||
|
|
||||||
|
x = A.get((i + j) / 2);
|
||||||
|
do {
|
||||||
|
while (x.getItemId() > A.get(i).getItemId()) i++;
|
||||||
|
while (x.getItemId() < A.get(j).getItemId()) j--;
|
||||||
|
|
||||||
|
if (i <= j) {
|
||||||
|
w = A.get(i);
|
||||||
|
A.set(i, A.get(j));
|
||||||
|
A.set(j, w);
|
||||||
|
|
||||||
|
i++;
|
||||||
|
j--;
|
||||||
|
}
|
||||||
|
} while (i <= j);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PartitionByName(int Esq, int Dir, ArrayList<Item> A) {
|
||||||
|
Item x, w;
|
||||||
|
|
||||||
|
i = Esq;
|
||||||
|
j = Dir;
|
||||||
|
|
||||||
|
x = A.get((i + j) / 2);
|
||||||
|
do {
|
||||||
|
while (ii.getName(x.getItemId()).compareTo(ii.getName(A.get(i).getItemId())) > 0) i++;
|
||||||
|
while (ii.getName(x.getItemId()).compareTo(ii.getName(A.get(j).getItemId())) < 0) j--;
|
||||||
|
|
||||||
|
if (i <= j) {
|
||||||
|
w = A.get(i);
|
||||||
|
A.set(i, A.get(j));
|
||||||
|
A.set(j, w);
|
||||||
|
|
||||||
|
i++;
|
||||||
|
j--;
|
||||||
|
}
|
||||||
|
} while (i <= j);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PartitionByQuantity(int Esq, int Dir, ArrayList<Item> A) {
|
||||||
|
Item x, w;
|
||||||
|
|
||||||
|
i = Esq;
|
||||||
|
j = Dir;
|
||||||
|
|
||||||
|
x = A.get((i + j) / 2);
|
||||||
|
do {
|
||||||
|
while (x.getQuantity() > A.get(i).getQuantity()) i++;
|
||||||
|
while (x.getQuantity() < A.get(j).getQuantity()) j--;
|
||||||
|
|
||||||
|
if (i <= j) {
|
||||||
|
w = A.get(i);
|
||||||
|
A.set(i, A.get(j));
|
||||||
|
A.set(j, w);
|
||||||
|
|
||||||
|
i++;
|
||||||
|
j--;
|
||||||
|
}
|
||||||
|
} while (i <= j);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PartitionByLevel(int Esq, int Dir, ArrayList<Item> A) {
|
||||||
|
Equip x, w, eqpI, eqpJ;
|
||||||
|
|
||||||
|
i = Esq;
|
||||||
|
j = Dir;
|
||||||
|
|
||||||
|
x = (Equip)(A.get((i + j) / 2));
|
||||||
|
|
||||||
|
do {
|
||||||
|
eqpI = (Equip)A.get(i);
|
||||||
|
eqpJ = (Equip)A.get(j);
|
||||||
|
|
||||||
|
while (x.getLevel() > eqpI.getLevel()) i++;
|
||||||
|
while (x.getLevel() < eqpJ.getLevel()) j--;
|
||||||
|
|
||||||
|
if (i <= j) {
|
||||||
|
w = (Equip)A.get(i);
|
||||||
|
A.set(i, A.get(j));
|
||||||
|
A.set(j, (Item)w);
|
||||||
|
|
||||||
|
i++;
|
||||||
|
j--;
|
||||||
|
}
|
||||||
|
} while (i <= j);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MapleQuicksort(int Esq, int Dir, ArrayList<Item> A, int sort) {
|
||||||
|
switch(sort) {
|
||||||
|
case 3:
|
||||||
|
PartitionByLevel(Esq, Dir, A);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
PartitionByName(Esq, Dir, A);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
PartitionByQuantity(Esq, Dir, A);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
PartitionByItemId(Esq, Dir, A);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (Esq < j) MapleQuicksort(Esq, j, A, sort);
|
||||||
|
if (i < Dir) MapleQuicksort(i, Dir, A, sort);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PairedQuicksort(ArrayList<Item> A, int primarySort, int secondarySort) {
|
||||||
|
intersect = new ArrayList<>();
|
||||||
|
|
||||||
|
MapleQuicksort(0, A.size() - 1, A, primarySort);
|
||||||
|
|
||||||
|
intersect.add(0);
|
||||||
|
for(int ind = 1; ind < A.size(); ind++) {
|
||||||
|
if(A.get(ind - 1).getItemId() != A.get(ind).getItemId()) {
|
||||||
|
intersect.add(ind);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intersect.add(A.size());
|
||||||
|
|
||||||
|
for(int ind = 0; ind < intersect.size() - 1; ind++) {
|
||||||
|
MapleQuicksort(intersect.get(ind), intersect.get(ind + 1) - 1, A, secondarySort);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class ItemIdSortHandler extends AbstractMaplePacketHandler {
|
||||||
@Override
|
@Override
|
||||||
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
||||||
MapleCharacter chr = c.getPlayer();
|
MapleCharacter chr = c.getPlayer();
|
||||||
chr.getAutobanManager().setTimestamp(4, slea.readInt(), 3);
|
chr.getAutobanManager().setTimestamp(3, slea.readInt(), 3);
|
||||||
byte inventoryType = slea.readByte();
|
byte inventoryType = slea.readByte();
|
||||||
|
|
||||||
if(!chr.isGM() || !ServerConstants.USE_ITEM_SORT) {
|
if(!ServerConstants.USE_ITEM_SORT) {
|
||||||
c.announce(MaplePacketCreator.enableActions());
|
c.announce(MaplePacketCreator.enableActions());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inventoryType < 1 || inventoryType > 5) {
|
if (inventoryType < 1 || inventoryType > 5) {
|
||||||
c.disconnect(false, false);
|
c.disconnect(false, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapleInventory inventory = chr.getInventory(MapleInventoryType.getByType(inventoryType));
|
MapleInventory inventory = chr.getInventory(MapleInventoryType.getByType(inventoryType));
|
||||||
|
|
||||||
ArrayList<Item> itemarray = new ArrayList<>();
|
ArrayList<Item> itemarray = new ArrayList<>();
|
||||||
List<ModifyInventory> mods = new ArrayList<>();
|
List<ModifyInventory> mods = new ArrayList<>();
|
||||||
|
|
||||||
for (short i = 1; i <= inventory.getSlotLimit(); i++) {
|
for (short i = 1; i <= inventory.getSlotLimit(); i++) {
|
||||||
Item item = inventory.getItem(i);
|
Item item = inventory.getItem(i);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
@@ -68,19 +213,18 @@ public final class ItemIdSortHandler extends AbstractMaplePacketHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(itemarray);
|
|
||||||
for (Item item : itemarray) {
|
for (Item item : itemarray) {
|
||||||
inventory.removeItem(item.getPosition());
|
inventory.removeSlot(item.getPosition());
|
||||||
|
mods.add(new ModifyInventory(3, item));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int invTypeCriteria = (MapleInventoryType.getByType(inventoryType) == MapleInventoryType.EQUIP) ? 3 : 1;
|
||||||
|
int sortCriteria = (ServerConstants.USE_ITEM_SORT_BY_NAME == true) ? 2 : 0;
|
||||||
|
PairedQuicksort pq = new PairedQuicksort(itemarray, sortCriteria, invTypeCriteria);
|
||||||
|
|
||||||
for (Item item : itemarray) {
|
for (Item item : itemarray) {
|
||||||
//short position = item.getPosition();
|
|
||||||
inventory.addItem(item);
|
inventory.addItem(item);
|
||||||
if (inventory.getType().equals(MapleInventoryType.EQUIP)) {
|
mods.add(new ModifyInventory(0, item.copy()));//to prevent crashes
|
||||||
mods.add(new ModifyInventory(3, item));
|
|
||||||
mods.add(new ModifyInventory(0, item.copy()));//to prevent crashes
|
|
||||||
//mods.add(new ModifyInventory(2, item.copy(), position));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
itemarray.clear();
|
itemarray.clear();
|
||||||
c.announce(MaplePacketCreator.modifyInventory(true, mods));
|
c.announce(MaplePacketCreator.modifyInventory(true, mods));
|
||||||
|
|||||||
@@ -28,31 +28,55 @@ import tools.MaplePacketCreator;
|
|||||||
import tools.data.input.SeekableLittleEndianAccessor;
|
import tools.data.input.SeekableLittleEndianAccessor;
|
||||||
import client.MapleCharacter;
|
import client.MapleCharacter;
|
||||||
import client.MapleClient;
|
import client.MapleClient;
|
||||||
|
import client.inventory.Item;
|
||||||
import client.inventory.MapleInventory;
|
import client.inventory.MapleInventory;
|
||||||
import client.inventory.MapleInventoryType;
|
import client.inventory.MapleInventoryType;
|
||||||
|
import server.MapleItemInformationProvider;
|
||||||
|
|
||||||
public final class ItemSortHandler extends AbstractMaplePacketHandler {
|
public final class ItemSortHandler extends AbstractMaplePacketHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
||||||
MapleCharacter chr = c.getPlayer();
|
MapleCharacter chr = c.getPlayer();
|
||||||
chr.getAutobanManager().setTimestamp(2, slea.readInt(), 3);
|
chr.getAutobanManager().setTimestamp(2, slea.readInt(), 3);
|
||||||
MapleInventoryType inventoryType = MapleInventoryType.getByType(slea.readByte());
|
MapleInventoryType inventoryType = MapleInventoryType.getByType(slea.readByte());
|
||||||
if (inventoryType.equals(MapleInventoryType.UNDEFINED) || c.getPlayer().getInventory(inventoryType).isFull()) {
|
|
||||||
c.getSession().write(MaplePacketCreator.enableActions());
|
if(!ServerConstants.USE_ITEM_SORT) {
|
||||||
return;
|
c.announce(MaplePacketCreator.enableActions());
|
||||||
}
|
return;
|
||||||
if(ServerConstants.USE_ITEM_SORT == false) {
|
}
|
||||||
c.announce(MaplePacketCreator.enableActions());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MapleInventory inventory = c.getPlayer().getInventory(inventoryType);
|
MapleInventory inventory = c.getPlayer().getInventory(inventoryType);
|
||||||
|
|
||||||
|
//------------------- RonanLana's SLOT MERGER -----------------
|
||||||
|
|
||||||
|
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||||
|
Item srcItem, dstItem;
|
||||||
|
|
||||||
|
for(short dst = 0; dst <= inventory.getSlotLimit(); dst++) {
|
||||||
|
dstItem = inventory.getItem(dst);
|
||||||
|
if(dstItem == null) continue;
|
||||||
|
|
||||||
|
for(short src = (short)(dst + 1); src <= inventory.getSlotLimit(); src++) {
|
||||||
|
srcItem = inventory.getItem(src);
|
||||||
|
if(srcItem == null) continue;
|
||||||
|
|
||||||
|
if(dstItem.getItemId() != srcItem.getItemId()) continue;
|
||||||
|
if(dstItem.getQuantity() == ii.getSlotMax(c, inventory.getItem(dst).getItemId())) break;
|
||||||
|
|
||||||
|
MapleInventoryManipulator.move(c, inventoryType, src, dst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------
|
||||||
|
|
||||||
|
inventory = c.getPlayer().getInventory(inventoryType);
|
||||||
boolean sorted = false;
|
boolean sorted = false;
|
||||||
|
|
||||||
while (!sorted) {
|
while (!sorted) {
|
||||||
short freeSlot = inventory.getNextFreeSlot();
|
short freeSlot = inventory.getNextFreeSlot();
|
||||||
if (freeSlot != -1) {
|
|
||||||
|
if (freeSlot != -1) {
|
||||||
short itemSlot = -1;
|
short itemSlot = -1;
|
||||||
for (short i = (short) (freeSlot + 1); i <= inventory.getSlotLimit(); i = (short) (i + 1)) {
|
for (short i = (short) (freeSlot + 1); i <= inventory.getSlotLimit(); i = (short) (i + 1)) {
|
||||||
if (inventory.getItem(i) != null) {
|
if (inventory.getItem(i) != null) {
|
||||||
@@ -69,7 +93,7 @@ public final class ItemSortHandler extends AbstractMaplePacketHandler {
|
|||||||
sorted = true;
|
sorted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.getSession().write(MaplePacketCreator.finishedSort(inventoryType.getType()));
|
c.announce(MaplePacketCreator.finishedSort(inventoryType.getType()));
|
||||||
c.getSession().write(MaplePacketCreator.enableActions());
|
c.announce(MaplePacketCreator.enableActions());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,6 +50,7 @@ import client.inventory.MapleInventoryType;
|
|||||||
import client.inventory.MaplePet;
|
import client.inventory.MaplePet;
|
||||||
import client.inventory.PetDataFactory;
|
import client.inventory.PetDataFactory;
|
||||||
import constants.GameConstants;
|
import constants.GameConstants;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import server.TimerManager;
|
import server.TimerManager;
|
||||||
|
|
||||||
public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
|
public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
|
||||||
@@ -76,9 +77,10 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
|
|||||||
player.newClient(c);
|
player.newClient(c);
|
||||||
}
|
}
|
||||||
if (player == null) { //If you are still getting null here then please just uninstall the game >.>, we dont need you fucking with the logs
|
if (player == null) { //If you are still getting null here then please just uninstall the game >.>, we dont need you fucking with the logs
|
||||||
c.disconnect(true, false);
|
c.disconnect(true, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.setPlayer(player);
|
c.setPlayer(player);
|
||||||
c.setAccID(player.getAccountID());
|
c.setAccID(player.getAccountID());
|
||||||
|
|
||||||
@@ -104,6 +106,7 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
|
|||||||
c.updateLoginState(MapleClient.LOGIN_LOGGEDIN);
|
c.updateLoginState(MapleClient.LOGIN_LOGGEDIN);
|
||||||
|
|
||||||
cserv.addPlayer(player);
|
cserv.addPlayer(player);
|
||||||
|
|
||||||
List<PlayerBuffValueHolder> buffs = server.getPlayerBuffStorage().getBuffsFromStorage(cid);
|
List<PlayerBuffValueHolder> buffs = server.getPlayerBuffStorage().getBuffsFromStorage(cid);
|
||||||
if (buffs != null) {
|
if (buffs != null) {
|
||||||
player.silentGiveBuffs(buffs);
|
player.silentGiveBuffs(buffs);
|
||||||
@@ -159,7 +162,7 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
|
|||||||
player.getMap().addPlayer(player);
|
player.getMap().addPlayer(player);
|
||||||
World world = server.getWorld(c.getWorld());
|
World world = server.getWorld(c.getWorld());
|
||||||
world.getPlayerStorage().addPlayer(player);
|
world.getPlayerStorage().addPlayer(player);
|
||||||
|
|
||||||
int buddyIds[] = player.getBuddylist().getBuddyIds();
|
int buddyIds[] = player.getBuddylist().getBuddyIds();
|
||||||
world.loggedOn(player.getName(), player.getId(), c.getChannel(), buddyIds);
|
world.loggedOn(player.getName(), player.getId(), c.getChannel(), buddyIds);
|
||||||
for (CharacterIdChannelPair onlineBuddy : server.getWorld(c.getWorld()).multiBuddyFind(player.getId(), buddyIds)) {
|
for (CharacterIdChannelPair onlineBuddy : server.getWorld(c.getWorld()).multiBuddyFind(player.getId(), buddyIds)) {
|
||||||
@@ -206,6 +209,7 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player.showNote();
|
player.showNote();
|
||||||
if (player.getParty() != null) {
|
if (player.getParty() != null) {
|
||||||
MaplePartyCharacter pchar = player.getMPC();
|
MaplePartyCharacter pchar = player.getMPC();
|
||||||
@@ -253,9 +257,18 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
|
|||||||
Server.getInstance().broadcastGMMessage(MaplePacketCreator.earnTitleMessage("GM " + player.getName() + " has logged in"));
|
Server.getInstance().broadcastGMMessage(MaplePacketCreator.earnTitleMessage("GM " + player.getName() + " has logged in"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getMap().getHPDec() > 0) {
|
|
||||||
player.doHurtHp();
|
}
|
||||||
|
|
||||||
|
if (player.getMap().getHPDec() > 0) {
|
||||||
|
final MapleCharacter mc = player;
|
||||||
|
|
||||||
|
ScheduledFuture<?> hpDecreaseTask = TimerManager.getInstance().schedule(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
mc.doHurtHp();
|
||||||
}
|
}
|
||||||
|
}, 10000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ public final class AfterLoginHandler extends AbstractMaplePacketHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
||||||
|
System.out.println("after login");
|
||||||
|
|
||||||
byte c2 = slea.readByte();
|
byte c2 = slea.readByte();
|
||||||
byte c3 = 5;
|
byte c3 = 5;
|
||||||
if (slea.available() > 0) {
|
if (slea.available() > 0) {
|
||||||
|
|||||||
@@ -175,6 +175,7 @@ public class CashShop {
|
|||||||
if (rs != null) rs.close();
|
if (rs != null) rs.close();
|
||||||
if (ps != null) ps.close();
|
if (ps != null) ps.close();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user