コード例 #1
0
        /// <summary>
        /// Checks whether the client is allowed to login and -if so- logs it in
        /// </summary>
        /// <remarks>Executed in IO-Context.</remarks>
        /// <param name="client"></param>
        /// <param name="charLowId"></param>
        private static void LoginCharacter(IRealmClient client, uint charLowId)
        {
            RealmAccount account = client.Account;

            if (account == null)
            {
                return;
            }
            CharacterRecord record = client.Account.GetCharacterRecord(charLowId);

            if (record == null)
            {
                LoginHandler.log.Error(string.Format(WCell_RealmServer.CharacterNotFound, (object)charLowId,
                                                     (object)account.Name));
                LoginHandler.SendCharacterLoginFail((IPacketReceiver)client, LoginErrorCode.CHAR_LOGIN_NO_CHARACTER);
            }
            else if (record.CharacterFlags.HasAnyFlag(CharEnumFlags.NeedsRename | CharEnumFlags.LockedForBilling))
            {
                LoginHandler.SendCharacterLoginFail((IPacketReceiver)client, LoginErrorCode.AUTH_BILLING_EXPIRED);
            }
            else
            {
                if (client.ActiveCharacter != null)
                {
                    return;
                }
                Character character = (Character)null;
                try
                {
                    Func <IRealmClient, CharacterRecord, CharacterRecord> beforeLogin = LoginHandler.BeforeLogin;
                    if (beforeLogin != null)
                    {
                        record = beforeLogin(client, record);
                        if (record == null)
                        {
                            throw new ArgumentNullException("record", "BeforeLogin returned null");
                        }
                    }

                    character = record.CreateCharacter();
                    character.Create(account, record, client);
                    character.LoadAndLogin();
                    string str = string.Format("Welcome to " + WCell.RealmServer.RealmServer.FormattedTitle);
                    MiscHandler.SendMotd((IPacketReceiver)client, str);
                }
                catch (Exception ex)
                {
                    LogUtil.ErrorException(ex, "Failed to load Character from Record: " + (object)record,
                                           new object[0]);
                    if (character == null)
                    {
                        return;
                    }
                    character.Dispose();
                    client.Disconnect(false);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Checks whether the client is allowed to login and -if so- logs it in
        /// </summary>
        /// <remarks>Executed in IO-Context.</remarks>
        /// <param name="client"></param>
        /// <param name="charLowId"></param>
        private static void LoginCharacter(IRealmClient client, uint charLowId)
        {
            var acc = client.Account;

            if (acc == null)
            {
                return;
            }

            var record = client.Account.GetCharacterRecord(charLowId);

            if (record == null)
            {
                log.Error(String.Format(WCell_RealmServer.CharacterNotFound, charLowId, acc.Name));

                SendCharacterLoginFail(client, LoginErrorCode.CHAR_LOGIN_NO_CHARACTER);
            }
            else if (record.CharacterFlags.HasAnyFlag(CharEnumFlags.NeedsRename | CharEnumFlags.LockedForBilling))
            {
                // TODO: Check in Char Enum?
                SendCharacterLoginFail(client, LoginErrorCode.AUTH_BILLING_EXPIRED);
            }
            else if (client.ActiveCharacter == null)
            {
                Character chr = null;
                try
                {
                    var evt = BeforeLogin;
                    if (evt != null)
                    {
                        record = evt(client, record);
                        if (record == null)
                        {
                            throw new ArgumentNullException("record", "BeforeLogin returned null");
                        }
                    }
                    chr = record.CreateCharacter();
                    chr.Create(acc, record, client);
                    chr.LoadAndLogin();

                    var message = String.Format("Welcome to " + RealmServer.FormattedTitle);

                    //chr.SendSystemMessage(message);
                    MiscHandler.SendMotd(client, message);
                }
                catch (Exception ex)
                {
                    LogUtil.ErrorException(ex, "Failed to load Character from Record: " + record);
                    if (chr != null)
                    {
                        // Force client to relog
                        chr.Dispose();
                        client.Disconnect();
                    }
                }
            }
        }
コード例 #3
0
 /// <summary>Handles an incoming ping request.</summary>
 /// <param name="client">the Session the incoming packet belongs to</param>
 /// <param name="packet">the full packet</param>
 public static void PingRequest(IRealmClient client, RealmPacketIn packet)
 {
     MiscHandler.SendPingReply((IPacketReceiver)client, packet.ReadUInt32());
     client.Latency = packet.ReadInt32();
 }
コード例 #4
0
        public static void HandleRealmStateRequest(IRealmClient client, RealmPacketIn packet)
        {
            uint realmNo = packet.ReadUInt32();

            MiscHandler.SendRealmStateResponse((IPacketReceiver)client, realmNo);
        }