Good news! I got items loading the correct way as far as I can tell so far. The code KLS had written for it was actually very close to being perfect, but had 1 minor mistake in it. The subitem code was adding "length" instead of "sub_length", and since length was defined and not being cleared out before doing subitems, it was forcing all subitems to load as the same length. Since the lengths need to vary depending on the string fields like name and lore, it was causing the structure to break as soon as the second subitem in the list tried to get loaded.
Here is the code change I made:
Code:
for(int x = 0; x < 10; ++x)
{
serialized = NULL;
uint32 sub_length = 0;
const ItemInst* subitem = ((const ItemInst*)eq->inst)->GetItem(x);
if(subitem)
{
serialized = SerializeItem(subitem, (((eq->slot_id+3)*10)+x+1), &sub_length, 0);
//serialized = SerializeItem(subitem, 0, &sub_length, 0);
if(serialized)
{
tempdata = data;
data = NULL;
data = new uchar[total_length+sub_length];
memcpy(data, tempdata, total_length);
memcpy(data+total_length, serialized, sub_length);
total_length += sub_length; // This was set to length before
delete[] tempdata;
tempdata = NULL;
delete[] serialized;
serialized = NULL;
}
}
}
That loaded a full inventory without a crash and it is almost flawlessly loaded. The only remaining issue with loading the inventory like this is that it seems the amount of slots to load at once are either limited by the client or by the server somehow. Basically, the char I logged in has almost a full inventory for most slots including bank slots. But, it seems that since bank slots are loaded last, the client isn't showing all of the items in my bank. I first noticed that only the shared bank and last row on the right in the normal bank (last 4 slots) were not showing up. I then summoned more items to fill all of the bags in my normal inventory and zoned. After zoning, I see even less slots showing up in my bank. So, it seems like some kind of cut-off on how many items can be sent in a single packet. Maybe we have to split the packet up if it gets too big or something and send a second packet. Though, 2 packets should be enough to send all possible items unless maybe if all slots were full of multiple augged items, then it might take 3 packets or something. I am not too sure about this issue yet, but at least it is getting closer to working perfectly.