Exemplo n.º 1
0
        public PlayerObject(CharacterInfo info, MirConnection connection)
        {
            if (info.Player != null)
                throw new InvalidOperationException("Player.Info not Null.");

            info.Player = this;
            Connection = connection;
            Info = info;
            Account = Connection.Account;

            if (Level == 255 || Account.AdminAccount)
            {
                IsGM = true;
                SMain.Enqueue(string.Format("{0} is now a GM", Name));
            }

            if (Level == 0) NewCharacter();

            RefreshStats();

            if (HP == 0)
            {
                SetHP(MaxHP);
                SetMP(MaxMP);
                CurrentLocation = BindLocation;
                CurrentMapIndex = BindMapIndex;
            }
        }
Exemplo n.º 2
0
        public void MessageAccount(AccountInfo account, string message, ChatType type)
        {
            if (account == null) return;
            if (account.Characters == null) return;

            for (int i = 0; i < account.Characters.Count; i++)
            {
                if (account.Characters[i].Player == null) continue;
                account.Characters[i].Player.ReceiveChat(message, type);
                return;
            }
        }
Exemplo n.º 3
0
        public void SoftDisconnect(byte reason)
        {
            Stage = GameStage.Disconnected;
            TimeDisconnected = SMain.Envir.Time;

            lock (Envir.AccountLock)
            {
                if (Player != null)
                    Player.StopGame(reason);

                if (Account != null && Account.Connection == this)
                    Account.Connection = null;
            }

            Account = null;
        }
Exemplo n.º 4
0
        public void Disconnect(byte reason)
        {
            if (!Connected) return;

            Connected = false;
            Stage = GameStage.Disconnected;
            TimeDisconnected = SMain.Envir.Time;

            lock (SMain.Envir.Connections)
                SMain.Envir.Connections.Remove(this);

            lock (Envir.AccountLock)
            {
                if (Player != null)
                    Player.StopGame(reason);

                if (Account != null && Account.Connection == this)
                    Account.Connection = null;

            }

            Account = null;

            _sendList = null;
            _receiveList = null;
            _retryList = null;
            _rawData = null;

            if (_client != null) _client.Client.Dispose();
            _client = null;
        }
Exemplo n.º 5
0
        public PlayerObject(CharacterInfo info, MirConnection connection)
        {
            if (info.Player != null)
                throw new InvalidOperationException("Player.Info not Null.");

            info.Player = this;
            info.Mount = new MountInfo(this);

            Connection = connection;
            Info = info;
            Account = Connection.Account;

            Report = new Reporting(this);

            if (Account.AdminAccount)
            {
                IsGM = true;
                SMain.Enqueue(string.Format("{0} is now a GM", Name));
            }

            if (Level == 0) NewCharacter();

            if (Info.GuildIndex != -1)
            {
                MyGuild = Envir.GetGuild(Info.GuildIndex);
            }
            RefreshStats();

            if (HP == 0)
            {
                SetHP(MaxHP);
                SetMP(MaxMP);

                CurrentLocation = BindLocation;
                CurrentMapIndex = BindMapIndex;

                if (Info.PKPoints >= 200)
                {
                    Map temp = Envir.GetMapByNameAndInstance(Settings.PKTownMapName, 1);
                    Point tempLocation = new Point(Settings.PKTownPositionX, Settings.PKTownPositionY);

                    if (temp != null && temp.ValidPoint(tempLocation))
                    {
                        CurrentMapIndex = temp.Info.Index;
                        CurrentLocation = tempLocation;
                    }
                }
            }
        }
Exemplo n.º 6
0
 private void CleanUp()
 {
     Connection.Player = null;
     Info.Player = null;
     Info.Mount = null;
     Connection = null;
     Account = null;
     Info = null;
 }
Exemplo n.º 7
0
        public static void Login(C.Login P, MirConnection Con)
        {
            if (!Settings.AllowLogin)
            {
                Con.QueuePacket(new S.Login {
                    Result = 1
                });
                return;
            }

            if (!AccountIDReg.IsMatch(P.AccountID))
            {
                Con.QueuePacket(new S.Login {
                    Result = 2
                });
                return;
            }

            if (!PasswordReg.IsMatch(P.Password))
            {
                Con.QueuePacket(new S.Login {
                    Result = 3
                });
                return;
            }


            AccountInfo TempAccount = GetAccount(P.AccountID);

            if (TempAccount == null)
            {
                Con.QueuePacket(new S.Login {
                    Result = 4
                });
                return;
            }

            if (TempAccount.Banned)
            {
                if (TempAccount.ExpiryDate > DateTime.Now)
                {
                    Con.QueuePacket(new S.LoginBanned {
                        Reason = TempAccount.BanReason, ExpiryDate = TempAccount.ExpiryDate
                    });
                    return;
                }
                else
                {
                    TempAccount.Banned     = false;
                    TempAccount.BanReason  = string.Empty;
                    TempAccount.ExpiryDate = DateTime.MinValue;
                }
            }

            if (string.Compare(TempAccount.Password, P.Password, false) != 0)
            {
                Con.QueuePacket(new S.Login {
                    Result = 5
                });
                return;
            }

            Network.Disconnect(TempAccount, 1);

            Con.QueuePacket(new S.LoginSuccess {
                CharacterList = TempAccount.GetSelectInfo()
            });

            Con.Account = TempAccount;
            Con.Stage   = GameStage.Select;
        }
Exemplo n.º 8
0
        public static void ChangePassword(C.ChangePassword P, MirConnection Con)
        {
            if (!Settings.AllowChangePassword)
            {
                Con.QueuePacket(new S.ChangePassword {
                    Result = 1
                });
                return;
            }

            if (!AccountIDReg.IsMatch(P.AccountID))
            {
                Con.QueuePacket(new S.ChangePassword {
                    Result = 2
                });
                return;
            }

            if (!PasswordReg.IsMatch(P.CurrentPassword))
            {
                Con.QueuePacket(new S.ChangePassword {
                    Result = 3
                });
                return;
            }

            if (!PasswordReg.IsMatch(P.NewPassword))
            {
                Con.QueuePacket(new S.ChangePassword {
                    Result = 4
                });
                return;
            }


            AccountInfo TempAccount = GetAccount(P.AccountID);

            if (TempAccount == null)
            {
                Con.QueuePacket(new S.ChangePassword {
                    Result = 5
                });
                return;
            }

            if (TempAccount.Banned)
            {
                if (TempAccount.ExpiryDate > Main.Now)
                {
                    Con.QueuePacket(new S.ChangePasswordBanned {
                        Reason = TempAccount.BanReason, ExpiryDate = TempAccount.ExpiryDate
                    });
                    return;
                }
                else
                {
                    TempAccount.Banned     = false;
                    TempAccount.BanReason  = string.Empty;
                    TempAccount.ExpiryDate = DateTime.MinValue;
                }
            }

            if (string.Compare(TempAccount.Password, P.CurrentPassword, false) != 0)
            {
                Con.QueuePacket(new S.ChangePassword {
                    Result = 6
                });
                return;
            }

            TempAccount.Password = P.NewPassword;
            Con.QueuePacket(new S.ChangePassword {
                Result = 7
            });
        }