Well, I am trying to work out how to make the serialization match up with how it works now for Live (and apparently since Anniversary or so), but I can't seem to get it to send the integers followed by null (00 in hex) bits.
I copied the function (GetNextItemInstSerialNumber()) to make Item Instanced Serial Numbers similar to how live does it to use in the Item Instancing part of the Serialization. That part seems to be working properly and I will definitely keep that in the final Serialization code. It may not really be required, but it doesn't hurt to copy the way Live does it as close as possible.
I then tried making the changes noted in green below, to force it to send the integers as int32, hoping that it would send them each as 4 bits. It still seems to just be sending the integers, without the 00s after them as it needs to be doing.
Code:
sint32 NextItemInstSerialNumber = 1;
int32 MaxInstances = 2000000000;
static inline sint32 GetNextItemInstSerialNumber() {
if(NextItemInstSerialNumber >= MaxInstances)
NextItemInstSerialNumber = 1;
else
NextItemInstSerialNumber++;
return NextItemInstSerialNumber;
}
char *SerializeItem(const ItemInst *inst, sint16 slot_id, uint32 *length, uint8 depth) {
char *serialization = NULL;
char *instance = NULL;
const char *protection=(const char *)"\\\\\\\\\\";
char *sub_items[10] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
bool stackable=inst->IsStackable();
uint32 merchant_slot=inst->GetMerchantSlot();
sint16 charges=inst->GetCharges();
const Item_Struct *item=inst->GetItem();
int i;
uint32 sub_length;
uint32 stack = stackable ? charges : 1;
uint32 zero = 0;
uint32 price = inst->GetPrice();
uint32 slot = (merchant_slot==0) ? slot_id : merchant_slot;
uint32 merchcount = (merchant_slot==0) ? 1 : inst->GetMerchantCount();
uint32 serialnumber = GetNextItemInstSerialNumber();
uint32 instnodrop = inst->IsInstNoDrop() ? 1 : 0;
uint32 typepotion = (stackable ? ((inst->GetItem()->ItemType == ItemTypePotion) ? 1 : 0) : charges);
MakeAnyLenString(&instance,
"%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i",
stack,
zero,
price,
slot,
merchcount,
zero,
serialnumber,
instnodrop,
typepotion,
zero,
zero,
zero,
zero,
zero,
zero
);
I also found the item_struct.h file which I hadn't seen before and it helped me understand how the serialization is working a little better. Basically, the item_struct is just handled in it's own separate file for some reason instead of being included in the eq_packet_structs.h file. So, if I understand correctly, it seems that the patch_itemfields.h files are just separate files to do basically the same thing as the encodes in the patch.cpp files.
I even noticed that the item_struct already has sizes defined for each field like int8, int32 etc just like normal structs. So, I think that I could just use that struct, and edit the field sizes where needed and add them to the anniversary_structs.h file and then do an encode of them like normal. But, I will still need to figure out how to make it send the structure as the size that it is supposed to be. The structure will vary in length slightly, because a couple fields are strings and don't have a set size limit on them. But, other than that, the rest should always be the same size.