summaryrefslogtreecommitdiff
path: root/src/net/tmwa/loginhandler.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-04 16:06:41 +0000
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-04 16:06:41 +0000
commit12bec57276d30cd513b1f6b865ee116bce86fc17 (patch)
tree2ccbf39a687b2601696dc721e039ab8fb4f45559 /src/net/tmwa/loginhandler.cpp
parenta25d857ed0bebc2c3e1473d06bea89286941886c (diff)
downloadmana-12bec57276d30cd513b1f6b865ee116bce86fc17.tar.gz
mana-12bec57276d30cd513b1f6b865ee116bce86fc17.tar.bz2
mana-12bec57276d30cd513b1f6b865ee116bce86fc17.tar.xz
mana-12bec57276d30cd513b1f6b865ee116bce86fc17.zip
Fixed duplication of player name in chat
* Fixed duplication of player name in chat Closes #49
Diffstat (limited to 'src/net/tmwa/loginhandler.cpp')
-rw-r--r--src/net/tmwa/loginhandler.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp
index 55336a84..725e0e35 100644
--- a/src/net/tmwa/loginhandler.cpp
+++ b/src/net/tmwa/loginhandler.cpp
@@ -41,9 +41,12 @@ namespace TmwAthena {
extern ServerInfo charServer;
-LoginHandler::LoginHandler():
- mVersionResponse(false),
- mRegistrationEnabled(true)
+enum ServerFlags
+{
+ FLAG_REGISTRATION = 1
+};
+
+LoginHandler::LoginHandler()
{
static const Uint16 _messages[] = {
SMSG_UPDATE_HOST,
@@ -196,16 +199,25 @@ void LoginHandler::handleMessage(MessageIn &msg)
case SMSG_SERVER_VERSION_RESPONSE:
{
- // TODO: verify these!
-
- msg.readInt8(); // -1
- msg.readInt8(); // T
- msg.readInt8(); // M
+ const uint8_t b1 = msg.readInt8(); // -1
+ const uint8_t b2 = msg.readInt8(); // T
+ const uint8_t b3 = msg.readInt8(); // M
msg.readInt8(); // W
+ const uint32_t options = msg.readInt32();
+
+ if (b1 == 255) // old TMWA
+ mServerVersion = 0;
+ else if (b1 >= 0x0d) // new TMWA
+ mServerVersion = (b1 << 16) | (b2 << 8) | b3;
+ else // eAthena
+ mServerVersion = 0;
- unsigned int options = msg.readInt32();
+ if (mServerVersion > 0)
+ logger->log("TMW server version: x%06x", mServerVersion);
+ else
+ logger->log("Server without version");
- mRegistrationEnabled = (options & 1);
+ mRegistrationEnabled = (options & FLAG_REGISTRATION);
// Leave this last
mVersionResponse = true;