Runtime: Use nullptr where applicable

Same behavior, but no magic 0 value.

While we're in the same area, we can do minor cosmetic changes.
This commit is contained in:
Lioncash 2020-03-27 20:11:51 -04:00
parent e0fe365dfd
commit 194cdf145f
6 changed files with 34 additions and 29 deletions

View File

@ -97,8 +97,10 @@ void CRasterFont::SinglePassDrawString(const CDrawStringOptions& opts, int x, in
if (opts.x0_direction == ETextDirection::Horizontal) {
x += glyph->GetLeftPadding();
if (prevGlyph != 0)
if (prevGlyph != nullptr) {
x += KernLookup(x1c_kerning, prevGlyph->GetKernStart(), *chr);
}
int left = 0;
int top = 0;

View File

@ -5,8 +5,9 @@
namespace urde {
void CFlameWarp::ModifyParticles(std::vector<CParticle>& particles) {
if (x9c_stateMgr == 0 || particles.size() < 9)
if (x9c_stateMgr == nullptr || particles.size() < 9) {
return;
}
std::vector<std::pair<float, u8>> vec;
vec.reserve(particles.size());

View File

@ -1785,36 +1785,35 @@ void CPlayerGun::UpdateGunIdle(bool inStrikeCooldown, float camBobT, float dt, C
void CPlayerGun::Update(float grappleSwingT, float cameraBobT, float dt, CStateManager& mgr) {
CPlayer& player = mgr.GetPlayer();
CPlayerState& playerState = *mgr.GetPlayerState();
bool isUnmorphed = player.GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Unmorphed;
const bool isUnmorphed = player.GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Unmorphed;
bool becameFrozen;
if (isUnmorphed)
bool becameFrozen = false;
if (isUnmorphed) {
becameFrozen = !x834_29_frozen && player.GetFrozenState();
else
becameFrozen = false;
}
bool becameThawed;
if (isUnmorphed)
bool becameThawed = false;
if (isUnmorphed) {
becameThawed = x834_29_frozen && !player.GetFrozenState();
else
becameThawed = false;
}
x834_29_frozen = isUnmorphed && player.GetFrozenState();
float advDt;
if (x834_29_frozen)
float advDt = dt;
if (x834_29_frozen) {
advDt = 0.f;
else
advDt = dt;
}
bool r23 = x678_morph.GetGunState() != CGunMorph::EGunState::OutWipeDone;
if (mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::XRay || r23)
const bool r23 = x678_morph.GetGunState() != CGunMorph::EGunState::OutWipeDone;
if (mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::XRay || r23) {
x6e0_rightHandModel.AdvanceAnimation(advDt, mgr, kInvalidAreaId, true);
if (r23 && x734_loadingBeam != 0 && x734_loadingBeam != x72c_currentBeam) {
}
if (r23 && x734_loadingBeam != nullptr && x734_loadingBeam != x72c_currentBeam) {
x744_auxWeapon->LoadIdle();
x734_loadingBeam->Update(advDt, mgr);
}
if (!x744_auxWeapon->IsLoaded())
if (!x744_auxWeapon->IsLoaded()) {
x744_auxWeapon->LoadIdle();
}
if (becameFrozen) {
x72c_currentBeam->EnableSecondaryFx(CGunWeapon::ESecondaryFxType::None);

View File

@ -233,7 +233,7 @@ public:
void RenderMorphBallTransitionFlash(const CStateManager&) const;
void UpdateIceBreakEffect(float dt);
void RenderIceBreakEffect(const CStateManager& mgr) const;
bool IsMorphBallTransitionFlashValid() const { return x19dc_morphBallTransitionFlashGen != 0; }
bool IsMorphBallTransitionFlashValid() const { return x19dc_morphBallTransitionFlashGen != nullptr; }
void RenderDamageEffects(const CStateManager& mgr, const zeus::CTransform& xf) const;
void UpdateHalfPipeStatus(CStateManager& mgr, float dt);
bool GetIsInHalfPipeMode() const { return x1df8_24_inHalfPipeMode; }

View File

@ -80,7 +80,7 @@ private:
u16 x1d0_sfx1;
u16 x1d2_sfx2;
u16 x1d4_sfx3;
CSfxHandle x1d8_sfxHandle = 0;
CSfxHandle x1d8_sfxHandle;
TLockedToken<CGenDescription> x1dc_particleGenDesc;
// TLockedToken<CGenDescription> x1e4_; both assign to x1dc_
std::unique_ptr<CElementGen> x1ec_particleGen1;

View File

@ -1013,15 +1013,18 @@ CEntity* ScriptLoader::LoadBeetle(CStateManager& mgr, CInputStream& in, int prop
}
CEntity* ScriptLoader::LoadHUDMemo(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
if (propCount != 5 && !EnsurePropertyCount(propCount, 6, "HUDMemo"))
return 0;
std::string name = mgr.HashInstanceName(in);
CHUDMemoParms hParms(in);
CScriptHUDMemo::EDisplayType displayType = CScriptHUDMemo::EDisplayType::MessageBox;
if (propCount == 6)
if (propCount != 5 && !EnsurePropertyCount(propCount, 6, "HUDMemo")) {
return nullptr;
}
const std::string name = mgr.HashInstanceName(in);
const CHUDMemoParms hParms(in);
auto displayType = CScriptHUDMemo::EDisplayType::MessageBox;
if (propCount == 6) {
displayType = CScriptHUDMemo::EDisplayType(in.readUint32Big());
CAssetId message = in.readUint32Big();
bool active = in.readBool();
}
const CAssetId message = in.readUint32Big();
const bool active = in.readBool();
return new CScriptHUDMemo(mgr.AllocateUniqueId(), name, info, hParms, displayType, message, active);
}