Fixed crash when launching or changing addons order

This commit is contained in:
KiritoDv 2021-07-26 07:36:02 -05:00
parent 21d6349453
commit 238246cebf
1 changed files with 6 additions and 2 deletions

View File

@ -5,6 +5,7 @@
#include "moon/mod-engine/engine.h" #include "moon/mod-engine/engine.h"
#include "moon/mod-engine/hooks/hook.h" #include "moon/mod-engine/hooks/hook.h"
#include "moon/mod-engine/interfaces/sound-entry.h" #include "moon/mod-engine/interfaces/sound-entry.h"
#include "moon/mod-engine/interfaces/file-entry.h"
extern "C" { extern "C" {
#include "text/libs/io_utils.h" #include "text/libs/io_utils.h"
@ -81,8 +82,11 @@ namespace MoonInternal {
void buildAudioCache(vector<int> order){ void buildAudioCache(vector<int> order){
soundCache.clear(); soundCache.clear();
for(int i = 0; i < order.size(); i++) for(int i = 0; i < order.size(); i++){
soundCache.push_back(Moon::addons[order[i]]); BitModule* addon = Moon::addons[order[i]];
if(addon->sounds != nullptr)
soundCache.push_back(addon);
}
Moon::setSoundEntry(soundCache[soundCache.size() - 1]->sounds); Moon::setSoundEntry(soundCache[soundCache.size() - 1]->sounds);
} }