Channel Services + Mob Movement patch + Portal map scripts

Refactored several schedulers within the channel class, now running within their own service modules.
Fixed a case where mob movements would get mistakably processed for other than the target mob during a map transition, leading to weird movements on the mob in the entered area.
Added usage of foreign key for petid's.
Implemented functionality for "Hair Membership" coupons.
Fixed skill Body Pressure not applying the chance to neutralise on touch.
Fixed quest related to NPC Shaman Rock not completing due to unmatched progress.
Fixed an issue with updating title progress "Touch the Sky".
This commit is contained in:
ronancpl
2019-10-12 17:13:03 -03:00
parent b93c9ce1d6
commit 80cd240ab8
65 changed files with 1195 additions and 779 deletions

View File

@@ -126,7 +126,11 @@ public class Item implements Comparable<Item> {
public int getPetId() {
return petid;
}
public Integer getPetIdForDb() {
return petid > -1 ? petid : null;
}
@Override
public int compareTo(Item other) {
if (this.id < other.getItemId()) {

View File

@@ -173,7 +173,12 @@ public enum ItemFactory {
if (mit.equals(MapleInventoryType.EQUIP) || mit.equals(MapleInventoryType.EQUIPPED)) {
items.add(new Pair<Item, MapleInventoryType>(loadEquipFromResultSet(rs), mit));
} else {
Item item = new Item(rs.getInt("itemid"), (byte) rs.getInt("position"), (short) rs.getInt("quantity"), rs.getInt("petid"));
int petid = rs.getInt("petid");
if (rs.wasNull()) {
petid = -1;
}
Item item = new Item(rs.getInt("itemid"), (byte) rs.getInt("position"), (short) rs.getInt("quantity"), petid);
item.setOwner(rs.getString("owner"));
item.setExpiration(rs.getLong("expiration"));
item.setGiftFrom(rs.getString("giftFrom"));
@@ -229,7 +234,7 @@ public enum ItemFactory {
ps.setInt(6, item.getPosition());
ps.setInt(7, item.getQuantity());
ps.setString(8, item.getOwner());
ps.setInt(9, item.getPetId());
ps.setObject(9, item.getPetIdForDb(), java.sql.Types.INTEGER);
ps.setInt(10, item.getFlag());
ps.setLong(11, item.getExpiration());
ps.setString(12, item.getGiftFrom());
@@ -329,7 +334,12 @@ public enum ItemFactory {
items.add(new Pair<Item, MapleInventoryType>(loadEquipFromResultSet(rs), mit));
} else {
if(bundles > 0) {
Item item = new Item(rs.getInt("itemid"), (byte) rs.getInt("position"), (short)(bundles * rs.getInt("quantity")), rs.getInt("petid"));
int petid = rs.getInt("petid");
if (rs.wasNull()) {
petid = -1;
}
Item item = new Item(rs.getInt("itemid"), (byte) rs.getInt("position"), (short)(bundles * rs.getInt("quantity")), petid);
item.setOwner(rs.getString("owner"));
item.setExpiration(rs.getLong("expiration"));
item.setGiftFrom(rs.getString("giftFrom"));
@@ -404,7 +414,7 @@ public enum ItemFactory {
ps.setInt(6, item.getPosition());
ps.setInt(7, item.getQuantity());
ps.setString(8, item.getOwner());
ps.setInt(9, item.getPetId());
ps.setObject(9, item.getPetIdForDb(), java.sql.Types.INTEGER);
ps.setInt(10, item.getFlag());
ps.setLong(11, item.getExpiration());
ps.setString(12, item.getGiftFrom());

View File

@@ -98,75 +98,11 @@ public class MaplePet extends Item {
}
}
private static void unreferenceMissingPetsFromInventoryDb() {
PreparedStatement ps = null;
Connection con = null;
try {
con = DatabaseConnection.getConnection();
ps = con.prepareStatement("UPDATE inventoryitems SET petid = -1, expiration = 0 WHERE petid != -1 AND petid NOT IN (SELECT petid FROM pets)");
ps.executeUpdate();
ps.close();
con.close();
} catch(SQLException ex) {
ex.printStackTrace();
} finally {
try {
if(ps != null && !ps.isClosed()) {
ps.close();
}
if(con != null && !con.isClosed()) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
private static void deleteMissingPetsFromDb() {
PreparedStatement ps = null;
Connection con = null;
try {
con = DatabaseConnection.getConnection();
ps = con.prepareStatement("DELETE FROM pets WHERE petid NOT IN (SELECT petid FROM inventoryitems WHERE petid != -1)");
ps.executeUpdate();
ps.close();
con.close();
} catch(SQLException ex) {
ex.printStackTrace();
} finally {
try {
if(ps != null && !ps.isClosed()) {
ps.close();
}
if(con != null && !con.isClosed()) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public static void clearMissingPetsFromDb() {
unreferenceMissingPetsFromInventoryDb();
deleteMissingPetsFromDb();
}
public static void deleteFromDb(MapleCharacter owner, int petid) {
try {
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM pets WHERE `petid` = ?");
ps.setInt(1, petid);
ps.executeUpdate();
ps.close();
ps = con.prepareStatement("DELETE FROM petignores WHERE `petid` = ?"); // thanks Vcoc for detecting petignores remaining after deletion
PreparedStatement ps = con.prepareStatement("DELETE FROM pets WHERE `petid` = ?"); // thanks Vcoc for detecting petignores remaining after deletion
ps.setInt(1, petid);
ps.executeUpdate();
ps.close();

View File

@@ -41,7 +41,10 @@ public class MapleCashidGenerator {
ResultSet rs = ps.executeQuery();
while (rs.next()) {
existentCashids.add(rs.getInt(1));
int id = rs.getInt(1);
if (!rs.wasNull()) {
existentCashids.add(id);
}
}
rs.close();