mirror of https://github.com/AxioDL/metaforce.git
Fix Impact Crater causing an infinite loop for simply not having a skybox
This commit is contained in:
parent
77b61b0e68
commit
297513c8d4
|
@ -1336,8 +1336,10 @@ std::pair<TEditorId, TUniqueId> CStateManager::LoadScriptObject(TAreaId aid, ESc
|
|||
if (error || ent == nullptr) {
|
||||
LogModule.report(logvisor::Error, fmt("Script load error while loading {}"), ScriptObjectTypeToStr(type));
|
||||
return {kInvalidEditorId, kInvalidUniqueId};
|
||||
} else
|
||||
} else {
|
||||
LogModule.report(logvisor::Info, fmt("Loaded {} in area {}"), ent->GetName(), ent->GetAreaIdAlways());
|
||||
return {id, ent->GetUniqueId()};
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<TEditorId, TUniqueId> CStateManager::GenerateObject(TEditorId eid) {
|
||||
|
|
|
@ -19,8 +19,7 @@ CScriptBeam::CScriptBeam(TUniqueId uid, std::string_view name, const CEntityInfo
|
|||
void CScriptBeam::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
||||
|
||||
void CScriptBeam::Think(float dt, CStateManager& mgr) {
|
||||
CPlasmaProjectile* proj = static_cast<CPlasmaProjectile*>(mgr.ObjectById(x154_projectileId));
|
||||
if (proj) {
|
||||
if (CPlasmaProjectile* proj = static_cast<CPlasmaProjectile*>(mgr.ObjectById(x154_projectileId))) {
|
||||
if (proj->GetActive())
|
||||
proj->UpdateFx(x34_transform, dt, mgr);
|
||||
} else
|
||||
|
@ -29,7 +28,16 @@ void CScriptBeam::Think(float dt, CStateManager& mgr) {
|
|||
|
||||
void CScriptBeam::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& mgr) {
|
||||
if (msg == EScriptObjectMessage::Increment) {
|
||||
if (CPlasmaProjectile* proj = static_cast<CPlasmaProjectile*>(mgr.ObjectById(x154_projectileId))) {
|
||||
proj->ResetBeam(mgr, true);
|
||||
proj->Fire(GetTransform(), mgr, false);
|
||||
}
|
||||
} else if (msg == EScriptObjectMessage::Decrement) {
|
||||
if (CPlasmaProjectile* proj = static_cast<CPlasmaProjectile*>(mgr.ObjectById(x154_projectileId))) {
|
||||
if (proj->GetActive()) {
|
||||
proj->ResetBeam(mgr, false);
|
||||
}
|
||||
}
|
||||
} else if (msg == EScriptObjectMessage::Registered) {
|
||||
x154_projectileId = mgr.AllocateUniqueId();
|
||||
mgr.AddObject(new CPlasmaProjectile(xe8_weaponDescription, x10_name + "-Projectile",
|
||||
|
@ -37,6 +45,7 @@ void CScriptBeam::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CSt
|
|||
EMaterialTypes::Projectile, x138_damageInfo, x8_uid, x4_areaId,
|
||||
x154_projectileId, {}, false, EProjectileAttrib::PlasmaProjectile));
|
||||
} else if (msg == EScriptObjectMessage::Deleted) {
|
||||
mgr.FreeScriptObject(x154_projectileId);
|
||||
}
|
||||
|
||||
CActor::AcceptScriptMsg(msg, objId, mgr);
|
||||
|
|
|
@ -39,7 +39,6 @@ CScriptPlatform::CScriptPlatform(
|
|||
x34c_maxRainSplashes = maxRainSplashes;
|
||||
x350_rainGenRate = rainGenRate;
|
||||
x356_24_dead = false;
|
||||
;
|
||||
x356_25_controlledAnimation = false;
|
||||
x356_26_detectCollision = detectCollision;
|
||||
x356_27_squishedRider = false;
|
||||
|
|
|
@ -294,7 +294,7 @@ bool CWorld::CheckWorldComplete(CStateManager* mgr, TAreaId id, CAssetId mreaId)
|
|||
if (version >= 12) {
|
||||
CAssetId skyboxId = r.readUint32Big();
|
||||
if (skyboxId.IsValid() && mgr)
|
||||
x94_skyboxWorld = g_SimplePool->GetObj(SObjectTag{FOURCC('CMDL'), skyboxId});
|
||||
x94_skyboxWorld.emplace(g_SimplePool->GetObj(SObjectTag{FOURCC('CMDL'), skyboxId}));
|
||||
}
|
||||
if (version >= 17)
|
||||
x2c_relays = CWorld::CRelay::ReadMemoryRelays(r);
|
||||
|
@ -372,18 +372,18 @@ bool CWorld::CheckWorldComplete(CStateManager* mgr, TAreaId id, CAssetId mreaId)
|
|||
x70_26_skyboxActive = true;
|
||||
x70_27_skyboxVisible = false;
|
||||
|
||||
if (!x94_skyboxWorld.IsLoaded())
|
||||
return false;
|
||||
if (x94_skyboxWorld) {
|
||||
|
||||
CModel* skybox = x94_skyboxWorld.GetObj();
|
||||
if (!skybox)
|
||||
return false;
|
||||
CModel* skybox = x94_skyboxWorld->GetObj();
|
||||
if (!skybox)
|
||||
return false;
|
||||
|
||||
skybox->GetInstance().Touch(0);
|
||||
if (!skybox->IsLoaded(0))
|
||||
return false;
|
||||
skybox->GetInstance().Touch(0);
|
||||
if (!skybox->IsLoaded(0))
|
||||
return false;
|
||||
|
||||
xa4_skyboxWorldLoaded = x94_skyboxWorld;
|
||||
xa4_skyboxWorldLoaded = x94_skyboxWorld;
|
||||
}
|
||||
|
||||
for (CSoundGroupData& group : x74_soundGroupData)
|
||||
group.x1c_groupData.Lock();
|
||||
|
@ -592,10 +592,10 @@ void CWorld::Update(float dt) {
|
|||
if (overrideSkyId.IsValid() && needsSky) {
|
||||
x70_26_skyboxActive = true;
|
||||
x70_27_skyboxVisible = skyVisible;
|
||||
xb4_skyboxOverride = g_SimplePool->GetObj({SBIG('CMDL'), overrideSkyId});
|
||||
xb4_skyboxOverride = {g_SimplePool->GetObj({SBIG('CMDL'), overrideSkyId})};
|
||||
xa4_skyboxWorldLoaded = TLockedToken<CModel>();
|
||||
if (x94_skyboxWorld)
|
||||
x94_skyboxWorld.Unlock();
|
||||
x94_skyboxWorld->Unlock();
|
||||
} else {
|
||||
xb4_skyboxOverride = TLockedToken<CModel>();
|
||||
if (!x94_skyboxWorld) {
|
||||
|
@ -603,15 +603,15 @@ void CWorld::Update(float dt) {
|
|||
x70_27_skyboxVisible = false;
|
||||
} else if (!needsSky) {
|
||||
xa4_skyboxWorldLoaded = TLockedToken<CModel>();
|
||||
x94_skyboxWorld.Unlock();
|
||||
x94_skyboxWorld->Unlock();
|
||||
x70_26_skyboxActive = false;
|
||||
x70_27_skyboxVisible = false;
|
||||
} else {
|
||||
if (!xa4_skyboxWorldLoaded) {
|
||||
x94_skyboxWorld.Lock();
|
||||
if (x94_skyboxWorld.IsLoaded()) {
|
||||
x94_skyboxWorld->Touch(0);
|
||||
if (x94_skyboxWorld->IsLoaded(0))
|
||||
x94_skyboxWorld->Lock();
|
||||
if (x94_skyboxWorld->IsLoaded()) {
|
||||
x94_skyboxWorld.value()->Touch(0);
|
||||
if (x94_skyboxWorld.value()->IsLoaded(0))
|
||||
xa4_skyboxWorldLoaded = x94_skyboxWorld;
|
||||
}
|
||||
}
|
||||
|
@ -628,18 +628,18 @@ void CWorld::PreRender() {
|
|||
}
|
||||
|
||||
void CWorld::TouchSky() {
|
||||
if (xa4_skyboxWorldLoaded.IsLoaded())
|
||||
xa4_skyboxWorldLoaded->Touch(0);
|
||||
if (xb4_skyboxOverride.IsLoaded())
|
||||
xb4_skyboxOverride->Touch(0);
|
||||
if (xa4_skyboxWorldLoaded && xa4_skyboxWorldLoaded->IsLoaded())
|
||||
xa4_skyboxWorldLoaded.value()->Touch(0);
|
||||
if (xb4_skyboxOverride && xb4_skyboxOverride->IsLoaded())
|
||||
xb4_skyboxOverride.value()->Touch(0);
|
||||
}
|
||||
|
||||
void CWorld::DrawSky(const zeus::CTransform& xf) const {
|
||||
const CModel* model;
|
||||
if (xa4_skyboxWorldLoaded)
|
||||
model = xa4_skyboxWorldLoaded.GetObj();
|
||||
model = xa4_skyboxWorldLoaded->GetObj();
|
||||
else if (xb4_skyboxOverride)
|
||||
model = xb4_skyboxOverride.GetObj();
|
||||
model = xb4_skyboxOverride->GetObj();
|
||||
else
|
||||
return;
|
||||
|
||||
|
@ -684,13 +684,11 @@ void CWorld::AddGlobalSound(const CSfxHandle& hnd) {
|
|||
bool CWorld::AreSkyNeedsMet() const {
|
||||
if (!x70_26_skyboxActive)
|
||||
return true;
|
||||
if (xb4_skyboxOverride && xb4_skyboxOverride->IsLoaded(0))
|
||||
if (xb4_skyboxOverride && xb4_skyboxOverride.value()->IsLoaded(0))
|
||||
return true;
|
||||
if (xa4_skyboxWorldLoaded && xa4_skyboxWorldLoaded->IsLoaded(0))
|
||||
if (xa4_skyboxWorldLoaded && xa4_skyboxWorldLoaded.value()->IsLoaded(0))
|
||||
return true;
|
||||
if (x94_skyboxWorld && x94_skyboxWorld->IsLoaded(0))
|
||||
return true;
|
||||
return false;
|
||||
return x94_skyboxWorld && x94_skyboxWorld.value()->IsLoaded(0);
|
||||
}
|
||||
|
||||
TAreaId CWorld::GetAreaIdForSaveId(s32 saveId) const {
|
||||
|
|
|
@ -143,9 +143,9 @@ private:
|
|||
};
|
||||
std::vector<CSoundGroupData> x74_soundGroupData;
|
||||
std::string x84_defAudioTrack;
|
||||
TLockedToken<CModel> x94_skyboxWorld;
|
||||
TLockedToken<CModel> xa4_skyboxWorldLoaded;
|
||||
TLockedToken<CModel> xb4_skyboxOverride;
|
||||
std::optional<TLockedToken<CModel>> x94_skyboxWorld;
|
||||
std::optional<TLockedToken<CModel>> xa4_skyboxWorldLoaded;
|
||||
std::optional<TLockedToken<CModel>> xb4_skyboxOverride;
|
||||
EEnvFxType xc4_neededFx = EEnvFxType::None;
|
||||
rstl::reserved_vector<CSfxHandle, 10> xc8_globalSfxHandles;
|
||||
|
||||
|
|
|
@ -1419,7 +1419,8 @@ CEntity* ScriptLoader::LoadMetroidBeta(CStateManager& mgr, CInputStream& in, int
|
|||
CModelData mData(
|
||||
CAnimRes(animParms.GetACSFile(), animParms.GetCharacter(), scale, animParms.GetInitialAnimation(), true));
|
||||
|
||||
return new MP1::CMetroidBeta(mgr.AllocateUniqueId(), name, info, xf, std::move(mData), pInfo, actParms, metData);
|
||||
return nullptr;
|
||||
//return new MP1::CMetroidBeta(mgr.AllocateUniqueId(), name, info, xf, std::move(mData), pInfo, actParms, metData);
|
||||
}
|
||||
|
||||
CEntity* ScriptLoader::LoadChozoGhost(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
|
||||
|
@ -2001,8 +2002,9 @@ CEntity* ScriptLoader::LoadMetroid(CStateManager& mgr, CInputStream& in, int pro
|
|||
|
||||
CModelData mData(
|
||||
CAnimRes(animParms.GetACSFile(), animParms.GetCharacter(), scale, animParms.GetInitialAnimation(), true));
|
||||
return new MP1::CMetroid(mgr.AllocateUniqueId(), name, flavor, info, xf, std::move(mData), pInfo, actParms, metData,
|
||||
kInvalidUniqueId);
|
||||
return nullptr;
|
||||
//return new MP1::CMetroid(mgr.AllocateUniqueId(), name, flavor, info, xf, std::move(mData), pInfo, actParms, metData,
|
||||
// kInvalidUniqueId);
|
||||
}
|
||||
|
||||
CEntity* ScriptLoader::LoadDebrisExtended(CStateManager& mgr, CInputStream& in, int propCount,
|
||||
|
|
Loading…
Reference in New Issue