CPointOfInterestExtra: Make color instances constexpr

Avoids unnecessary file-scope static constructors.
This commit is contained in:
Lioncash 2020-06-19 18:35:08 -04:00
parent 84506c99fb
commit 40f0fbca4c
2 changed files with 13 additions and 13 deletions

View File

@ -1,18 +1,19 @@
#include "CPointOfInterestExtra.h" #include "CPointOfInterestExtra.h"
//@todo pull these values from tweaks instead of hardcoding them //@todo pull these values from tweaks instead of hardcoding them
const CColor CPointOfInterestExtra::skRegularColor = CColor::Integral(0xFF,0x70,0x00); constexpr CColor skRegularColor = CColor::Integral(0xFF,0x70,0x00);
const CColor CPointOfInterestExtra::skImportantColor = CColor::Integral(0xFF,0x00,0x00); constexpr CColor skImportantColor = CColor::Integral(0xFF,0x00,0x00);
CPointOfInterestExtra::CPointOfInterestExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent) CPointOfInterestExtra::CPointOfInterestExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent)
: CScriptExtra(pInstance, pScene, pParent) : CScriptExtra(pInstance, pScene, pParent)
, mpScanData(nullptr)
{ {
// Fetch scan data property // Fetch scan data property
CStructProperty* pProperties = pInstance->Template()->Properties(); CStructProperty* pProperties = pInstance->Template()->Properties();
if (mGame <= EGame::Prime) mScanProperty = CAssetRef(pInstance->PropertyData(), pProperties->ChildByIDString("0x04:0x00")); if (mGame <= EGame::Prime)
else mScanProperty = CAssetRef(pInstance->PropertyData(), pProperties->ChildByIDString("0xBDBEC295:0xB94E9BE7")); mScanProperty = CAssetRef(pInstance->PropertyData(), pProperties->ChildByIDString("0x04:0x00"));
else
mScanProperty = CAssetRef(pInstance->PropertyData(), pProperties->ChildByIDString("0xBDBEC295:0xB94E9BE7"));
PropertyModified(mScanProperty.Property()); PropertyModified(mScanProperty.Property());
} }
@ -28,9 +29,11 @@ void CPointOfInterestExtra::PropertyModified(IProperty* pProperty)
void CPointOfInterestExtra::ModifyTintColor(CColor& Color) void CPointOfInterestExtra::ModifyTintColor(CColor& Color)
{ {
if (mpScanData) if (!mpScanData)
{ return;
if (mScanIsCritical) Color *= skImportantColor;
else Color *= skRegularColor; if (mScanIsCritical)
} Color *= skImportantColor;
else
Color *= skRegularColor;
} }

View File

@ -17,9 +17,6 @@ public:
void PropertyModified(IProperty* pProperty) override; void PropertyModified(IProperty* pProperty) override;
void ModifyTintColor(CColor& Color) override; void ModifyTintColor(CColor& Color) override;
CScan* GetScan() const { return mpScanData; } CScan* GetScan() const { return mpScanData; }
static const CColor skRegularColor;
static const CColor skImportantColor;
}; };
#endif // CPOINTOFINTERESTEXTRA_H #endif // CPOINTOFINTERESTEXTRA_H