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

04/05/2011 01:00 Spirited42#1
Code:
            if (_cryptKey1 != null)
            {
                [COLOR="Red"]if (_cryptKey1.Length != 0)[/COLOR]
                    return;
            }
What's the purpose of this line in red?
If the key isn't null... then the length cannot be 0... so why does it check that?

Sincerely,
Spirited
04/05/2011 01:10 Korvacs#2
Null simple means undefined in the majority of cases, Length indicates the number of values within it, or if its a string, the string is empty, but not null.

Very different things.
04/05/2011 01:11 Spirited42#3
Quote:
Originally Posted by Korvacs View Post
Null simple means undefined in the majority of cases, Length indicates the number of values within it, or if its a string, the string is empty, but not null.

Very different things.
I thought that you couldn't put values into an undefined variable though.
04/05/2011 01:12 Korvacs#4
Quote:
Originally Posted by Spirited View Post
I thought that you couldn't put values into an undefined variable though.
Correct.........

Sorry just noticed the not equal, i believe this may have been an attempt to compensate for bad threading in whichever source your looking at.

Actually that makes even less sense, whats this from? If the key isnt null, then it has been defined, but that doesnt mean it has values within it.
04/05/2011 01:50 Spirited42#5
Quote:
Originally Posted by Korvacs View Post
Correct.........

Sorry just noticed the not equal, i believe this may have been an attempt to compensate for bad threading in whichever source your looking at.

Actually that makes even less sense, whats this from? If the key isnt null, then it has been defined, but that doesnt mean it has values within it.
It's from Impulse's Public source. I'm using it as a very rough guide for my Cryptography.
04/05/2011 02:24 -impulse-#6
It's actually really easy.

That stops the function PrepareAuthCryptography() from re-generating the keys.

if (_cryptKey1 != null)
{
if (_cryptKey1.Length != 0)
return;
}

The second 'if' can be removed, it will be exactly the same.
04/05/2011 02:26 Spirited42#7
Quote:
Originally Posted by -impulse- View Post
It's actually really easy.

That stops the function PrepareAuthCryptography() from re-generating the keys.

if (_cryptKey1 != null)
{
if (_cryptKey1.Length != 0)
return;
}

The second 'if' can be removed, it will be exactly the same.
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];
04/05/2011 09:24 Korvacs#8
You should use the cryptographer from my cuosp project, its very good.
04/05/2011 10:50 -impulse-#9
Quote:
Originally Posted by Spirited View Post
Code:
string IP = wr._socket.RemoteEndPoint.[COLOR="Red"]ToString()[/COLOR].Split(':')[0].[COLOR="Red"]ToString()[/COLOR];
socket.RemoteEndPoint is not a string and so you have to use ToString to parse it. The second ToString, again, can be removed lol.
04/05/2011 12:41 Spirited42#10
Quote:
Originally Posted by Korvacs View Post
You should use the cryptographer from my cuosp project, its very good.
Weird. I never got the chance to look at yours. It looks just like mine (Account Cryp). Mine works fine though. I haven't had an error since I completed it so I've kinda just stuck with it and just rewrote it using other influences (such as Impulse's crypt).

Quote:
Originally Posted by -impulse- View Post
socket.RemoteEndPoint is not a string and so you have to use ToString to parse it. The second ToString, again, can be removed lol.
Thanks. lol, but you don't have to explain things like that to me. I learned that in my first month of coding... ._.
04/05/2011 12:52 -impulse-#11
Quote:
Originally Posted by Spirited View Post
Weird. I never got the chance to look at yours. It looks just like mine (Account Cryp). Mine works fine though. I haven't had an error since I completed it so I've kinda just stuck with it and just rewrote it using other influences (such as Impulse's crypt).



Thanks. lol, but you don't have to explain things like that to me. I learned that in my first month of coding... ._.
You know, you're not the only one to read whatever anyone posts, there are usually hundreds...and not everyone knows.
04/05/2011 19:18 Spirited42#12
Quote:
Originally Posted by -impulse- View Post
You know, you're not the only one to read whatever anyone posts, there are usually hundreds...and not everyone knows.
Sorry, I didn't think about that.
04/05/2011 23:13 _tao4229_#13
int[] i = new int[0];

Non null array with 0 length.
04/05/2011 23:34 -impulse-#14
Quote:
Originally Posted by _tao4229_ View Post
int[] i = new int[0];

Non null array with 0 length.
I know, I thought of that too, but the array is initialized with the length 0x100 so the second 'if' is really useless.
04/06/2011 01:26 _tao4229_#15
Quote:
Originally Posted by -impulse- View Post
I know, I thought of that too, but the array is initialized with the length 0x100 so the second 'if' is really useless.
Under that assumption then the first if is "really useless" as well.