Fix DynOS_Lvl_GetActiveGfx()

This commit is contained in:
MysterD 2023-06-05 15:19:19 -07:00
parent 17edd42b5d
commit 016c385d7f

View file

@ -96,14 +96,15 @@ void DynOS_Lvl_Activate(s32 modIndex, const SysPath &aFilename, const char *aLev
GfxData* DynOS_Lvl_GetActiveGfx(void) { GfxData* DynOS_Lvl_GetActiveGfx(void) {
auto& _CustomLevelScripts = DynOS_Lvl_GetArray(); auto& _CustomLevelScripts = DynOS_Lvl_GetArray();
for (s32 i = 0; i < _CustomLevelScripts.Count(); ++i) { for (s32 i = 0; i < _CustomLevelScripts.Count(); ++i) {
auto& gfxData = _CustomLevelScripts[i].second; auto& gfxData = _CustomLevelScripts[i].second;
auto& scripts = gfxData->mLevelScripts; auto& scripts = gfxData->mLevelScripts;
if (gLevelScriptActive == scripts[scripts.Count() - 1]->mData) { for (auto& s : scripts) {
if (gLevelScriptActive == s->mData) {
return gfxData; return gfxData;
} }
} }
}
return NULL; return NULL;
} }
@ -173,7 +174,6 @@ double_break:
void *DynOS_Lvl_Override(void *aCmd) { void *DynOS_Lvl_Override(void *aCmd) {
auto& _OverrideLevelScripts = DynosOverrideLevelScripts(); auto& _OverrideLevelScripts = DynosOverrideLevelScripts();
for (auto& overrideStruct : _OverrideLevelScripts) { for (auto& overrideStruct : _OverrideLevelScripts) {
if (aCmd == overrideStruct.originalScript || aCmd == overrideStruct.newScript) { if (aCmd == overrideStruct.originalScript || aCmd == overrideStruct.newScript) {
aCmd = (void*)overrideStruct.newScript; aCmd = (void*)overrideStruct.newScript;
@ -184,11 +184,14 @@ void *DynOS_Lvl_Override(void *aCmd) {
auto& _CustomLevelScripts = DynOS_Lvl_GetArray(); auto& _CustomLevelScripts = DynOS_Lvl_GetArray();
for (auto& script : _CustomLevelScripts) { for (auto& script : _CustomLevelScripts) {
if (aCmd == script.second->mLevelScripts[0]->mData) { auto& scripts = script.second->mLevelScripts;
for (auto& s : scripts) {
if (aCmd == s->mData) {
gLevelScriptModIndex = script.second->mModIndex; gLevelScriptModIndex = script.second->mModIndex;
gLevelScriptActive = (LevelScript*)aCmd; gLevelScriptActive = (LevelScript*)aCmd;
} }
} }
}
return aCmd; return aCmd;
} }