2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 14:24:56 +00:00

Numerous uninitialized memory fixes

This commit is contained in:
Jack Andersen
2019-04-06 19:14:48 -10:00
parent b72cc490e8
commit 3a0d2930fa
48 changed files with 112 additions and 79 deletions

View File

@@ -604,12 +604,14 @@ void CSfxManager::Update(float dt) {
}
}
#ifndef URDE_MSAN
for (const CSfxHandle& handle : chanObj.x48_handles) {
if (handle->IsPlaying())
continue;
if (handle->Ready() && handle->IsInArea())
handle->Play();
}
#endif
m_doUpdate = false;
}

View File

@@ -113,8 +113,8 @@ public:
, x14_26_looped(looped)
, x14_27_inArea(true)
, x14_28_isReleased(false)
, m_isClosed(false)
, x14_29_useAcoustics(useAcoustics) {}
, x14_29_useAcoustics(useAcoustics)
, m_isClosed(false) {}
};
class CSfxEmitterWrapper : public CBaseSfxWrapper {

View File

@@ -129,10 +129,10 @@ public:
static const CArchMsgParmVoidPtr& GetParmDeleteIOWin(const CArchitectureMessage& msg) {
return *msg.GetParm<CArchMsgParmVoidPtr>();
}
static CArchitectureMessage CreateFrameBegin(EArchMsgTarget target, const s32& a) {
static CArchitectureMessage CreateFrameBegin(EArchMsgTarget target, s32 a) {
return CArchitectureMessage(target, EArchMsgType::FrameBegin, std::make_shared<CArchMsgParmInt32>(a));
}
static CArchitectureMessage CreateFrameEnd(EArchMsgTarget target, const s32& a) {
static CArchitectureMessage CreateFrameEnd(EArchMsgTarget target, s32 a) {
return CArchitectureMessage(target, EArchMsgType::FrameEnd, std::make_shared<CArchMsgParmInt32>(a));
}
/* URDE Messages */

View File

@@ -6,6 +6,7 @@
#include <thread>
#include <mutex>
#include <condition_variable>
#include <unordered_map>
namespace urde {

View File

@@ -13,6 +13,7 @@ public:
float x0_fadeIn, x4_fadeOut, x8_volume;
std::string xc_fileName;
CAssetId x1c_res;
Audio() = default;
Audio(float fadeIn, float fadeOut, float vol, std::string_view fileName, u32 handle)
: x0_fadeIn(fadeIn), x4_fadeOut(fadeOut), x8_volume(vol), xc_fileName(fileName), x1c_res(handle) {}
float GetFadeIn() const { return x0_fadeIn; }

View File

@@ -992,7 +992,7 @@ bool CStateManager::GetVisSetForArea(TAreaId a, TAreaId b, CPVSVisSet& setOut) c
TAreaId connArea = dock.GetConnectedAreaId(i);
if (connArea == a) {
const auto& verts = dock.GetPlaneVertices();
zeus::CVector3f dockCenter = (verts[0] + verts[1] + verts[2] + verts[4]) * 0.25f;
zeus::CVector3f dockCenter = (verts[0] + verts[1] + verts[2] + verts[3]) * 0.25f;
if (hasClosestDock)
if ((dockCenter - viewPoint).magSquared() >= (closestDockPoint - viewPoint).magSquared())
continue;

View File

@@ -96,8 +96,7 @@ CSequenceFundamentals CSequenceHelper::ComputeSequenceFundamentals() {
}
if (i < x10_treeNodes.size() - 1) {
node = CTreeUtils::GetTransitionTree(node, CAnimTreeNode::Cast(std::move(x10_treeNodes[i + 1]->Clone())),
x0_animCtx);
node = CTreeUtils::GetTransitionTree(node, CAnimTreeNode::Cast(x10_treeNodes[i + 1]->Clone()), x0_animCtx);
}
}
}

View File

@@ -44,7 +44,6 @@ public:
public:
CNode() = default;
CNode(const CNode&) = default;
CNode(const zeus::CTransform&, const zeus::CVector3f&, std::unique_ptr<CNode>&&, std::unique_ptr<CNode>&&,
std::unique_ptr<CLeafData>&&);
CNode(CInputStream&);

View File

@@ -48,6 +48,7 @@ CHudVisorBeamMenu::CHudVisorBeamMenu(CGuiFrame& baseHud, EHudVisorBeamMenu type,
x24_model_ghost = static_cast<CGuiModel*>(x0_baseHud.FindWidget(hecl::Format("%sghost", ModelNames[int(x4_type)])));
x28_menuItems.resize(4);
for (int i = 0; i < 4; ++i) {
SMenuItem& item = x28_menuItems[i];
item.x0_model_loz = static_cast<CGuiModel*>(

View File

@@ -6,7 +6,7 @@
namespace urde {
CRasterFont::CRasterFont(urde::CInputStream& in, urde::IObjectStore& store) {
u32 magic;
u32 magic = 0;
in.readBytesToBuf(&magic, 4);
if (magic != SBIG('FONT'))
return;

View File

@@ -153,10 +153,10 @@ struct CFinalInput {
CFinalInput ScaleAnalogueSticks(float leftDiv, float rightDiv) const;
bool PKey(char k) const { return m_kbm && m_PCharKeys[k]; }
bool PKey(char k) const { return m_kbm && m_PCharKeys[int(k)]; }
bool PSpecialKey(boo::ESpecialKey k) const { return m_kbm && m_PSpecialKeys[int(k)]; }
bool PMouseButton(boo::EMouseButton k) const { return m_kbm && m_PMouseButtons[int(k)]; }
bool DKey(char k) const { return m_kbm && m_kbm->m_charKeys[k]; }
bool DKey(char k) const { return m_kbm && m_kbm->m_charKeys[int(k)]; }
bool DSpecialKey(boo::ESpecialKey k) const { return m_kbm && m_kbm->m_specialKeys[int(k)]; }
bool DMouseButton(boo::EMouseButton k) const { return m_kbm && m_kbm->m_mouseButtons[int(k)]; }
bool AKey(char k) const { return DKey(k) ? 1.f : 0.f; }

View File

@@ -127,7 +127,7 @@ class CGameArchitectureSupport
CInputGenerator x30_inputGenerator;
CGuiSys x44_guiSys;
CIOWinManager x58_ioWinManager;
s32 x78_gameFrameCount;
s32 x78_gameFrameCount = 0;
enum class EAudioLoadStatus { Loading, Loaded, Uninitialized };
EAudioLoadStatus x88_audioLoadStatus = EAudioLoadStatus::Uninitialized;

View File

@@ -51,7 +51,7 @@ public:
void Think(float, CStateManager&);
const CDamageVulnerability* GetDamageVulnerability() const;
EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&,
const CWeaponMode& mode) const {
const CWeaponMode& mode, EProjectileAttrib) const {
return GetDamageVulnerability()->WeaponHits(mode, false) ? EWeaponCollisionResponseTypes::AtomicBeta
: EWeaponCollisionResponseTypes::AtomicBetaReflect;
}

View File

@@ -13,12 +13,11 @@ CFlickerBat::CFlickerBat(TUniqueId uid, std::string_view name, CPatterned::EFlav
EColliderType colType, bool b1, const CActorParameters& actParms, bool b2)
: CPatterned(ECharacter::FlickerBat, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Flyer,
colType, EBodyType::Pitchable, actParms, EKnockBackVariant::Small)
, x574_state(EFlickerBatState(b1))
, x580_24_wasInXray(false)
, x580_25_heardShot(false)
, x580_26_inLOS(false)
, x580_27_enableLOSCheck(b2)
, x574_state(EFlickerBatState(b1)) {
, x580_27_enableLOSCheck(b2) {
SetupPlayerCollision(b1);
x3d8_xDamageThreshold = 0.f;
x402_27_noXrayModel = false;
@@ -140,7 +139,7 @@ void CFlickerBat::Death(CStateManager& mgr, const zeus::CVector3f& direction, ES
CPatterned::Death(mgr, direction, state);
}
bool CFlickerBat::CanBeShot(CStateManager& mgr, int) {
bool CFlickerBat::CanBeShot(const CStateManager& mgr, int) {
return (GetFlickerBatState() == EFlickerBatState::Visible || GetFlickerBatState() == EFlickerBatState::FadeIn ||
mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::XRay);
}

View File

@@ -35,7 +35,7 @@ public:
void Touch(CActor&, CStateManager&);
void DoUserAnimEvent(CStateManager&, const CInt32POINode&, EUserEventType, float dt);
void Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state);
bool CanBeShot(CStateManager&, int);
bool CanBeShot(const CStateManager&, int);
void Patrol(CStateManager&, EStateMsg, float);
void Attack(CStateManager&, EStateMsg, float);
void Shuffle(CStateManager&, EStateMsg, float);

View File

@@ -31,8 +31,8 @@ CPuddleSpore::CPuddleSpore(TUniqueId uid, std::string_view name, EFlavorType fla
, x590_halfExtent(pInfo.GetHalfExtent())
, x594_height(pInfo.GetHeight())
, x5a0_(CalculateBoundingBox(), GetMaterialList())
, x5ec_projectileInfo(weapon, dInfo)
, x5d0_(g_SimplePool->GetObj({SBIG('PART'), glowFx}))
, x5ec_projectileInfo(weapon, dInfo)
, x614_24(false)
, x614_25(false) {
x5dc_elemGens.reserve(kEyeCount);

View File

@@ -86,7 +86,7 @@ void CPuffer::Touch(CActor& act, CStateManager& mgr) {
x401_30_pendingDeath = true;
}
void CPuffer::Death(CStateManager& mgr, zeus::CVector3f& vec, EScriptObjectState state) {
void CPuffer::Death(CStateManager& mgr, const zeus::CVector3f& vec, EScriptObjectState state) {
CPatterned::Death(mgr, vec, state);
mgr.ApplyDamageToWorld(GetUniqueId(), *this, GetTranslation(), x59c_explosionDamage,
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}));

View File

@@ -33,6 +33,6 @@ public:
void Think(float, CStateManager&);
rstl::optional<zeus::CAABox> GetTouchBounds() const;
void Touch(CActor&, CStateManager&);
void Death(CStateManager&, zeus::CVector3f&, EScriptObjectState);
void Death(CStateManager&, const zeus::CVector3f&, EScriptObjectState);
};
} // namespace urde::MP1

View File

@@ -33,7 +33,7 @@ public:
bool x5c_24_DMAB : 1;
bool x5c_25_DMOO : 1;
};
u8 dummy = 0;
u32 dummy = 0;
};
};

View File

@@ -30,6 +30,6 @@ public:
SSwooshGeneratorDesc x40_SSWH;
SChildGeneratorDesc x50_GPSM;
SChildGeneratorDesc x60_EPSM;
bool x70_ZERY;
bool x70_ZERY = false;
};
} // namespace urde

View File

@@ -60,7 +60,7 @@ public:
bool x30_30_ORNT : 1;
bool x30_31_RSOP : 1;
};
uint32_t dummy1 = 0;
u32 dummy1 = 0;
};
std::unique_ptr<CIntElement> x48_x34_MBSP;
std::unique_ptr<CRealElement> x4c_x38_SIZE;

View File

@@ -22,7 +22,7 @@ bool CParticleDataFactory::GetBool(CInputStream& in) {
}
FourCC CParticleDataFactory::GetClassID(CInputStream& in) {
uint32_t val;
u32 val = 0;
in.readBytesToBuf(&val, 4);
return val;
}

View File

@@ -42,7 +42,7 @@ public:
bool x45_25_ORNT : 1;
bool x45_26_CRND : 1;
};
u16 dummy = 0;
u32 dummy = 0;
};
CSwooshDescription() { x44_25_CROS = true; }

View File

@@ -24,19 +24,19 @@ public:
std::unique_ptr<CVectorElement> x4_IVEC;
std::unique_ptr<CVectorElement> x8_PSOV;
std::unique_ptr<CModVectorElement> xc_PSVM;
bool x10_VMD2;
bool x10_VMD2 = false;
std::unique_ptr<CIntElement> x14_PSLT;
std::unique_ptr<CVectorElement> x18_PSCL;
std::unique_ptr<CColorElement> x1c_PCOL;
std::unique_ptr<CVectorElement> x20_POFS;
std::unique_ptr<CVectorElement> x24_OFST;
bool x28_APSO;
bool x29_HOMG;
bool x2a_AP11;
bool x2b_AP21;
bool x2c_AS11;
bool x2d_AS12;
bool x2e_AS13;
bool x28_APSO = false;
bool x29_HOMG = false;
bool x2a_AP11 = false;
bool x2b_AP21 = false;
bool x2c_AS11 = false;
bool x2d_AS12 = false;
bool x2e_AS13 = false;
std::unique_ptr<CRealElement> x30_TRAT;
SChildGeneratorDesc x34_APSM;
SChildGeneratorDesc x44_APS2;

View File

@@ -165,3 +165,9 @@ struct hash<urde::CAssetId> {
size_t operator()(const urde::CAssetId& id) const noexcept { return id.Value(); }
};
} // namespace std
#if defined(__has_feature)
#if __has_feature(memory_sanitizer)
#define URDE_MSAN 1
#endif
#endif

View File

@@ -110,14 +110,14 @@ zeus::CPlane CFishCloud::FindClosestPlane(const zeus::CAABox& aabb, const zeus::
zeus::CAABox::EBoxFaceId minFace = zeus::CAABox::EBoxFaceId::YMin;
for (int i = 0; i < 6; ++i) {
auto tri = aabb.getTri(zeus::CAABox::EBoxFaceId(i), 0);
float dist = zeus::CPlane(tri.x10_[0], tri.x10_[2], tri.x10_[1]).pointToPlaneDist(point);
float dist = zeus::CPlane(tri.x10_verts[0], tri.x10_verts[2], tri.x10_verts[1]).pointToPlaneDist(point);
if (dist >= 0.f && dist < minDist) {
minDist = dist;
minFace = zeus::CAABox::EBoxFaceId(i);
}
}
auto tri = aabb.getTri(minFace, 0);
return zeus::CPlane(tri.x10_[0], tri.x10_[2], tri.x10_[1]);
return zeus::CPlane(tri.x10_verts[0], tri.x10_verts[2], tri.x10_verts[1]);
} else {
auto unPoint = GetTransform().transposeRotate(point - GetTranslation());
auto unAabb = GetUntransformedBoundingBox();
@@ -125,14 +125,16 @@ zeus::CPlane CFishCloud::FindClosestPlane(const zeus::CAABox& aabb, const zeus::
zeus::CAABox::EBoxFaceId minFace = zeus::CAABox::EBoxFaceId::YMin;
for (int i = 0; i < 6; ++i) {
auto tri = unAabb.getTri(zeus::CAABox::EBoxFaceId(i), 0);
float dist = zeus::CPlane(tri.x10_[0], tri.x10_[2], tri.x10_[1]).pointToPlaneDist(unPoint);
float dist = zeus::CPlane(tri.x10_verts[0], tri.x10_verts[2], tri.x10_verts[1]).pointToPlaneDist(unPoint);
if (dist >= 0.f && dist < minDist) {
minDist = dist;
minFace = zeus::CAABox::EBoxFaceId(i);
}
}
auto tri = unAabb.getTri(minFace, 0);
return zeus::CPlane(GetTransform() * tri.x10_[0], GetTransform() * tri.x10_[2], GetTransform() * tri.x10_[1]);
return zeus::CPlane(GetTransform() * tri.x10_verts[0],
GetTransform() * tri.x10_verts[2],
GetTransform() * tri.x10_verts[1]);
}
}

View File

@@ -105,8 +105,8 @@ protected:
float x240_stepDownHeight;
float x244_restitutionCoefModifier = 0.f;
float x248_collisionAccuracyModifier = 1.f;
u32 x24c_numTicksStuck;
u32 x250_numTicksPartialUpdate;
u32 x24c_numTicksStuck = 0;
u32 x250_numTicksPartialUpdate = 0;
public:
CPhysicsActor(TUniqueId, bool, std::string_view, const CEntityInfo&, const zeus::CTransform&, CModelData&&,

View File

@@ -261,7 +261,7 @@ private:
EFootstepSfx x790_footstepSfxSel = EFootstepSfx::None;
zeus::CVector3f x794_lastVelocity;
CVisorSteam x7a0_visorSteam = CVisorSteam(0.f, 0.f, 0.f, CAssetId() /*kInvalidAssetId*/);
CPlayerState::EPlayerSuit x7cc_transitionSuit;
CPlayerState::EPlayerSuit x7cc_transitionSuit = CPlayerState::EPlayerSuit::Invalid;
CAnimRes x7d0_animRes;
zeus::CVector3f x7d8_beamScale;
bool x7e4_ = true;

View File

@@ -18,7 +18,6 @@ class CProjectedShadow {
float x98_ = 1.f;
public:
CProjectedShadow() = default;
CProjectedShadow(u32, u32, bool);
zeus::CAABox CalculateRenderBounds();

View File

@@ -53,7 +53,7 @@ void CScriptEMPulse::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CS
}
}
void CScriptEMPulse::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) const {
void CScriptEMPulse::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const {
CActor::AddToRenderer(frustum, mgr);
if (GetActive())
g_Renderer->AddParticleGen(*x114_particleGen);

View File

@@ -26,7 +26,7 @@ public:
void Accept(IVisitor&);
void Think(float, CStateManager&);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
void AddToRenderer(const zeus::CFrustum&, CStateManager&) const;
void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const;
void CalculateRenderBounds();
rstl::optional<zeus::CAABox> GetTouchBounds() const;
void Touch(CActor&, CStateManager&);

View File

@@ -16,7 +16,7 @@ class CWorldShadow {
float x64_objHalfExtent = 1.f;
zeus::CVector3f x68_objPos = {0.f, 1.f, 0.f};
zeus::CVector3f x74_lightPos;
TAreaId x80_aid;
TAreaId x80_aid = kInvalidAreaId;
s32 x84_lightIdx = -1;
bool x88_blurReset = true;
#if CWORLDSHADOW_FEEDBACK

View File

@@ -21,7 +21,7 @@ public:
u32 x0_referenceCount = 0;
std::vector<SDockReference> x4_dockReferences;
rstl::reserved_vector<zeus::CVector3f, 4> x14_planeVertices;
bool x48_isReferenced;
bool x48_isReferenced = false;
public:
const rstl::reserved_vector<zeus::CVector3f, 4>& GetPlaneVertices() const { return x14_planeVertices; }

View File

@@ -1701,7 +1701,7 @@ CEntity* ScriptLoader::LoadDistanceFog(CStateManager& mgr, CInputStream& in, int
rangeDelta.readBig(in);
bool expl = in.readBool();
bool active = in.readBool();
ERglFogMode realMode;
ERglFogMode realMode = ERglFogMode::None;
if (mode == 0)
realMode = ERglFogMode::None;

View File

@@ -477,8 +477,20 @@ public:
const_reverse_iterator crbegin() const noexcept { return rbegin(); }
const_reverse_iterator crend() const noexcept { return rend(); }
T& operator[](size_t idx) { return _value(idx); }
const T& operator[](size_t idx) const { return _value(idx); }
T& operator[](size_t idx) {
#ifndef NDEBUG
if (idx >= x0_size)
Log.report(logvisor::Fatal, "out of bounds access on reserved_vector.");
#endif
return _value(idx);
}
const T& operator[](size_t idx) const {
#ifndef NDEBUG
if (idx >= x0_size)
Log.report(logvisor::Fatal, "out of bounds access on reserved_vector.");
#endif
return _value(idx);
}
};
/**