Skip to content

Commit

Permalink
Change the const_cast by removing const
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhobean committed Oct 11, 2024
1 parent 4183b84 commit 56d5f1f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/network/send.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ PacketCombatDamage::PacketCombatDamage(const CClient* target, word damage, CUID
*
*
***************************************************************************/
PacketObjectStatus::PacketObjectStatus(const CClient* target, CObjBase* object) : PacketSend(XCMD_Status, 7, g_Cfg.m_fUsePacketPriorities? PRI_LOW : PRI_NORMAL)
PacketObjectStatus::PacketObjectStatus(CClient* target, CObjBase* object) : PacketSend(XCMD_Status, 7, g_Cfg.m_fUsePacketPriorities? PRI_LOW : PRI_NORMAL)
{
ADDTOCALLSTACK("PacketObjectStatus::PacketObjectStatus");
ASSERT(object);

const CNetState * state = target->GetNetState();
const CChar *character = target->GetChar();
CChar *character = target->GetChar();
CChar *objectChar = object->IsChar() ? static_cast<CChar *>(object) : nullptr;
bool fCanRename = false;

Expand All @@ -154,8 +154,7 @@ PacketObjectStatus::PacketObjectStatus(const CClient* target, CObjBase* object)
CScriptTriggerArgs args;
args.m_s1 = object->GetName();

CChar* pCharBase = const_cast<CChar*>(character); // Remove the const to be able to use on OnTrigger
if (objectChar->OnTrigger(CTRIG_DisplayName, pCharBase, &args) == TRIGRET_RET_TRUE)
if (objectChar->OnTrigger(CTRIG_DisplayName, character, &args) == TRIGRET_RET_TRUE)
{
bCustomName = 1;
sShowName = args.m_s1;
Expand Down
2 changes: 1 addition & 1 deletion src/network/send.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class PacketCombatDamage : public PacketSend
class PacketObjectStatus : public PacketSend
{
public:
PacketObjectStatus(const CClient* target, CObjBase* object);
PacketObjectStatus(CClient* target, CObjBase* object);

private:
void WriteVersionSpecific(const CClient* target, CChar* other, byte version);
Expand Down

0 comments on commit 56d5f1f

Please sign in to comment.