Supporting new clients
Posted: 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
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
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.
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?
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;The highlighted bytes are the ones that need to be totaled up
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.<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>
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;
}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?