From b2af3fa9d4a50d1dbe3792af6e91cc34d3f18839 Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Tue, 24 Dec 2024 12:36:54 -0800 Subject: [PATCH 1/3] use binary dir paths, create ones that dont exist, do not run if critical ones do not exist. --- CMakeVariables.txt | 4 ++-- dDatabase/GameDatabase/SQLite/SQLiteDatabase.cpp | 10 +++++++++- dMasterServer/MasterServer.cpp | 11 ++++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CMakeVariables.txt b/CMakeVariables.txt index 4ded5f593..0aa3c8cb9 100644 --- a/CMakeVariables.txt +++ b/CMakeVariables.txt @@ -1,5 +1,5 @@ -PROJECT_VERSION_MAJOR=2 -PROJECT_VERSION_MINOR=3 +PROJECT_VERSION_MAJOR=3 +PROJECT_VERSION_MINOR=0 PROJECT_VERSION_PATCH=0 # Debugging diff --git a/dDatabase/GameDatabase/SQLite/SQLiteDatabase.cpp b/dDatabase/GameDatabase/SQLite/SQLiteDatabase.cpp index 635ca8fb8..0f2b97a28 100644 --- a/dDatabase/GameDatabase/SQLite/SQLiteDatabase.cpp +++ b/dDatabase/GameDatabase/SQLite/SQLiteDatabase.cpp @@ -5,6 +5,7 @@ #include "dConfig.h" #include "Logger.h" #include "dPlatforms.h" +#include "BinaryPathFinder.h" // Static Variables @@ -17,7 +18,14 @@ namespace { void SQLiteDatabase::Connect() { LOG("Using SQLite database"); con = new CppSQLite3DB(); - con->open(Game::config->GetValue("sqlite_database_path").c_str()); + const auto path = BinaryPathFinder::GetBinaryDir() / Game::config->GetValue("sqlite_database_path"); + + if (!std::filesystem::exists(path)) { + LOG("Creating sqlite path %s", path.string().c_str()); + std::filesystem::create_directories(path.parent_path()); + } + + con->open(path.string().c_str()); isConnected = true; // Make sure wal is enabled for the database. diff --git a/dMasterServer/MasterServer.cpp b/dMasterServer/MasterServer.cpp index b764169a4..3895473b0 100644 --- a/dMasterServer/MasterServer.cpp +++ b/dMasterServer/MasterServer.cpp @@ -84,6 +84,15 @@ int main(int argc, char** argv) { Server::SetupLogger("MasterServer"); if (!Game::logger) return EXIT_FAILURE; + auto folders = { "navmeshes", "migrations", "vanity" }; + + for (const auto folder : folders) { + if (!std::filesystem::exists(BinaryPathFinder::GetBinaryDir() / folder)) { + LOG("The %s folder was not copied to the binary directory. Please copy the %s folder from your download to the binary directory or re-run cmake.", folder, folder); + return EXIT_FAILURE; + } + } + if (!dConfig::Exists("authconfig.ini")) LOG("Could not find authconfig.ini, using default settings"); if (!dConfig::Exists("chatconfig.ini")) LOG("Could not find chatconfig.ini, using default settings"); if (!dConfig::Exists("masterconfig.ini")) LOG("Could not find masterconfig.ini, using default settings"); @@ -177,7 +186,7 @@ int main(int argc, char** argv) { } // Run migrations should any need to be run. - MigrationRunner::RunSQLiteMigrations(); + MigrationRunner::RunSQLiteMigrations(); //If the first command line argument is -a or --account then make the user //input a username and password, with the password being hidden. From e869c0ad032cf57e9ea1bf6ce3bfc28bce861132 Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Tue, 24 Dec 2024 12:39:18 -0800 Subject: [PATCH 2/3] Add parenthesis around path --- dMasterServer/MasterServer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dMasterServer/MasterServer.cpp b/dMasterServer/MasterServer.cpp index 3895473b0..2c7064004 100644 --- a/dMasterServer/MasterServer.cpp +++ b/dMasterServer/MasterServer.cpp @@ -88,7 +88,7 @@ int main(int argc, char** argv) { for (const auto folder : folders) { if (!std::filesystem::exists(BinaryPathFinder::GetBinaryDir() / folder)) { - LOG("The %s folder was not copied to the binary directory. Please copy the %s folder from your download to the binary directory or re-run cmake.", folder, folder); + LOG("The (%s) folder was not copied to the binary directory. Please copy the (%s) folder from your download to the binary directory or re-run cmake.", folder, folder); return EXIT_FAILURE; } } From a787673baf6e9615ff4145aa668fd594f5e380ff Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Tue, 24 Dec 2024 12:57:20 -0800 Subject: [PATCH 3/3] show error box for windows --- dMasterServer/MasterServer.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dMasterServer/MasterServer.cpp b/dMasterServer/MasterServer.cpp index 2c7064004..89ecef058 100644 --- a/dMasterServer/MasterServer.cpp +++ b/dMasterServer/MasterServer.cpp @@ -88,7 +88,16 @@ int main(int argc, char** argv) { for (const auto folder : folders) { if (!std::filesystem::exists(BinaryPathFinder::GetBinaryDir() / folder)) { - LOG("The (%s) folder was not copied to the binary directory. Please copy the (%s) folder from your download to the binary directory or re-run cmake.", folder, folder); + std::string msg = "The (" + + std::string(folder) + + ") folder was not copied to the binary directory. Please copy the (" + + std::string(folder) + + ") folder from your download to the binary directory or re-run cmake."; + LOG("%s", msg.c_str()); +// toss an error box up for windows users running the download +#ifdef DARKFLAME_PLATFORM_WIN32 + MessageBoxA(nullptr, msg.c_str(), "Missing Folder", MB_OK | MB_ICONERROR); +#endif return EXIT_FAILURE; } }