fix loader impl not loading hooks

This commit is contained in:
HJfod 2022-12-12 14:03:15 +02:00
parent 5e8a321a36
commit c1b5a16e27
2 changed files with 14 additions and 31 deletions

View file

@ -67,6 +67,19 @@ Result<> Loader::Impl::setup() {
log::debug("Setting up Loader...");
log::debug("Set up internal mod representation");
log::debug("Loading hooks... ");
if (!this->loadHooks()) {
return Err("There were errors loading some hooks, see console for details");
}
log::debug("Loaded hooks");
log::debug("Setting up IPC...");
this->setupIPC();
this->createDirectories();
auto sett = this->loadData();
if (!sett) {
@ -454,22 +467,6 @@ bool Loader::Impl::platformConsoleOpen() const {
return m_platformConsoleOpen;
}
bool Loader::Impl::shownInfoAlert(std::string const& key) {
if (m_shownInfoAlerts.count(key)) {
return true;
}
m_shownInfoAlerts.insert(key);
return false;
}
void Loader::Impl::saveInfoAlerts(nlohmann::json& json) {
json["alerts"] = m_shownInfoAlerts;
}
void Loader::Impl::loadInfoAlerts(nlohmann::json& json) {
m_shownInfoAlerts = json["alerts"].get<std::unordered_set<std::string>>();
}
void Loader::Impl::downloadLoaderResources() {
auto version = this->getVersion().toString();
auto tempResourcesZip = dirs::getTempDir() / "new.zip";

View file

@ -50,19 +50,12 @@ public:
mutable std::mutex m_scheduledFunctionsMutex;
bool m_isSetup = false;
std::atomic_bool m_earlyLoadFinished = false;
// InternalLoader
std::vector<std::function<void(void)>> m_gdThreadQueue;
mutable std::mutex m_gdThreadMutex;
bool m_platformConsoleOpen = false;
std::unordered_set<std::string> m_shownInfoAlerts;
std::vector<std::pair<Hook*, Mod*>> m_internalHooks;
bool m_readyToHook = false;
void saveInfoAlerts(nlohmann::json& json);
void loadInfoAlerts(nlohmann::json& json);
void downloadLoaderResources();
bool loadHooks();
@ -113,13 +106,6 @@ public:
nlohmann::json processRawIPC(void* rawHandle, std::string const& buffer);
/**
* Check if a one-time event has been shown to the user,
* and set it to true if not. Will return the previous
* state of the event before setting it to true
*/
bool shownInfoAlert(std::string const& key);
void queueInGDThread(ScheduledFunction func);
void executeGDThreadQueue();
@ -140,4 +126,4 @@ namespace geode {
public:
static Loader::Impl* get();
};
}
}