2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 11:07:44 +00:00

CToken: Add HasReference() member function

Has the same semantics of operator bool(), but explains at the call site
what is actually being tested for in the relation to the object itself.

Aims to make readability slightly better (and removed the need for
casts).
This commit is contained in:
Lioncash
2020-03-08 21:10:15 -04:00
parent fc5170ede9
commit 2233a78fe2
4 changed files with 11 additions and 9 deletions

View File

@@ -148,16 +148,16 @@ public:
const zeus::CVector3f& GetScale() const { return x0_scale; }
void SetScale(const zeus::CVector3f& scale) { x0_scale = scale; }
bool HasAnimData() const { return x10_animData != nullptr; }
bool HasNormalModel() const { return bool(x1c_normalModel); }
bool HasNormalModel() const { return x1c_normalModel.HasReference(); }
bool HasModel(EWhichModel which) const {
if (x10_animData) {
switch (which) {
case EWhichModel::Normal:
return true;
case EWhichModel::XRay:
return x10_animData->GetXRayModel().operator bool();
return x10_animData->GetXRayModel() != nullptr;
case EWhichModel::Thermal:
return x10_animData->GetInfraModel().operator bool();
return x10_animData->GetInfraModel() != nullptr;
default:
return false;
}
@@ -165,11 +165,11 @@ public:
switch (which) {
case EWhichModel::Normal:
return bool(x1c_normalModel);
return x1c_normalModel.HasReference();
case EWhichModel::XRay:
return bool(x2c_xrayModel);
return x2c_xrayModel.HasReference();
case EWhichModel::Thermal:
return bool(x3c_infraModel);
return x3c_infraModel.HasReference();
default:
return false;
}