aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobTheBob9 <for.oliver.kirkham@gmail.com>2022-09-19 23:33:49 +0100
committerBobTheBob9 <for.oliver.kirkham@gmail.com>2022-09-19 23:33:49 +0100
commitad9fc6dda75ced36476d7a6a931d556a3470cefb (patch)
tree3759755cafaea6545e5d8ef2237b89f941c48587
parent9a35efe0b0f5e632d4f182dc490a587390539392 (diff)
downloadNorthstarLauncher-ad9fc6dda75ced36476d7a6a931d556a3470cefb.tar.gz
NorthstarLauncher-ad9fc6dda75ced36476d7a6a931d556a3470cefb.zip
set launcher directory and error on fail creating log files
-rw-r--r--NorthstarDLL/logging.cpp25
-rw-r--r--NorthstarLauncher/main.cpp2
-rw-r--r--loader_launcher_proxy/dllmain.cpp2
-rw-r--r--loader_wsock32_proxy/dllmain.cpp2
4 files changed, 23 insertions, 8 deletions
diff --git a/NorthstarDLL/logging.cpp b/NorthstarDLL/logging.cpp
index 7c6d50a6..99179d26 100644
--- a/NorthstarDLL/logging.cpp
+++ b/NorthstarDLL/logging.cpp
@@ -219,14 +219,23 @@ void CreateLogFiles()
}
else
{
- // todo: might be good to delete logs that are too old
- time_t time = std::time(nullptr);
- tm currentTime = *std::localtime(&time);
- std::stringstream stream;
-
- stream << std::put_time(&currentTime, (GetNorthstarPrefix() + "/logs/nslog%Y-%m-%d %H-%M-%S.txt").c_str());
- spdlog::default_logger()->sinks().push_back(std::make_shared<spdlog::sinks::basic_file_sink_mt>(stream.str(), false));
- spdlog::flush_on(spdlog::level::info);
+ try
+ {
+ // todo: might be good to delete logs that are too old
+ time_t time = std::time(nullptr);
+ tm currentTime = *std::localtime(&time);
+ std::stringstream stream;
+
+ stream << std::put_time(&currentTime, (GetNorthstarPrefix() + "/logs/nslog%Y-%m-%d %H-%M-%S.txt").c_str());
+ spdlog::default_logger()->sinks().push_back(std::make_shared<spdlog::sinks::basic_file_sink_mt>(stream.str(), false));
+ spdlog::flush_on(spdlog::level::info);
+ }
+ catch (...)
+ {
+ spdlog::error("Failed creating log file!");
+ MessageBoxA(
+ 0, "Failed creating log file! Make sure the profile directory is writable.", "Northstar Warning", MB_ICONWARNING | MB_OK);
+ }
}
}
diff --git a/NorthstarLauncher/main.cpp b/NorthstarLauncher/main.cpp
index 078cbc4a..92c7de7a 100644
--- a/NorthstarLauncher/main.cpp
+++ b/NorthstarLauncher/main.cpp
@@ -334,6 +334,8 @@ int main(int argc, char* argv[])
return 1;
}
+ SetCurrentDirectoryW(exePath);
+
bool noOriginStartup = false;
bool dedicated = false;
bool nostubs = false;
diff --git a/loader_launcher_proxy/dllmain.cpp b/loader_launcher_proxy/dllmain.cpp
index a382bc97..06abb7b2 100644
--- a/loader_launcher_proxy/dllmain.cpp
+++ b/loader_launcher_proxy/dllmain.cpp
@@ -128,6 +128,8 @@ extern "C" __declspec(dllexport) int LauncherMain(HINSTANCE hInstance, HINSTANCE
return 1;
}
+ SetCurrentDirectoryW(exePath);
+
bool loadNorthstar = ShouldLoadNorthstar();
if (loadNorthstar)
diff --git a/loader_wsock32_proxy/dllmain.cpp b/loader_wsock32_proxy/dllmain.cpp
index 7feb278d..c5610042 100644
--- a/loader_wsock32_proxy/dllmain.cpp
+++ b/loader_wsock32_proxy/dllmain.cpp
@@ -39,6 +39,8 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD reason, LPVOID)
return true;
}
+ SetCurrentDirectoryW(exePath);
+
if (!ProvisionNorthstar()) // does not call InitialiseNorthstar yet, will do it on LauncherMain hook
return true;