mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 21:40:05 +00:00
Open DB from settings path
This commit is contained in:
parent
c2f640fd97
commit
a1062f220b
@ -18,13 +18,18 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::mutex dbCrit;
|
std::mutex dbCrit;
|
||||||
|
sqlite3* db;
|
||||||
|
|
||||||
#pragma region LoginServer
|
#pragma region LoginServer
|
||||||
|
|
||||||
void Database::open() {
|
void Database::open() {
|
||||||
// this parameter means it will try to preserve data during migration
|
|
||||||
bool preserve = true;
|
int rc = sqlite3_open(settings::DBPATH.c_str(), &db);
|
||||||
db.sync_schema(preserve);
|
if (rc != SQLITE_OK) {
|
||||||
|
std::cout << "[FATAL] Cannot open database: " << sqlite3_errmsg(db) << std::endl;
|
||||||
|
terminate(0);
|
||||||
|
}
|
||||||
|
|
||||||
std::cout << "[INFO] Database in operation ";
|
std::cout << "[INFO] Database in operation ";
|
||||||
int accounts = getAccountsCount();
|
int accounts = getAccountsCount();
|
||||||
int players = getPlayersCount();
|
int players = getPlayersCount();
|
||||||
|
@ -28,6 +28,7 @@ std::string settings::DROPSJSON = "tdata/drops.json";
|
|||||||
std::string settings::EGGSJSON = "tdata/eggs.json";
|
std::string settings::EGGSJSON = "tdata/eggs.json";
|
||||||
std::string settings::GRUNTWORKJSON = "tdata/gruntwork.json";
|
std::string settings::GRUNTWORKJSON = "tdata/gruntwork.json";
|
||||||
std::string settings::MOTDSTRING = "Welcome to OpenFusion!";
|
std::string settings::MOTDSTRING = "Welcome to OpenFusion!";
|
||||||
|
std::string settings::DBPATH = "database.db";
|
||||||
int settings::ACCLEVEL = 1;
|
int settings::ACCLEVEL = 1;
|
||||||
|
|
||||||
// monitor settings
|
// monitor settings
|
||||||
@ -72,6 +73,7 @@ void settings::init() {
|
|||||||
PATHJSON = reader.Get("shard", "pathdata", PATHJSON);
|
PATHJSON = reader.Get("shard", "pathdata", PATHJSON);
|
||||||
GRUNTWORKJSON = reader.Get("shard", "gruntwork", GRUNTWORKJSON);
|
GRUNTWORKJSON = reader.Get("shard", "gruntwork", GRUNTWORKJSON);
|
||||||
MOTDSTRING = reader.Get("shard", "motd", MOTDSTRING);
|
MOTDSTRING = reader.Get("shard", "motd", MOTDSTRING);
|
||||||
|
DBPATH = reader.Get("shard", "dbpath", DBPATH);
|
||||||
ACCLEVEL = reader.GetInteger("shard", "accountlevel", ACCLEVEL);
|
ACCLEVEL = reader.GetInteger("shard", "accountlevel", ACCLEVEL);
|
||||||
EVENTMODE = reader.GetInteger("shard", "eventmode", EVENTMODE);
|
EVENTMODE = reader.GetInteger("shard", "eventmode", EVENTMODE);
|
||||||
EVENTCRATECHANCE = reader.GetInteger("shard", "eventcratechance", EVENTCRATECHANCE);
|
EVENTCRATECHANCE = reader.GetInteger("shard", "eventcratechance", EVENTCRATECHANCE);
|
||||||
|
@ -23,6 +23,7 @@ namespace settings {
|
|||||||
extern std::string DROPSJSON;
|
extern std::string DROPSJSON;
|
||||||
extern std::string EGGSJSON;
|
extern std::string EGGSJSON;
|
||||||
extern std::string GRUNTWORKJSON;
|
extern std::string GRUNTWORKJSON;
|
||||||
|
extern std::string DBPATH;
|
||||||
extern int EVENTMODE;
|
extern int EVENTMODE;
|
||||||
extern int EVENTCRATECHANCE;
|
extern int EVENTCRATECHANCE;
|
||||||
extern bool MONITORENABLED;
|
extern bool MONITORENABLED;
|
||||||
|
Loading…
Reference in New Issue
Block a user