コード例 #1
0
        /// <inheritdoc/>
        public void HandlePacket(Player player, Span <byte> packet)
        {
            // todo: determine password length by looking at the packet length
            var usernameBytes = packet.Slice(4, 10);
            var passwordBytes = packet.Slice(14, player.GameContext.Configuration.MaximumPasswordLength);

            this.decryptor.Decrypt(usernameBytes);
            this.decryptor.Decrypt(passwordBytes);
            var username = usernameBytes.ExtractString(0, 10, Encoding.UTF8);
            var password = passwordBytes.ExtractString(0, player.GameContext.Configuration.MaximumPasswordLength, Encoding.UTF8);

            int startTickCountIndex = 14 + player.GameContext.Configuration.MaximumPasswordLength;

            ////Player.StartTickCount = Utils.MakeDword(buffer[sti], buffer[sti + 1], buffer[sti + 2], buffer[sti + 3]);
            ////Player.StartTick = DateTime.Now;
            this.loginAction.Login(player, username, password);
            var versionStartIndex = startTickCountIndex + 4;
            var version           = packet.Slice(versionStartIndex, 5).ToArray();

            if (player is RemotePlayer remotePlayer)
            {
                // Set Version in RemotePlayer so that the right plugins will be selected
                var clientVersion = ClientVersionResolver.Resolve(version);
                remotePlayer.ClientVersion = clientVersion;
            }
        }
コード例 #2
0
        /// <inheritdoc/>
        public void ShowLoginWindow()
        {
            using var writer = this.player.Connection.StartSafeWrite(GameServerEntered.HeaderType, GameServerEntered.Length);
            var message = new GameServerEntered(writer.Span)
            {
                PlayerId = ViewExtensions.ConstantPlayerId,
            };

            ClientVersionResolver.Resolve(this.player.ClientVersion).CopyTo(message.Version);
            writer.Commit();
        }
コード例 #3
0
 /// <inheritdoc/>
 public void ShowLoginWindow()
 {
     using (var writer = this.player.Connection.StartSafeWrite(0xC1, 0x0C))
     {
         var message = writer.Span;
         message[2] = 0xF1;
         message[3] = 0x00;
         message[4] = 0x01; // Success
         message[5] = ViewExtensions.ConstantPlayerId.GetHighByte();
         message[6] = ViewExtensions.ConstantPlayerId.GetLowByte();
         ClientVersionResolver.Resolve(this.player.ClientVersion).CopyTo(message.Slice(7, 5));
         writer.Commit();
     }
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: psydox/OpenMU
        private void LoadGameClientDefinitions(IContext persistenceContext)
        {
            var versions = persistenceContext.Get <GameClientDefinition>().ToList();

            foreach (var gameClientDefinition in versions)
            {
                ClientVersionResolver.Register(
                    gameClientDefinition.Version,
                    new ClientVersion(gameClientDefinition.Season, gameClientDefinition.Episode, gameClientDefinition.Language));
            }

            if (versions.FirstOrDefault() is { } firstVersion)
            {
                ClientVersionResolver.DefaultVersion = ClientVersionResolver.Resolve(firstVersion.Version);
            }
        }
コード例 #5
0
        private void HandleLogin(Player player, Span <byte> userNameSpan, Span <byte> passwordSpan, uint tickCount, Span <byte> version)
        {
            this.decryptor.Decrypt(userNameSpan);
            this.decryptor.Decrypt(passwordSpan);
            var username = userNameSpan.ExtractString(0, 10, Encoding.UTF8);
            var password = passwordSpan.ExtractString(0, 20, Encoding.UTF8);

            if (player.Logger.IsEnabled(LogLevel.Debug))
            {
                player.Logger.LogDebug($"User tries to log in. username:{username}, version:{version.AsString()}, tickCount:{tickCount} ");
            }

            this.loginAction.Login(player, username, password);
            if (player is RemotePlayer remotePlayer)
            {
                // Set Version in RemotePlayer so that the right plugins will be selected
                var clientVersion = ClientVersionResolver.Resolve(version);
                remotePlayer.ClientVersion = clientVersion;
            }
        }