Fix CMemoryCardSys shutdown crash

This commit is contained in:
Phillip Stephens 2017-01-22 09:36:25 -08:00
parent eb955c53ec
commit 12c6163e32
9 changed files with 88 additions and 20 deletions

View File

@ -585,4 +585,10 @@ void CMemoryCardSys::CommitToDisk(kabufuda::ECardSlot port)
card.commit();
}
void CMemoryCardSys::Shutdown()
{
UnmountCard(kabufuda::ECardSlot::SlotA);
UnmountCard(kabufuda::ECardSlot::SlotB);
}
}

View File

@ -63,6 +63,7 @@ class CMemoryCardSys
std::vector<std::pair<ResId, CSaveWorldMemory>> xc_memoryWorlds; /* MLVL as key */
std::experimental::optional<std::vector<CSaveWorldIntermediate>> x1c_worldInter; /* used to be auto_ptr of vector */
std::vector<std::pair<ResId, CSaveWorld::EScanCategory>> x20_scanStates;
public:
static kabufuda::SystemString ResolveDolphinCardPath(kabufuda::ECardSlot slot);
@ -174,6 +175,7 @@ public:
static ECardResult FormatCard(kabufuda::ECardSlot port);
static void CommitToDisk(kabufuda::ECardSlot port);
static void Shutdown();
};
}

View File

@ -4,6 +4,8 @@
#include "CTexture.hpp"
#include "CModel.hpp"
#include "Particle/CParticleGen.hpp"
#include "Particle/CDecal.hpp"
#include "Particle/CElementGen.hpp"
#include "CMetroidModelInstance.hpp"
#include "Collision/CAreaOctTree.hpp"
@ -652,6 +654,8 @@ void CBooRenderer::SetThermal(bool thermal, float level, const zeus::CColor& col
x318_29_thermalVisor = thermal;
x2f0_thermalVisorLevel = level;
x2f4_thermColor = color;
CDecal::SetMoveRedToAlphaBuffer(false);
CElementGen::SetMoveRedToAlphaBuffer(false);
}
void CBooRenderer::SetThermalColdScale(float scale)
@ -680,6 +684,8 @@ void CBooRenderer::DoThermalBlendCold()
m_thermColdFilter.setShift(x2a8_thermalRand.Next() % 32);
m_thermColdFilter.draw();
CElementGen::SetMoveRedToAlphaBuffer(true);
CDecal::SetMoveRedToAlphaBuffer(true);
}
void CBooRenderer::DoThermalBlendHot()

View File

@ -66,6 +66,7 @@ void CGameArchitectureSupport::UpdateTicks()
void CGameArchitectureSupport::Update()
{
g_GameState->GetWorldTransitionManager()->TouchModels();
x30_inputGenerator.Update(1 / 60.f, x4_archQueue);
x4_archQueue.Push(MakeMsg::CreateFrameBegin(EArchMsgTarget::Game, x78_));
x58_ioWinManager.PumpMessages(x4_archQueue);
}
@ -282,6 +283,7 @@ void CMain::ShutdownSubsystems()
CDecalManager::Shutdown();
CElementGen::Shutdown();
CAnimData::FreeCache();
CMemoryCardSys::Shutdown();
}
void CMain::Shutdown()

View File

@ -2,6 +2,8 @@
namespace urde
{
CRandom16 CDecal::sDecalRandom(99);
bool CDecal::sMoveRedToAphaBuffer = false;
CDecal::CDecal(const TToken<CDecalDescription>& desc, const zeus::CTransform& xf)
: x0_description(desc),
@ -11,11 +13,25 @@ CDecal::CDecal(const TToken<CDecalDescription>& desc, const zeus::CTransform& xf
{
CGlobalRandom gr(sDecalRandom);
InitQuad(x3c_decalQuad1, x0_description.GetObj()->x0_Quad);
InitQuad(x48_decalQuad2, x0_description.GetObj()->x1c_Quad);
x5c_31_quad1Invalid = InitQuad(x3c_decalQuad1, x0_description.GetObj()->x0_Quad);
x5c_30_quad2Invalid = InitQuad(x48_decalQuad2, x0_description.GetObj()->x1c_Quad);
CDecalDescription* d = x0_description.GetObj();
if (d->x38_DMDL)
{
if (d->x48_DLFT)
d->x48_DLFT->GetValue(0, x54_lifetime);
else
x54_lifetime = 0x7FFFFF;
if (d->x50_DMRT)
d->x50_DMRT->GetValue(0, x60_rotation);
}
else
x5c_29_modelInvalid = true;
}
void CDecal::InitQuad(CDecal::CQuadDecal& quad, const CDecalDescription::SQuadDescr& desc)
bool CDecal::InitQuad(CDecal::CQuadDecal& quad, const CDecalDescription::SQuadDescr& desc)
{
if (desc.x14_TEX)
{
@ -26,18 +42,34 @@ void CDecal::InitQuad(CDecal::CQuadDecal& quad, const CDecalDescription::SQuadDe
if (desc.x8_ROT)
{
desc.x8_ROT->GetValue(0, quad.x8_rotation);
u32 r0 = (quad._dummy >> 25) & 1;
r0 &= desc.x8_ROT->IsConstant();
quad._dummy = (quad._dummy & ~0x80) | ((r0 << 7) & 0x80);
quad.x0_24_invalid = desc.x8_ROT->IsConstant();
}
if (desc.x4_SZE)
{
quad.x0_24_invalid = desc.x4_SZE->IsConstant();
float size = 1.f;
desc.x4_SZE->GetValue(0, size);
quad.x0_24_invalid = size <= 1.f;
}
if (desc.xc_OFF)
quad.x0_24_invalid = desc.xc_OFF->IsFastConstant();
return false;
}
else
quad.x0_24_ = false;
quad.x0_24_invalid = false;
return true;
}
void CDecal::SetGlobalSeed(u16 seed)
{
sDecalRandom.SetSeed(seed);
}
void CDecal::SetMoveRedToAlphaBuffer(bool move)
{
sMoveRedToAphaBuffer = move;
}
}

View File

@ -18,7 +18,7 @@ public:
{
struct
{
bool x0_24_ : 1;
bool x0_24_invalid : 1;
};
u32 _dummy = 0;
};
@ -28,7 +28,7 @@ public:
: x4_lifetime(i),
x8_rotation(f)
{
x0_24_ = true;
x0_24_invalid = true;
}
};
private:
@ -39,11 +39,20 @@ private:
zeus::CTransform xc_transform;
CQuadDecal x3c_decalQuad1;
CQuadDecal x48_decalQuad2;
u32 x54_ = 0;
u32 x58_ = 0;
u32 x5c_ = 0;
zeus::CVector3f x60_;
void InitQuad(CQuadDecal&, const CDecalDescription::SQuadDescr&);
s32 x54_lifetime = 0;
s32 x58_frameIdx = 0;
union
{
struct
{
bool x5c_31_quad1Invalid : 1;
bool x5c_30_quad2Invalid : 1;
bool x5c_29_modelInvalid : 1;
};
u32 x5c_dummy = 0;
};
zeus::CVector3f x60_rotation;
bool InitQuad(CQuadDecal&, const CDecalDescription::SQuadDescr&);
public:
CDecal(const TToken<CDecalDescription>&, const zeus::CTransform&);
bool IsDone() const;

View File

@ -21,7 +21,7 @@ int CElementGen::g_ParticleAliveCount;
int CElementGen::g_ParticleSystemAliveCount;
s32 CElementGen::g_FreeIndex;
bool CElementGen::g_StaticListInitialized = false;
bool CElementGen::g_MoveRedToAlphaBuffer = false;
bool CElementGen::sMoveRedToAlphaBuffer = false;
CElementGen::CParticle* CElementGen::g_currentParticle = nullptr;
static rstl::reserved_vector<CElementGen::CParticle, MAX_GLOBAL_PARTICLES> g_StaticParticleList;
static rstl::reserved_vector<u16, MAX_GLOBAL_PARTICLES> g_StaticFreeList;
@ -1273,7 +1273,7 @@ void CElementGen::RenderModels()
if (desc->x45_24_x31_26_PMUS)
{
if (g_MoveRedToAlphaBuffer && desc->x44_31_x31_25_PMAB && desc->x54_x40_TEXR)
if (sMoveRedToAlphaBuffer && desc->x44_31_x31_25_PMAB && desc->x54_x40_TEXR)
moveRedToAlphaBuffer = true;
if (desc->x44_31_x31_25_PMAB)
@ -1638,7 +1638,7 @@ void CElementGen::RenderParticles()
}
bool moveRedToAlphaBuffer = false;
if (g_MoveRedToAlphaBuffer && x224_26_AAPH)
if (sMoveRedToAlphaBuffer && x224_26_AAPH)
moveRedToAlphaBuffer = true;
if (moveRedToAlphaBuffer)
@ -2321,4 +2321,9 @@ void CElementGen::Reset()
x225_28_warmedUp = false;
}
void CElementGen::SetMoveRedToAlphaBuffer(bool move)
{
sMoveRedToAlphaBuffer = move;
}
}

View File

@ -172,7 +172,7 @@ public:
static bool g_StaticListInitialized;
static int g_ParticleAliveCount;
static int g_ParticleSystemAliveCount;
static bool g_MoveRedToAlphaBuffer;
static bool sMoveRedToAlphaBuffer;
static void Initialize();
static void Shutdown();
@ -239,6 +239,8 @@ public:
bool GetParticleEmission() const;
void DestroyParticles();
void Reset();
static void SetMoveRedToAlphaBuffer(bool);
};
ENABLE_BITWISE_ENUM(CElementGen::EOptionalSystemFlags)

View File

@ -31,6 +31,7 @@ struct SParticleModel
SParticleModel() = default;
SParticleModel(CToken&& tok, bool found)
: m_token(std::move(tok)), m_found(found) {}
operator bool() const { return m_found; }
};
struct SChildGeneratorDesc
@ -41,6 +42,7 @@ struct SChildGeneratorDesc
SChildGeneratorDesc() = default;
SChildGeneratorDesc(CToken&& tok, bool found)
: m_token(std::move(tok)), m_found(found) {}
operator bool() const { return m_found; }
};
struct SSwooshGeneratorDesc
@ -51,6 +53,7 @@ struct SSwooshGeneratorDesc
SSwooshGeneratorDesc() = default;
SSwooshGeneratorDesc(CToken&& tok, bool found)
: m_token(std::move(tok)), m_found(found) {}
operator bool() const { return m_found; }
};
struct SElectricGeneratorDesc
@ -61,6 +64,7 @@ struct SElectricGeneratorDesc
SElectricGeneratorDesc() = default;
SElectricGeneratorDesc(CToken&& tok, bool found)
: m_token(std::move(tok)), m_found(found) {}
operator bool() const { return m_found; }
};
class CParticleDataFactory