mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2025-10-03 21:20:26 +00:00
DB v2 Tweaks
This commit is contained in:
@@ -144,15 +144,14 @@ void CNLoginServer::login(CNSocket* sock, CNPacketData* data) {
|
||||
return loginFail(LoginError::ID_AND_PASSWORD_DO_NOT_MATCH, userLogin, sock);
|
||||
|
||||
// is the account banned
|
||||
if (findUser.BannedUntil > getTimestamp())
|
||||
{
|
||||
if (findUser.BannedUntil > getTimestamp()) {
|
||||
// send a custom error message
|
||||
INITSTRUCT(sP_FE2CL_GM_REP_PC_ANNOUNCE, msg);
|
||||
|
||||
// ceiling devision
|
||||
int64_t remainingDays = (findUser.BannedUntil-getTimestamp()) / 86400 + ((findUser.BannedUntil - getTimestamp()) % 86400 != 0);
|
||||
|
||||
std::string text = "Your account has been banned by game master\nReason: ";
|
||||
std::string text = "Your account has been banned. \nReason: ";
|
||||
text += findUser.BanReason;
|
||||
text += "\nBan expires in " + std::to_string(remainingDays) + " day";
|
||||
if (remainingDays > 1)
|
||||
@@ -161,7 +160,7 @@ void CNLoginServer::login(CNSocket* sock, CNPacketData* data) {
|
||||
U8toU16(text, msg.szAnnounceMsg, sizeof(msg.szAnnounceMsg));
|
||||
msg.iDuringTime = 99999999;
|
||||
sock->sendPacket((void*)&msg, P_FE2CL_GM_REP_PC_ANNOUNCE, sizeof(sP_FE2CL_GM_REP_PC_ANNOUNCE));
|
||||
// don't send fail packet to softlock sucker's client
|
||||
// don't send fail packet
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <filesystem>
|
||||
|
||||
#if defined(__MINGW32__) && !defined(_GLIBCXX_HAS_GTHREADS)
|
||||
#include "mingw/mingw.mutex.h"
|
||||
@@ -134,9 +135,19 @@ void Database::checkMetaTable() {
|
||||
if (dbVersion > DATABASE_VERSION) {
|
||||
std::cout << "[FATAL] Server Build is incompatible with DB Version" << std::endl;
|
||||
exit(1);
|
||||
} else if (dbVersion < DATABASE_VERSION) {
|
||||
// we're gonna migrate; back up the DB
|
||||
try {
|
||||
std::cout << "[INFO] Backing up database" << std::endl;
|
||||
std::filesystem::copy_file(settings::DBPATH, settings::DBPATH + ".old." + std::to_string(dbVersion));
|
||||
}
|
||||
catch (std::filesystem::filesystem_error& e) {
|
||||
std::cout << "[FATAL] Failed to backup database before migration" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
while (dbVersion != DATABASE_VERSION){
|
||||
while (dbVersion != DATABASE_VERSION) {
|
||||
// db migrations
|
||||
std::cout << "[INFO] Migrating Database to Version " << dbVersion + 1 << std::endl;
|
||||
|
||||
@@ -158,7 +169,7 @@ void Database::checkMetaTable() {
|
||||
}
|
||||
|
||||
dbVersion++;
|
||||
std::cout << "[INFO] Successfull Database Migration to Version " << dbVersion << std::endl;
|
||||
std::cout << "[INFO] Successful Database Migration to Version " << dbVersion << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,14 +237,12 @@ void Database::createTables() {
|
||||
std::string read = stream.str();
|
||||
const char* sql = read.c_str();
|
||||
|
||||
dbCrit.lock();
|
||||
char* errMsg = 0;
|
||||
int rc = sqlite3_exec(db, sql, NULL, NULL, &errMsg);
|
||||
if (rc != SQLITE_OK) {
|
||||
std::cout << "[FATAL] Database failed to create tables: " << errMsg << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
dbCrit.unlock();
|
||||
}
|
||||
|
||||
int Database::getTableSize(std::string tableName) {
|
||||
|
Reference in New Issue
Block a user