mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-14 02:10:06 +00:00
Enforce minimum supported libsqlite version
The server now checks the libsqlite both at compile time and on server startup. The version the executable was built with and the one it's running with may be different, so long as they're both at or above the minimum supported version. One or both version numbers are printed on startup, depending on if they're identical or not. The compile-time ("Built with") version depends on the sqlite3.h header used during compilation, while the runtime ("Using") version depends on either: * The sqlite3.c version used during compilation, if statically linked. (Which may be different from the header version and still compile and run fine.) * The version of the libsqlite3.so or sqlite3.dll that the server loaded, if dynamically linked. Version mismatches here are normal, especially on Unix systems with their own system libraries. The current minimum version is 3.33.0, from 2020-08-14, as that's the one that introduced the UPDATE-FROM syntax used during login by Database::updateSelectedByPlayerId(). Also rearranged the prints and initialization calls in main() slightly.
This commit is contained in:
parent
8eb1af20c8
commit
be6a4c0a5d
@ -83,7 +83,7 @@ This just works if you're all under the same LAN, but if you want to play over t
|
|||||||
|
|
||||||
## Compiling
|
## 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.
|
You have two choices for compiling OpenFusion: the included Makefile and the included CMakeLists file.
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ namespace Database {
|
|||||||
uint64_t Timestamp;
|
uint64_t Timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void init();
|
||||||
void open();
|
void open();
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
|
@ -236,7 +236,20 @@ static int getTableSize(std::string tableName) {
|
|||||||
return result;
|
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() {
|
void Database::open() {
|
||||||
|
|
||||||
// XXX: move locks here
|
// XXX: move locks here
|
||||||
int rc = sqlite3_open(settings::DBPATH.c_str(), &db);
|
int rc = sqlite3_open(settings::DBPATH.c_str(), &db);
|
||||||
if (rc != SQLITE_OK) {
|
if (rc != SQLITE_OK) {
|
||||||
|
@ -3,6 +3,15 @@
|
|||||||
#include "db/Database.hpp"
|
#include "db/Database.hpp"
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
|
|
||||||
|
#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 std::mutex dbCrit;
|
||||||
extern sqlite3 *db;
|
extern sqlite3 *db;
|
||||||
|
|
||||||
|
16
src/main.cpp
16
src/main.cpp
@ -98,6 +98,9 @@ void initsignals() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
std::cout << "[INFO] OpenFusion v" GIT_VERSION << std::endl;
|
||||||
|
std::cout << "[INFO] Protocol version: " << PROTOCOL_VERSION << std::endl;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
|
if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
|
||||||
@ -105,15 +108,15 @@ int main() {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
initsignals();
|
initsignals();
|
||||||
settings::init();
|
settings::init();
|
||||||
|
Database::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;
|
|
||||||
|
|
||||||
Rand::init(getTime());
|
Rand::init(getTime());
|
||||||
TableData::init();
|
TableData::init();
|
||||||
|
|
||||||
|
std::cout << "[INFO] Intializing Packet Managers..." << std::endl;
|
||||||
|
|
||||||
PlayerManager::init();
|
PlayerManager::init();
|
||||||
PlayerMovement::init();
|
PlayerMovement::init();
|
||||||
BuiltinCommands::init();
|
BuiltinCommands::init();
|
||||||
@ -132,9 +135,10 @@ int main() {
|
|||||||
Email::init();
|
Email::init();
|
||||||
Groups::init();
|
Groups::init();
|
||||||
Racing::init();
|
Racing::init();
|
||||||
Database::open();
|
|
||||||
Trading::init();
|
Trading::init();
|
||||||
|
|
||||||
|
Database::open();
|
||||||
|
|
||||||
switch (settings::EVENTMODE) {
|
switch (settings::EVENTMODE) {
|
||||||
case 0: break; // no event
|
case 0: break; // no event
|
||||||
case 1: std::cout << "[INFO] Event active. Hey, Hey It's Knishmas!" << std::endl; break;
|
case 1: std::cout << "[INFO] Event active. Hey, Hey It's Knishmas!" << std::endl; break;
|
||||||
|
Loading…
Reference in New Issue
Block a user