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.
This commit is contained in:
@@ -782,7 +782,7 @@ void cClientHandle::HandleEnchantItem(UInt8 a_WindowID, UInt8 a_Enchantment)
|
||||
return;
|
||||
}
|
||||
|
||||
cEnchantingWindow * Window = reinterpret_cast<cEnchantingWindow *>(m_Player->GetWindow());
|
||||
cEnchantingWindow * Window = static_cast<cEnchantingWindow *>(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<cBeaconWindow *>(Window);
|
||||
cBeaconWindow * BeaconWindow = static_cast<cBeaconWindow *>(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<cAnvilWindow *>(m_Player->GetWindow())->SetRepairedItemName(a_ItemName, m_Player);
|
||||
static_cast<cAnvilWindow *>(m_Player->GetWindow())->SetRepairedItemName(a_ItemName, m_Player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user