[last question] ArguementOutOfBoundsException

10/08/2011 20:33 killersub#1
Okay this is my last question, I keep getting tha error in my base source from impulse.

Here's the error:
Code:
index was out of range. Must be non_negative and less than the size of the collection
Here:

Code:
if (kernel.gamepool.containskey(this.entity.UID))
At here aswell:

Code:
iny Len = BitConverter.ToInt32(arg1, position); position += 4;
Here is the entity UID part:

Code:
public uint UID { get { return _uid; } set { _uid = value; WriteUInt32(value, 8, SpawnPacket); } }
I would like a little more explanation on this error and tips on how to get rid of it.

Regards,
Killersub
10/09/2011 02:03 BaussHacker#2
Either you were trying to access an index that was bigger than the length.

Ex.
Code:
int[] array = new int[] { 0, 1, 2, 3, 4, 5 };
int valid_value = array[6];//The value will be 5, because arrays are 0 indexed.
int invalid_value = array[7];//There is no 7th index in the array.
Or you were trying to enter a negative index.

Code:
int[] array = new int[] { 0, 1, 2, 3 };
int value = arry[-1];//the lowest index in an array is 0
10/09/2011 02:57 killersub#3
Quote:
Originally Posted by BaussHacker View Post
Either you were trying to access an index that was bigger than the length.

Ex.
Code:
int[] array = new int[] { 0, 1, 2, 3, 4, 5 };
int valid_value = array[6];//The value will be 5, because arrays are 0 indexed.
int invalid_value = array[7];//There is no 7th index in the array.
Or you were trying to enter a negative index.

Code:
int[] array = new int[] { 0, 1, 2, 3 };
int value = arry[-1];//the lowest index in an array is 0
So what are u implying? I tried using my SafeReturn method but no luck on that either.

None of my indexes (that I've checked) are negative/out of bounds that I know of.
10/09/2011 12:23 BaussHacker#4
Could be this:
iny Len = BitConverter.ToInt32(arg1, position); position += 4;

s position will be the psoition within the array (arg1).
10/09/2011 15:07 killersub#5
Quote:
Originally Posted by BaussHacker View Post
Could be this:
int Len = BitConverter.ToInt32(arg1, position); position += 4;

s position will be the psoition within the array (arg1).
so should I change the coversion type? The 'arg1' is in 'byte[]' form.
And the position is
Code:
ushort position = 7;
Just asking before I start changing shit around.
10/09/2011 15:49 BaussHacker#6
Just make sure the position does not get bigger than the arraysize or that it's a valid packet.
10/09/2011 15:59 killersub#7
Quote:
Originally Posted by BaussHacker View Post
Just make sure the position does not get bigger than the arraysize or that it's a valid packet.
Code:
byte[] pubkey = new byte[Len];
Code:
for (int x = 0; x < Len; x++) pubkey[x] = arg1[x + position];
Are all associated with that code.

Would that be it?
10/09/2011 23:19 _DreadNought_#8
Your using impulse's source?
10/09/2011 23:24 killersub#9
Quote:
Originally Posted by _DreadNought_ View Post
Your using impulse's source?
Correct my friend.