Revert loader changes

This commit is contained in:
kynex7510 2024-05-28 21:03:52 +02:00
parent 663637e98e
commit 1419dcafb0
No known key found for this signature in database
GPG key ID: 2BFE7F696DF44E71
3 changed files with 23 additions and 41 deletions

View file

@ -107,11 +107,6 @@ int geodeEntry(void* platformData) {
}
#endif
// Check if `Mod::get()` is valid, i.e. the internal mod has been succesfully setup
if (!Mod::get()) {
return 1;
}
std::string forwardCompatSuffix;
if (LoaderImpl::get()->isForwardCompatMode())
forwardCompatSuffix = " (forward compatibility mode)";
@ -129,6 +124,21 @@ int geodeEntry(void* platformData) {
auto begin = std::chrono::high_resolution_clock::now();
// set up internal mod, settings and data
log::info("Setting up internal mod");
log::pushNest();
auto internalSetupRes = LoaderImpl::get()->setupInternalMod();
log::popNest();
if (!internalSetupRes) {
console::messageBox(
"Unable to Load Geode!",
"There was a fatal error setting up "
"the internal mod and Geode can not be loaded: " + internalSetupRes.unwrapErr()
);
LoaderImpl::get()->forceReset();
return 1;
}
tryShowForwardCompat();
// open console

View file

@ -129,6 +129,7 @@ namespace geode {
void addUninitializedHook(Hook* hook, Mod* mod);
Mod* getInternalMod();
Result<> setupInternalMod();
bool userTriedToLoadDLLs() const;

View file

@ -844,41 +844,12 @@ Mod* Loader::Impl::getInternalMod() {
}
mod->m_impl->m_enabled = true;
m_mods.insert({ mod->getID(), mod });
// Set up internal mod right here so it's usable through `$execute`
log::info("Setting up internal mod");
log::pushNest();
// Run normal mod setup
auto setupRes = mod->m_impl->setup();
if (!setupRes) {
console::messageBox(
"Unable to Load Geode!",
"There was a fatal error setting up "
"the internal mod and Geode can not be loaded: " + setupRes.unwrapErr()
);
LoaderImpl::get()->forceReset();
return nullptr;
}
// The resources for the internal mod have to be handled differently
// since they live in their own directory outside of unzipped/
auto resourcesDir = dirs::getGeodeResourcesDir() / Mod::get()->getID();
auto resourcesRes = ModMetadataImpl::getImpl(ModImpl::get()->m_metadata).addSpecialFiles(resourcesDir);
if (!resourcesRes) {
console::messageBox(
"Unable to Load Geode!",
"There was a fatal error loading the resources for "
"the internal mod and Geode can not be loaded: " + resourcesRes.unwrapErr()
);
LoaderImpl::get()->forceReset();
return nullptr;
}
// Should this be RAII so if one of the conditions before fail the nest
// still gets popped? I mean after `forceReset()` the game is getting closed
// anyway but still
log::popNest();
return mod;
}
Result<> Loader::Impl::setupInternalMod() {
GEODE_UNWRAP(Mod::get()->m_impl->setup());
auto resourcesDir = dirs::getGeodeResourcesDir() / Mod::get()->getID();
GEODE_UNWRAP(ModMetadataImpl::getImpl(ModImpl::get()->m_metadata).addSpecialFiles(resourcesDir));
return Ok();
}