mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-12-23 03:40:05 +00:00
DB v2 Tweaks
This commit is contained in:
parent
1fb48536c2
commit
2e173df2ca
@ -7,7 +7,7 @@ ALTER TABLE RaceResults ADD Time INTEGER NOT NULL;
|
||||
INSERT INTO Meta (Key, Value) VALUES ('Created', 0);
|
||||
INSERT INTO Meta (Key, Value) VALUES ('LastMigration', strftime('%s', 'now'));
|
||||
UPDATE Meta SET Value = (SELECT Created FROM Meta WHERE Key = 'ProtocolVersion') Where Key = 'Created';
|
||||
-- Get rid of 'Created' Collumn
|
||||
-- Get rid of 'Created' Column
|
||||
CREATE TABLE Temp(Key TEXT NOT NULL UNIQUE, Value INTEGER NOT NULL);
|
||||
INSERT INTO Temp SELECT Key, Value FROM Meta;
|
||||
DROP TABLE Meta;
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user