diff --git a/README.md b/README.md index 3310051..1ba82f9 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ This just works if you're all under the same LAN, but if you want to play over t ## Compiling -OpenFusion has one external dependency: SQLite. You can install it on Windows using `vcpkg`, and on Unix/Linux using your distribution's package manager. For a more indepth guide on how to set up vcpkg, [read this guide on the wiki](https://github.com/OpenFusionProject/OpenFusion/wiki/Installing-SQLite-on-Windows-using-vcpkg). +OpenFusion has one external dependency: SQLite. The oldest compatible version is `3.33.0`. You can install it on Windows using `vcpkg`, and on Unix/Linux using your distribution's package manager. For a more indepth guide on how to set up vcpkg, [read this guide on the wiki](https://github.com/OpenFusionProject/OpenFusion/wiki/Installing-SQLite-on-Windows-using-vcpkg). You have two choices for compiling OpenFusion: the included Makefile and the included CMakeLists file. diff --git a/src/db/Database.hpp b/src/db/Database.hpp index 4d8a25d..48fd0f6 100644 --- a/src/db/Database.hpp +++ b/src/db/Database.hpp @@ -41,6 +41,7 @@ namespace Database { uint64_t Timestamp; }; + void init(); void open(); void close(); diff --git a/src/db/init.cpp b/src/db/init.cpp index a827473..942522f 100644 --- a/src/db/init.cpp +++ b/src/db/init.cpp @@ -236,7 +236,20 @@ static int getTableSize(std::string tableName) { return result; } +void Database::init() { + std::cout << "[INFO] Built with libsqlite " SQLITE_VERSION << std::endl; + + if (sqlite3_libversion_number() != SQLITE_VERSION_NUMBER) + std::cout << "[INFO] Using libsqlite " << std::string(sqlite3_libversion()) << std::endl; + + if (sqlite3_libversion_number() < MIN_SUPPORTED_SQLITE_NUMBER) { + std::cerr << "[FATAL] Runtime sqlite version too old. Minimum compatible version: " MIN_SUPPORTED_SQLITE << std::endl; + exit(1); + } +} + void Database::open() { + // XXX: move locks here int rc = sqlite3_open(settings::DBPATH.c_str(), &db); if (rc != SQLITE_OK) { diff --git a/src/db/internal.hpp b/src/db/internal.hpp index 376960e..b51258f 100644 --- a/src/db/internal.hpp +++ b/src/db/internal.hpp @@ -3,6 +3,15 @@ #include "db/Database.hpp" #include +#define MIN_SUPPORTED_SQLITE_NUMBER 3033000 +#define MIN_SUPPORTED_SQLITE "3.33.0" +// we can't use this in #error, since it doesn't expand macros + +// Compile-time libsqlite version check +#if SQLITE_VERSION_NUMBER < MIN_SUPPORTED_SQLITE_NUMBER +#error libsqlite version too old. Minimum compatible version: 3.33.0 +#endif + extern std::mutex dbCrit; extern sqlite3 *db; diff --git a/src/main.cpp b/src/main.cpp index 314bb22..750d9f8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -98,6 +98,9 @@ void initsignals() { } int main() { + std::cout << "[INFO] OpenFusion v" GIT_VERSION << std::endl; + std::cout << "[INFO] Protocol version: " << PROTOCOL_VERSION << std::endl; + #ifdef _WIN32 WSADATA wsaData; if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) { @@ -105,15 +108,15 @@ int main() { exit(EXIT_FAILURE); } #endif + initsignals(); settings::init(); - - std::cout << "[INFO] OpenFusion v" GIT_VERSION << std::endl; - std::cout << "[INFO] Protocol version: " << PROTOCOL_VERSION << std::endl; - std::cout << "[INFO] Intializing Packet Managers..." << std::endl; - + Database::init(); Rand::init(getTime()); TableData::init(); + + std::cout << "[INFO] Intializing Packet Managers..." << std::endl; + PlayerManager::init(); PlayerMovement::init(); BuiltinCommands::init(); @@ -132,9 +135,10 @@ int main() { Email::init(); Groups::init(); Racing::init(); - Database::open(); Trading::init(); + Database::open(); + switch (settings::EVENTMODE) { case 0: break; // no event case 1: std::cout << "[INFO] Event active. Hey, Hey It's Knishmas!" << std::endl; break;