diff --git a/build/built-jar.properties b/build/built-jar.properties index 75f7faff7e..7c00507c44 100644 --- a/build/built-jar.properties +++ b/build/built-jar.properties @@ -1,4 +1,4 @@ -#Thu, 01 Jun 2017 00:42:50 -0300 +#Thu, 01 Jun 2017 21:33:39 -0300 C\:\\Nexon\\MapleSolaxia\\MapleSolaxiaV2= diff --git a/build/classes/client/MapleCharacter$10.class b/build/classes/client/MapleCharacter$10.class index e273be6009..3a3efdb2b6 100644 Binary files a/build/classes/client/MapleCharacter$10.class and b/build/classes/client/MapleCharacter$10.class differ diff --git a/build/classes/client/MapleCharacter$11.class b/build/classes/client/MapleCharacter$11.class index 9caeea7267..4252e637f9 100644 Binary files a/build/classes/client/MapleCharacter$11.class and b/build/classes/client/MapleCharacter$11.class differ diff --git a/build/classes/client/MapleCharacter$12.class b/build/classes/client/MapleCharacter$12.class index df91b620d9..7e07646415 100644 Binary files a/build/classes/client/MapleCharacter$12.class and b/build/classes/client/MapleCharacter$12.class differ diff --git a/build/classes/client/MapleCharacter$13.class b/build/classes/client/MapleCharacter$13.class index e195f87785..81a23e7eb6 100644 Binary files a/build/classes/client/MapleCharacter$13.class and b/build/classes/client/MapleCharacter$13.class differ diff --git a/build/classes/client/MapleCharacter$14.class b/build/classes/client/MapleCharacter$14.class index 3ba8b3ea3e..fb8197d77c 100644 Binary files a/build/classes/client/MapleCharacter$14.class and b/build/classes/client/MapleCharacter$14.class differ diff --git a/build/classes/client/MapleCharacter$15.class b/build/classes/client/MapleCharacter$15.class index 88ceb64320..11a189b7d7 100644 Binary files a/build/classes/client/MapleCharacter$15.class and b/build/classes/client/MapleCharacter$15.class differ diff --git a/build/classes/client/MapleCharacter$16.class b/build/classes/client/MapleCharacter$16.class index 8914270469..b2126df10c 100644 Binary files a/build/classes/client/MapleCharacter$16.class and b/build/classes/client/MapleCharacter$16.class differ diff --git a/build/classes/client/MapleCharacter$17.class b/build/classes/client/MapleCharacter$17.class index 0de6f0995f..c13f335e1e 100644 Binary files a/build/classes/client/MapleCharacter$17.class and b/build/classes/client/MapleCharacter$17.class differ diff --git a/build/classes/client/MapleCharacter$18.class b/build/classes/client/MapleCharacter$18.class index 967bda803c..6181a97224 100644 Binary files a/build/classes/client/MapleCharacter$18.class and b/build/classes/client/MapleCharacter$18.class differ diff --git a/build/classes/client/MapleCharacter$3.class b/build/classes/client/MapleCharacter$3.class index b95cb59664..1ce930e54f 100644 Binary files a/build/classes/client/MapleCharacter$3.class and b/build/classes/client/MapleCharacter$3.class differ diff --git a/build/classes/client/MapleCharacter$4.class b/build/classes/client/MapleCharacter$4.class index 63be24cd20..71dee6a07a 100644 Binary files a/build/classes/client/MapleCharacter$4.class and b/build/classes/client/MapleCharacter$4.class differ diff --git a/build/classes/client/MapleCharacter$5.class b/build/classes/client/MapleCharacter$5.class index 30906d1177..b4335bf396 100644 Binary files a/build/classes/client/MapleCharacter$5.class and b/build/classes/client/MapleCharacter$5.class differ diff --git a/build/classes/client/MapleCharacter$6.class b/build/classes/client/MapleCharacter$6.class index 9e40627898..b0abe9ad97 100644 Binary files a/build/classes/client/MapleCharacter$6.class and b/build/classes/client/MapleCharacter$6.class differ diff --git a/build/classes/client/MapleCharacter$7.class b/build/classes/client/MapleCharacter$7.class index 68dcf33d42..08349e41ce 100644 Binary files a/build/classes/client/MapleCharacter$7.class and b/build/classes/client/MapleCharacter$7.class differ diff --git a/build/classes/client/MapleCharacter$8.class b/build/classes/client/MapleCharacter$8.class index a890b1e9eb..9cd51606e5 100644 Binary files a/build/classes/client/MapleCharacter$8.class and b/build/classes/client/MapleCharacter$8.class differ diff --git a/build/classes/client/MapleCharacter$9.class b/build/classes/client/MapleCharacter$9.class index c70704cc75..ede27e6191 100644 Binary files a/build/classes/client/MapleCharacter$9.class and b/build/classes/client/MapleCharacter$9.class differ diff --git a/build/classes/client/MapleCharacter$FameStatus.class b/build/classes/client/MapleCharacter$FameStatus.class index 7c52224209..bcecb9a9b7 100644 Binary files a/build/classes/client/MapleCharacter$FameStatus.class and b/build/classes/client/MapleCharacter$FameStatus.class differ diff --git a/build/classes/client/MapleCharacter$MapleBuffStatValueHolder.class b/build/classes/client/MapleCharacter$MapleBuffStatValueHolder.class index 0883f2992d..65a3a7ed99 100644 Binary files a/build/classes/client/MapleCharacter$MapleBuffStatValueHolder.class and b/build/classes/client/MapleCharacter$MapleBuffStatValueHolder.class differ diff --git a/build/classes/client/MapleCharacter$MapleCoolDownValueHolder.class b/build/classes/client/MapleCharacter$MapleCoolDownValueHolder.class index b7d6d4dc79..2c5c5f7b89 100644 Binary files a/build/classes/client/MapleCharacter$MapleCoolDownValueHolder.class and b/build/classes/client/MapleCharacter$MapleCoolDownValueHolder.class differ diff --git a/build/classes/client/MapleCharacter$SkillEntry.class b/build/classes/client/MapleCharacter$SkillEntry.class index 02debfb1a6..205a73a2f0 100644 Binary files a/build/classes/client/MapleCharacter$SkillEntry.class and b/build/classes/client/MapleCharacter$SkillEntry.class differ diff --git a/build/classes/client/MapleCharacter.class b/build/classes/client/MapleCharacter.class index d2cfc550a0..e1462c1d12 100644 Binary files a/build/classes/client/MapleCharacter.class and b/build/classes/client/MapleCharacter.class differ diff --git a/build/classes/client/MapleClient$1.class b/build/classes/client/MapleClient$1.class index 300f774338..c254e8e3a3 100644 Binary files a/build/classes/client/MapleClient$1.class and b/build/classes/client/MapleClient$1.class differ diff --git a/build/classes/client/MapleClient$CharNameAndId.class b/build/classes/client/MapleClient$CharNameAndId.class index 9998feaa36..715593300e 100644 Binary files a/build/classes/client/MapleClient$CharNameAndId.class and b/build/classes/client/MapleClient$CharNameAndId.class differ diff --git a/build/classes/client/MapleClient.class b/build/classes/client/MapleClient.class index 5fba824711..e9d93388b7 100644 Binary files a/build/classes/client/MapleClient.class and b/build/classes/client/MapleClient.class differ diff --git a/build/classes/client/inventory/Equip$ScrollResult.class b/build/classes/client/inventory/Equip$ScrollResult.class index 040f1fb976..fd818c1789 100644 Binary files a/build/classes/client/inventory/Equip$ScrollResult.class and b/build/classes/client/inventory/Equip$ScrollResult.class differ diff --git a/build/classes/client/inventory/Equip.class b/build/classes/client/inventory/Equip.class index 8c05392c88..44c4c21f06 100644 Binary files a/build/classes/client/inventory/Equip.class and b/build/classes/client/inventory/Equip.class differ diff --git a/build/classes/constants/ServerConstants.class b/build/classes/constants/ServerConstants.class index 72356b7256..744f90648e 100644 Binary files a/build/classes/constants/ServerConstants.class and b/build/classes/constants/ServerConstants.class differ diff --git a/build/classes/net/server/Server$1.class b/build/classes/net/server/Server$1.class index f933d5ed48..29a4d8a87d 100644 Binary files a/build/classes/net/server/Server$1.class and b/build/classes/net/server/Server$1.class differ diff --git a/build/classes/net/server/Server.class b/build/classes/net/server/Server.class index ee0a828229..f89934da00 100644 Binary files a/build/classes/net/server/Server.class and b/build/classes/net/server/Server.class differ diff --git a/build/classes/net/server/channel/handlers/AllianceOperationHandler.class b/build/classes/net/server/channel/handlers/AllianceOperationHandler.class index 3f80e50a81..feaf8fd115 100644 Binary files a/build/classes/net/server/channel/handlers/AllianceOperationHandler.class and b/build/classes/net/server/channel/handlers/AllianceOperationHandler.class differ diff --git a/build/classes/net/server/channel/handlers/BuddylistModifyHandler.class b/build/classes/net/server/channel/handlers/BuddylistModifyHandler.class index fcbce51119..fb9a95ed9f 100644 Binary files a/build/classes/net/server/channel/handlers/BuddylistModifyHandler.class and b/build/classes/net/server/channel/handlers/BuddylistModifyHandler.class differ diff --git a/build/classes/net/server/guild/MapleAlliance.class b/build/classes/net/server/guild/MapleAlliance.class index 0fba8a5851..60cc0121e3 100644 Binary files a/build/classes/net/server/guild/MapleAlliance.class and b/build/classes/net/server/guild/MapleAlliance.class differ diff --git a/build/classes/net/server/guild/MapleGuild.class b/build/classes/net/server/guild/MapleGuild.class index f216704ce2..f519cead26 100644 Binary files a/build/classes/net/server/guild/MapleGuild.class and b/build/classes/net/server/guild/MapleGuild.class differ diff --git a/build/classes/tools/MaplePacketCreator.class b/build/classes/tools/MaplePacketCreator.class index fdc6c8e9cd..632ea90e1a 100644 Binary files a/build/classes/tools/MaplePacketCreator.class and b/build/classes/tools/MaplePacketCreator.class differ diff --git a/dist/MapleSolaxia.jar b/dist/MapleSolaxia.jar index 5404bfa6af..03f0f4877a 100644 Binary files a/dist/MapleSolaxia.jar and b/dist/MapleSolaxia.jar differ diff --git a/mychanges_ptbr.txt b/mychanges_ptbr.txt index 7227706827..505c10c9c0 100644 --- a/mychanges_ptbr.txt +++ b/mychanges_ptbr.txt @@ -271,4 +271,7 @@ MapleCouponInstaller: ferramenta desenvolvida para coleta de informa 31 Maio 2017, Compilada uma nova tabela de EXP para equips no jogo. -Adicionado novo sistema de EXP e nivelamento para todos os equipamentos, para além daqueles de tipo Reverse e Timeless. \ No newline at end of file +Adicionado novo sistema de EXP e nivelamento para todos os equipamentos, para além daqueles de tipo Reverse e Timeless. + +01 Junho 2017, +Consertadas mecânicas principais para deletar character, possivelmente eliminando quaisquer resíduos do mesmo da DB. Requer que ENABLE_PIC esteja ativado para funcionar. \ No newline at end of file diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml index f02502d335..5c91255d43 100644 --- a/nbproject/private/private.xml +++ b/nbproject/private/private.xml @@ -12,9 +12,18 @@ + file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/net/server/channel/handlers/AllianceOperationHandler.java + file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/net/server/guild/MapleGuild.java + file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/net/MapleServerHandler.java + file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/net/server/guild/MapleAlliance.java file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/net/server/Server.java - file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/net/server/CouponWorker.java + file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/scripting/npc/NPCConversationManager.java + file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/constants/ServerConstants.java + file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/net/server/handlers/login/CreateCharHandler.java file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/client/MapleCharacter.java + file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/net/server/handlers/login/DeleteCharHandler.java + file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/client/MapleClient.java + file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/tools/MaplePacketCreator.java diff --git a/src/client/MapleCharacter.java b/src/client/MapleCharacter.java index 276aec3ad5..bc6e4bbff7 100644 --- a/src/client/MapleCharacter.java +++ b/src/client/MapleCharacter.java @@ -1524,6 +1524,213 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject { ex.printStackTrace(); } } + + private void nextPendingRequest(MapleClient c) { + CharacterNameAndId pendingBuddyRequest = c.getPlayer().getBuddylist().pollPendingRequest(); + if (pendingBuddyRequest != null) { + c.announce(MaplePacketCreator.requestBuddylistAdd(pendingBuddyRequest.getId(), c.getPlayer().getId(), pendingBuddyRequest.getName())); + } + } + + private void notifyRemoteChannel(MapleClient c, int remoteChannel, int otherCid, BuddyList.BuddyOperation operation) { + MapleCharacter player = c.getPlayer(); + if (remoteChannel != -1) { + c.getWorldServer().buddyChanged(otherCid, player.getId(), player.getName(), c.getChannel(), operation); + } + } + + public void deleteBuddy(int otherCid) { + BuddyList bl = getBuddylist(); + + if (bl.containsVisible(otherCid)) { + notifyRemoteChannel(client, client.getWorldServer().find(otherCid), otherCid, BuddyList.BuddyOperation.DELETED); + } + bl.remove(otherCid); + client.announce(MaplePacketCreator.updateBuddylist(getBuddylist().getBuddies())); + nextPendingRequest(client); + } + + public static boolean deleteCharFromDB(MapleCharacter player) { + int cid = player.getId(), accId = -1, world = 0; + + Connection con = DatabaseConnection.getConnection(); + try { + try (PreparedStatement ps = con.prepareStatement("SELECT accountid, world FROM characters WHERE id = ?")) { + ps.setInt(1, cid); + + try (ResultSet rs = ps.executeQuery()) { + if(rs.next()) { + accId = rs.getInt("accountid"); + world = rs.getInt("world"); + } + } + } + + try (PreparedStatement ps = con.prepareStatement("SELECT buddyid FROM buddies WHERE characterid = ?")) { + ps.setInt(1, cid); + + try (ResultSet rs = ps.executeQuery()) { + while(rs.next()) { + int buddyid = rs.getInt("buddyid"); + MapleCharacter buddy = Server.getInstance().getWorld(world).getPlayerStorage().getCharacterById(buddyid); + + if(buddy != null) { + buddy.deleteBuddy(cid); + } + } + } + } + try (PreparedStatement ps = con.prepareStatement("DELETE FROM buddies WHERE characterid = ?")) { + ps.setInt(1, cid); + ps.executeUpdate(); + } + + try (PreparedStatement ps = con.prepareStatement("SELECT threadid FROM bbs_threads WHERE postercid = ?")) { + ps.setInt(1, cid); + + try (ResultSet rs = ps.executeQuery()) { + while (rs.next()) { + int tid = rs.getInt("threadid"); + + try (PreparedStatement ps2 = con.prepareStatement("DELETE FROM bbs_replies WHERE threadid = ?")) { + ps2.setInt(1, tid); + ps2.executeUpdate(); + } + } + } + } + try (PreparedStatement ps = con.prepareStatement("DELETE FROM bbs_threads WHERE postercid = ?")) { + ps.setInt(1, cid); + ps.executeUpdate(); + } + + try (PreparedStatement ps = con.prepareStatement("SELECT id, guildid, guildrank, name, allianceRank FROM characters WHERE id = ? AND accountid = ?")) { + ps.setInt(1, cid); + ps.setInt(2, accId); + try (ResultSet rs = ps.executeQuery()) { + if (rs.next() && rs.getInt("guildid") > 0) { + Server.getInstance().deleteGuildCharacter(new MapleGuildCharacter(player, cid, 0, rs.getString("name"), (byte) -1, (byte) -1, 0, rs.getInt("guildrank"), rs.getInt("guildid"), false, rs.getInt("allianceRank"))); + } + } + } + + if(con.isClosed()) con = DatabaseConnection.getConnection(); //wtf tho + + try (PreparedStatement ps = con.prepareStatement("DELETE FROM wishlists WHERE charid = ?")) { + ps.setInt(1, cid); + ps.executeUpdate(); + } + try (PreparedStatement ps = con.prepareStatement("DELETE FROM cooldowns WHERE charid = ?")) { + ps.setInt(1, cid); + ps.executeUpdate(); + } + try (PreparedStatement ps = con.prepareStatement("DELETE FROM area_info WHERE charid = ?")) { + ps.setInt(1, cid); + ps.executeUpdate(); + } + try (PreparedStatement ps = con.prepareStatement("DELETE FROM monsterbook WHERE charid = ?")) { + ps.setInt(1, cid); + ps.executeUpdate(); + } + try (PreparedStatement ps = con.prepareStatement("DELETE FROM characters WHERE id = ?")) { + ps.setInt(1, cid); + ps.executeUpdate(); + } + try (PreparedStatement ps = con.prepareStatement("DELETE FROM famelog WHERE characterid_to = ?")) { + ps.setInt(1, cid); + ps.executeUpdate(); + } + + try (PreparedStatement ps = con.prepareStatement("SELECT inventoryitemid, petid FROM inventoryitems WHERE characterid = ?")) { + ps.setInt(1, cid); + + try (ResultSet rs = ps.executeQuery()) { + while (rs.next()) { + int inventoryitemid = rs.getInt("inventoryitemid"); + + try (PreparedStatement ps2 = con.prepareStatement("SELECT ringid FROM inventoryequipment WHERE inventoryitemid = ?")) { + ps2.setInt(1, inventoryitemid); + + try (ResultSet rs2 = ps2.executeQuery()) { + while (rs2.next()) { + int ringid = rs2.getInt("ringid"); + + if(ringid > -1) { + try (PreparedStatement ps3 = con.prepareStatement("DELETE FROM rings WHERE id = ?")) { + ps3.setInt(1, ringid); + ps3.executeUpdate(); + } + } + } + } + } + + try (PreparedStatement ps2 = con.prepareStatement("DELETE FROM inventoryequipment WHERE inventoryitemid = ?")) { + ps2.setInt(1, inventoryitemid); + ps2.executeUpdate(); + } + + if(rs.getInt("petid") > -1) { + try (PreparedStatement ps2 = con.prepareStatement("DELETE FROM pets WHERE petid = ?")) { + ps2.setInt(1, rs.getInt("petid")); + ps2.executeUpdate(); + } + } + } + } + } + + try (PreparedStatement ps = con.prepareStatement("SELECT queststatusid FROM queststatus WHERE characterid = ?")) { + ps.setInt(1, cid); + + try (ResultSet rs = ps.executeQuery()) { + while (rs.next()) { + int queststatusid = rs.getInt("queststatusid"); + + try (PreparedStatement ps2 = con.prepareStatement("DELETE FROM medalmaps WHERE queststatusid = ?")) { + ps2.setInt(1, queststatusid); + ps2.executeUpdate(); + } + + try (PreparedStatement ps2 = con.prepareStatement("DELETE FROM questprogress WHERE queststatusid = ?")) { + ps2.setInt(1, queststatusid); + ps2.executeUpdate(); + } + } + } + } + + try (PreparedStatement ps = con.prepareStatement("SELECT id FROM mts_cart WHERE cid = ?")) { + ps.setInt(1, cid); + + try (ResultSet rs = ps.executeQuery()) { + while (rs.next()) { + int mtsid = rs.getInt("id"); + + try (PreparedStatement ps2 = con.prepareStatement("DELETE FROM mts_items WHERE id = ?")) { + ps2.setInt(1, mtsid); + ps2.executeUpdate(); + } + } + } + } + try (PreparedStatement ps = con.prepareStatement("DELETE FROM mts_cart WHERE cid = ?")) { + ps.setInt(1, cid); + ps.executeUpdate(); + } + + String[] toDel = {"famelog", "inventoryitems", "keymap", "queststatus", "savedlocations", "trocklocations", "skillmacros", "skills", "eventstats", "server_queue"}; + for (String s : toDel) { + MapleCharacter.deleteWhereCharacterId(con, "DELETE FROM `" + s + "` WHERE characterid = ?", cid); + } + + con.close(); + return true; + } catch (SQLException e) { + e.printStackTrace(); + return false; + } + } private void deleteWhereCharacterId(Connection con, String sql) throws SQLException { try (PreparedStatement ps = con.prepareStatement(sql)) { diff --git a/src/client/MapleClient.java b/src/client/MapleClient.java index 4abf8998e9..801013d3a4 100644 --- a/src/client/MapleClient.java +++ b/src/client/MapleClient.java @@ -60,6 +60,7 @@ import net.server.world.World; import org.apache.mina.core.session.IoSession; import client.inventory.MapleInventoryType; +import constants.ServerConstants; import scripting.event.EventManager; import scripting.npc.NPCConversationManager; import scripting.npc.NPCScriptManager; @@ -445,6 +446,8 @@ public class MapleClient { } public boolean checkPic(String other) { + if(!ServerConstants.ENABLE_PIC) return true; + picattempt++; if (picattempt > 5) { getSession().close(true); @@ -899,50 +902,12 @@ public class MapleClient { } public boolean deleteCharacter(int cid) { - Connection con = DatabaseConnection.getConnection(); - - MapleCharacter player = Server.getInstance().getWorld(0).getPlayerStorage().getCharacterById(cid); - if (player != null){ - player.getClient().disconnect(false, false); - disconnect(false, false); - return false; //DC both and return, fuck that - } - try { - try (PreparedStatement ps = con.prepareStatement("SELECT id, guildid, guildrank, name, allianceRank FROM characters WHERE id = ? AND accountid = ?")) { - ps.setInt(1, cid); - ps.setInt(2, accId); - try (ResultSet rs = ps.executeQuery()) { - if (!rs.next()) { - return false; - } - if (rs.getInt("guildid") > 0) { - try { - Server.getInstance().deleteGuildCharacter(new MapleGuildCharacter(player, cid, 0, rs.getString("name"), (byte) -1, (byte) -1, 0, rs.getInt("guildrank"), rs.getInt("guildid"), false, rs.getInt("allianceRank"))); - } catch (Exception re) { - re.printStackTrace(); - return false; - } - } - } - } - - try (PreparedStatement ps = con.prepareStatement("DELETE FROM wishlists WHERE charid = ?")) { - ps.setInt(1, cid); - ps.executeUpdate(); - } - try (PreparedStatement ps = con.prepareStatement("DELETE FROM characters WHERE id = ?")) { - ps.setInt(1, cid); - ps.executeUpdate(); - } - String[] toDel = {"famelog", "inventoryitems", "keymap", "queststatus", "savedlocations", "skillmacros", "skills", "eventstats"}; - for (String s : toDel) { - MapleCharacter.deleteWhereCharacterId(con, "DELETE FROM `" + s + "` WHERE characterid = ?", cid); - } - return true; - } catch (SQLException e) { - e.printStackTrace(); - return false; - } + try { + return MapleCharacter.deleteCharFromDB(MapleCharacter.loadCharFromDB(cid, this, false)); + } catch(SQLException ex) { + ex.printStackTrace(); + return false; + } } public String getAccountName() { diff --git a/src/client/inventory/Equip.java b/src/client/inventory/Equip.java index 521c1604f8..563fcbead1 100644 --- a/src/client/inventory/Equip.java +++ b/src/client/inventory/Equip.java @@ -26,6 +26,8 @@ import constants.ServerConstants; import constants.ExpTable; import java.util.LinkedList; import java.util.List; +import java.util.HashMap; +import java.util.Map; import server.MapleItemInformationProvider; import tools.MaplePacketCreator; import tools.Pair; @@ -52,7 +54,7 @@ public class Equip extends Item { private float itemExp; private int ringid = -1; private boolean wear = false; - private boolean isElemental = false; // timeless or reverse + private boolean isUpgradeable, isElemental = false; // timeless or reverse public Equip(int id, short position) { this(id, position, 0); @@ -260,6 +262,8 @@ public class Equip extends Item { } private int getStatModifier(boolean isAttribute) { + // each set of stat points grants a chance for a bonus stat point upgrade at equip level up. + if(ServerConstants.USE_EQUIPMNT_LVLUP_POWER) { if(isAttribute) return 2; else return 4; @@ -270,11 +274,42 @@ public class Equip extends Item { } } + private int randomizeStatUpgrade(int limit) { + Map pool = new HashMap<>(); + + pool.put(0, 1); + pool.put(1, 1); + for(int i = 2; i <= limit; i++) { + for(int j = 0; j < i; j++) { + pool.put(j, pool.get(j) + 1); + } + pool.put(i, 1); + } + + int poolCount = 0; + for(Integer i: pool.values()) { + poolCount += i; + } + + int rnd = Randomizer.rand(0, poolCount); + int stat = 0; + for(Integer i: pool.values()) { + if(rnd < i) break; + + stat++; + rnd -= i; + } + + return(stat); + } + private void getUnitStatUpgrade(List> stats, String name, int curStat, boolean isAttribute) { - int maxUpgrade = Randomizer.rand(0, 1 + (curStat / getStatModifier(isAttribute))); + isUpgradeable = true; + + int maxUpgrade = randomizeStatUpgrade((int)(1 + (curStat / getStatModifier(isAttribute)))); if(maxUpgrade == 0) return; - stats.add(new Pair<>(name, maxUpgrade)); // each 4 stat point grants a bonus stat upgrade on equip level up. + stats.add(new Pair<>(name, maxUpgrade)); } private void getUnitSlotUpgrade(List> stats, String name) { @@ -302,76 +337,103 @@ public class Equip extends Item { public void gainLevel(MapleClient c) { List> stats = MapleItemInformationProvider.getInstance().getItemLevelupStats(getItemId(), itemLevel); - if(stats.isEmpty()) improveDefaultStats(stats); - - if(ServerConstants.USE_EQUIPMNT_LVLUP_SLOTS) { - getUnitSlotUpgrade(stats, "incVicious"); - getUnitSlotUpgrade(stats, "incSlot"); + if(!stats.isEmpty()) { + if(ServerConstants.USE_EQUIPMNT_LVLUP_SLOTS) { + if(vicious > 0) getUnitSlotUpgrade(stats, "incVicious"); + getUnitSlotUpgrade(stats, "incSlot"); + } + } + else { + isUpgradeable = false; + + do { + improveDefaultStats(stats); + + if(ServerConstants.USE_EQUIPMNT_LVLUP_SLOTS) { + if(vicious > 0) getUnitSlotUpgrade(stats, "incVicious"); + getUnitSlotUpgrade(stats, "incSlot"); + } + } while(stats.isEmpty() && isUpgradeable); } itemLevel++; - if(ServerConstants.USE_DEBUG) c.getPlayer().dropMessage(6, "'" + MapleItemInformationProvider.getInstance().getName(this.getItemId()) + "' has LEVELED UP to level " + itemLevel + "!"); + boolean gotVicious = false, gotSlot = false; + String lvupStr = "'" + MapleItemInformationProvider.getInstance().getName(this.getItemId()) + "' is now level " + itemLevel + "! "; for (Pair stat : stats) { switch (stat.getLeft()) { case "incDEX": dex += stat.getRight(); + lvupStr += "+" + stat.getRight() + "DEX "; break; case "incSTR": str += stat.getRight(); + lvupStr += "+" + stat.getRight() + "STR "; break; case "incINT": _int += stat.getRight(); + lvupStr += "+" + stat.getRight() + "INT "; break; case "incLUK": luk += stat.getRight(); + lvupStr += "+" + stat.getRight() + "LUK "; break; case "incMHP": hp += stat.getRight(); + lvupStr += "+" + stat.getRight() + "HP "; break; case "incMMP": mp += stat.getRight(); + lvupStr += "+" + stat.getRight() + "MP "; break; case "incPAD": watk += stat.getRight(); + lvupStr += "+" + stat.getRight() + "WATK "; break; case "incMAD": matk += stat.getRight(); + lvupStr += "+" + stat.getRight() + "MATK "; break; case "incPDD": wdef += stat.getRight(); + lvupStr += "+" + stat.getRight() + "WDEF "; break; case "incMDD": mdef += stat.getRight(); + lvupStr += "+" + stat.getRight() + "MDEF "; break; case "incEVA": avoid += stat.getRight(); + lvupStr += "+" + stat.getRight() + "AVOID "; break; case "incACC": acc += stat.getRight(); + lvupStr += "+" + stat.getRight() + "ACC "; break; case "incSpeed": speed += stat.getRight(); + lvupStr += "+" + stat.getRight() + "SPEED "; break; case "incJump": jump += stat.getRight(); + lvupStr += "+" + stat.getRight() + "JUMP "; break; case "incVicious": - if(vicious > 0) { - vicious -= stat.getRight(); - if(vicious < 0) vicious = 0; - - c.getPlayer().dropMessage(6, "A new Vicious Hammer opportunity has been found on the '" + MapleItemInformationProvider.getInstance().getName(getItemId()) + "'!"); - } - + vicious -= stat.getRight(); + gotVicious = true; break; case "incSlot": upgradeSlots += stat.getRight(); - c.getPlayer().dropMessage(6, "A new upgrade slot has been found on the '" + MapleItemInformationProvider.getInstance().getName(getItemId()) + "'!"); + gotSlot = true; break; } } + + c.getPlayer().dropMessage(6, lvupStr); + if(gotVicious) c.getPlayer().dropMessage(6, "A new Vicious Hammer opportunity has been found on the '" + MapleItemInformationProvider.getInstance().getName(getItemId()) + "'!"); + if(gotSlot) c.getPlayer().dropMessage(6, "A new upgrade slot has been found on the '" + MapleItemInformationProvider.getInstance().getName(getItemId()) + "'!"); + c.announce(MaplePacketCreator.showEquipmentLevelUp()); c.getPlayer().getMap().broadcastMessage(c.getPlayer(), MaplePacketCreator.showForeignEffect(c.getPlayer().getId(), 15)); c.getPlayer().forceUpdateItem(this); diff --git a/src/constants/ServerConstants.java b/src/constants/ServerConstants.java index 564f5f45a4..523ff83923 100644 --- a/src/constants/ServerConstants.java +++ b/src/constants/ServerConstants.java @@ -15,7 +15,7 @@ public class ServerConstants { public static final long PURGING_INTERVAL = 5 * 60 * 1000; public static final long RANKING_INTERVAL = 60 * 60 * 1000; //60 minutes, 3600000. public static final long COUPON_INTERVAL = 60 * 60 * 1000; //60 minutes, 3600000. - public static final boolean ENABLE_PIC = false; //Pick true/false to enable or disable Pic. + public static final boolean ENABLE_PIC = true; //Pick true/false to enable or disable Pic. //Ip Configuration public static String HOST; @@ -33,6 +33,7 @@ public class ServerConstants { public static final boolean USE_CUSTOM_KEYSET = true; public static final boolean USE_MAXRANGE = true; //Will send and receive packets from all events of a map, rather than those of only view range. public static final boolean USE_DEBUG = true; //Will enable some text prints and new commands in the client oriented for debugging. + public static final boolean USE_DEBUG_SHOW_RCVD_PACKETS = false; public static final boolean USE_MTS = false; public static final boolean USE_FAMILY_SYSTEM = false; public static final boolean USE_DUEY = true; diff --git a/src/net/MapleServerHandler.java b/src/net/MapleServerHandler.java index 83ef54705f..114c2027bb 100644 --- a/src/net/MapleServerHandler.java +++ b/src/net/MapleServerHandler.java @@ -131,7 +131,7 @@ public class MapleServerHandler extends IoHandlerAdapter { short packetId = slea.readShort(); MapleClient client = (MapleClient) session.getAttribute(MapleClient.CLIENT_KEY); - //System.out.println("Received packet id " + packetId); + if(ServerConstants.USE_DEBUG_SHOW_RCVD_PACKETS) System.out.println("Received packet id " + packetId); final MaplePacketHandler packetHandler = processor.getHandler(packetId); if (packetHandler != null && packetHandler.validateState(client)) { try { diff --git a/src/net/server/Server.java b/src/net/server/Server.java index cb73c53753..dbbd1dda8a 100644 --- a/src/net/server/Server.java +++ b/src/net/server/Server.java @@ -484,6 +484,10 @@ public class Server implements Runnable { } } + public MapleGuild getGuild(int id, int world) { + return getGuild(id, world, null); + } + public MapleGuild getGuild(int id, int world, MapleCharacter mc) { synchronized (guilds) { if (guilds.get(id) != null) { diff --git a/src/net/server/channel/handlers/AllianceOperationHandler.java b/src/net/server/channel/handlers/AllianceOperationHandler.java index 86a0089583..0f2e8aae8f 100644 --- a/src/net/server/channel/handlers/AllianceOperationHandler.java +++ b/src/net/server/channel/handlers/AllianceOperationHandler.java @@ -62,16 +62,8 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler { if (c.getPlayer().getGuild().getAllianceId() == 0 || c.getPlayer().getGuildId() < 1 || c.getPlayer().getGuildRank() != 1) { return; } - int guildid = c.getPlayer().getGuildId(); - Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.removeGuildFromAlliance(alliance, guildid, c), -1, -1); - Server.getInstance().removeGuildFromAlliance(alliance.getId(), guildid); - - Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, c), -1, -1); - Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.allianceNotice(alliance.getId(), alliance.getNotice()), -1, -1); - Server.getInstance().guildMessage(guildid, MaplePacketCreator.disbandAlliance(alliance.getId())); - - alliance.dropMessage("[" + c.getPlayer().getGuild().getName() + "] guild has left the union."); + MapleAlliance.removeGuildFromAlliance(c.getPlayer().getGuild().getAllianceId(), c.getPlayer().getGuildId(), c.getPlayer().getWorld()); break; } case 0x03: // send alliance invite... or at least it would be this way if i could find the right way to call it! @@ -129,10 +121,10 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler { return; } - Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.removeGuildFromAlliance(alliance, guildid, c), -1, -1); + Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.removeGuildFromAlliance(alliance, guildid, c.getWorld()), -1, -1); Server.getInstance().removeGuildFromAlliance(alliance.getId(), guildid); - Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, c), -1, -1); + Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, c.getWorld()), -1, -1); Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.allianceNotice(alliance.getId(), alliance.getNotice()), -1, -1); Server.getInstance().guildMessage(guildid, MaplePacketCreator.disbandAlliance(allianceid)); @@ -189,7 +181,7 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler { newLeader.getMGC().setAllianceRank(1); newLeader.saveGuildStatus(); - Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, newLeader.getClient()), -1, -1); + Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, newLeader.getWorld()), -1, -1); alliance.dropMessage("'" + newLeader.getName() + "' has been appointed as the new head of this Alliance."); } @@ -200,7 +192,7 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler { chr.getMGC().setAllianceRank(newRank); chr.saveGuildStatus(); - Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, chr.getClient()), -1, -1); + Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, chr.getWorld()), -1, -1); alliance.dropMessage("'" + chr.getName() + "' has been reassigned as '" + alliance.getRankTitle(newRank) + "' in this Alliance."); } diff --git a/src/net/server/channel/handlers/BuddylistModifyHandler.java b/src/net/server/channel/handlers/BuddylistModifyHandler.java index a017fb2685..be781a0510 100644 --- a/src/net/server/channel/handlers/BuddylistModifyHandler.java +++ b/src/net/server/channel/handlers/BuddylistModifyHandler.java @@ -192,12 +192,7 @@ public class BuddylistModifyHandler extends AbstractMaplePacketHandler { nextPendingRequest(c); } else if (mode == 3) { // delete int otherCid = slea.readInt(); - if (buddylist.containsVisible(otherCid)) { - notifyRemoteChannel(c, c.getWorldServer().find(otherCid), otherCid, BuddyOperation.DELETED); - } - buddylist.remove(otherCid); - c.announce(MaplePacketCreator.updateBuddylist(player.getBuddylist().getBuddies())); - nextPendingRequest(c); + player.deleteBuddy(otherCid); } } diff --git a/src/net/server/guild/MapleAlliance.java b/src/net/server/guild/MapleAlliance.java index 2bdf04a03c..dbb9e30d54 100644 --- a/src/net/server/guild/MapleAlliance.java +++ b/src/net/server/guild/MapleAlliance.java @@ -294,6 +294,19 @@ public class MapleAlliance { } } + public static void removeGuildFromAlliance(int allianceId, int guildId, int worldId) { + MapleAlliance alliance = Server.getInstance().getAlliance(allianceId); + + Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.removeGuildFromAlliance(alliance, guildId, worldId), -1, -1); + Server.getInstance().removeGuildFromAlliance(alliance.getId(), guildId); + + Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, worldId), -1, -1); + Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.allianceNotice(alliance.getId(), alliance.getNotice()), -1, -1); + Server.getInstance().guildMessage(guildId, MaplePacketCreator.disbandAlliance(alliance.getId())); + + alliance.dropMessage("[" + Server.getInstance().getGuild(guildId, worldId) + "] guild has left the union."); + } + public void updateAlliancePackets(MapleCharacter chr) { if (allianceId > 0) { this.broadcastMessage(MaplePacketCreator.updateAllianceInfo(this, chr.getClient())); diff --git a/src/net/server/guild/MapleGuild.java b/src/net/server/guild/MapleGuild.java index d9fa2aaf1e..b03917df1c 100644 --- a/src/net/server/guild/MapleGuild.java +++ b/src/net/server/guild/MapleGuild.java @@ -136,6 +136,7 @@ public class MapleGuild { public void writeToDB(boolean bDisband) { try { Connection con = DatabaseConnection.getConnection(); + if (!bDisband) { StringBuilder builder = new StringBuilder(); builder.append("UPDATE guilds SET GP = ?, logo = ?, logoColor = ?, logoBG = ?, logoBGColor = ?, "); @@ -496,6 +497,13 @@ public class MapleGuild { } public void disbandGuild() { + if(allianceId > 0) { + MapleAlliance alliance = Server.getInstance().getAlliance(allianceId); + + if(alliance.getLeader().getGuildId() != id) MapleAlliance.removeGuildFromAlliance(allianceId, id, world); + else MapleAlliance.disbandAlliance(allianceId); + } + this.writeToDB(true); this.broadcast(null, -1, BCOp.DISBAND); } diff --git a/src/net/server/handlers/login/CreateCharHandler.java b/src/net/server/handlers/login/CreateCharHandler.java index 02f846b4e3..53dd4b6c14 100644 --- a/src/net/server/handlers/login/CreateCharHandler.java +++ b/src/net/server/handlers/login/CreateCharHandler.java @@ -88,7 +88,7 @@ public final class CreateCharHandler extends AbstractMaplePacketHandler { for (int i = 0; i < items.length; i++){ if (!isLegal(items[i])) { AutobanFactory.PACKET_EDIT.alert(newchar, name + " tried to packet edit in character creation."); - FilePrinter.printError(FilePrinter.EXPLOITS + newchar + ".txt", "Tried to packet edit in char creation."); + FilePrinter.printError(FilePrinter.EXPLOITS + newchar + ".txt", "Tried to packet edit in char creation."); c.disconnect(true, false); return; } diff --git a/src/net/server/handlers/login/DeleteCharHandler.java b/src/net/server/handlers/login/DeleteCharHandler.java index 8e1ecd8d0a..b6b678aa81 100644 --- a/src/net/server/handlers/login/DeleteCharHandler.java +++ b/src/net/server/handlers/login/DeleteCharHandler.java @@ -34,7 +34,7 @@ public final class DeleteCharHandler extends AbstractMaplePacketHandler { String pic = slea.readMapleAsciiString(); int cid = slea.readInt(); if (c.checkPic(pic)) { - FilePrinter.printError(FilePrinter.DELETED_CHARACTERS + c.getAccountName() + ".txt", c.getAccountName() + " deleted CID: " + cid + "\r\n"); + FilePrinter.printError(FilePrinter.DELETED_CHARACTERS + c.getAccountName() + ".txt", c.getAccountName() + " deleted CID: " + cid + "\r\n"); c.announce(MaplePacketCreator.deleteCharResponse(cid, 0)); c.deleteCharacter(cid); } else { diff --git a/src/net/server/handlers/login/RegisterPicHandler.java b/src/net/server/handlers/login/RegisterPicHandler.java index 795db39548..7510658f48 100644 --- a/src/net/server/handlers/login/RegisterPicHandler.java +++ b/src/net/server/handlers/login/RegisterPicHandler.java @@ -16,10 +16,10 @@ public final class RegisterPicHandler extends AbstractMaplePacketHandler { slea.readByte(); int charId = slea.readInt(); String macs = slea.readMapleAsciiString(); - String hwid = slea.readMapleAsciiString(); + String hwid = slea.readMapleAsciiString(); c.updateMacs(macs); - c.updateHWID(hwid); + c.updateHWID(hwid); if (c.hasBannedMac() || c.hasBannedHWID()) { c.getSession().close(true); diff --git a/src/tools/MaplePacketCreator.java b/src/tools/MaplePacketCreator.java index 1a08a5fe14..b24709bfc2 100644 --- a/src/tools/MaplePacketCreator.java +++ b/src/tools/MaplePacketCreator.java @@ -5944,13 +5944,13 @@ public class MaplePacketCreator { return mplew.getPacket(); } - public static byte[] getGuildAlliances(MapleAlliance alliance, MapleClient c) { + public static byte[] getGuildAlliances(MapleAlliance alliance, int worldId) { final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(); mplew.writeShort(SendOpcode.ALLIANCE_OPERATION.getValue()); mplew.write(0x0D); mplew.writeInt(alliance.getGuilds().size()); for (Integer guild : alliance.getGuilds()) { - getGuildInfo(mplew, Server.getInstance().getGuild(guild, c.getWorld(), null)); + getGuildInfo(mplew, Server.getInstance().getGuild(guild, worldId, null)); } return mplew.getPacket(); } @@ -6018,7 +6018,7 @@ public class MaplePacketCreator { return mplew.getPacket(); } - public static byte[] removeGuildFromAlliance(MapleAlliance alliance, int expelledGuild, MapleClient c) { + public static byte[] removeGuildFromAlliance(MapleAlliance alliance, int expelledGuild, int worldId) { final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(); mplew.writeShort(SendOpcode.ALLIANCE_OPERATION.getValue()); mplew.write(0x10); @@ -6034,7 +6034,7 @@ public class MaplePacketCreator { mplew.writeInt(alliance.getCapacity()); mplew.writeMapleAsciiString(alliance.getNotice()); mplew.writeInt(expelledGuild); - getGuildInfo(mplew, Server.getInstance().getGuild(expelledGuild, c.getWorld(), null)); + getGuildInfo(mplew, Server.getInstance().getGuild(expelledGuild, worldId, null)); mplew.write(0x01); return mplew.getPacket(); }