fix internal mod setting up at static init time

This commit is contained in:
altalk23 2023-01-21 19:54:19 +03:00
parent 51f70bc810
commit d8c0ba6799
5 changed files with 23 additions and 6 deletions

View file

@ -3799,6 +3799,7 @@ class LevelSettingsObject : cocos2d::CCNode {
int m_groundIndex;
int m_fontIndex;
bool m_startsWithStartPos;
bool m_isFlipped;
GJGameLevel* m_level;
gd::string m_guidelineString;
int m_unknown;

View file

@ -591,13 +591,14 @@ ResourceDownloadFilter::ResourceDownloadFilter() {}
void Loader::Impl::provideNextMod(Mod* mod) {
m_nextModLock.lock();
m_nextMod = mod;
if (mod) {
m_nextMod = mod;
}
}
Mod* Loader::Impl::takeNextMod() {
if (!m_nextMod) {
this->setupInternalMod();
m_nextMod = Mod::sharedMod<>;
m_nextMod = this->createInternalMod();
}
auto ret = m_nextMod;
return ret;

View file

@ -134,6 +134,7 @@ namespace geode {
bool isReadyToHook() const;
void addInternalHook(Hook* hook, Mod* mod);
Mod* createInternalMod();
void setupInternalMod();
};

View file

@ -669,12 +669,15 @@ static ModInfo getModImplInfo() {
}
}
void Loader::Impl::setupInternalMod() {
Mod* Loader::Impl::createInternalMod() {
auto& mod = Mod::sharedMod<>;
if (mod) return;
if (mod) return mod;
mod = new Mod(getModImplInfo());
return mod;
}
auto setupRes = mod->m_impl->setup();
void Loader::Impl::setupInternalMod() {
auto setupRes = Mod::get()->m_impl->setup();
if (!setupRes) {
log::error("Failed to setup internal mod! ({})", setupRes.unwrapErr());
}

View file

@ -164,6 +164,17 @@ int geodeEntry(void* platformData) {
return 1;
}
// set up internal mod, settings and data
if (!LoaderImpl::get()->setup()) {
LoaderImpl::get()->setupInternalMod(
"Unable to Load Geode!",
"There was an unknown fatal error setting up "
"the internal mod and Geode can not be loaded."
);
LoaderImpl::get()->reset();
return 1;
}
// set up loader, load mods, etc.
auto setupRes = LoaderImpl::get()->setup();
if (!setupRes) {