COmegaPirate/CPhazonHealingNodule/CPhazonPool: Remove usages of const_cast

This commit is contained in:
Luke Street 2020-04-09 20:15:25 -04:00
parent 6b814262fc
commit 3b0b3a39f9
6 changed files with 17 additions and 18 deletions

View File

@ -196,7 +196,7 @@ void COmegaPirate::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSta
CMaterialList includes = GetMaterialFilter().GetIncludeList(); CMaterialList includes = GetMaterialFilter().GetIncludeList();
platform->SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(includes, excludes)); platform->SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(includes, excludes));
xae4_platformVuln = *platform->GetDamageVulnerability(); xae4_platformVuln = *platform->GetDamageVulnerability();
xb54_platformColor = platform->GetDrawFlags().x4_color; // TODO does this work? xb54_platformColor = platform->GetDrawFlags().x4_color;
} else if (TCastToPtr<CScriptSound> sound = mgr.ObjectById(connId)) { } else if (TCastToPtr<CScriptSound> sound = mgr.ObjectById(connId)) {
xaa0_scriptSounds.emplace_back(connId, sound->GetName()); xaa0_scriptSounds.emplace_back(connId, sound->GetName());
} }
@ -432,15 +432,15 @@ void COmegaPirate::Faint(CStateManager& mgr, EStateMsg msg, float dt) {
if (xb4c_ < 4 && x9c8_ == 0 && xb58_ >= 2.5f) { if (xb4c_ < 4 && x9c8_ == 0 && xb58_ >= 2.5f) {
float alpha = std::max(xb50_, 1.f); float alpha = std::max(xb50_, 1.f);
float invAlpha = 1.f - alpha; float invAlpha = 1.f - alpha;
size_t uVar6 = 0; size_t idx = 0;
for (const auto& entry : x9dc_scriptPlatforms) { for (const auto& entry : x9dc_scriptPlatforms) {
if (auto platform = static_cast<CScriptPlatform*>(mgr.ObjectById(entry.first))) { if (auto platform = static_cast<CScriptPlatform*>(mgr.ObjectById(entry.first))) {
if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::XRay) { if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::XRay) {
if (xb4c_ > uVar6) { if (xb4c_ > idx) {
CModelFlags flags{5, 0, 3, zeus::skWhite}; CModelFlags flags{5, 0, 3, zeus::skWhite};
flags.addColor = zeus::skBlack; flags.addColor = zeus::skBlack;
platform->SetDrawFlags(flags); platform->SetDrawFlags(flags);
} else if (xb4c_ == uVar6) { } else if (xb4c_ == idx) {
if (!xb6e_) { if (!xb6e_) {
SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::None); SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::None);
xb6e_ = true; xb6e_ = true;
@ -455,7 +455,7 @@ void COmegaPirate::Faint(CStateManager& mgr, EStateMsg msg, float dt) {
platform->SetDrawFlags(flags); platform->SetDrawFlags(flags);
} }
} }
++uVar6; ++idx;
} }
if (xb50_ > 1.f) { if (xb50_ > 1.f) {
++xb4c_; ++xb4c_;
@ -569,23 +569,22 @@ void COmegaPirate::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum)
} }
} }
void COmegaPirate::Render(const CStateManager& mgr) const { void COmegaPirate::Render(CStateManager& mgr) {
const auto* mData = GetModelData(); auto* mData = GetModelData();
auto* animData = const_cast<CAnimData*>(mData->GetAnimationData()); auto* animData = mData->GetAnimationData();
CGraphics::SetModelMatrix(GetTransform() * zeus::CTransform::Scale(mData->GetScale())); CGraphics::SetModelMatrix(GetTransform() * zeus::CTransform::Scale(mData->GetScale()));
if (mgr.GetPlayerState()->GetCurrentVisor() != CPlayerState::EPlayerVisor::XRay && xa2c_ > 0.f) { if (mgr.GetPlayerState()->GetCurrentVisor() != CPlayerState::EPlayerVisor::XRay && xa2c_ > 0.f) {
auto& model = const_cast<CSkinnedModel&>(x9f0_);
const CModelFlags flags{5, 0, 3, zeus::CColor{1.f, xa2c_}}; const CModelFlags flags{5, 0, 3, zeus::CColor{1.f, xa2c_}};
animData->Render(model, flags, std::nullopt, nullptr); animData->Render(x9f0_, flags, std::nullopt, nullptr);
} }
if (x9a0_) { if (x9a0_) {
bool isXRay = mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::XRay; bool isXRay = mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::XRay;
if (isXRay) { if (isXRay) {
g_Renderer->SetWorldFog(ERglFogMode::None, 0.f, 1.f, zeus::skBlack); g_Renderer->SetWorldFog(ERglFogMode::None, 0.f, 1.f, zeus::skBlack);
const CModelFlags flags{5, 0, 1, zeus::CColor{1.f, 0.2f}}; const CModelFlags flags{5, 0, 1, zeus::CColor{1.f, 0.2f}};
auto& model = const_cast<CSkinnedModel&>(*animData->GetModelData().GetObj()); auto& model = *animData->GetModelData().GetObj();
animData->Render(model, flags, std::nullopt, nullptr); animData->Render(model, flags, std::nullopt, nullptr);
} }
CPatterned::Render(mgr); CPatterned::Render(mgr);

View File

@ -95,7 +95,7 @@ public:
void Think(float dt, CStateManager& mgr) override; void Think(float dt, CStateManager& mgr) override;
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override; void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override;
void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) override; void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) override;
void Render(const CStateManager& mgr) const override; void Render(CStateManager& mgr) override;
zeus::CVector3f GetOrbitPosition(const CStateManager& mgr) const override; zeus::CVector3f GetOrbitPosition(const CStateManager& mgr) const override;
void DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt) override; void DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt) override;
void PathFind(CStateManager& mgr, EStateMsg msg, float dt) override; void PathFind(CStateManager& mgr, EStateMsg msg, float dt) override;

View File

@ -133,7 +133,7 @@ void CPhazonHealingNodule::Patrol(CStateManager& mgr, EStateMsg msg, float dt) {
} }
} }
void CPhazonHealingNodule::Render(const CStateManager& mgr) const { void CPhazonHealingNodule::Render(CStateManager& mgr) {
if (x57c_particleElectric) { if (x57c_particleElectric) {
x57c_particleElectric->Render(); x57c_particleElectric->Render();
} }

View File

@ -25,7 +25,7 @@ public:
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override; void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override;
void DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt) override; void DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt) override;
void Render(const CStateManager& mgr) const override; void Render(CStateManager& mgr) override;
void Think(float dt, CStateManager& mgr) override; void Think(float dt, CStateManager& mgr) override;
void Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state) override; void Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state) override;

View File

@ -75,7 +75,7 @@ void CPhazonPool::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat
CScriptTrigger::AcceptScriptMsg(msg, uid, mgr); CScriptTrigger::AcceptScriptMsg(msg, uid, mgr);
} }
void CPhazonPool::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { void CPhazonPool::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) {
if (GetActive()) { if (GetActive()) {
if (x170_elementGen1) { if (x170_elementGen1) {
g_Renderer->AddParticleGen(*x170_elementGen1); g_Renderer->AddParticleGen(*x170_elementGen1);
@ -90,7 +90,7 @@ void CPhazonPool::AddToRenderer(const zeus::CFrustum& frustum, const CStateManag
std::optional<zeus::CAABox> CPhazonPool::GetTouchBounds() const { return CScriptTrigger::GetTouchBounds(); } std::optional<zeus::CAABox> CPhazonPool::GetTouchBounds() const { return CScriptTrigger::GetTouchBounds(); }
void CPhazonPool::Render(const CStateManager& mgr) const { void CPhazonPool::Render(CStateManager& mgr) {
CActor::Render(mgr); CActor::Render(mgr);
bool discard = x1a4_ < 0.25f; bool discard = x1a4_ < 0.25f;
const CModelFlags flags{5, 0, static_cast<u16>(discard ? 3 : 0), zeus::CColor{1.f, x1a4_}}; const CModelFlags flags{5, 0, static_cast<u16>(discard ? 3 : 0), zeus::CColor{1.f, x1a4_}};

View File

@ -42,9 +42,9 @@ public:
void Accept(IVisitor& visitor) override; void Accept(IVisitor& visitor) override;
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override; void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override;
void AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const override; void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) override;
[[nodiscard]] std::optional<zeus::CAABox> GetTouchBounds() const override; [[nodiscard]] std::optional<zeus::CAABox> GetTouchBounds() const override;
void Render(const CStateManager& mgr) const override; void Render(CStateManager& mgr) override;
void Think(float dt, CStateManager& mgr) override; void Think(float dt, CStateManager& mgr) override;
void Touch(CActor& actor, CStateManager& mgr) override; void Touch(CActor& actor, CStateManager& mgr) override;