[Help] GameClient.cs and ALT Codes

04/11/2010 21:27 HardNotTo#1
I am just wondering if I am correct in thinking that if I add the ALT codes to the following code, that people would not be able to try make characters with the ALT codes

Code:
public bool ValidName(string Name)
        {
            if (Name.IndexOfAny(new char[14] {[COLOR="Red"] ' ', '[', ']', '#', '*', '\\', '/', '<', '>', ':', '"', '|', '?', '='[/COLOR]}) > -1) //this is all windows folder invalids characters
            {
                return false;
            }
            else
            {
                return true;
            }
        }
If so then wouldn't it be simpler to do something like this:

Code:
public bool ValidName(string Name)
        {
            if (Name.IndexOfAny(new char[14] {'insert english alphabet'}) > -1) //this is all windows folder invalids characters
            {
                return true;
            }
            else
            {
                return false;
            }
        }
04/11/2010 21:29 AndreaCo#2
yes
04/11/2010 22:25 -impulse-#3
Code:
        public bool ValidName(string name)
        {
            foreach (char ch in name)
            {
                byte c = Convert.ToByte(ch);
                if (!
                    ((c >= 48 && c <= 57) || 
                    (c >= 65 && c <= 90) || 
                    (c >= 97 && c <= 122))
                    )
                    return false;
            }
            return true;
        }
04/12/2010 18:02 HardNotTo#4
Quote:
Originally Posted by -impulse- View Post
Code:
        public bool ValidName(string name)
        {
            foreach (char ch in name)
            {
                byte c = Convert.ToByte(ch);
                if (!
                    [COLOR="Red"]((c >= 48 && c <= 57) || 
                    (c >= 65 && c <= 90) || 
                    (c >= 97 && c <= 122))[/COLOR]
                    )
                    return false;
            }
            return true;
        }
Ok, there is no doubt in my mind that something you make is going to work so I will use it, but one question, as a learning experience, I know what the code is doing, but on the red that i marked, is that the range numbers that define the alt codes or something? Im thinking those might be the numbers of the keys themselves that are on the keyboard. just asking for future reference.
oh and thanks for the help
04/12/2010 18:44 ~Yuki~#5
if (!((c >= 48 && c <= 57) || (c >= 65 && c <= 90) || (c >= 97 && c <= 122)))
{
//contains a invalid char so returns FALSE

// 48, 57, 65 ,90 , 97 ,122 Are ASCII Codes for the Symboles.
}
04/12/2010 21:53 -impulse-#6
Quote:
Originally Posted by ~Yuki~ View Post
if (!((c >= 48 && c <= 57) || (c >= 65 && c <= 90) || (c >= 97 && c <= 122)))
{
//contains a invalid char so returns FALSE

// 48, 57, 65 ,90 , 97 ,122 Are ASCII Codes for the Symboles.
}

ALT + 48 = 0
ALT + 57 = 9

Characters between 48 and 57 are numbers

Alt + 65 = A
Alt + 90 = Z

Characters between 65 and 90 are big characters

Alt + 97 = a
Alt + 122 = z

Characters between 97 and 122 are small characters
04/13/2010 14:20 ~Yuki~#7
:O blame me!