[Problem] Error with warehouse

09/17/2010 17:33 Korvacs#16
Quote:
Originally Posted by salem rey View Post
i did it but still i got error i see this in my source

In my packet.cs

public static COPacket SendWarehouse(Game.Character C, ushort NPC)
{
ArrayList Warehouse = new ArrayList();
switch (NPC)
{
case 8: { Warehouse = C.Warehouses.TCWarehouse; break; }
case 10012: { Warehouse = C.Warehouses.PCWarehouse; break; }
case 10028: { Warehouse = C.Warehouses.ACWarehouse; break; }
case 10011: { Warehouse = C.Warehouses.DCWarehouse; break; }
case 10027: { Warehouse = C.Warehouses.BIWarehouse; break; }
case 44: { Warehouse = C.Warehouses.MAWarehouse; break; }
case 4101: { Warehouse = C.Warehouses.SCWarehouse; break; }
default: return new COPacket(new byte[0]);
}


In my Warehouse.cs

ArrayList Warehouse = null;
switch (NPC)
{
case 8: { Warehouse = GC.MyChar.Warehouses.TCWarehouse; break; }
case 10012: { Warehouse = GC.MyChar.Warehouses.PCWarehouse; break; }
case 10028: { Warehouse = GC.MyChar.Warehouses.ACWarehouse; break; }
case 10011: { Warehouse = GC.MyChar.Warehouses.DCWarehouse; break; }
case 10027: { Warehouse = GC.MyChar.Warehouses.BIWarehouse; break; }
case 44: { Warehouse = GC.MyChar.Warehouses.MAWarehouse; break; }
case 4101: { Warehouse = GC.MyChar.Warehouses.SCWarehouse; break; }
}
Did you not read mine and Ians post?
09/17/2010 18:59 -impulse-#17
Quote:
Originally Posted by -Fáng- View Post
Korvac's
Last time I checked, names or things that end with s won't get a double s but a '. like "His brothers' car is ready."(two brothers :P) so it would be " Korvacs' "

This error might not occur because the array is set as null and not as new array().

This error occurs because when a character is loading, it also loads the warehouses one by one, doing wharr = new ArrayList() after it finishes the last one, and if one errors, the others will remain null, which when trying:

buffer = new byte[xx + Warehouse.Count + 8] will result into a null exception.

Even setting ArrayList Warehouse = new ArrayList(), once it hits that switch, it will make it back null, which will still lead to that null exception.

To make it go away, just do something like:

public GameClient(...)
{
...
Warehouses.TCWarehouse = new ArrayList();
Warehouses.PCWarehouse = new ArrayList();
Warehouses.ACWarehouse = new ArrayList();
Warehouses.DCWarehouse = new ArrayList();
Warehouses.BIWarehouse = new ArrayList();
//Warehouses.SWarehouse = new ArrayList();//Stone wh? Not added? Dunno myself lol
}
and it shall work like a charm.
09/18/2010 03:38 -Fáng-#18
Quote:
Originally Posted by -impulse- View Post
Last time I checked, names or things that end with s won't get a double s but a '. like "His brothers' car is ready."(two brothers :P) so it would be " Korvacs' "
If you have nothing better to do than to comment on my fast typing then get a hobby. I'm self taught at coding and I'm trying very hard at my project. Don't be a troll.
09/18/2010 06:19 iLikeSkittles#19
Thanks everyone for the help. I got it fixed :)

#request close
09/18/2010 12:39 -impulse-#20
Quote:
Originally Posted by -Fáng- View Post
If you have nothing better to do than to comment on my fast typing then get a hobby. I'm self taught at coding and I'm trying very hard at my project. Don't be a troll.
Hmm, I don't search for your posts to see where you mistype words or things like that... other than what I typed about that 's thing, I also typed the fix for topic starter problem, so it was kinda on-topic. I don't really remember where I posted something that wasn't on topic, and if I did, I certainly added something that would go on topic.

Blah, blah, blah, blah...this is getting boring.
09/18/2010 21:34 _DreadNought_#21
Fang, -Impulse- is NOT a troll at all