From a4dbb5c58270959884c17d720185da06464fa256 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Wed, 2 May 2018 08:50:36 +0100 Subject: Prefer static_cast to reinterpret_cast (#4223) * Change reinterpret_cast -> static_cast wherever possible * Remove more unnecessary `const_cast`s. reinterpret_casts should be avoided for the same reason as c-style casts - they don't do any type-checking. reinterpret_cast was mainly being used for down-casting in inheritance hierarchies but static_cast works just as well while also making sure that there is actually an inheritance relationship there. --- src/ClientHandle.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 87ba9014e..a895dd3b3 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -782,7 +782,7 @@ void cClientHandle::HandleEnchantItem(UInt8 a_WindowID, UInt8 a_Enchantment) return; } - cEnchantingWindow * Window = reinterpret_cast(m_Player->GetWindow()); + cEnchantingWindow * Window = static_cast(m_Player->GetWindow()); cItem Item = *Window->m_SlotArea->GetSlot(0, *m_Player); // Make a copy of the item short BaseEnchantmentLevel = Window->GetPropertyValue(a_Enchantment); @@ -959,7 +959,7 @@ void cClientHandle::HandleBeaconSelection(int a_PrimaryEffect, int a_SecondaryEf { return; } - cBeaconWindow * BeaconWindow = reinterpret_cast(Window); + cBeaconWindow * BeaconWindow = static_cast(Window); if (Window->GetSlot(*m_Player, 0)->IsEmpty()) { @@ -1044,7 +1044,7 @@ void cClientHandle::HandleAnvilItemName(const AString & a_ItemName) if (a_ItemName.length() <= 30) { - reinterpret_cast(m_Player->GetWindow())->SetRepairedItemName(a_ItemName, m_Player); + static_cast(m_Player->GetWindow())->SetRepairedItemName(a_ItemName, m_Player); } } -- cgit v1.2.3