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) {
|
if (error || ent == nullptr) {
|
||||||
LogModule.report(logvisor::Error, fmt("Script load error while loading {}"), ScriptObjectTypeToStr(type));
|
LogModule.report(logvisor::Error, fmt("Script load error while loading {}"), ScriptObjectTypeToStr(type));
|
||||||
return {kInvalidEditorId, kInvalidUniqueId};
|
return {kInvalidEditorId, kInvalidUniqueId};
|
||||||
} else
|
} else {
|
||||||
|
LogModule.report(logvisor::Info, fmt("Loaded {} in area {}"), ent->GetName(), ent->GetAreaIdAlways());
|
||||||
return {id, ent->GetUniqueId()};
|
return {id, ent->GetUniqueId()};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<TEditorId, TUniqueId> CStateManager::GenerateObject(TEditorId eid) {
|
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::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
||||||
|
|
||||||
void CScriptBeam::Think(float dt, CStateManager& mgr) {
|
void CScriptBeam::Think(float dt, CStateManager& mgr) {
|
||||||
CPlasmaProjectile* proj = static_cast<CPlasmaProjectile*>(mgr.ObjectById(x154_projectileId));
|
if (CPlasmaProjectile* proj = static_cast<CPlasmaProjectile*>(mgr.ObjectById(x154_projectileId))) {
|
||||||
if (proj) {
|
|
||||||
if (proj->GetActive())
|
if (proj->GetActive())
|
||||||
proj->UpdateFx(x34_transform, dt, mgr);
|
proj->UpdateFx(x34_transform, dt, mgr);
|
||||||
} else
|
} else
|
||||||
|
@ -29,7 +28,16 @@ void CScriptBeam::Think(float dt, CStateManager& mgr) {
|
||||||
|
|
||||||
void CScriptBeam::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& mgr) {
|
void CScriptBeam::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& mgr) {
|
||||||
if (msg == EScriptObjectMessage::Increment) {
|
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) {
|
} 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) {
|
} else if (msg == EScriptObjectMessage::Registered) {
|
||||||
x154_projectileId = mgr.AllocateUniqueId();
|
x154_projectileId = mgr.AllocateUniqueId();
|
||||||
mgr.AddObject(new CPlasmaProjectile(xe8_weaponDescription, x10_name + "-Projectile",
|
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,
|
EMaterialTypes::Projectile, x138_damageInfo, x8_uid, x4_areaId,
|
||||||
x154_projectileId, {}, false, EProjectileAttrib::PlasmaProjectile));
|
x154_projectileId, {}, false, EProjectileAttrib::PlasmaProjectile));
|
||||||
} else if (msg == EScriptObjectMessage::Deleted) {
|
} else if (msg == EScriptObjectMessage::Deleted) {
|
||||||
|
mgr.FreeScriptObject(x154_projectileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
CActor::AcceptScriptMsg(msg, objId, mgr);
|
CActor::AcceptScriptMsg(msg, objId, mgr);
|
||||||
|
|
|
@ -39,7 +39,6 @@ CScriptPlatform::CScriptPlatform(
|
||||||
x34c_maxRainSplashes = maxRainSplashes;
|
x34c_maxRainSplashes = maxRainSplashes;
|
||||||
x350_rainGenRate = rainGenRate;
|
x350_rainGenRate = rainGenRate;
|
||||||
x356_24_dead = false;
|
x356_24_dead = false;
|
||||||
;
|
|
||||||
x356_25_controlledAnimation = false;
|
x356_25_controlledAnimation = false;
|
||||||
x356_26_detectCollision = detectCollision;
|
x356_26_detectCollision = detectCollision;
|
||||||
x356_27_squishedRider = false;
|
x356_27_squishedRider = false;
|
||||||
|
|
|
@ -294,7 +294,7 @@ bool CWorld::CheckWorldComplete(CStateManager* mgr, TAreaId id, CAssetId mreaId)
|
||||||
if (version >= 12) {
|
if (version >= 12) {
|
||||||
CAssetId skyboxId = r.readUint32Big();
|
CAssetId skyboxId = r.readUint32Big();
|
||||||
if (skyboxId.IsValid() && mgr)
|
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)
|
if (version >= 17)
|
||||||
x2c_relays = CWorld::CRelay::ReadMemoryRelays(r);
|
x2c_relays = CWorld::CRelay::ReadMemoryRelays(r);
|
||||||
|
@ -372,18 +372,18 @@ bool CWorld::CheckWorldComplete(CStateManager* mgr, TAreaId id, CAssetId mreaId)
|
||||||
x70_26_skyboxActive = true;
|
x70_26_skyboxActive = true;
|
||||||
x70_27_skyboxVisible = false;
|
x70_27_skyboxVisible = false;
|
||||||
|
|
||||||
if (!x94_skyboxWorld.IsLoaded())
|
if (x94_skyboxWorld) {
|
||||||
return false;
|
|
||||||
|
|
||||||
CModel* skybox = x94_skyboxWorld.GetObj();
|
CModel* skybox = x94_skyboxWorld->GetObj();
|
||||||
if (!skybox)
|
if (!skybox)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
skybox->GetInstance().Touch(0);
|
skybox->GetInstance().Touch(0);
|
||||||
if (!skybox->IsLoaded(0))
|
if (!skybox->IsLoaded(0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
xa4_skyboxWorldLoaded = x94_skyboxWorld;
|
xa4_skyboxWorldLoaded = x94_skyboxWorld;
|
||||||
|
}
|
||||||
|
|
||||||
for (CSoundGroupData& group : x74_soundGroupData)
|
for (CSoundGroupData& group : x74_soundGroupData)
|
||||||
group.x1c_groupData.Lock();
|
group.x1c_groupData.Lock();
|
||||||
|
@ -592,10 +592,10 @@ void CWorld::Update(float dt) {
|
||||||
if (overrideSkyId.IsValid() && needsSky) {
|
if (overrideSkyId.IsValid() && needsSky) {
|
||||||
x70_26_skyboxActive = true;
|
x70_26_skyboxActive = true;
|
||||||
x70_27_skyboxVisible = skyVisible;
|
x70_27_skyboxVisible = skyVisible;
|
||||||
xb4_skyboxOverride = g_SimplePool->GetObj({SBIG('CMDL'), overrideSkyId});
|
xb4_skyboxOverride = {g_SimplePool->GetObj({SBIG('CMDL'), overrideSkyId})};
|
||||||
xa4_skyboxWorldLoaded = TLockedToken<CModel>();
|
xa4_skyboxWorldLoaded = TLockedToken<CModel>();
|
||||||
if (x94_skyboxWorld)
|
if (x94_skyboxWorld)
|
||||||
x94_skyboxWorld.Unlock();
|
x94_skyboxWorld->Unlock();
|
||||||
} else {
|
} else {
|
||||||
xb4_skyboxOverride = TLockedToken<CModel>();
|
xb4_skyboxOverride = TLockedToken<CModel>();
|
||||||
if (!x94_skyboxWorld) {
|
if (!x94_skyboxWorld) {
|
||||||
|
@ -603,15 +603,15 @@ void CWorld::Update(float dt) {
|
||||||
x70_27_skyboxVisible = false;
|
x70_27_skyboxVisible = false;
|
||||||
} else if (!needsSky) {
|
} else if (!needsSky) {
|
||||||
xa4_skyboxWorldLoaded = TLockedToken<CModel>();
|
xa4_skyboxWorldLoaded = TLockedToken<CModel>();
|
||||||
x94_skyboxWorld.Unlock();
|
x94_skyboxWorld->Unlock();
|
||||||
x70_26_skyboxActive = false;
|
x70_26_skyboxActive = false;
|
||||||
x70_27_skyboxVisible = false;
|
x70_27_skyboxVisible = false;
|
||||||
} else {
|
} else {
|
||||||
if (!xa4_skyboxWorldLoaded) {
|
if (!xa4_skyboxWorldLoaded) {
|
||||||
x94_skyboxWorld.Lock();
|
x94_skyboxWorld->Lock();
|
||||||
if (x94_skyboxWorld.IsLoaded()) {
|
if (x94_skyboxWorld->IsLoaded()) {
|
||||||
x94_skyboxWorld->Touch(0);
|
x94_skyboxWorld.value()->Touch(0);
|
||||||
if (x94_skyboxWorld->IsLoaded(0))
|
if (x94_skyboxWorld.value()->IsLoaded(0))
|
||||||
xa4_skyboxWorldLoaded = x94_skyboxWorld;
|
xa4_skyboxWorldLoaded = x94_skyboxWorld;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -628,18 +628,18 @@ void CWorld::PreRender() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWorld::TouchSky() {
|
void CWorld::TouchSky() {
|
||||||
if (xa4_skyboxWorldLoaded.IsLoaded())
|
if (xa4_skyboxWorldLoaded && xa4_skyboxWorldLoaded->IsLoaded())
|
||||||
xa4_skyboxWorldLoaded->Touch(0);
|
xa4_skyboxWorldLoaded.value()->Touch(0);
|
||||||
if (xb4_skyboxOverride.IsLoaded())
|
if (xb4_skyboxOverride && xb4_skyboxOverride->IsLoaded())
|
||||||
xb4_skyboxOverride->Touch(0);
|
xb4_skyboxOverride.value()->Touch(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWorld::DrawSky(const zeus::CTransform& xf) const {
|
void CWorld::DrawSky(const zeus::CTransform& xf) const {
|
||||||
const CModel* model;
|
const CModel* model;
|
||||||
if (xa4_skyboxWorldLoaded)
|
if (xa4_skyboxWorldLoaded)
|
||||||
model = xa4_skyboxWorldLoaded.GetObj();
|
model = xa4_skyboxWorldLoaded->GetObj();
|
||||||
else if (xb4_skyboxOverride)
|
else if (xb4_skyboxOverride)
|
||||||
model = xb4_skyboxOverride.GetObj();
|
model = xb4_skyboxOverride->GetObj();
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -684,13 +684,11 @@ void CWorld::AddGlobalSound(const CSfxHandle& hnd) {
|
||||||
bool CWorld::AreSkyNeedsMet() const {
|
bool CWorld::AreSkyNeedsMet() const {
|
||||||
if (!x70_26_skyboxActive)
|
if (!x70_26_skyboxActive)
|
||||||
return true;
|
return true;
|
||||||
if (xb4_skyboxOverride && xb4_skyboxOverride->IsLoaded(0))
|
if (xb4_skyboxOverride && xb4_skyboxOverride.value()->IsLoaded(0))
|
||||||
return true;
|
return true;
|
||||||
if (xa4_skyboxWorldLoaded && xa4_skyboxWorldLoaded->IsLoaded(0))
|
if (xa4_skyboxWorldLoaded && xa4_skyboxWorldLoaded.value()->IsLoaded(0))
|
||||||
return true;
|
return true;
|
||||||
if (x94_skyboxWorld && x94_skyboxWorld->IsLoaded(0))
|
return x94_skyboxWorld && x94_skyboxWorld.value()->IsLoaded(0);
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TAreaId CWorld::GetAreaIdForSaveId(s32 saveId) const {
|
TAreaId CWorld::GetAreaIdForSaveId(s32 saveId) const {
|
||||||
|
|
|
@ -143,9 +143,9 @@ private:
|
||||||
};
|
};
|
||||||
std::vector<CSoundGroupData> x74_soundGroupData;
|
std::vector<CSoundGroupData> x74_soundGroupData;
|
||||||
std::string x84_defAudioTrack;
|
std::string x84_defAudioTrack;
|
||||||
TLockedToken<CModel> x94_skyboxWorld;
|
std::optional<TLockedToken<CModel>> x94_skyboxWorld;
|
||||||
TLockedToken<CModel> xa4_skyboxWorldLoaded;
|
std::optional<TLockedToken<CModel>> xa4_skyboxWorldLoaded;
|
||||||
TLockedToken<CModel> xb4_skyboxOverride;
|
std::optional<TLockedToken<CModel>> xb4_skyboxOverride;
|
||||||
EEnvFxType xc4_neededFx = EEnvFxType::None;
|
EEnvFxType xc4_neededFx = EEnvFxType::None;
|
||||||
rstl::reserved_vector<CSfxHandle, 10> xc8_globalSfxHandles;
|
rstl::reserved_vector<CSfxHandle, 10> xc8_globalSfxHandles;
|
||||||
|
|
||||||
|
|
|
@ -1419,7 +1419,8 @@ CEntity* ScriptLoader::LoadMetroidBeta(CStateManager& mgr, CInputStream& in, int
|
||||||
CModelData mData(
|
CModelData mData(
|
||||||
CAnimRes(animParms.GetACSFile(), animParms.GetCharacter(), scale, animParms.GetInitialAnimation(), true));
|
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) {
|
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(
|
CModelData mData(
|
||||||
CAnimRes(animParms.GetACSFile(), animParms.GetCharacter(), scale, animParms.GetInitialAnimation(), true));
|
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,
|
return nullptr;
|
||||||
kInvalidUniqueId);
|
//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,
|
CEntity* ScriptLoader::LoadDebrisExtended(CStateManager& mgr, CInputStream& in, int propCount,
|
||||||
|
|
Loading…
Reference in New Issue