Example #1
0
        /// <summary>
        /// Handles the JoinGameIn packet. This packet is sent in response to our request to join
        /// a game. If successful, we fire an event to notify the driver to start the game server.
        /// </summary>
        /// <param name="packet">The packet.</param>
        private void OnJoinGame(RealmServerPacket packet)
        {
            JoinGameIn fromServer = new JoinGameIn(packet);

            LogServer(fromServer);

            if (!fromServer.IsSuccessful())
            {
                Fail(FailureArgs.FailureTypes.FailedToJoinGame, fromServer.ToString());
                return;
            }

            GameServerArgs args = new GameServerArgs();

            args.Address        = fromServer.GameServerIp.ToString();
            args.Port           = 4000;
            args.GameHash       = fromServer.GameHash;
            args.GameToken      = fromServer.GameToken;
            args.CharacterClass = (byte)CharacterClassType.Barbarian;
            args.PlayerCount    = playerCount;
            args.MaxPlayers     = maxPlayers;
            args.PlayerNames    = playerNames;

            // Pad the character name to 16 bytes. This is required by the game server.
            byte[] charNameBytes = ASCIIEncoding.ASCII.GetBytes(characterName);
            Array.Resize(ref charNameBytes, 16);
            args.CharacterName = (byte[])charNameBytes.Clone();

            ReadyToConnectToGameServer(this, args);
        }
Example #2
0
        public GameInfoIn(RealmServerPacket packet)
        {
            BinaryReader br = new BinaryReader(new MemoryStream(packet.Data));

            RequestID      = br.ReadUInt16();
            Status         = br.ReadUInt32();
            GameUptime     = br.ReadUInt32();
            Unknown        = br.ReadUInt16();
            MaximumPlayers = br.ReadByte();
            PlayerCount    = br.ReadByte();

            PlayerClasses = new CharacterClassType[16];
            for (int i = 0; i < PlayerClasses.Length; i++)
            {
                PlayerClasses[i] = (CharacterClassType)br.ReadByte();
            }

            PlayerLevels = new byte[16];
            for (int i = 0; i < PlayerLevels.Length; i++)
            {
                PlayerLevels[i] = br.ReadByte();
            }

            Description = Util.ReadSpecialString(br);

            CharacterNames = new string[16];
            for (int i = 0; i < PlayerCount; i++)
            {
                CharacterNames[i] = Util.ReadSpecialString(br);
            }
        }
Example #3
0
        public CreateGameIn(RealmServerPacket packet)
        {
            BinaryReader br = new BinaryReader(new MemoryStream(packet.Data));

            RequestId = br.ReadUInt16();
            GameToken = br.ReadUInt16();
            Unknown   = br.ReadUInt16();
            Result    = br.ReadUInt32();
        }
Example #4
0
        public GameListIn(RealmServerPacket packet)
        {
            BinaryReader br = new BinaryReader(new MemoryStream(packet.Data));

            RequestId       = br.ReadUInt16();
            Index           = br.ReadUInt32();
            PlayerCount     = br.ReadByte();
            Status          = br.ReadUInt32();
            GameName        = Util.ReadSpecialString(br);
            GameDescription = Util.ReadSpecialString(br);
        }
Example #5
0
        public JoinGameIn(RealmServerPacket packet)
        {
            BinaryReader br = new BinaryReader(new MemoryStream(packet.Data));

            RequestID    = br.ReadUInt16();
            GameToken    = br.ReadUInt16();
            Unknown      = br.ReadUInt16();
            GameServerIp = new IPAddress(br.ReadBytes(4));
            GameHash     = br.ReadUInt32();
            Result       = br.ReadUInt32();
        }
Example #6
0
        /// <summary>
        /// Handles the GameInfoIn packet.
        /// </summary>
        /// <param name="packet">The packet.</param>
        private void OnGameInfo(RealmServerPacket packet)
        {
            GameInfoIn fromServer = new GameInfoIn(packet);

            LogServer(fromServer);

            playerCount = fromServer.PlayerCount;
            maxPlayers  = fromServer.MaximumPlayers;
            playerNames = new List <string>(fromServer.CharacterNames);
            playerNames.RemoveAll(n => String.IsNullOrEmpty(n));

            JoinGameOut toServer = new JoinGameOut(settings.GameName, settings.GamePass);

            SendPacket(RealmServerPacketType.JOINGAME, toServer.GetBytes());
        }
Example #7
0
        /// <summary>
        /// Handles the StartupIn packet. This packet is sent in response to our StartupOut packet when
        /// we initially connected to the Realm Server. If successful, we request a list of characters
        /// on the account.
        /// </summary>
        /// <param name="packet">The packet.</param>
        private void OnStartup(RealmServerPacket packet)
        {
            StartupIn fromServer = new StartupIn(packet);

            LogServer(fromServer);

            if (!fromServer.IsSuccessful())
            {
                Fail(FailureArgs.FailureTypes.ServerDeniedConnection, fromServer.ToString());
                return;
            }

            CharList2Out toServer = new CharList2Out(8);

            SendPacket(RealmServerPacketType.CHARLIST2, toServer.GetBytes());
        }
Example #8
0
        /// <summary>
        /// Handles the CharList2In packet. This packet contains a list of all the characters on the
        /// account. We respond by sending a CharLogonOut packet containing the name of the character
        /// to logon as.
        /// </summary>
        /// <param name="packet">The packet.</param>
        private void OnCharList2(RealmServerPacket packet)
        {
            CharList2In fromServer = new CharList2In(packet);

            LogServer(fromServer);

            if (!fromServer.CharacterExists(characterName))
            {
                Fail(FailureArgs.FailureTypes.CharacterNotFound, "Character not found");
                return;
            }

            CharLogonOut toServer = new CharLogonOut(characterName);

            SendPacket(RealmServerPacketType.CHARLOGON, toServer.GetBytes());
        }
Example #9
0
        /// <summary>
        /// Handles the CharLogonIn packet. This packet is sent in response to a CharLogonOut
        /// packet. If this packet status is successful, we respond by requesting to create a game.
        /// </summary>
        /// <remarks>
        /// Requesting to create a game that already exists is correct because we're told if the
        /// game already exists or has been created successfully when the server responds with a
        /// CreateGameIn packet. From there we just query and join it.
        /// </remarks>
        /// <param name="packet">The packet.</param>
        private void OnCharLogon(RealmServerPacket packet)
        {
            CharLogonIn fromServer = new CharLogonIn(packet);

            LogServer(fromServer);

            if (!fromServer.IsSuccessful())
            {
                Fail(FailureArgs.FailureTypes.FailedToLoginToChat, fromServer.ToString());
                return;
            }

            CreateGameOut toServer = new CreateGameOut(settings.GameName, settings.GamePass, settings.GameDescription, settings.GameDifficulty, 1);

            SendPacket(RealmServerPacketType.CREATEGAME, toServer.GetBytes());
        }
Example #10
0
        /// <summary>
        /// Handles the CreateGameIn packet. This packet is sent in response to our CreateGameOut
        /// request. If successful, we will request the game info.
        /// </summary>
        /// <param name="packet">The packet.</param>
        private void OnCreateGame(RealmServerPacket packet)
        {
            CreateGameIn fromServer = new CreateGameIn(packet);

            LogServer(fromServer);

            if (!fromServer.IsSuccessful())
            {
                Fail(FailureArgs.FailureTypes.FailedToCreateGame, fromServer.ToString());
                return;
            }

            GameInfoOut toServer = new GameInfoOut(settings.GameName);

            SendPacket(RealmServerPacketType.GAMEINFO, toServer.GetBytes());
        }
        public CharList2In(RealmServerPacket packet)
        {
            BinaryReader br = new BinaryReader(new MemoryStream(packet.Data));
            RequestedCharacters = br.ReadUInt16();
            TotalCharacters = br.ReadUInt32();
            RetrievedCharacters = br.ReadUInt16();
            charData = new CharListData[RetrievedCharacters];

            for (int i = 0; i < RetrievedCharacters; i++)
            {
                uint timeStamp = br.ReadUInt32();

                charData[i].ExpirationDate = new DateTime(1970, 1, 1).AddSeconds(timeStamp);
                charData[i].CharacterName = Util.ReadSpecialString(br);
                charData[i].CharacterStatString = Util.ReadSpecialString(br);
            }
        }
Example #12
0
        public CharList2In(RealmServerPacket packet)
        {
            BinaryReader br = new BinaryReader(new MemoryStream(packet.Data));

            RequestedCharacters = br.ReadUInt16();
            TotalCharacters     = br.ReadUInt32();
            RetrievedCharacters = br.ReadUInt16();
            charData            = new CharListData[RetrievedCharacters];

            for (int i = 0; i < RetrievedCharacters; i++)
            {
                uint timeStamp = br.ReadUInt32();

                charData[i].ExpirationDate      = new DateTime(1970, 1, 1).AddSeconds(timeStamp);
                charData[i].CharacterName       = Util.ReadSpecialString(br);
                charData[i].CharacterStatString = Util.ReadSpecialString(br);
            }
        }
 public StartupIn(RealmServerPacket packet)
 {
     BinaryReader br = new BinaryReader(new MemoryStream(packet.Data));
     Result = br.ReadUInt32();
 }
 public GameListIn(RealmServerPacket packet)
 {
     BinaryReader br = new BinaryReader(new MemoryStream(packet.Data));
     RequestId = br.ReadUInt16();
     Index = br.ReadUInt32();
     PlayerCount = br.ReadByte();
     Status = br.ReadUInt32();
     GameName = Util.ReadSpecialString(br);
     GameDescription = Util.ReadSpecialString(br);
 }
 public JoinGameIn(RealmServerPacket packet)
 {
     BinaryReader br = new BinaryReader(new MemoryStream(packet.Data));
     RequestID = br.ReadUInt16();
     GameToken = br.ReadUInt16();
     Unknown = br.ReadUInt16();
     GameServerIp = new IPAddress(br.ReadBytes(4));
     GameHash = br.ReadUInt32();
     Result = br.ReadUInt32();
 }
        public GameInfoIn(RealmServerPacket packet)
        {
            BinaryReader br = new BinaryReader(new MemoryStream(packet.Data));
            RequestID = br.ReadUInt16();
            Status = br.ReadUInt32();
            GameUptime = br.ReadUInt32();
            Unknown = br.ReadUInt16();
            MaximumPlayers = br.ReadByte();
            PlayerCount = br.ReadByte();

            PlayerClasses = new CharacterClassType[16];
            for (int i = 0; i < PlayerClasses.Length; i++)
            {
                PlayerClasses[i] = (CharacterClassType)br.ReadByte();
            }

            PlayerLevels = new byte[16];
            for (int i = 0; i < PlayerLevels.Length; i++)
            {
                PlayerLevels[i] = br.ReadByte();
            }

            Description = Util.ReadSpecialString(br);

            CharacterNames = new string[16];
            for (int i = 0; i < PlayerCount; i++)
            {
                CharacterNames[i] = Util.ReadSpecialString(br);
            }
        }
Example #17
0
        /// <summary>
        /// Handles the CreateQueueIn packet. This packet is sent when you're forced to enter a
        /// join game queue. CreateQueueIn will be resent every now and then to update your position
        /// until your request is finally accepted, which will send us a JoinGameIn packet.
        /// </summary>
        /// <param name="packet">The packet.</param>
        private void OnCreateQueue(RealmServerPacket packet)
        {
            CreateQueueIn fromServer = new CreateQueueIn(packet);

            LogServer(fromServer);
        }
 public CreateGameIn(RealmServerPacket packet)
 {
     BinaryReader br = new BinaryReader(new MemoryStream(packet.Data));
     RequestId = br.ReadUInt16();
     GameToken = br.ReadUInt16();
     Unknown = br.ReadUInt16();
     Result = br.ReadUInt32();
 }
 public CreateQueueIn(RealmServerPacket packet)
 {
     BinaryReader br = new BinaryReader(new MemoryStream(packet.Data));
     Position = br.ReadUInt32();
 }
Example #20
0
        /// <summary>
        /// Handles the CharLogonIn packet. This packet is sent in response to a CharLogonOut
        /// packet. If this packet status is successful, we respond by requesting to create a game.
        /// </summary>
        /// <remarks>
        /// Requesting to create a game that already exists is correct because we're told if the
        /// game already exists or has been created successfully when the server responds with a
        /// CreateGameIn packet. From there we just query and join it.
        /// </remarks>
        /// <param name="packet">The packet.</param>
        private void OnCharLogon(RealmServerPacket packet)
        {
            CharLogonIn fromServer = new CharLogonIn(packet);
            LogServer(fromServer);

            if (!fromServer.IsSuccessful())
            {
                Fail(FailureArgs.FailureTypes.FailedToLoginToChat, fromServer.ToString());
                return;
            }

            CreateGameOut toServer = new CreateGameOut(settings.GameName, settings.GamePass, settings.GameDescription, settings.GameDifficulty, 1);
            SendPacket(RealmServerPacketType.CREATEGAME, toServer.GetBytes());
        }
Example #21
0
        /// <summary>
        /// Handles the CharList2In packet. This packet contains a list of all the characters on the
        /// account. We respond by sending a CharLogonOut packet containing the name of the character
        /// to logon as.
        /// </summary>
        /// <param name="packet">The packet.</param>
        private void OnCharList2(RealmServerPacket packet)
        {
            CharList2In fromServer = new CharList2In(packet);
            LogServer(fromServer);

            if (!fromServer.CharacterExists(characterName))
            {
                Fail(FailureArgs.FailureTypes.CharacterNotFound, "Character not found");
                return;
            }

            CharLogonOut toServer = new CharLogonOut(characterName);
            SendPacket(RealmServerPacketType.CHARLOGON, toServer.GetBytes());
        }
Example #22
0
        /// <summary>
        /// Handles the CreateGameIn packet. This packet is sent in response to our CreateGameOut
        /// request. If successful, we will request the game info.
        /// </summary>
        /// <param name="packet">The packet.</param>
        private void OnCreateGame(RealmServerPacket packet)
        {
            CreateGameIn fromServer = new CreateGameIn(packet);
            LogServer(fromServer);

            if (!fromServer.IsSuccessful())
            {
                Fail(FailureArgs.FailureTypes.FailedToCreateGame, fromServer.ToString());
                return;
            }

            GameInfoOut toServer = new GameInfoOut(settings.GameName);
            SendPacket(RealmServerPacketType.GAMEINFO, toServer.GetBytes());
        }
Example #23
0
        public CreateQueueIn(RealmServerPacket packet)
        {
            BinaryReader br = new BinaryReader(new MemoryStream(packet.Data));

            Position = br.ReadUInt32();
        }
Example #24
0
 /// <summary>
 /// Handles the CreateQueueIn packet. This packet is sent when you're forced to enter a
 /// join game queue. CreateQueueIn will be resent every now and then to update your position
 /// until your request is finally accepted, which will send us a JoinGameIn packet.
 /// </summary>
 /// <param name="packet">The packet.</param>
 private void OnCreateQueue(RealmServerPacket packet)
 {
     CreateQueueIn fromServer = new CreateQueueIn(packet);
     LogServer(fromServer);
 }
Example #25
0
        public CharLogonIn(RealmServerPacket packet)
        {
            BinaryReader br = new BinaryReader(new MemoryStream(packet.Data));

            Result = br.ReadUInt32();
        }
Example #26
0
        /// <summary>
        /// Handles the GameInfoIn packet.
        /// </summary>
        /// <param name="packet">The packet.</param>
        private void OnGameInfo(RealmServerPacket packet)
        {
            GameInfoIn fromServer = new GameInfoIn(packet);
            LogServer(fromServer);

            playerCount = fromServer.PlayerCount;
            maxPlayers = fromServer.MaximumPlayers;
            playerNames = new List<string>(fromServer.CharacterNames);
            playerNames.RemoveAll(n => String.IsNullOrEmpty(n));

            JoinGameOut toServer = new JoinGameOut(settings.GameName, settings.GamePass);
            SendPacket(RealmServerPacketType.JOINGAME, toServer.GetBytes());
        }
Example #27
0
        /// <summary>
        /// Handles the StartupIn packet. This packet is sent in response to our StartupOut packet when
        /// we initially connected to the Realm Server. If successful, we request a list of characters
        /// on the account.
        /// </summary>
        /// <param name="packet">The packet.</param>
        private void OnStartup(RealmServerPacket packet)
        {
            StartupIn fromServer = new StartupIn(packet);
            LogServer(fromServer);

            if (!fromServer.IsSuccessful())
            {
                Fail(FailureArgs.FailureTypes.ServerDeniedConnection, fromServer.ToString());
                return;
            }

            CharList2Out toServer = new CharList2Out(8);
            SendPacket(RealmServerPacketType.CHARLIST2, toServer.GetBytes());
        }
Example #28
0
        /// <summary>
        /// Handles the JoinGameIn packet. This packet is sent in response to our request to join
        /// a game. If successful, we fire an event to notify the driver to start the game server.
        /// </summary>
        /// <param name="packet">The packet.</param>
        private void OnJoinGame(RealmServerPacket packet)
        {
            JoinGameIn fromServer = new JoinGameIn(packet);
            LogServer(fromServer);

            if (!fromServer.IsSuccessful())
            {
                Fail(FailureArgs.FailureTypes.FailedToJoinGame, fromServer.ToString());
                return;
            }

            GameServerArgs args = new GameServerArgs();
            args.Address = fromServer.GameServerIp.ToString();
            args.Port = 4000;
            args.GameHash = fromServer.GameHash;
            args.GameToken = fromServer.GameToken;
            args.CharacterClass = (byte)CharacterClassType.Barbarian;
            args.PlayerCount = playerCount;
            args.MaxPlayers = maxPlayers;
            args.PlayerNames = playerNames;

            // Pad the character name to 16 bytes. This is required by the game server.
            byte[] charNameBytes = ASCIIEncoding.ASCII.GetBytes(characterName);
            Array.Resize(ref charNameBytes, 16);
            args.CharacterName = (byte[])charNameBytes.Clone();

            ReadyToConnectToGameServer(this, args);
        }