Skip to content
Open
2 changes: 1 addition & 1 deletion src/Ext/Techno/Body.Update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void TechnoExt::ExtData::AmmoAutoConvertActions()
if ((skipMinimum || pThis->Ammo >= pTypeExt->Ammo_AutoConvertMinimumAmount) // More than minimum
&& (skipMaximum || pThis->Ammo <= pTypeExt->Ammo_AutoConvertMaximumAmount)) // Less than maximum
{
const auto pFoot = abstract_cast<FootClass*>(pThis);
const auto pFoot = pThis && (pThis->AbstractFlags & AbstractFlags::Foot) ? static_cast<FootClass*>(pThis) : nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const auto pFoot = abstract_cast<FootClass* , true >(pThis); is a method of using encapsulated functions, which can be directly used.

Copy link
Contributor Author

@FS-21 FS-21 May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But you are suggesting a code change or simply explaining a recommendation for future similar situations? is for going direct & closing the pending conversation :-P

Copy link
Contributor

@CrimRecya CrimRecya May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to do sanity check on pThis. You have already used pThis->Ammo and are even still using pThis->GetTechnoType(), it cannot be empty.
I explained for a while just to make you understand what the true in abstract_cast means.

Copy link
Contributor Author

@FS-21 FS-21 May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok now I understood, so I'll leave as
const auto pFoot = abstract_cast<FootClass*, true>(pThis);
because as you said pThis was already used and the last bit of information i wanted to know is if pThis is a FootClass object or something else for future things.

Copy link
Contributor

@CrimRecya CrimRecya May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if pThis is a FootClass object or something else for future things.

Sorry, I didn't understand what you meant. pThis is a TechnoClass pointer and the converted pFoot is a FootClass pointer. Unless it is not a Foot (such as a Building), they all point to the same entity.


if (!pFoot)
return;
Expand Down