Code Coupons + Worldmap update + Mini-games + Player Interaction wrap

Fixed several cases on the Cash Shop that would freeze some player actions when triggered, requiring exit Cash Shop to unstuck.
Implemented Code Coupons, supporting several items bundled on the same code, and also devised a way to automate code generation.
Added a current status on-demand option on the Buyback command. Info such as "current fee" or "time remaining" are available now.
Reviewed several cases where non-owned items would get stacked with owner-tagged items.
Added Door support for Happyville, Crimsonwood Keep.
Added worldmap tooltip support for some maps in Masteria's C. Keep and H. House.
Added Masteria region to the world map.
C. Keep interiors no longer relocates players to entrance after actions such as logout.
Overhauled minigame mechanics: from player boxes tooltip and in-match improvements to deploy different minigame types, accordingly with item description or player choice.
Fixed Amoria outskirts not relocating players to city after getting KO'ed.
Fixed issues with pets, rings and cash items being assigned the same cash unique ids leading to some quirks on the cash shop inventory.
Fixed an issue with the recently added HP/MP ratio update, arbitrarily taking off 1 point in certain cases.
Answer positions on the explorer's 3rd job quiz are now randomed.
Fixed several issues that showed up when the bcrypt system is disabled.
DOT from maps such as El Nath and Aqua Road now procs at a 5sec interval, GMS-like.
Improved performance of Whodrops and Search commands.
Concurrently protected player interaction handlers, thus mitigating several exploits on these lines.
Adjusted several expedition timers, such as Horntail, now having a more sane deadline.
Concurrently protected chair modules.
Fixed "seduce" debuff not working on chairs.
This commit is contained in:
ronancpl
2018-10-09 22:39:36 -03:00
parent 3a8377c283
commit 2b44b4baa2
213 changed files with 16547 additions and 11031 deletions

View File

@@ -26,10 +26,12 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import client.inventory.manipulator.MapleKarmaManipulator;
import server.MapleItemInformationProvider;
public class Item implements Comparable<Item> {
private static AtomicInteger runningCashId = new AtomicInteger(0);
private static AtomicInteger runningCashId = new AtomicInteger(777000000); // pets & rings shares cashid values
private int id, cashId, sn;
private short position;
@@ -83,7 +85,7 @@ public class Item implements Comparable<Item> {
public int getCashId() {
if (cashId == 0) {
cashId = runningCashId.incrementAndGet();
cashId = runningCashId.getAndIncrement();
}
return cashId;
}
@@ -177,4 +179,8 @@ public class Item implements Comparable<Item> {
public MaplePet getPet() {
return pet;
}
public boolean isUntradeable() {
return ((this.getFlag() & ItemConstants.UNTRADEABLE) == ItemConstants.UNTRADEABLE) || (MapleItemInformationProvider.getInstance().isDropRestricted(this.getItemId()) && !MapleKarmaManipulator.hasKarmaFlag(this));
}
}

View File

@@ -21,7 +21,6 @@
*/
package client.inventory;
import com.mysql.jdbc.Statement;
import constants.ExpTable;
import java.awt.Point;
import java.sql.PreparedStatement;
@@ -34,6 +33,7 @@ import server.movement.AbsoluteLifeMovement;
import server.movement.LifeMovement;
import server.movement.LifeMovementFragment;
import client.MapleCharacter;
import client.inventory.manipulator.MapleCashidGenerator;
import java.sql.Connection;
import tools.MaplePacketCreator;
import tools.Pair;
@@ -90,6 +90,8 @@ public class MaplePet extends Item {
ps.executeUpdate();
ps.close();
con.close();
MapleCashidGenerator.freeCashId(this.getUniqueId());
} catch (SQLException ex) {
ex.printStackTrace();
}
@@ -116,15 +118,11 @@ public class MaplePet extends Item {
public static int createPet(int itemid) {
try {
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO pets (name, level, closeness, fullness, summoned) VALUES (?, 1, 0, 100, 0)", Statement.RETURN_GENERATED_KEYS);
ps.setString(1, MapleItemInformationProvider.getInstance().getName(itemid));
PreparedStatement ps = con.prepareStatement("INSERT INTO pets (petid, name, level, closeness, fullness, summoned) VALUES (?, ?, 1, 0, 100, 0)");
int ret = MapleCashidGenerator.generateCashId();
ps.setInt(1, ret);
ps.setString(2, MapleItemInformationProvider.getInstance().getName(itemid));
ps.executeUpdate();
ResultSet rs = ps.getGeneratedKeys();
int ret = -1;
if (rs.next()) {
ret = rs.getInt(1);
}
rs.close();
ps.close();
con.close();
return ret;
@@ -137,18 +135,14 @@ public class MaplePet extends Item {
public static int createPet(int itemid, byte level, int closeness, int fullness) {
try {
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO pets (name, level, closeness, fullness, summoned) VALUES (?, ?, ?, ?, 0)", Statement.RETURN_GENERATED_KEYS);
ps.setString(1, MapleItemInformationProvider.getInstance().getName(itemid));
ps.setByte(2, level);
ps.setInt(3, closeness);
ps.setInt(4, fullness);
PreparedStatement ps = con.prepareStatement("INSERT INTO pets (petid, name, level, closeness, fullness, summoned) VALUES (?, ?, ?, ?, ?, 0)");
int ret = MapleCashidGenerator.generateCashId();
ps.setInt(1, ret);
ps.setString(2, MapleItemInformationProvider.getInstance().getName(itemid));
ps.setByte(3, level);
ps.setInt(4, closeness);
ps.setInt(5, fullness);
ps.executeUpdate();
ResultSet rs = ps.getGeneratedKeys();
int ret = -1;
if (rs.next()) {
ret = rs.getInt(1);
}
rs.close();
ps.close();
con.close();
return ret;

View File

@@ -0,0 +1,104 @@
/*
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 client.inventory.manipulator;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashSet;
import java.util.Set;
import tools.DatabaseConnection;
/**
*
* @author RonanLana
*/
public class MapleCashidGenerator {
private final static Set<Integer> existentCashids = new HashSet<>(10000);
private static Integer runningCashid = 0;
private static void loadExistentCashIdsFromQuery(Connection con, String query) throws SQLException {
PreparedStatement ps = con.prepareStatement(query);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
existentCashids.add(rs.getInt(1));
}
rs.close();
ps.close();
}
public static synchronized void loadExistentCashIdsFromDb() {
Connection con = null;
try {
con = DatabaseConnection.getConnection();
loadExistentCashIdsFromQuery(con, "SELECT id FROM rings");
loadExistentCashIdsFromQuery(con, "SELECT petid FROM pets");
con.close();
} catch (SQLException ex) {
ex.printStackTrace();
} finally {
try {
if (con != null && !con.isClosed()) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
runningCashid = 0;
do {
runningCashid++; // hopefully the id will never surpass the allotted amount for pets/rings?
} while (existentCashids.contains(runningCashid));
}
private static void getNextAvailableCashId() {
runningCashid++;
if (runningCashid >= 777000000) {
existentCashids.clear();
loadExistentCashIdsFromDb();
}
}
public static synchronized int generateCashId() {
while (true) {
if (!existentCashids.contains(runningCashid)) {
int ret = runningCashid;
getNextAvailableCashId();
// existentCashids.add(ret)... no need to do this since the wrap over already refetches already used cashids from the DB
return ret;
}
getNextAvailableCashId();
}
}
public static synchronized void freeCashId(int cashId) {
existentCashids.remove(cashId);
}
}

View File

@@ -520,16 +520,18 @@ public class MapleInventoryManipulator {
//1112413, 1112414, 1112405 (Lilin's Ring)
source = (Equip) eqpInv.getItem(src);
Equip target = (Equip) eqpdInv.getItem(dst);
eqpInv.removeSlot(src);
if (target != null) {
eqpdInv.lockInventory();
try {
Equip target;
eqpdInv.lockInventory();
try {
target = (Equip) eqpdInv.getItem(dst);
if (target != null) {
chr.unequippedItem(target);
eqpdInv.removeSlot(dst);
} finally {
eqpdInv.unlockInventory();
}
} finally {
eqpdInv.unlockInventory();
}
final List<ModifyInventory> mods = new ArrayList<>();
@@ -705,7 +707,7 @@ public class MapleInventoryManipulator {
}
private static boolean isDroppedItemRestricted(Item it) {
return ServerConstants.USE_ERASE_UNTRADEABLE_DROP && ((it.getFlag() & ItemConstants.UNTRADEABLE) == ItemConstants.UNTRADEABLE);
return ServerConstants.USE_ERASE_UNTRADEABLE_DROP && it.isUntradeable();
}
public static boolean isSandboxItem(Item it) {