Compare commits

...

7 Commits

Author SHA1 Message Date
Ponk
3091d747e6 Merge pull request #165 from P0nk/feat/upgrade-dependencies #patch
Upgrade dependencies
2023-03-02 18:35:59 +01:00
P0nk
f4062e5ebb Upgrade dependencies 2023-03-02 18:31:21 +01:00
Ponk
a8807f1ef0 Merge pull request #164 from P0nk/fix/custom-charset-string #patch
Fix writeString not fully respecting charset
2023-03-02 18:13:52 +01:00
P0nk
10945927c1 Fix writeString not fully respecting charset
The string would be cut short for charsets
with characters more than 1 byte.
2023-03-02 18:11:41 +01:00
Ponk
ab25f698da Merge pull request #160 from P0nk/bug/110/zenumist-portal #patch
Fix top portal in Zenumist Society (261000010) not working for GM
2023-02-17 00:48:33 +01:00
P0nk
b30e03ffb3 Fix portal in Zenumist society not working for GM chr 2023-02-17 00:42:33 +01:00
P0nk
82157c7bd1 Flatten ChangeMapHandler 2023-02-16 23:46:13 +01:00
3 changed files with 131 additions and 119 deletions

26
pom.xml
View File

@@ -19,22 +19,22 @@
<mainClass>net.server.Server</mainClass> <mainClass>net.server.Server</mainClass>
<!-- Maven plugins --> <!-- Maven plugins -->
<maven-surefire-plugin.version>3.0.0-M7</maven-surefire-plugin.version> <!-- For running unit tests --> <maven-surefire-plugin.version>3.0.0-M9</maven-surefire-plugin.version> <!-- For running unit tests -->
<maven-jar-plugin.version>3.2.2</maven-jar-plugin.version> <!-- Disabled. (for building thin jar) --> <maven-jar-plugin.version>3.3.0</maven-jar-plugin.version> <!-- Disabled. (for building thin jar) -->
<maven-assembly-plugin.version>3.4.2</maven-assembly-plugin.version> <!-- For packaging the executable fat jar --> <maven-assembly-plugin.version>3.5.0</maven-assembly-plugin.version> <!-- For packaging the executable fat jar -->
<!-- Dependencies --> <!-- Dependencies -->
<slf4j-api.version>1.7.36</slf4j-api.version> <!-- Logging facade --> <slf4j-api.version>1.7.36</slf4j-api.version> <!-- Logging facade -->
<log4j.version>2.18.0</log4j.version> <!-- Slf4j implementation --> <log4j.version>2.20.0</log4j.version> <!-- Slf4j implementation -->
<graalvm.version>22.2.0</graalvm.version> <!-- ScriptEngine implementation --> <graalvm.version>22.3.1</graalvm.version> <!-- ScriptEngine implementation -->
<netty.version>4.1.79.Final</netty.version> <!-- Networking --> <netty.version>4.1.89.Final</netty.version> <!-- Networking -->
<yamlbeans.version>1.15</yamlbeans.version> <!-- Config file --> <yamlbeans.version>1.15</yamlbeans.version> <!-- Config file -->
<jcip-annotations.version>1.0</jcip-annotations.version> <!-- Annotations for concurrency documentation --> <jcip-annotations.version>1.0</jcip-annotations.version> <!-- Annotations for concurrency documentation -->
<HikariCP.version>5.0.1</HikariCP.version> <!-- Database connection pool --> <HikariCP.version>5.0.1</HikariCP.version> <!-- Database connection pool -->
<mysql-connector-java.version>8.0.30</mysql-connector-java.version> <!-- MySQL JDBC driver --> <mysql-connector-j.version>8.0.32</mysql-connector-j.version> <!-- MySQL JDBC driver -->
<jdbi-version>3.35.0</jdbi-version> <!-- Convenience wrapper around JDBC --> <jdbi-version>3.37.1</jdbi-version> <!-- Convenience wrapper around JDBC -->
<junit.version>5.9.0</junit.version> <!-- Unit test --> <junit.version>5.9.2</junit.version> <!-- Unit test -->
<mockito.version>4.7.0</mockito.version> <!-- Unit test --> <mockito.version>5.1.1</mockito.version> <!-- Unit test -->
</properties> </properties>
<dependencies> <dependencies>
@@ -56,9 +56,9 @@
<version>${HikariCP.version}</version> <version>${HikariCP.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>com.mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-j</artifactId>
<version>${mysql-connector-java.version}</version> <version>${mysql-connector-j.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jdbi</groupId> <groupId>org.jdbi</groupId>

View File

@@ -71,8 +71,9 @@ public class ByteBufOutPacket implements OutPacket {
@Override @Override
public void writeString(String value) { public void writeString(String value) {
writeShort((short) value.length()); byte[] bytes = value.getBytes(CharsetConstants.CHARSET);
writeBytes(value.getBytes(CharsetConstants.CHARSET)); writeShort(bytes.length);
writeBytes(bytes);
} }
@Override @Override

View File

@@ -58,40 +58,33 @@ public final class ChangeMapHandler extends AbstractPacketHandler {
if (chr.getTrade() != null) { if (chr.getTrade() != null) {
Trade.cancelTrade(chr, Trade.TradeResult.UNSUCCESSFUL_ANOTHER_MAP); Trade.cancelTrade(chr, Trade.TradeResult.UNSUCCESSFUL_ANOTHER_MAP);
} }
if (p.available() == 0) { //Cash Shop :)
if (!chr.getCashShop().isOpened()) { boolean enteringMapFromCashShop = p.available() == 0;
c.disconnect(false, false); if (enteringMapFromCashShop) {
enterFromCashShop(c);
return; return;
} }
String[] socket = c.getChannelServer().getIP().split(":");
chr.getCashShop().open(false);
chr.setSessionTransitionState();
try {
c.sendPacket(PacketCreator.getChannelChange(InetAddress.getByName(socket[0]), Integer.parseInt(socket[1])));
} catch (UnknownHostException ex) {
ex.printStackTrace();
}
} else {
if (chr.getCashShop().isOpened()) { if (chr.getCashShop().isOpened()) {
c.disconnect(false, false); c.disconnect(false, false);
return; return;
} }
try { try {
p.readByte(); // 1 = from dying 0 = regular portals p.readByte(); // 1 = from dying 0 = regular portals
int targetid = p.readInt(); int targetMapId = p.readInt();
String startwp = p.readString(); String portalName = p.readString();
Portal portal = chr.getMap().getPortal(startwp); Portal portal = chr.getMap().getPortal(portalName);
p.readByte(); p.readByte();
boolean wheel = p.readByte() > 0; boolean wheel = p.readByte() > 0;
boolean chasing = p.readByte() == 1 && chr.isGM(); boolean chasing = p.readByte() == 1 && chr.isGM() && p.available() == 2 * Integer.BYTES;
if (chasing) { if (chasing) {
chr.setChasing(true); chr.setChasing(true);
chr.setPosition(new Point(p.readInt(), p.readInt())); chr.setPosition(new Point(p.readInt(), p.readInt()));
} }
if (targetid != -1) { if (targetMapId != -1) {
if (!chr.isAlive()) { if (!chr.isAlive()) {
MapleMap map = chr.getMap(); MapleMap map = chr.getMap();
if (wheel && chr.haveItemWithId(ItemId.WHEEL_OF_FORTUNE, false)) { if (wheel && chr.haveItemWithId(ItemId.WHEEL_OF_FORTUNE, false)) {
@@ -113,40 +106,40 @@ public final class ChangeMapHandler extends AbstractPacketHandler {
} }
} else { } else {
if (chr.isGM()) { if (chr.isGM()) {
MapleMap to = chr.getWarpMap(targetid); MapleMap to = chr.getWarpMap(targetMapId);
chr.changeMap(to, to.getPortal(0)); chr.changeMap(to, to.getPortal(0));
} else { } else {
final int divi = chr.getMapId() / 100; final int divi = chr.getMapId() / 100;
boolean warp = false; boolean warp = false;
if (divi == 0) { if (divi == 0) {
if (targetid == 10000) { if (targetMapId == 10000) {
warp = true; warp = true;
} }
} else if (divi == 20100) { } else if (divi == 20100) {
if (targetid == MapId.LITH_HARBOUR) { if (targetMapId == MapId.LITH_HARBOUR) {
c.sendPacket(PacketCreator.lockUI(false)); c.sendPacket(PacketCreator.lockUI(false));
c.sendPacket(PacketCreator.disableUI(false)); c.sendPacket(PacketCreator.disableUI(false));
warp = true; warp = true;
} }
} else if (divi == 9130401) { // Only allow warp if player is already in Intro map, or else = hack } else if (divi == 9130401) { // Only allow warp if player is already in Intro map, or else = hack
if (targetid == MapId.EREVE || targetid / 100 == 9130401) { // Cygnus introduction if (targetMapId == MapId.EREVE || targetMapId / 100 == 9130401) { // Cygnus introduction
warp = true; warp = true;
} }
} else if (divi == 9140900) { // Aran Introduction } else if (divi == 9140900) { // Aran Introduction
if (targetid == MapId.ARAN_TUTO_2 || targetid == MapId.ARAN_TUTO_3 || targetid == MapId.ARAN_TUTO_4 || targetid == MapId.ARAN_INTRO) { if (targetMapId == MapId.ARAN_TUTO_2 || targetMapId == MapId.ARAN_TUTO_3 || targetMapId == MapId.ARAN_TUTO_4 || targetMapId == MapId.ARAN_INTRO) {
warp = true; warp = true;
} }
} else if (divi / 10 == 1020) { // Adventurer movie clip Intro } else if (divi / 10 == 1020) { // Adventurer movie clip Intro
if (targetid == 1020000) { if (targetMapId == 1020000) {
warp = true; warp = true;
} }
} else if (divi / 10 >= 980040 && divi / 10 <= 980045) { } else if (divi / 10 >= 980040 && divi / 10 <= 980045) {
if (targetid == MapId.WITCH_TOWER_ENTRANCE) { if (targetMapId == MapId.WITCH_TOWER_ENTRANCE) {
warp = true; warp = true;
} }
} }
if (warp) { if (warp) {
final MapleMap to = chr.getWarpMap(targetid); final MapleMap to = chr.getWarpMap(targetMapId);
chr.changeMap(to, to.getPortal(0)); chr.changeMap(to, to.getPortal(0));
} }
} }
@@ -178,6 +171,24 @@ public final class ChangeMapHandler extends AbstractPacketHandler {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
}
private void enterFromCashShop(Client c) {
final Character chr = c.getPlayer();
if (!chr.getCashShop().isOpened()) {
c.disconnect(false, false);
return;
}
String[] socket = c.getChannelServer().getIP().split(":");
chr.getCashShop().open(false);
chr.setSessionTransitionState();
try {
c.sendPacket(PacketCreator.getChannelChange(InetAddress.getByName(socket[0]), Integer.parseInt(socket[1])));
} catch (UnknownHostException ex) {
ex.printStackTrace();
} }
} }
} }