[Question] The purpose of this is...?

04/06/2011 02:42 nTL3fTy#16
Quote:
Originally Posted by Spirited View Post
K, just making sure it isn't something with a meaning that I'm not aware of.

EDIT: You have a lot of things like that in your code Impulse... o.o
Code:
string IP = wr._socket.RemoteEndPoint.[COLOR="Red"]ToString()[/COLOR].Split(':')[0].[COLOR="Red"]ToString()[/COLOR];
Code:
string IP = ((IPEndPoint) wr._socket.RemoteEndPoint).Address.ToString();
04/06/2011 05:33 Spirited42#17
Quote:
Originally Posted by _tao4229_ View Post
int[] i = new int[0];

Non null array with 0 length.
You're right. There is a possibility that, but it doesn't matter what key1 is because it's (forgive my terminology...) reassigned 3 lines below that.

Code:
public static void Initialization()
        {
            if (_key1 != null)
                if (_key1.Length != 0)
                    return;
            byte i_key1 = 0x9D, i_key2 = 0x62;
            _key1 = new byte[0x100];
            _key2 = new byte[0x100];
            for (int i = 0; i < 0x100; i++)
            {
                _key1[i] = i_key1;
                _key2[i] = i_key2;
                i_key1 = (byte)((0x0F + (byte)(i_key1 * 0xFA)) * i_key1 + 0x13);
                i_key2 = (byte)((0x79 - (byte)(i_key2 * 0x5C)) * i_key2 + 0x6D);
            }
        }
So... it should really look like this:
Code:
public static void Initialization()
        {
            byte i_key1 = 0x9D, i_key2 = 0x62;
            _key1 = new byte[0x100];
            _key2 = new byte[0x100];
            for (int i = 0; i < 0x100; i++)
            {
                _key1[i] = i_key1;
                _key2[i] = i_key2;
                i_key1 = (byte)((0x0F + (byte)(i_key1 * 0xFA)) * i_key1 + 0x13);
                i_key2 = (byte)((0x79 - (byte)(i_key2 * 0x5C)) * i_key2 + 0x6D);
            }
        }
04/06/2011 09:02 -impulse-#18
Quote:
Originally Posted by _tao4229_ View Post
Under that assumption then the first if is "really useless" as well.
Nah, I don't think so, it just stops the generation of the keys so they won't be generated twice.
04/06/2011 09:11 Spirited42#19
Quote:
Originally Posted by -impulse- View Post
Nah, I don't think so, it just stops the generation of the keys so they won't be generated twice.
'm not flaming, just curious because I don't often see the full picture. If you have to invoke the void, then how could it be generated twice?
04/06/2011 09:27 Korvacs#20
Based on what you have posted fang, the check returns and doesnt re-compute the key if Key1 has a value, saves time.
04/06/2011 09:31 Spirited42#21
Quote:
Originally Posted by Korvacs View Post
Based on what you have posted fang, the check returns and doesnt re-compute the key if Key1 has a value, saves time.
But I'm confused, the key isn't assigned a value until the Initialization process. It will never hit that return unless it's spontaneously invoked ._.
04/06/2011 09:51 Korvacs#22
Quote:
Originally Posted by Spirited View Post
But I'm confused, the key isn't assigned a value until the Initialization process. It will never hit that return unless it's spontaneously invoked ._.
It depends really, personally i wouldn't want the keys to be the same for every client anyway, but you can set it up so that it uses the same keys. I assume due to that snippet that the class and keys are static and that its only defined once and then initialization is called whenever a client logs in, if thats the case then the method is efficient because it doesnt re-create the keys.
04/06/2011 09:54 -impulse-#23
Quote:
Originally Posted by Spirited View Post
But I'm confused, the key isn't assigned a value until the Initialization process. It will never hit that return unless it's spontaneously invoked ._.
Retards usually tend to test things and forget, and so we have to make sure they won't waste time with finding what's wrong...(lol).

You are right Fang, if it is not spontaneously invoked the checks won't be needed, the call should be made once at the server start up.
04/06/2011 09:56 Spirited42#24
Korvacs, you have permission to decide when to close this thread.
Thanks for the help you two. I know what I'm doing next.
04/06/2011 09:58 Korvacs#25
Quote:
Originally Posted by Spirited View Post
Korvacs, you have permission to decide when to close this thread.
Thanks for the help you two. I know what I'm doing next.
I had permission anyway, but thanks..?
04/06/2011 10:07 Spirited42#26
Quote:
Originally Posted by Korvacs View Post
I had permission anyway, but thanks..?
Yah, i guess you do... .-.
I meant you can close it unless you have purpose for this thread being left open. I'm going to sleep in a few so I probably won't check back here until tomorrow.