From 61fca2c742dc8a3d84ead0aeaec710c6a3622211 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 31 Mar 2024 10:13:17 -0400 Subject: [PATCH] Handler created for ServerInfoMsg --- .../client/handlers/ServerInfoMsgHandler.java | 49 +++++++++++++++++++ .../server/login/LoginServerMsgHandler.java | 15 ------ 2 files changed, 49 insertions(+), 15 deletions(-) create mode 100644 src/engine/net/client/handlers/ServerInfoMsgHandler.java diff --git a/src/engine/net/client/handlers/ServerInfoMsgHandler.java b/src/engine/net/client/handlers/ServerInfoMsgHandler.java new file mode 100644 index 00000000..6eebb470 --- /dev/null +++ b/src/engine/net/client/handlers/ServerInfoMsgHandler.java @@ -0,0 +1,49 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + +package engine.net.client.handlers; + +import engine.exception.MsgSendException; +import engine.net.client.ClientConnection; +import engine.net.client.msg.ClientNetMsg; +import engine.net.client.msg.ServerInfoMsg; +import engine.objects.PlayerCharacter; +import engine.server.MBServerStatics; +import engine.server.login.LoginServerMsgHandler; +import org.pmw.tinylog.Logger; + +public class ServerInfoMsgHandler extends AbstractClientMsgHandler { + + public ServerInfoMsgHandler() { + super(ServerInfoMsg.class); + } + + @Override + protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { + + PlayerCharacter playerCharacter = origin.getPlayerCharacter(); + + // Member variable declaration + + ServerInfoMsg msg; + + // Member variable assignment + + msg = (ServerInfoMsg) baseMsg; + + ServerInfoMsg sim = new ServerInfoMsg(); + + if (!origin.sendMsg(sim)) { + Logger.error("Failed to send message"); + LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Unable to send ServerInfoMsg to client.", origin); + } + + return true; + } + +} \ No newline at end of file diff --git a/src/engine/server/login/LoginServerMsgHandler.java b/src/engine/server/login/LoginServerMsgHandler.java index cf76cf5a..6c0a7d51 100644 --- a/src/engine/server/login/LoginServerMsgHandler.java +++ b/src/engine/server/login/LoginServerMsgHandler.java @@ -21,7 +21,6 @@ import engine.net.NetMsgHandler; import engine.net.client.ClientConnection; import engine.net.client.Protocol; import engine.net.client.msg.ClientNetMsg; -import engine.net.client.msg.ServerInfoMsg; import engine.net.client.msg.login.*; import engine.objects.Account; import engine.objects.GuildStatusController; @@ -73,10 +72,6 @@ public class LoginServerMsgHandler implements NetMsgHandler { try { switch (protocolMsg) { - case SELECTSERVER: - this.SendServerInfo(origin); - break; - case CREATECHAR: this.CommitNewCharacter((CommitNewCharacterMsg) clientNetMsg, origin); break; @@ -142,16 +137,6 @@ public class LoginServerMsgHandler implements NetMsgHandler { } } - private void SendServerInfo(ClientConnection conn) { - ServerInfoMsg sim = new ServerInfoMsg(); - - if (!conn.sendMsg(sim)) { - Logger.error("Failed to send message"); - - this.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Unable to send ServerInfoMsg to client.", conn); - } - } - private void CommitNewCharacter(CommitNewCharacterMsg commitNewCharacterMessage, ClientConnection clientConnection) { Session session = SessionManager.getSession(clientConnection);