Removed any 'legacy' functions from the new code

This commit is contained in:
dannuic
2026-04-27 17:52:45 -06:00
parent f3634e54ae
commit d16c1b2483
14 changed files with 141 additions and 132 deletions
+1 -6
View File
@@ -24,14 +24,9 @@ public:
IBuff() = default;
virtual ~IBuff() = default;
// TODO: I think all of the legacy stuff can just be rolled into regular buff functions and the call sites modified
virtual std::unique_ptr<EQApplicationPacket> MakeLegacyBuffsPacket(Mob* mob, bool for_target,
bool clear_buffs) const = 0;
virtual std::unique_ptr<EQApplicationPacket> LegacyBuffDefinition(Mob* mob, Buffs_Struct& buff, int slot) const = 0; // TODO: add the buffs definition packet
virtual std::unique_ptr<EQApplicationPacket> BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot,
bool fade) const = 0;
virtual std::unique_ptr<EQApplicationPacket> RefreshBuffs(EmuOpcode opcode, Mob* mob, int32_t timer, bool remove,
virtual std::unique_ptr<EQApplicationPacket> RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const = 0;
virtual void SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const = 0;
};
+26 -17
View File
@@ -35,6 +35,7 @@
#include <iostream>
#include <sstream>
#include "zone/client.h"
#include "zone/mob.h"
@@ -4290,21 +4291,15 @@ namespace SoD
namespace Buff {
std::unique_ptr<EQApplicationPacket> SoD::MakeLegacyBuffsPacket(Mob* mob, bool for_target, bool clear_buffs) const
std::unique_ptr<EQApplicationPacket> SoD::RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const
{
// SoD only supports target refresh, not self refresh packets
if (for_target) {
if (opcode == OP_RefreshTargetBuffs) {
uint32 count = 0;
uint32 buff_count;
// for self we want all buffs, for target, we want to skip song window buffs
// since NPCs and pets don't have a song window, we still see it for them :P
if (for_target) {
buff_count = (clear_buffs) ? 0 : mob->GetMaxBuffSlots();
}
else {
buff_count = mob->GetMaxTotalSlots();
}
buff_count = mob->GetMaxTotalSlots();
Buffs_Struct* buffs = mob->GetBuffs();
@@ -4314,7 +4309,7 @@ std::unique_ptr<EQApplicationPacket> SoD::MakeLegacyBuffsPacket(Mob* mob, bool f
}
}
auto outapp = std::make_unique<EQApplicationPacket>(OP_RefreshTargetBuffs,
auto outapp = std::make_unique<EQApplicationPacket>(opcode,
sizeof(BuffIcon_Struct) + sizeof(BuffIconEntry_Struct) * count);
BuffIcon_Struct *buff = (BuffIcon_Struct*)outapp->pBuffer;
@@ -4322,12 +4317,8 @@ std::unique_ptr<EQApplicationPacket> SoD::MakeLegacyBuffsPacket(Mob* mob, bool f
buff->count = count;
buff->all_buffs = 1;
buff->tic_timer = mob->GetRemainingTicTime();
// there are more types, the client doesn't seem to really care though. The others are also currently hard to fill in here ...
// (see comment in common/eq_packet_structs.h)
if (for_target)
buff->type = mob->IsClient() ? 5 : 7;
else
buff->type = 0;
// (see comment in common/eq_packet_structs.h), mutated in SetRefreshType
buff->type = mob->IsClient() ? 5 : 7;
buff->name_lengths = 0; // hacky shit
uint32 index = 0;
@@ -4349,4 +4340,22 @@ std::unique_ptr<EQApplicationPacket> SoD::MakeLegacyBuffsPacket(Mob* mob, bool f
return nullptr;
}
// 0 = self buff window, 1 = self target window, 2 = pet buff or target window, 4 = group, 5 = PC, 7 = NPC
void SoD::SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const
{
if (packet) {
BuffIcon_Struct *buff = (BuffIcon_Struct*)packet->pBuffer;
if (target->GetID() == source->GetID())
buff->type = 1;
else if (target->IsPet())
buff->type = 2;
else if (target->HasGroup() && source->GetGroup() == target->GetGroup())
buff->type = 4;
else if (target->IsClient())
buff->type = 5;
else
buff->type = 7;
}
}
} // namespace Buff
+3 -2
View File
@@ -69,8 +69,9 @@ public:
SoD() = default;
~SoD() override = default;
std::unique_ptr<EQApplicationPacket> MakeLegacyBuffsPacket(Mob* mob, bool for_target,
bool clear_buffs) const override;
std::unique_ptr<EQApplicationPacket> RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const override;
void SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const override;
};
} // namespace Buff
+4 -13
View File
@@ -4019,12 +4019,9 @@ void Titanium::ResolveArguments(uint32_t id, std::array<const char*, 9>& args) c
} // namespace Message
namespace Buff {
std::unique_ptr<EQApplicationPacket> Titanium::MakeLegacyBuffsPacket(Mob* mob, bool for_target, bool clear_buffs) const
{
return nullptr;
}
std::unique_ptr<EQApplicationPacket> Titanium::LegacyBuffDefinition(Mob* mob, Buffs_Struct& buff, int slot) const
std::unique_ptr<EQApplicationPacket> Titanium::BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot,
bool fade) const
{
auto outapp = std::make_unique<EQApplicationPacket>(OP_BuffDefinition, sizeof(SpellBuffPacket_Struct));
SpellBuffPacket_Struct* sbf = (SpellBuffPacket_Struct*) outapp->pBuffer;
@@ -4052,18 +4049,12 @@ std::unique_ptr<EQApplicationPacket> Titanium::LegacyBuffDefinition(Mob* mob, Bu
sbf->buff.z = buff.caston_z;
sbf->slotid = slot;
sbf->bufffade = 0;
sbf->bufffade = fade;
return outapp;
}
std::unique_ptr<EQApplicationPacket> Titanium::BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot,
bool fade) const
{
return nullptr;
}
std::unique_ptr<EQApplicationPacket> Titanium::RefreshBuffs(EmuOpcode opcode, Mob* mob, int32_t timer, bool remove,
std::unique_ptr<EQApplicationPacket> Titanium::RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const
{
return nullptr;
+3 -7
View File
@@ -85,13 +85,9 @@ public:
Titanium() = default;
~Titanium() override = default;
std::unique_ptr<EQApplicationPacket> MakeLegacyBuffsPacket(Mob* mob, bool for_target,
bool clear_buffs) const override;
std::unique_ptr<EQApplicationPacket> LegacyBuffDefinition(Mob* mob, Buffs_Struct& buff, int slot) const override;
std::unique_ptr<EQApplicationPacket>
BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot, bool fade) const override;
std::unique_ptr<EQApplicationPacket> RefreshBuffs(EmuOpcode opcode, Mob* mob, int32_t timer, bool remove,
std::unique_ptr<EQApplicationPacket> BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot,
bool fade) const override;
std::unique_ptr<EQApplicationPacket> RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const override;
void SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const override;
};
+17 -16
View File
@@ -5613,7 +5613,6 @@ std::unique_ptr<EQApplicationPacket> TOB::InterruptSpellOther(Mob* sender, uint3
} // namespace Message
namespace Buff {
// std::unique_ptr<EQApplicationPacket> TOB::MakeLegacyBuffsPacket(Mob* mob, bool for_target, bool clear_buffs) const { return nullptr; }
std::unique_ptr<EQApplicationPacket> TOB::BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot, bool fade) const
{
@@ -5641,7 +5640,7 @@ std::unique_ptr<EQApplicationPacket> TOB::BuffDefinition(Mob* mob, const Buffs_S
affect->affect.flags = 0;
affect->affect.spell_id = buff.spellid;
affect->affect.duration = buff.ticsremaining;
affect->affect.initial_duration = buff.ticsremaining; // this isn't correct, it's the total duration
affect->affect.initial_duration = buff.ticsremaining; // TODO: this isn't correct, it's the total duration
affect->affect.hit_count = buff.hit_number;
affect->affect.viral_timer = 0;
affect->affect.modifier = static_cast<float>(buff.instrument_mod) / 10.f;
@@ -5667,7 +5666,7 @@ std::unique_ptr<EQApplicationPacket> TOB::BuffDefinition(Mob* mob, const Buffs_S
return packet;
}
std::unique_ptr<EQApplicationPacket> TOB::RefreshBuffs(EmuOpcode opcode, Mob* mob, int32_t timer, bool remove,
std::unique_ptr<EQApplicationPacket> TOB::RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const
{
Buffs_Struct* buffs = mob->GetBuffs();
@@ -5692,8 +5691,8 @@ std::unique_ptr<EQApplicationPacket> TOB::RefreshBuffs(EmuOpcode opcode, Mob* mo
SerializeBuffer buffer(buffer_size);
buffer.WriteUInt32(mob->GetID());
buffer.WriteInt32(timer);
buffer.WriteUInt8(slots.empty() ? 1 : 0); // 1 indicates all buffs on the player (0 to add or remove a single buff)
buffer.WriteInt32(mob->GetRemainingTicTime());
buffer.WriteUInt8(slots.empty() ? 1 : 0); // 1 indicates all buffs on the mob (0 to add or remove a single buff)
buffer.WriteUInt16(send_slots.size());
for (uint32_t slot : send_slots) {
@@ -5713,18 +5712,20 @@ std::unique_ptr<EQApplicationPacket> TOB::RefreshBuffs(EmuOpcode opcode, Mob* mo
// 0 = self buff window, 1 = self target window, 2 = pet buff or target window, 4 = group, 5 = PC, 7 = NPC
void TOB::SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const
{
unsigned char* type = &packet->pBuffer[packet->size - 2];
if (packet) {
unsigned char* type = &packet->pBuffer[packet->size - 2];
if (target->GetID() == source->GetID())
*type = 1;
else if (target->IsPet())
*type = 2;
else if (target->HasGroup() && source->GetGroup() == target->GetGroup())
*type = 4;
else if (target->IsClient())
*type = 5;
else
*type = 7;
if (target->GetID() == source->GetID())
*type = 1;
else if (target->IsPet())
*type = 2;
else if (target->HasGroup() && source->GetGroup() == target->GetGroup())
*type = 4;
else if (target->IsClient())
*type = 5;
else
*type = 7;
}
}
} // namespace Buff
+1 -4
View File
@@ -65,12 +65,9 @@ public:
TOB() = default;
~TOB() override = default;
// std::unique_ptr<EQApplicationPacket> MakeLegacyBuffsPacket(Mob* mob, bool for_target,
// bool clear_buffs) const override;
std::unique_ptr<EQApplicationPacket>
BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot, bool fade) const override;
std::unique_ptr<EQApplicationPacket> RefreshBuffs(EmuOpcode opcode, Mob* mob, int32_t timer, bool remove,
std::unique_ptr<EQApplicationPacket> RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const override;
void SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const override;
};
+5 -15
View File
@@ -5239,21 +5239,15 @@ namespace UF
namespace Buff {
std::unique_ptr<EQApplicationPacket> UF::MakeLegacyBuffsPacket(Mob* mob, bool for_target, bool clear_buffs) const
std::unique_ptr<EQApplicationPacket> UF::RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const
{
// UF introduced the self update buff packet
uint32 count = 0;
uint32 buff_count;
// for self we want all buffs, for target, we want to skip song window buffs
// since NPCs and pets don't have a song window, we still see it for them :P
if (for_target) {
buff_count = (clear_buffs) ? 0 : mob->GetMaxBuffSlots();
}
else {
buff_count = mob->GetMaxTotalSlots();
}
buff_count = mob->GetMaxTotalSlots();
Buffs_Struct* buffs = mob->GetBuffs();
@@ -5264,7 +5258,7 @@ std::unique_ptr<EQApplicationPacket> UF::MakeLegacyBuffsPacket(Mob* mob, bool fo
}
//Create it for a targeting window, else create it for a create buff packet.
auto outapp = std::make_unique<EQApplicationPacket>(for_target ? OP_RefreshTargetBuffs : OP_RefreshBuffs,
auto outapp = std::make_unique<EQApplicationPacket>(opcode,
sizeof(BuffIcon_Struct) + sizeof(BuffIconEntry_Struct) * count);
BuffIcon_Struct *buff = (BuffIcon_Struct*)outapp->pBuffer;
@@ -5272,12 +5266,8 @@ std::unique_ptr<EQApplicationPacket> UF::MakeLegacyBuffsPacket(Mob* mob, bool fo
buff->count = count;
buff->all_buffs = 1;
buff->tic_timer = mob->GetRemainingTicTime();
// there are more types, the client doesn't seem to really care though. The others are also currently hard to fill in here ...
// (see comment in common/eq_packet_structs.h)
if (for_target)
buff->type = mob->IsClient() ? 5 : 7;
else
buff->type = 0;
buff->type = mob->IsClient() ? 5 : 7;
buff->name_lengths = 0; // hacky shit
uint32 index = 0;
+2 -2
View File
@@ -69,8 +69,8 @@ public:
UF() = default;
~UF() override = default;
std::unique_ptr<EQApplicationPacket> MakeLegacyBuffsPacket(Mob* mob, bool for_target,
bool clear_buffs) const override;
std::unique_ptr<EQApplicationPacket> RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const override;
};
} // namespace Buff