Exemple #1
0
        /// <summary>
        /// Read login
        /// </summary>
        /// <param name="recvLogin">
        /// Username sent by client
        /// </param>
        public void GetLoginFlags(string recvLogin)
        {
            DBLoginData login = LoginDataDao.GetByUsername(recvLogin);

            if (login != null)
            {
                this.flagsL = login.Flags;
            }
        }
Exemple #2
0
        /// <summary>
        /// </summary>
        /// <param name="recvLogin">
        /// </param>
        public void GetLoginName(string recvLogin)
        {
            this.loginN = null;
            DBLoginData temp = LoginDataDao.GetByUsername(recvLogin);

            if (temp != null)
            {
                this.loginN = LoginDataDao.GetByUsername(recvLogin).Username;
            }
        }
Exemple #3
0
        /// <summary>
        /// </summary>
        /// <param name="RecvLogin">
        /// </param>
        /// <returns>
        /// </returns>
        private string GetLoginPassword(string RecvLogin)
        {
            DBLoginData loginPassword = LoginDataDao.GetByUsername(RecvLogin);

            if (loginPassword != null)
            {
                return(loginPassword.Password);
            }

            LogUtil.Debug(string.Format("No entry for account username '{0}' found", RecvLogin));
            return(string.Empty);
        }
Exemple #4
0
        // TODO: Figure out how to get ChatServe to gather some information about Users?

        // public TwitterUser TwitterUser
        // {
        // get;
        // private set;
        // }

        #region Public Methods and Operators

        /// <summary>
        /// </summary>
        /// <param name="username">
        /// </param>
        /// <param name="password">
        /// </param>
        /// <returns>
        /// </returns>
        public bool LogIn(string username, string password)
        {
            try
            {
                string dUser = LoginDataDao.GetByUsername(username).Username;

                if (dUser != username)
                {
                    return(false);
                }

                this.IsAuthenticated = true;

                return(true);
            }
            catch (SqlException)
            {
                throw;
            }
        }
        /// <summary>
        /// </summary>
        /// <param name="sender">
        /// </param>
        /// <param name="message">
        /// </param>
        public void Handle(object sender, Message message)
        {
            var client = (Client)sender;
            var userCredentialsMessage = (UserCredentialsMessage)message.Body;
            var checkLogin             = new CheckLogin();

            if (checkLogin.IsLoginAllowed(client, userCredentialsMessage.UserName) == false)
            {
                Colouring.Push(ConsoleColor.Green);
                Console.WriteLine(
                    "Client '" + client.AccountName
                    + "' banned, not a valid username, or sent a malformed Authentication Packet");
                Colouring.Pop();

                client.Send(0x00001F83, new LoginErrorMessage {
                    Error = LoginError.InvalidUserNamePassword
                });
                client.Server.DisconnectClient(client);
                return;
            }

            if (checkLogin.IsLoginCorrect(client, userCredentialsMessage.Credentials) == false)
            {
                Colouring.Push(ConsoleColor.Green);
                Console.WriteLine("Client '" + client.AccountName + "' failed Authentication.");

                client.Send(0x00001F83, new LoginErrorMessage {
                    Error = LoginError.InvalidUserNamePassword
                });
                client.Server.DisconnectClient(client);
                Colouring.Pop();

                return;
            }

            int expansions        = 0;
            int allowedCharacters = 0;

            /* This checks your expansions and
             * number of characters allowed (num. of chars doesn't work)*/
            string sqlQuery = "SELECT `Expansions`,`Allowed_Characters` FROM `login` WHERE Username = '******'";
            DBLoginData loginData = LoginDataDao.GetByUsername(client.AccountName);

            expansions        = loginData.Expansions;
            allowedCharacters = loginData.Allowed_Characters;

            IEnumerable <LoginCharacterInfo> characters = from c in CharacterList.LoadCharacters(client.AccountName)
                                                          select
                                                          new LoginCharacterInfo
            {
                Unknown1 = 4,
                Id       = c.Id,
                PlayfieldProxyVersion = 0x61,
                PlayfieldId           =
                    new Identity {
                    Type = IdentityType.Playfield, Instance = c.Playfield
                },
                PlayfieldAttribute   = 1,
                ExitDoor             = 0,
                ExitDoorId           = Identity.None,
                Unknown2             = 1,
                CharacterInfoVersion = 5,
                CharacterId          = c.Id,
                Name       = c.Name,
                Breed      = (Breed)c.Breed,
                Gender     = (Gender)c.Gender,
                Profession = (Profession)c.Profession,
                Level      = c.Level,
                AreaName   = "area unknown",
                Status     = CharacterStatus.Active
            };
            var characterListMessage = new CharacterListMessage
            {
                Characters        = characters.ToArray(),
                AllowedCharacters = allowedCharacters,
                Expansions        = expansions
            };

            client.Send(0x0000615B, characterListMessage);
        }
Exemple #6
0
        /// <summary>
        /// </summary>
        /// <returns>
        /// </returns>
        private int CreateNewChar()
        {
            int charID = 0;

            switch (this.Breed)
            {
            case 0x1:     /* solitus */
                this.Abis = new[] { 6, 6, 6, 6, 6, 6 };
                break;

            case 0x2:     /* opifex */
                this.Abis = new[] { 3, 3, 10, 6, 6, 15 };
                break;

            case 0x3:     /* nanomage */
                this.Abis = new[] { 3, 10, 6, 15, 3, 3 };
                break;

            case 0x4:     /* atrox */
                this.Abis = new[] { 15, 3, 3, 3, 10, 6 };
                break;

            default:
                Console.WriteLine("unknown breed: ", this.Breed);
                break;
            }

            /*
             * Note, all default values are not specified here as defaults are handled
             * in the CharacterStats Class for us automatically. Also minimises SQL
             * usage for default stats that are never changed from their default value
             *           ~NV
             */
            // Delete orphaned stats for charID
            StatDao.DeleteStats(50000, charID);
            try
            {
                CharacterDao.AddCharacter(
                    new DBCharacter
                {
                    FirstName = string.Empty,
                    LastName  = string.Empty,
                    Name      = this.Name,
                    Username  = this.AccountName,
                });
            }
            catch (Exception e)
            {
                LogUtil.ErrorException(e);
                return(0);
            }

            try
            {
                /* select new char id */
                charID = CharacterDao.GetByCharName(this.Name).Id;
            }
            catch (Exception e)
            {
                LogUtil.ErrorException(e);
                return(0);
            }

            List <DBStats> stats = new List <DBStats>();

            // Transmit GM level into stats table
            stats.Add(
                new DBStats
            {
                type      = 50000,
                instance  = charID,
                statid    = 215,
                statvalue = LoginDataDao.GetByUsername(this.AccountName).GM
            });

            // Flags
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 0, statvalue = 20
            });

            // Level
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 54, statvalue = 1
            });

            // SEXXX
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 59, statvalue = this.Gender
            });

            // Headmesh
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 64, statvalue = this.HeadMesh
            });

            // MonsterScale
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 360, statvalue = this.MonsterScale
            });

            // Visual Sex (even better ^^)
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 369, statvalue = this.Gender
            });

            // Breed
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 4, statvalue = this.Breed
            });

            // Visual Breed
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 367, statvalue = this.Breed
            });

            // Profession / 60
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 60, statvalue = this.Profession
            });

            // VisualProfession / 368
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 368, statvalue = this.Profession
            });

            // Fatness / 47
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 47, statvalue = this.Fatness
            });

            // Strength / 16
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 16, statvalue = this.Abis[0]
            });

            // Psychic / 21
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 21, statvalue = this.Abis[1]
            });

            // Sense / 20
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 20, statvalue = this.Abis[2]
            });

            // Intelligence / 19
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 19, statvalue = this.Abis[3]
            });

            // Stamina / 18
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 18, statvalue = this.Abis[4]
            });

            // Agility / 17
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 17, statvalue = this.Abis[5]
            });

            // Set HP and NP auf 1
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 1, statvalue = 1
            });
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 214, statvalue = 1
            });

            stats.Add(
                new DBStats
            {
                type      = 50000,
                instance  = charID,
                statid    = 389,
                statvalue = LoginDataDao.GetByUsername(this.AccountName).Expansions
            });

            StatDao.BulkReplace(stats);

            return(charID);
        }
 /// <summary>
 /// Returns the Password hash
 /// </summary>
 /// <param name="recvLogin">
 /// Username received from the client
 /// </param>
 public void GetLoginPassword(string recvLogin)
 {
     this.passwdL = LoginDataDao.GetByUsername(recvLogin).Username;
 }