From 4507b063f53fb03e8c8357bd7a21cb9f53bca044 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Fri, 26 Nov 2021 21:33:49 -0500 Subject: [PATCH] Switch server to use new style ManaChange_Struct (#1843) This will allow us to fix some bugs the current handling has. Note: the decoder isn't needed since the client always sends it up as a 0 length packet. --- common/eq_packet_structs.h | 1 + common/patches/rof.cpp | 14 -------------- common/patches/rof2.cpp | 14 -------------- common/patches/rof2_ops.h | 1 - common/patches/rof_ops.h | 1 - common/patches/sod.cpp | 14 -------------- common/patches/sod_ops.h | 1 - common/patches/sof.cpp | 14 -------------- common/patches/sof_ops.h | 1 - common/patches/titanium.cpp | 13 +++++++++++++ common/patches/titanium_ops.h | 1 + common/patches/uf.cpp | 14 -------------- common/patches/uf_ops.h | 1 - zone/client.cpp | 4 +--- zone/spells.cpp | 2 ++ 15 files changed, 18 insertions(+), 78 deletions(-) diff --git a/common/eq_packet_structs.h b/common/eq_packet_structs.h index 304411d03..872f89859 100644 --- a/common/eq_packet_structs.h +++ b/common/eq_packet_structs.h @@ -448,6 +448,7 @@ struct ManaChange_Struct /*08*/ uint32 spell_id; /*12*/ uint8 keepcasting; // won't stop the cast. Change mana while casting? /*13*/ uint8 padding[3]; // client doesn't read it, garbage data seems like +/*16*/ int32 slot; // -1 normal, otherwise clear ETA and GCD }; struct SwapSpell_Struct diff --git a/common/patches/rof.cpp b/common/patches/rof.cpp index 8e40e43ce..908ecc26b 100644 --- a/common/patches/rof.cpp +++ b/common/patches/rof.cpp @@ -1634,20 +1634,6 @@ namespace RoF FINISH_ENCODE(); } - ENCODE(OP_ManaChange) - { - ENCODE_LENGTH_EXACT(ManaChange_Struct); - SETUP_DIRECT_ENCODE(ManaChange_Struct, structs::ManaChange_Struct); - - OUT(new_mana); - OUT(stamina); - OUT(spell_id); - OUT(keepcasting); - eq->slot = -1; // this is spell gem slot. It's -1 in normal operation - - FINISH_ENCODE(); - } - ENCODE(OP_MercenaryDataResponse) { //consume the packet diff --git a/common/patches/rof2.cpp b/common/patches/rof2.cpp index 03f636560..e6404a62a 100644 --- a/common/patches/rof2.cpp +++ b/common/patches/rof2.cpp @@ -1683,20 +1683,6 @@ namespace RoF2 FINISH_ENCODE(); } - ENCODE(OP_ManaChange) - { - ENCODE_LENGTH_EXACT(ManaChange_Struct); - SETUP_DIRECT_ENCODE(ManaChange_Struct, structs::ManaChange_Struct); - - OUT(new_mana); - OUT(stamina); - OUT(spell_id); - OUT(keepcasting); - eq->slot = -1; // this is spell gem slot. It's -1 in normal operation - - FINISH_ENCODE(); - } - ENCODE(OP_MercenaryDataResponse) { //consume the packet diff --git a/common/patches/rof2_ops.h b/common/patches/rof2_ops.h index 22b6e6662..130686cdf 100644 --- a/common/patches/rof2_ops.h +++ b/common/patches/rof2_ops.h @@ -93,7 +93,6 @@ E(OP_ItemVerifyReply) E(OP_LeadershipExpUpdate) E(OP_LogServer) E(OP_LootItem) -E(OP_ManaChange) E(OP_MercenaryDataResponse) E(OP_MercenaryDataUpdate) E(OP_MoveItem) diff --git a/common/patches/rof_ops.h b/common/patches/rof_ops.h index f06834d21..7cca08e61 100644 --- a/common/patches/rof_ops.h +++ b/common/patches/rof_ops.h @@ -79,7 +79,6 @@ E(OP_ItemVerifyReply) E(OP_LeadershipExpUpdate) E(OP_LogServer) E(OP_LootItem) -E(OP_ManaChange) E(OP_MercenaryDataResponse) E(OP_MercenaryDataUpdate) E(OP_MoveItem) diff --git a/common/patches/sod.cpp b/common/patches/sod.cpp index 034679bd5..32e58e432 100644 --- a/common/patches/sod.cpp +++ b/common/patches/sod.cpp @@ -1170,20 +1170,6 @@ namespace SoD FINISH_ENCODE(); } - ENCODE(OP_ManaChange) - { - ENCODE_LENGTH_EXACT(ManaChange_Struct); - SETUP_DIRECT_ENCODE(ManaChange_Struct, structs::ManaChange_Struct); - - OUT(new_mana); - OUT(stamina); - OUT(spell_id); - OUT(keepcasting); - eq->slot = -1; // this is spell gem slot. It's -1 in normal operation - - FINISH_ENCODE(); - } - ENCODE(OP_MercenaryDataResponse) { //consume the packet diff --git a/common/patches/sod_ops.h b/common/patches/sod_ops.h index 5216a77ce..c98ab5ff0 100644 --- a/common/patches/sod_ops.h +++ b/common/patches/sod_ops.h @@ -63,7 +63,6 @@ E(OP_ItemVerifyReply) E(OP_LeadershipExpUpdate) E(OP_LogServer) E(OP_LootItem) -E(OP_ManaChange) E(OP_MercenaryDataResponse) E(OP_MercenaryDataUpdate) E(OP_MoveItem) diff --git a/common/patches/sof.cpp b/common/patches/sof.cpp index 56fbba8f4..ff77e788b 100644 --- a/common/patches/sof.cpp +++ b/common/patches/sof.cpp @@ -966,20 +966,6 @@ namespace SoF FINISH_ENCODE(); } - ENCODE(OP_ManaChange) - { - ENCODE_LENGTH_EXACT(ManaChange_Struct); - SETUP_DIRECT_ENCODE(ManaChange_Struct, structs::ManaChange_Struct); - - OUT(new_mana); - OUT(stamina); - OUT(spell_id); - OUT(keepcasting); - eq->slot = -1; // this is spell gem slot. It's -1 in normal operation - - FINISH_ENCODE(); - } - ENCODE(OP_MemorizeSpell) { ENCODE_LENGTH_EXACT(MemorizeSpell_Struct); diff --git a/common/patches/sof_ops.h b/common/patches/sof_ops.h index 653bb5979..0dd34e060 100644 --- a/common/patches/sof_ops.h +++ b/common/patches/sof_ops.h @@ -59,7 +59,6 @@ E(OP_ItemVerifyReply) E(OP_LeadershipExpUpdate) E(OP_LogServer) E(OP_LootItem) -E(OP_ManaChange) E(OP_MemorizeSpell) E(OP_MoveItem) E(OP_NewSpawn) diff --git a/common/patches/titanium.cpp b/common/patches/titanium.cpp index 200beebf5..25ef3be5c 100644 --- a/common/patches/titanium.cpp +++ b/common/patches/titanium.cpp @@ -932,6 +932,19 @@ namespace Titanium FINISH_ENCODE(); } + ENCODE(OP_ManaChange) + { + ENCODE_LENGTH_EXACT(ManaChange_Struct); + SETUP_DIRECT_ENCODE(ManaChange_Struct, structs::ManaChange_Struct); + + OUT(new_mana); + OUT(stamina); + OUT(spell_id); + OUT(keepcasting); + + FINISH_ENCODE(); + } + ENCODE(OP_MemorizeSpell) { ENCODE_LENGTH_EXACT(MemorizeSpell_Struct); diff --git a/common/patches/titanium_ops.h b/common/patches/titanium_ops.h index 961c850fe..c7557a32f 100644 --- a/common/patches/titanium_ops.h +++ b/common/patches/titanium_ops.h @@ -55,6 +55,7 @@ E(OP_ItemPacket) E(OP_LeadershipExpUpdate) E(OP_LFGuild) E(OP_LootItem) +E(OP_ManaChange) E(OP_MemorizeSpell) E(OP_MoveItem) E(OP_OnLevelMessage) diff --git a/common/patches/uf.cpp b/common/patches/uf.cpp index 81c76aa62..1e33ed307 100644 --- a/common/patches/uf.cpp +++ b/common/patches/uf.cpp @@ -1390,20 +1390,6 @@ namespace UF FINISH_ENCODE(); } - ENCODE(OP_ManaChange) - { - ENCODE_LENGTH_EXACT(ManaChange_Struct); - SETUP_DIRECT_ENCODE(ManaChange_Struct, structs::ManaChange_Struct); - - OUT(new_mana); - OUT(stamina); - OUT(spell_id); - OUT(keepcasting); - eq->slot = -1; // this is spell gem slot. It's -1 in normal operation - - FINISH_ENCODE(); - } - ENCODE(OP_MercenaryDataResponse) { //consume the packet diff --git a/common/patches/uf_ops.h b/common/patches/uf_ops.h index 76b7e014b..5d728f067 100644 --- a/common/patches/uf_ops.h +++ b/common/patches/uf_ops.h @@ -68,7 +68,6 @@ E(OP_ItemVerifyReply) E(OP_LeadershipExpUpdate) E(OP_LogServer) E(OP_LootItem) -E(OP_ManaChange) E(OP_MercenaryDataResponse) E(OP_MercenaryDataUpdate) E(OP_MoveItem) diff --git a/zone/client.cpp b/zone/client.cpp index fe163a2c7..f09bcefcd 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -1869,9 +1869,7 @@ void Client::CheckManaEndUpdate() { mana_change->stamina = current_endurance; mana_change->spell_id = casting_spell_id; mana_change->keepcasting = 1; - mana_change->padding[0] = 0; - mana_change->padding[1] = 0; - mana_change->padding[2] = 0; + mana_change->slot = -1; outapp->priority = 6; QueuePacket(outapp); safe_delete(outapp); diff --git a/zone/spells.cpp b/zone/spells.cpp index 863646492..3d333d768 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -1001,6 +1001,7 @@ void Mob::StopCasting() mc->stamina = GetEndurance(); mc->spell_id = casting_spell_id; mc->keepcasting = 0; + mc->slot = -1; c->FastQueuePacket(&outapp); } ZeroCastingVars(); @@ -5218,6 +5219,7 @@ void Mob::SendSpellBarEnable(uint16 spell_id) manachange->spell_id = spell_id; manachange->stamina = CastToClient()->GetEndurance(); manachange->keepcasting = 0; + manachange->slot = -1; outapp->priority = 6; CastToClient()->QueuePacket(outapp); safe_delete(outapp);