Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: folder and file checks #1692

Merged
merged 3 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeVariables.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 9 additions & 1 deletion dDatabase/GameDatabase/SQLite/SQLiteDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "dConfig.h"
#include "Logger.h"
#include "dPlatforms.h"
#include "BinaryPathFinder.h"

// Static Variables

Expand All @@ -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.
Expand Down
20 changes: 19 additions & 1 deletion dMasterServer/MasterServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,24 @@ 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)) {
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;
}
}

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");
Expand Down Expand Up @@ -177,7 +195,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.
Expand Down
Loading