MagicBot
8 months ago
2 changed files with 81 additions and 67 deletions
@ -0,0 +1,78 @@
@@ -0,0 +1,78 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.exception.MsgSendException; |
||||
import engine.gameManager.SessionManager; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.login.GameServerIPRequestMsg; |
||||
import engine.net.client.msg.login.GameServerIPResponseMsg; |
||||
import engine.objects.Account; |
||||
import engine.objects.PlayerCharacter; |
||||
import engine.server.MBServerStatics; |
||||
import engine.server.login.LoginServerMsgHandler; |
||||
import engine.session.CSSession; |
||||
import engine.session.Session; |
||||
import engine.util.ByteUtils; |
||||
import org.pmw.tinylog.Logger; |
||||
|
||||
public class GameServerIPRequestMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public GameServerIPRequestMsgHandler() { |
||||
super(GameServerIPRequestMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
Session session = SessionManager.getSession(origin); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
GameServerIPRequestMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (GameServerIPRequestMsg) baseMsg; |
||||
|
||||
if (playerCharacter == null) { |
||||
Logger.info("Unable to find character ID " + msg.getCharacterUUID()); |
||||
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "PlayerCharacter lookup failed in .RequestGameServer().", origin); |
||||
return true; |
||||
} |
||||
|
||||
try { |
||||
if (!CSSession.updateCrossServerSession(ByteUtils.byteArrayToSafeStringHex(origin.getSecretKeyBytes()), msg.getCharacterUUID())) { |
||||
Logger.info("Failed to update Cross server session, Kicking to Login for Character " + playerCharacter.getObjectUUID()); |
||||
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Failed to update Session Information", origin); |
||||
return true; |
||||
} |
||||
} catch (Exception e) { |
||||
Logger.info("Failed to update Cross server session, Kicking to Login for Character " + playerCharacter.getObjectUUID()); |
||||
Logger.error(e); |
||||
} |
||||
|
||||
// Set the last character used.
|
||||
Account account = session.getAccount(); |
||||
account.setLastCharIDUsed(msg.getCharacterUUID()); |
||||
|
||||
GameServerIPResponseMsg gameServerIPResponseMsg = new GameServerIPResponseMsg(); |
||||
|
||||
if (!origin.sendMsg(gameServerIPResponseMsg)) { |
||||
Logger.error("Failed to send message"); |
||||
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Unable to send GameServerIPResponseMsg to client.", origin); |
||||
} |
||||
|
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue