Supporting new clients

EQ2Emulator Development forum.

Moderator: Team Members

Post Reply
Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Supporting new clients

Post by Jabantiz » Fri Jan 04, 2013 12:31 pm

This is mainly for the devs that will be working to support newer clients. There are some required code changes when certain packets change that I don't think was ever discussed so I am doing that now before I forget what to do again...

First is when the spell book struct changes, WS_UpdateSpellBook, the bytes in the array need to be totaled up and that value needs to be added to the if in Player::GetSpellBookUpdatePacket(int16 version) in player.cpp

Code: Select all

		if (packet->GetVersion() >= 1188)
			total_bytes = 46 ;
		else if (packet->GetVersion() >= 1144)
			total_bytes = 42;
		else if (packet->GetVersion() >= 1096)
			total_bytes = 37;
		else
			total_bytes = 30;
Just add an if with the new version and the new byte count and add an else before the if currently there.

The highlighted bytes are the ones that need to be totaled up
<Struct Name="WS_UpdateSpellBook" ClientVersion="1" OpcodeName="OP_UpdateSpellBookMsg" >
<Data ElementName="spell_count" Type="int16" />
<Data ElementName="packed_size" Type="int32" />
<Data ElementName="spell_array" Type="Array" ArraySizeVariable="spell_count">
<Data ElementName="spell_id" Type="int32" />
<Data ElementName="unique_id" Type="int32" />
<Data ElementName="recast_available" Type="int32" Size="1" />
<Data ElementName="type" Type="int16" Size="1" />
<Data ElementName="recast_time" Type="int16" Size="1" />
<Data ElementName="unknown3" Type="int16" />
<Data ElementName="icon" Type="sint16" />
<Data ElementName="icon_type" Type="int16" />
<Data ElementName="icon2" Type="int16" Size="1" />
<Data ElementName="charges" Type="int8" Size="1" />
<Data ElementName="unknown5" Type="int8" Size="4" />
<Data ElementName="status" Type="int8" Size="1" />

</Data>
If this is not done then the SERVER will crash when a char tries to log on. Again this only needs to be done when the highlighted byte count changes.


The next is for items, there is an element in the struct called packettype, when that value changes it needs to added to the code, I refactored the code so this only need to be added in one spot now instead of 4, in int16 GetItemPacketType(int32 version) in miscfunctions.cpp just add a new if to the top with the new packet type.

Code: Select all

int16 GetItemPacketType(int32 version) {
	int16 item_version;
	if (version >= 1188)
		item_version = 0x3FFE;
	else if(version >= 1096)
		item_version = 0x35FE;
	else if(version >= 1027)
		item_version = 0x31FE;
	else if(version >= 1008)
		item_version = 0x2CFE;
	else if(version >= 927)
		item_version = 0x23FE;
	else if(version >= 893)
		item_version = 0x22FE;
	else if(version >= 860)
		item_version = 0x20FE;
	else
		item_version = 0x1CFE;

	return item_version;
}
If this is not done items will not display properly in game. There is also the player movement code for when that changes but I am going to look into a better way to do that before discussing it.

Zcoretri, I noticed in Spell::SerializeSpell in spells.cpp it seems to use the same packettype values as items does, could the above function also be used for that as well?

User avatar
Zcoretri
Team Member
Posts: 1642
Joined: Fri Jul 27, 2007 12:55 pm
Location: SoCal

Re: Supporting new clients

Post by Zcoretri » Fri Jan 04, 2013 6:17 pm

Zcoretri, I noticed in Spell::SerializeSpell in spells.cpp it seems to use the same packettype values as items does, could the above function also be used for that as well?
Yes, it uses the same packettype values for spell examines.

Nice work Jabantiz, will be great to only have to remember 1 spot in which to change these :D

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: Supporting new clients

Post by Jabantiz » Fri Jan 04, 2013 6:38 pm

Ok, updated Spell::SerializeSpell to use this new function. I also corrected some mistakes I had with packet types, the new values are from 1188-1193 logs I quickly looked up. I think I got all the spots where this was used, if I missed any let me know and I'll fix it.

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: Supporting new clients

Post by Jabantiz » Fri Jan 11, 2013 10:07 pm

There is also the player movement code for when that changes but I am going to look into a better way to do that before discussing it.
This is no longer an issue, when player movement packets change only the new WS_PlayerPosUpdate struct needs to be updated.

Also the first half of my original post about WS_UpdateSpellBook is no longer relevant, I made some changes to the structs and code so no code changes need to be done for new clients just update the struct, here is the new struct

Code: Select all

<Struct Name="WS_UpdateSpellBook" ClientVersion="1193" OpcodeName="OP_UpdateSpellBookMsg" >
<Data ElementName="spell_count" Type="int16" />
<Data ElementName="packed_size" Type="int32" />
<Data ElementName="spell_array" Type="Array" ArraySizeVariable="spell_count">
  <Data ElementName="spells" Substruct="SubStruct_UpdateSpellBook" Size="1" />
</Data>

<Struct Name="SubStruct_UpdateSpellBook" ClientVersion="1193">
<Data ElementName="spell_id" Type="int32" />
<Data ElementName="unique_id" Type="int32" />
<Data ElementName="recast_available" Type="int32" Size="1" />
<Data ElementName="type" Type="int8" Size="1" />
<Data ElementName="unknown1" Type="int8" Size="1" />
<Data ElementName="recast_time" Type="int16" Size="1" />
<Data ElementName="unknown3" Type="int16" Size="2" />
<Data ElementName="icon" Type="sint16" />
<Data ElementName="icon_type" Type="int16" />
<Data ElementName="icon2" Type="int16" Size="1" />
<Data ElementName="charges" Type="int8" Size="1" />
<Data ElementName="unknown5" Type="int8" Size="15" />
<Data ElementName="status" Type="int8" Size="1" />
<Data ElementName="unknown6" Type="int8" Size="3" />
</Struct>
Notice the array was broken off into a substruct, this is usually the only data that changes but when it is updated you need to make a new WS_UpdateSpellBook for the new version.

The only code changes needed now is the packet type in miscfunctions.cpp. If any one finds another spot that needs updating for newer clients let me know and I will look into a way to change it so we don't. (not including defines)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest