Compare commits

...

6 Commits

Author SHA1 Message Date
Ponk
d307eff71f Merge pull request #177 from LynxStar/patch/mini-dungeons #patch
Fix mini-dungeon portals for parties
2023-07-10 23:09:51 +02:00
Arthur Charlton
b935725096 Handle the potentially null portal based on the name.
Matches the behavior of warping a character to a named portal.
2023-07-10 17:01:48 -04:00
Ponk
12248acd7b Merge pull request #178 from LynxStar/patch/delivery-system #patch
Delivery System - Invalid Recipient Name Patch
2023-07-10 22:40:57 +02:00
Arthur Charlton
07eb0f5e8e Untangle nested control flow conditions. 2023-07-05 14:16:09 -04:00
Arthur Charlton
cfb5fc25c3 Calling code assumes the pair never null and uses -1 to signify not found. 2023-07-05 14:12:42 -04:00
Arthur Charlton
3816e1c5bd Add the warp party function that the scripts use 2023-07-03 18:25:14 -04:00
2 changed files with 31 additions and 18 deletions

View File

@@ -92,14 +92,15 @@ public class DueyProcessor {
}
private static Pair<Integer, Integer> getAccountCharacterIdFromCNAME(String name) {
Pair<Integer, Integer> ids = null;
Pair<Integer, Integer> ids = new Pair<>(-1, -1);
try (Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT id,accountid FROM characters WHERE name = ?")) {
ps.setString(1, name);
try (ResultSet rs = ps.executeQuery()) {
if (rs.next()) {
ids = new Pair<>(rs.getInt("accountid"), rs.getInt("id"));
ids.left = rs.getInt("accountid");
ids.right = rs.getInt("id");
}
}
} catch (SQLException e) {
@@ -315,30 +316,25 @@ public class DueyProcessor {
return;
}
Pair<Integer, Integer> accIdCid;
if (c.getPlayer().getMeso() >= finalcost) {
accIdCid = getAccountCharacterIdFromCNAME(recipient);
int recipientAccId = accIdCid.getLeft();
if (recipientAccId != -1) {
if (recipientAccId == c.getAccID()) {
c.sendPacket(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_SAMEACC_ERROR.getCode()));
return;
}
} else {
c.sendPacket(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_NAME_DOES_NOT_EXIST.getCode()));
return;
}
} else {
if(c.getPlayer().getMeso() < finalcost) {
c.sendPacket(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_NOT_ENOUGH_MESOS.getCode()));
return;
}
int recipientCid = accIdCid.getRight();
if (recipientCid == -1) {
var accIdCid = getAccountCharacterIdFromCNAME(recipient);
var recipientAccId = accIdCid.getLeft();
var recipientCid = accIdCid.getRight();
if (recipientAccId == -1 || recipientCid == -1) {
c.sendPacket(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_NAME_DOES_NOT_EXIST.getCode()));
return;
}
if (recipientAccId == c.getAccID()) {
c.sendPacket(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_SAMEACC_ERROR.getCode()));
return;
}
if (quick) {
InventoryManipulator.removeById(c, InventoryType.CASH, ItemId.QUICK_DELIVERY_TICKET, (short) 1, false, false);
}

View File

@@ -133,6 +133,23 @@ public class AbstractPlayerInteraction {
warpParty(id, portalId, mapid, mapid);
}
public void warpParty(int map, String portalName) {
int mapid = getMapId();
var warpMap = c.getChannelServer().getMapFactory().getMap(map);
var portal = warpMap.getPortal(portalName);
if (portal == null) {
portal = warpMap.getPortal(0);
}
var portalId = portal.getId();
warpParty(map, portalId, mapid, mapid);
}
public void warpParty(int id, int fromMinId, int fromMaxId) {
warpParty(id, 0, fromMinId, fromMaxId);
}