From 073eb0583ab7386cc85b503f16bd7e8e09df925d Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 14 Oct 2022 20:45:42 +0200 Subject: [PATCH] Fix loading the config values from the config files --- src/main.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index f1e49fc..83729f1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,6 +27,27 @@ INITIALIZE_PLUGIN() { } else { gLibRPXLoaderInitDone = true; } + + // Open storage to read values + WUPSStorageError storageRes = WUPS_OpenStorage(); + if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to open storage %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes); + } else { + if ((storageRes = WUPS_GetBool(nullptr, WIILOAD_ENABLED_STRING, &gWiiloadServerEnabled)) == WUPS_STORAGE_ERROR_NOT_FOUND) { + // Add the value to the storage if it's missing. + if (WUPS_StoreBool(nullptr, WIILOAD_ENABLED_STRING, gWiiloadServerEnabled) != WUPS_STORAGE_ERROR_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to store bool"); + } + } else if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to get bool %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes); + } + + // Close storage + if (WUPS_CloseStorage() != WUPS_STORAGE_ERROR_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to close storage"); + } + } + thread = nullptr; }