Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

Reply
 
Thread Tools Display Modes
  #1  
Old 04-11-2009, 05:06 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Also, for augments to be 100% functional, we would need to update the OP_ItemPacket encode to handle them. This would make it so that newly augmented items would show the augments without having to zone. It should also make it so that augments will show up in itemlinks.

This is not functioning for handling subitems yet, and I am not sure why. It causes a crash (zone crash I think) when I try to click a link of an item that is augmented. So, I have commented out the subitem part until that is working fully. But, as far as I can tell, this way works just as well as the way the item packet is currently set to be handled. Just need to figure out how to get subitems reporting propely.

In SoF.cpp replace the entire OP_ItemPacket code here:
Code:
ENCODE(OP_ItemLinkResponse) {  ENCODE_FORWARD(OP_ItemPacket); }
ENCODE(OP_ItemPacket) {
	//consume the packet
	EQApplicationPacket *in = *p;
	*p = NULL;
	
	unsigned char *__emu_buffer = in->pBuffer;
	ItemPacket_Struct *old_item_pkt=(ItemPacket_Struct *)__emu_buffer;
	InternalSerializedItem_Struct *int_struct=(InternalSerializedItem_Struct *)(old_item_pkt->SerializedItem);

	uint32 length;
	char *serialized=SerializeItem((ItemInst *)int_struct->inst,int_struct->slot_id,&length,0);

	if (!serialized) {
		_log(NET__STRUCTS, "Serialization failed on item slot %d.",int_struct->slot_id);
		delete in;
		return;
	}
	in->size = length+4;
	in->pBuffer = new unsigned char[in->size];
	ItemPacket_Struct *new_item_pkt=(ItemPacket_Struct *)in->pBuffer;
	new_item_pkt->PacketType=old_item_pkt->PacketType;
	memcpy(new_item_pkt->SerializedItem,serialized,length);

	delete[] __emu_buffer;
	safe_delete_array(serialized);
	dest->FastQueuePacket(&in, ack_req);
}
With this:
Code:
ENCODE(OP_ItemLinkResponse) {  ENCODE_FORWARD(OP_ItemPacket); }
ENCODE(OP_ItemPacket) {
	//consume the packet
	EQApplicationPacket *in = *p;
	*p = NULL;
	
	unsigned char *__emu_buffer = in->pBuffer;
	ItemPacket_Struct *old_item_pkt=(ItemPacket_Struct *)__emu_buffer;
	InternalSerializedItem_Struct *int_struct=(InternalSerializedItem_Struct *)(old_item_pkt->SerializedItem);

	uchar *data = NULL;
	uchar *tempdata = NULL;

	int r;
	char* serialized = NULL;
	uint32 total_length = 0;
	uint32 length = 0;

	//serialized = SerializeItem((ItemInst *)int_struct->inst,int_struct->slot_id,&length,0);
	serialized = SerializeItem((const ItemInst*)int_struct->inst,int_struct->slot_id,&length,0);

	if(serialized)
	{
		bool normal_item = false;
		const Item_Struct *item = ((const ItemInst*)int_struct->inst)->GetItem();
		uint8 itemclass = item->ItemClass;
		if(itemclass == 0)
			normal_item = true;

		tempdata = data;
		data = NULL;
		data = new uchar[total_length+length];
		memcpy(data, tempdata, total_length);
		memcpy(data+total_length, serialized, length);
		total_length += length;

		delete[] tempdata;
		tempdata = NULL;
		delete[] serialized;
		serialized = NULL;

		uint32 sub_length;
		/*
		if(normal_item)
		{
			for(int x = 0; x < MAX_AUGMENT_SLOTS; ++x)
			{
				const ItemInst* subitem = ((const ItemInst*)int_struct->inst)->GetItem(x);
				if(subitem)
				{
					sub_length = 0;
					serialized = NULL;
					serialized = SerializeItem(subitem, int_struct->slot_id, &sub_length, 0);

					if(serialized)
					{
						data = new uchar[total_length+sub_length+4];
						memcpy(data, tempdata, total_length);
						*((uint32*)(data+total_length)) = x;
						total_length += 4;
						memcpy(data+total_length, serialized, sub_length);
						total_length += sub_length;
						delete[] tempdata;
						tempdata = NULL;
						delete[] serialized;
						serialized = NULL; 
					}
				}
			}
		}
		/*/
	}
	else
	{
		_log(NET__ERROR, "Serialization failed on item slot %d.",int_struct->slot_id);
		delete in;
		return;
	}

	in->size = total_length;
	in->pBuffer = new unsigned char[in->size];
	ItemPacket_Struct *new_item_pkt=(ItemPacket_Struct *)in->pBuffer;
	new_item_pkt->PacketType=old_item_pkt->PacketType;
	memcpy(new_item_pkt->SerializedItem,data,in->size);

	delete[] __emu_buffer;
	_log(NET__ERROR, "Sending item to client");
	_hex(NET__ERROR, in->pBuffer, in->size);
	safe_delete_array(serialized);

	dest->FastQueuePacket(&in, ack_req);


}
Note that this code change shouldn't cause any crashes, so it should be ok to actually replace this now. But, I would like to get it working properly for augments before updating the SVN with it. As it is now, there is no noticeable difference from the current code to the new code, so no real reason to make this change yet.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #2  
Old 04-12-2009, 03:41 AM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default

I think I got this working. Will do a bit more testing/cleanup and post it later.

It seems aug_count is really subitem count, so applies to bags as well. I also handled the subitem serialization from recursively within SerializeItem.
Reply With Quote
  #3  
Old 04-12-2009, 04:00 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

That is awesome news, Derision! Yeah, it did apply to bags as well. That is why I had it check that the "hdr.ItemClass == 0", which would mean that it only counts subitems on normal items, since bags and books would be 1 and 2 respectively.

LOL, with your help lately, SoF should be fully functional in no time! Maybe I should start manually pulling out the new AA tables info from Live. It is going to really suck to do manually, but at least it can be done that way.

I have most of the itemlink issues worked out for itemlinks from commands like #peekinv and #searchitem and such. Just trying to finish that up and will have 1 more thing done for SoF. Then, itemlinks will almost be finished for SoF. Though, for them to be 100% caught up with Titanium, the itempacket will also have to handle subitems similar to the client inventory encode.

I can't wait to see augs working smoothly
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 03:27 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3