Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.49 KB | None | 0 0
  1. using DragonMose.LoginService.Config;
  2. using DragonMose.LoginService.Data.Version;
  3. using DragonMose.LoginService.Game.Account;
  4. using DragonMose.LoginService.Game.Version;
  5. using DragonMose.LoginService.GameNetwork.Handlers.Server;
  6. using DragonMose.LoginService.GameNetwork.Protocol.Client;
  7. using DragonMose.Networking.GameHandlerTypes;
  8. using System;
  9.  
  10. namespace DragonMose.LoginService.GameNetwork.Handlers.Client
  11. {
  12.     [GameHandlerClass(GameHandler03Type._Header)]
  13.     public class CH03Handler
  14.     {
  15.         [GameHandler(typeof(CMSG_USER_CLIENT_VERSION_CHECK_REQ_GER))]
  16.         public static void CMSG_USER_CLIENT_VERSION_CHECK_REQ_GER(LoginSession Session, CMSG_USER_CLIENT_VERSION_CHECK_REQ_GER PACKET)
  17.         {
  18.             if (LoginConfiguration.Instance.Info.AllowNewVersion &&
  19.                 !VersionDataProvider.GetVersionByHash(PACKET.Version, out VersionData Version) &&
  20.                 VersionManager.AddVersion(PACKET.Version, DateTime.Now))
  21.             {
  22.                 return;
  23.             }
  24.         }
  25.  
  26.         [GameHandler(typeof(CMSG_USER_GER_LOGIN_REQ))]
  27.         public static void CMSG_USER_GER_LOGIN_REQ(LoginSession Session, CMSG_USER_GER_LOGIN_REQ GER_LOGIN_PACKET)
  28.         {
  29.             if (!AccountManager.Instance.GetAccountByName(GER_LOGIN_PACKET.UserName, out LoginAccount Account))
  30.             {
  31.                 SH03Handler.SMSG_USER_LOGINFAIL_ACK(Session, AUTH_CODE.INVALID_ID_OR_PW);
  32.                 return;
  33.             }
  34.  
  35.             if (!Account.Password.Equals(GER_LOGIN_PACKET.Password))
  36.             {
  37.                 SH03Handler.SMSG_USER_LOGINFAIL_ACK(Session, AUTH_CODE.INVALID_ID_OR_PW);
  38.                 return;
  39.             }
  40.  
  41.             if (Account.IsOnline) //Detecting Dublicate...
  42.             {
  43.                 if (AccountManager.Instance.GetSession(Account, out LoginSession Dub_Session))
  44.                 {
  45.                     SH03Handler.SMSG_USER_CONNECTION_CUT_CMD(Dub_Session);
  46.                     return;
  47.                 }
  48.                 else
  49.                 {
  50.                     InternalNetwork.Handlers.Server.SH03Handler.SMSG_ACCOUNT_LOGIN_DUBLICATE(Account);
  51.                     SH03Handler.SMSG_USER_LOGINFAIL_ACK(Session, AUTH_CODE.LOGIN_FAILED);
  52.                     return;
  53.                 }
  54.             }
  55.  
  56.             if (Session.Region != ClientRegion.DE)
  57.             {
  58.                 SH03Handler.SMSG_USER_LOGINFAIL_ACK(Session, AUTH_CODE.WRONG_REGION);
  59.                 return;
  60.             }
  61.  
  62.             if (!Account.IsActivated)
  63.             {
  64.                 SH03Handler.SMSG_USER_LOGINFAIL_ACK(Session, AUTH_CODE.AGREEMENT_MISSING);
  65.                 return;
  66.             }
  67.  
  68.             if (Account.IsBanned || Account.BanTime >= 0)
  69.             {
  70.                 SH03Handler.SMSG_USER_LOGINFAIL_ACK(Session, AUTH_CODE.BLOCKED);
  71.                 return;
  72.             }
  73.  
  74.             Session.Account = Account;
  75.  
  76.             if (!AccountManager.Instance.AddSession(Session))
  77.             {
  78.                 InternalNetwork.Handlers.Server.SH03Handler.SMSG_ACCOUNT_LOGIN_DUBLICATE(Account);
  79.                 SH03Handler.SMSG_USER_LOGINFAIL_ACK(Session, AUTH_CODE.LOGIN_FAILED);
  80.                 return;
  81.             }
  82.  
  83.             if (!AccountManager.Instance.UpdateAccount(Account))
  84.             {
  85.                 SH03Handler.SMSG_USER_LOGINFAIL_ACK(Session, AUTH_CODE.DATABASE_ERROR);
  86.                 return;
  87.             }
  88.             //All OK We Can Logget in...
  89.             SH03Handler.SMSG_USER_LOGIN_ACK(Session);
  90.         }
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement