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.
207 lines
6.3 KiB
Java
207 lines
6.3 KiB
Java
/*
|
|
This file is part of the OdinMS Maple Story Server
|
|
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
|
Matthias Butz <matze@odinms.de>
|
|
Jan Christian Meyer <vimes@odinms.de>
|
|
|
|
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;
|
|
|
|
import java.sql.Connection;
|
|
import java.sql.PreparedStatement;
|
|
import java.sql.ResultSet;
|
|
import java.sql.SQLException;
|
|
import tools.Pair;
|
|
import tools.DatabaseConnection;
|
|
import client.inventory.manipulator.MapleCashidGenerator;
|
|
|
|
/**
|
|
*
|
|
* @author Danny
|
|
*/
|
|
public class MapleRing implements Comparable<MapleRing> {
|
|
private int ringId;
|
|
private int ringId2;
|
|
private int partnerId;
|
|
private int itemId;
|
|
private String partnerName;
|
|
private boolean equipped = false;
|
|
|
|
public MapleRing(int id, int id2, int partnerId, int itemid, String partnername) {
|
|
this.ringId = id;
|
|
this.ringId2 = id2;
|
|
this.partnerId = partnerId;
|
|
this.itemId = itemid;
|
|
this.partnerName = partnername;
|
|
}
|
|
|
|
public static MapleRing loadFromDb(int ringId) {
|
|
try {
|
|
MapleRing ret = null;
|
|
Connection con = DatabaseConnection.getConnection();
|
|
PreparedStatement ps = con.prepareStatement("SELECT * FROM rings WHERE id = ?"); // Get ring details..
|
|
ps.setInt(1, ringId);
|
|
ResultSet rs = ps.executeQuery();
|
|
if (rs.next()) {
|
|
ret = new MapleRing(ringId, rs.getInt("partnerRingId"), rs.getInt("partnerChrId"), rs.getInt("itemid"), rs.getString("partnerName"));
|
|
}
|
|
rs.close();
|
|
ps.close();
|
|
con.close();
|
|
return ret;
|
|
} catch (SQLException ex) {
|
|
ex.printStackTrace();
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static void removeRing(final MapleRing ring) {
|
|
try {
|
|
if (ring == null) {
|
|
return;
|
|
}
|
|
|
|
Connection con = DatabaseConnection.getConnection();
|
|
|
|
PreparedStatement ps = con.prepareStatement("DELETE FROM rings WHERE id=?");
|
|
ps.setInt(1, ring.getRingId());
|
|
ps.addBatch();
|
|
|
|
ps.setInt(1, ring.getPartnerRingId());
|
|
ps.addBatch();
|
|
|
|
ps.executeBatch();
|
|
ps.close();
|
|
|
|
MapleCashidGenerator.freeCashId(ring.getRingId());
|
|
MapleCashidGenerator.freeCashId(ring.getPartnerRingId());
|
|
|
|
ps = con.prepareStatement("UPDATE inventoryequipment SET ringid=-1 WHERE ringid=?");
|
|
ps.setInt(1, ring.getRingId());
|
|
ps.addBatch();
|
|
|
|
ps.setInt(1, ring.getPartnerRingId());
|
|
ps.addBatch();
|
|
|
|
ps.executeBatch();
|
|
ps.close();
|
|
|
|
con.close();
|
|
} catch (SQLException ex) {
|
|
ex.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public static Pair<Integer, Integer> createRing(int itemid, final MapleCharacter partner1, final MapleCharacter partner2) {
|
|
try {
|
|
if (partner1 == null) {
|
|
return new Pair<>(-3, -3);
|
|
} else if (partner2 == null) {
|
|
return new Pair<>(-2, -2);
|
|
}
|
|
|
|
int[] ringID = new int[2];
|
|
ringID[0] = MapleCashidGenerator.generateCashId();
|
|
ringID[1] = MapleCashidGenerator.generateCashId();
|
|
|
|
Connection con = DatabaseConnection.getConnection();
|
|
PreparedStatement ps = con.prepareStatement("INSERT INTO rings (id, itemid, partnerRingId, partnerChrId, partnername) VALUES (?, ?, ?, ?, ?)");
|
|
ps.setInt(1, ringID[0]);
|
|
ps.setInt(2, itemid);
|
|
ps.setInt(3, ringID[1]);
|
|
ps.setInt(4, partner2.getId());
|
|
ps.setString(5, partner2.getName());
|
|
ps.executeUpdate();
|
|
ps.close();
|
|
ps = con.prepareStatement("INSERT INTO rings (id, itemid, partnerRingId, partnerChrId, partnername) VALUES (?, ?, ?, ?, ?)");
|
|
ps.setInt(1, ringID[1]);
|
|
ps.setInt(2, itemid);
|
|
ps.setInt(3, ringID[0]);
|
|
ps.setInt(4, partner1.getId());
|
|
ps.setString(5, partner1.getName());
|
|
ps.executeUpdate();
|
|
ps.close();
|
|
con.close();
|
|
return new Pair<>(ringID[0], ringID[1]);
|
|
} catch (SQLException ex) {
|
|
ex.printStackTrace();
|
|
return new Pair<>(-1, -1);
|
|
}
|
|
}
|
|
|
|
public int getRingId() {
|
|
return ringId;
|
|
}
|
|
|
|
public int getPartnerRingId() {
|
|
return ringId2;
|
|
}
|
|
|
|
public int getPartnerChrId() {
|
|
return partnerId;
|
|
}
|
|
|
|
public int getItemId() {
|
|
return itemId;
|
|
}
|
|
|
|
public String getPartnerName() {
|
|
return partnerName;
|
|
}
|
|
|
|
public boolean equipped() {
|
|
return equipped;
|
|
}
|
|
|
|
public void equip() {
|
|
this.equipped = true;
|
|
}
|
|
|
|
public void unequip() {
|
|
this.equipped = false;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
if (o instanceof MapleRing) {
|
|
if (((MapleRing) o).getRingId() == getRingId()) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
int hash = 5;
|
|
hash = 53 * hash + this.ringId;
|
|
return hash;
|
|
}
|
|
|
|
@Override
|
|
public int compareTo(MapleRing other) {
|
|
if (ringId < other.getRingId()) {
|
|
return -1;
|
|
} else if (ringId == other.getRingId()) {
|
|
return 0;
|
|
}
|
|
return 1;
|
|
}
|
|
}
|