From a097681d8604b28f215a37c5b09f78af9ec720c1 Mon Sep 17 00:00:00 2001 From: Jgunishka <53265225+Jgunishka@users.noreply.github.com> Date: Sun, 22 Aug 2021 18:50:50 +0300 Subject: [PATCH] v92.9 changes --- .../emulinker/kaillera/controller/v086/protocol/Chat.java | 2 +- .../controller/v086/protocol/ConnectionRejected.java | 2 +- .../kaillera/controller/v086/protocol/CreateGame.java | 2 +- .../kaillera/controller/v086/protocol/GameChat.java | 2 +- .../controller/v086/protocol/InformationMessage.java | 2 +- .../kaillera/controller/v086/protocol/JoinGame.java | 2 +- .../kaillera/controller/v086/protocol/PlayerDrop.java | 2 +- .../controller/v086/protocol/PlayerInformation.java | 2 +- .../emulinker/kaillera/controller/v086/protocol/Quit.java | 2 +- .../kaillera/controller/v086/protocol/QuitGame.java | 2 +- .../kaillera/controller/v086/protocol/ServerStatus.java | 4 ++-- .../kaillera/controller/v086/protocol/UserInformation.java | 2 +- .../kaillera/controller/v086/protocol/UserJoined.java | 2 +- .../kaillera/controller/v086/protocol/V086Message.java | 6 ++++++ .../kaillera/release/KailleraServerReleaseInfo.java | 4 ++-- 15 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/org/emulinker/kaillera/controller/v086/protocol/Chat.java b/src/org/emulinker/kaillera/controller/v086/protocol/Chat.java index 7397bbb..d303c52 100644 --- a/src/org/emulinker/kaillera/controller/v086/protocol/Chat.java +++ b/src/org/emulinker/kaillera/controller/v086/protocol/Chat.java @@ -43,7 +43,7 @@ public abstract class Chat extends V086Message public int getBodyLength() { //return (charset.encode(userName).remaining() + charset.encode(message).remaining() + 2); - return (userName.length() + message.length() + 2); + return (getNumBytes(userName) + getNumBytes(message) + 2); } public void writeBodyTo(ByteBuffer buffer) diff --git a/src/org/emulinker/kaillera/controller/v086/protocol/ConnectionRejected.java b/src/org/emulinker/kaillera/controller/v086/protocol/ConnectionRejected.java index 4bb6926..64e3504 100644 --- a/src/org/emulinker/kaillera/controller/v086/protocol/ConnectionRejected.java +++ b/src/org/emulinker/kaillera/controller/v086/protocol/ConnectionRejected.java @@ -65,7 +65,7 @@ public class ConnectionRejected extends V086Message public int getBodyLength() { //return (charset.encode(userName).remaining() + charset.encode(message).remaining() + 4); - return (userName.length() + message.length() + 4); + return (getNumBytes(userName) + getNumBytes(message) + 4); } public void writeBodyTo(ByteBuffer buffer) diff --git a/src/org/emulinker/kaillera/controller/v086/protocol/CreateGame.java b/src/org/emulinker/kaillera/controller/v086/protocol/CreateGame.java index d14b00b..baf4ba1 100644 --- a/src/org/emulinker/kaillera/controller/v086/protocol/CreateGame.java +++ b/src/org/emulinker/kaillera/controller/v086/protocol/CreateGame.java @@ -72,7 +72,7 @@ public abstract class CreateGame extends V086Message public int getBodyLength() { //return (charset.encode(userName).remaining() + charset.encode(romName).remaining() + charset.encode(clientType).remaining() + 7); - return (userName.length() + romName.length() + clientType.length() + 7); + return (getNumBytes(userName) + getNumBytes(romName) + getNumBytes(clientType) + 7); } public void writeBodyTo(ByteBuffer buffer) diff --git a/src/org/emulinker/kaillera/controller/v086/protocol/GameChat.java b/src/org/emulinker/kaillera/controller/v086/protocol/GameChat.java index c12ef93..2039d60 100644 --- a/src/org/emulinker/kaillera/controller/v086/protocol/GameChat.java +++ b/src/org/emulinker/kaillera/controller/v086/protocol/GameChat.java @@ -42,7 +42,7 @@ public abstract class GameChat extends V086Message public int getBodyLength() { //return (charset.encode(userName).remaining() + charset.encode(message).remaining() + 2); - return (userName.length() + message.length() + 2); + return (getNumBytes(userName) + getNumBytes(message) + 2); } public void writeBodyTo(ByteBuffer buffer) diff --git a/src/org/emulinker/kaillera/controller/v086/protocol/InformationMessage.java b/src/org/emulinker/kaillera/controller/v086/protocol/InformationMessage.java index f79ff7b..01701de 100644 --- a/src/org/emulinker/kaillera/controller/v086/protocol/InformationMessage.java +++ b/src/org/emulinker/kaillera/controller/v086/protocol/InformationMessage.java @@ -55,7 +55,7 @@ public class InformationMessage extends V086Message public int getBodyLength() { //return (charset.encode(source).remaining() + charset.encode(message).remaining() + 2); - return (source.length() + message.length() + 2); + return (getNumBytes(source) + getNumBytes(message) + 2); } public void writeBodyTo(ByteBuffer buffer) diff --git a/src/org/emulinker/kaillera/controller/v086/protocol/JoinGame.java b/src/org/emulinker/kaillera/controller/v086/protocol/JoinGame.java index cdef265..dbeb4d8 100644 --- a/src/org/emulinker/kaillera/controller/v086/protocol/JoinGame.java +++ b/src/org/emulinker/kaillera/controller/v086/protocol/JoinGame.java @@ -82,7 +82,7 @@ public abstract class JoinGame extends V086Message public int getBodyLength() { //return (charset.encode(userName).remaining() + 13); - return (userName.length() + 13); + return (getNumBytes(userName) + 13); } public void writeBodyTo(ByteBuffer buffer) diff --git a/src/org/emulinker/kaillera/controller/v086/protocol/PlayerDrop.java b/src/org/emulinker/kaillera/controller/v086/protocol/PlayerDrop.java index 129fb8d..5b45db5 100644 --- a/src/org/emulinker/kaillera/controller/v086/protocol/PlayerDrop.java +++ b/src/org/emulinker/kaillera/controller/v086/protocol/PlayerDrop.java @@ -48,7 +48,7 @@ public abstract class PlayerDrop extends V086Message public int getBodyLength() { //return (charset.encode(userName).remaining() + 2); - return (userName.length() + 2); + return (getNumBytes(userName) + 2); } public void writeBodyTo(ByteBuffer buffer) diff --git a/src/org/emulinker/kaillera/controller/v086/protocol/PlayerInformation.java b/src/org/emulinker/kaillera/controller/v086/protocol/PlayerInformation.java index 422a0fb..f353751 100644 --- a/src/org/emulinker/kaillera/controller/v086/protocol/PlayerInformation.java +++ b/src/org/emulinker/kaillera/controller/v086/protocol/PlayerInformation.java @@ -165,7 +165,7 @@ public class PlayerInformation extends V086Message public int getLength() { //return (charset.encode(userName).remaining() + 2); - return (userName.length() + 8); + return (getNumBytes(userName) + 8); } public void writeTo(ByteBuffer buffer) diff --git a/src/org/emulinker/kaillera/controller/v086/protocol/Quit.java b/src/org/emulinker/kaillera/controller/v086/protocol/Quit.java index 3234dbe..c670116 100644 --- a/src/org/emulinker/kaillera/controller/v086/protocol/Quit.java +++ b/src/org/emulinker/kaillera/controller/v086/protocol/Quit.java @@ -55,7 +55,7 @@ public abstract class Quit extends V086Message public int getBodyLength() { //return (charset.encode(userName).remaining() + charset.encode(message).remaining() + 4); - return (userName.length() + message.length() + 4); + return (getNumBytes(userName) + getNumBytes(message) + 4); } public void writeBodyTo(ByteBuffer buffer) diff --git a/src/org/emulinker/kaillera/controller/v086/protocol/QuitGame.java b/src/org/emulinker/kaillera/controller/v086/protocol/QuitGame.java index a1e8d70..b694dc3 100644 --- a/src/org/emulinker/kaillera/controller/v086/protocol/QuitGame.java +++ b/src/org/emulinker/kaillera/controller/v086/protocol/QuitGame.java @@ -43,7 +43,7 @@ public abstract class QuitGame extends V086Message public int getBodyLength() { //return (charset.encode(userName).remaining() + 3); - return (userName.length() + 3); + return (getNumBytes(userName) + 3); } public void writeBodyTo(ByteBuffer buffer) diff --git a/src/org/emulinker/kaillera/controller/v086/protocol/ServerStatus.java b/src/org/emulinker/kaillera/controller/v086/protocol/ServerStatus.java index 27ceece..e88ff5e 100644 --- a/src/org/emulinker/kaillera/controller/v086/protocol/ServerStatus.java +++ b/src/org/emulinker/kaillera/controller/v086/protocol/ServerStatus.java @@ -233,7 +233,7 @@ public class ServerStatus extends V086Message public int getLength() { //return (charset.encode(userName).remaining() + 9); - return (userName.length() + 9); + return (getNumBytes(userName) + 9); } public void writeTo(ByteBuffer buffer) @@ -318,7 +318,7 @@ public class ServerStatus extends V086Message public int getLength() { //return (charset.encode(romName).remaining() + 1 + 4 + charset.encode(clientType).remaining() + 1 + charset.encode(userName).remaining() + 1 + charset.encode(players).remaining() + 1 + 1); - return (romName.length() + 1 + 4 + clientType.length() + 1 + userName.length() + 1 + players.length() + 1 + 1); + return (getNumBytes(romName) + 1 + 4 + getNumBytes(clientType) + 1 + getNumBytes(userName) + 1 + getNumBytes(players) + 1 + 1); } public void writeTo(ByteBuffer buffer) diff --git a/src/org/emulinker/kaillera/controller/v086/protocol/UserInformation.java b/src/org/emulinker/kaillera/controller/v086/protocol/UserInformation.java index e2651db..5351c7d 100644 --- a/src/org/emulinker/kaillera/controller/v086/protocol/UserInformation.java +++ b/src/org/emulinker/kaillera/controller/v086/protocol/UserInformation.java @@ -40,7 +40,7 @@ public class UserInformation extends V086Message public int getBodyLength() { //return (charset.encode(userName).remaining() + charset.encode(clientType).remaining() + 3); - return (userName.length() + clientType.length() + 3); + return (getNumBytes(userName) + getNumBytes(clientType) + 3); } public String getUserName() diff --git a/src/org/emulinker/kaillera/controller/v086/protocol/UserJoined.java b/src/org/emulinker/kaillera/controller/v086/protocol/UserJoined.java index 27fb42f..91df80e 100644 --- a/src/org/emulinker/kaillera/controller/v086/protocol/UserJoined.java +++ b/src/org/emulinker/kaillera/controller/v086/protocol/UserJoined.java @@ -75,7 +75,7 @@ public class UserJoined extends V086Message public int getBodyLength() { //return (charset.encode(userName).remaining() + 8); - return (userName.length() + 8); + return (getNumBytes(userName) + 8); } public void writeBodyTo(ByteBuffer buffer) diff --git a/src/org/emulinker/kaillera/controller/v086/protocol/V086Message.java b/src/org/emulinker/kaillera/controller/v086/protocol/V086Message.java index 50dd605..7af205d 100644 --- a/src/org/emulinker/kaillera/controller/v086/protocol/V086Message.java +++ b/src/org/emulinker/kaillera/controller/v086/protocol/V086Message.java @@ -39,6 +39,12 @@ public abstract class V086Message extends ByteBufferMessage return (getBodyLength() + 1); //return (getBodyLength() + 5); } + + /** Gets the number of bytes to represent the string in the charset defined in emulinker.cfg **/ + protected static int getNumBytes(String s) + { + return s.getBytes(charset).length; + } public abstract int getBodyLength(); diff --git a/src/org/emulinker/kaillera/release/KailleraServerReleaseInfo.java b/src/org/emulinker/kaillera/release/KailleraServerReleaseInfo.java index 7aad5e8..232f03e 100644 --- a/src/org/emulinker/kaillera/release/KailleraServerReleaseInfo.java +++ b/src/org/emulinker/kaillera/release/KailleraServerReleaseInfo.java @@ -13,9 +13,9 @@ public final class KailleraServerReleaseInfo implements ReleaseInfo private final int majorVersion = 0; private final int minorVersion = 92; - private final int buildNumber = 7; + private final int buildNumber = 9; - private final String releaseDate = "08-21-2021"; + private final String releaseDate = "08-22-2021"; private final String licenseInfo = "Usage of this sofware is subject to the terms found in the included license"; private final String website = "https://www.EmuLinker.org";