mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-11 01:48:07 +00:00
experimenting; not looking to pr
This commit is contained in:
@@ -157,7 +157,7 @@ void CDClientManager::LoadValuesFromDatabase() {
|
||||
}
|
||||
|
||||
void CDClientManager::LoadValuesFromDefaults() {
|
||||
LOG("Loading default CDClient tables!");
|
||||
Log::Info("Loading default CDClient tables!");
|
||||
|
||||
CDPetComponentTable::Instance().LoadValuesFromDefaults();
|
||||
}
|
||||
|
@@ -57,7 +57,7 @@ CDPetComponent& CDPetComponentTable::GetByID(const uint32_t componentID) {
|
||||
auto& entries = GetEntriesMutable();
|
||||
auto itr = entries.find(componentID);
|
||||
if (itr == entries.end()) {
|
||||
LOG("Unable to load pet component (ID %i) values from database! Using default values instead.", componentID);
|
||||
Log::Warn("Unable to load pet component (ID {:d}) values from database! Using default values instead.", componentID);
|
||||
return defaultEntry;
|
||||
}
|
||||
return itr->second;
|
||||
|
@@ -15,7 +15,7 @@ target_include_directories(dDatabaseCDClient PUBLIC "."
|
||||
"${PROJECT_SOURCE_DIR}/dCommon"
|
||||
"${PROJECT_SOURCE_DIR}/dCommon/dEnums"
|
||||
)
|
||||
target_link_libraries(dDatabaseCDClient PRIVATE sqlite3)
|
||||
target_link_libraries(dDatabaseCDClient PRIVATE fmt sqlite3)
|
||||
|
||||
if (${CDCLIENT_CACHE_ALL})
|
||||
add_compile_definitions(dDatabaseCDClient PRIVATE CDCLIENT_CACHE_ALL=${CDCLIENT_CACHE_ALL})
|
||||
|
@@ -4,4 +4,5 @@ add_subdirectory(GameDatabase)
|
||||
add_library(dDatabase STATIC "MigrationRunner.cpp")
|
||||
target_include_directories(dDatabase PUBLIC ".")
|
||||
target_link_libraries(dDatabase
|
||||
PUBLIC dDatabaseCDClient dDatabaseGame)
|
||||
PUBLIC dDatabaseCDClient dDatabaseGame
|
||||
PRIVATE fmt)
|
||||
|
@@ -16,6 +16,7 @@ target_include_directories(dDatabaseGame PUBLIC "."
|
||||
)
|
||||
target_link_libraries(dDatabaseGame
|
||||
PUBLIC MariaDB::ConnCpp
|
||||
PRIVATE fmt
|
||||
INTERFACE dCommon)
|
||||
|
||||
# Glob together all headers that need to be precompiled
|
||||
|
@@ -30,7 +30,7 @@ namespace sql {
|
||||
};
|
||||
|
||||
#ifdef _DEBUG
|
||||
# define DLU_SQL_TRY_CATCH_RETHROW(x) do { try { x; } catch (sql::SQLException& ex) { LOG("SQL Error: %s", ex.what()); throw; } } while(0)
|
||||
# define DLU_SQL_TRY_CATCH_RETHROW(x) do { try { x; } catch (sql::SQLException& ex) { Log::Warn("SQL Error: {:s}", ex.what()); throw; } } while(0)
|
||||
#else
|
||||
# define DLU_SQL_TRY_CATCH_RETHROW(x) x
|
||||
#endif // _DEBUG
|
||||
|
@@ -53,8 +53,8 @@ void MySQLDatabase::Connect() {
|
||||
void MySQLDatabase::Destroy(std::string source) {
|
||||
if (!con) return;
|
||||
|
||||
if (source.empty()) LOG("Destroying MySQL connection!");
|
||||
else LOG("Destroying MySQL connection from %s!", source.c_str());
|
||||
if (source.empty()) Log::Info("Destroying MySQL connection!");
|
||||
else Log::Info("Destroying MySQL connection from {:s}!", source);
|
||||
|
||||
con->close();
|
||||
delete con;
|
||||
@@ -68,7 +68,7 @@ void MySQLDatabase::ExecuteCustomQuery(const std::string_view query) {
|
||||
sql::PreparedStatement* MySQLDatabase::CreatePreppedStmt(const std::string& query) {
|
||||
if (!con) {
|
||||
Connect();
|
||||
LOG("Trying to reconnect to MySQL");
|
||||
Log::Info("Trying to reconnect to MySQL");
|
||||
}
|
||||
|
||||
if (!con->isValid() || con->isClosed()) {
|
||||
@@ -77,7 +77,7 @@ sql::PreparedStatement* MySQLDatabase::CreatePreppedStmt(const std::string& quer
|
||||
con = nullptr;
|
||||
|
||||
Connect();
|
||||
LOG("Trying to reconnect to MySQL from invalid or closed connection");
|
||||
Log::Info("Trying to reconnect to MySQL from invalid or closed connection");
|
||||
}
|
||||
|
||||
return con->prepareStatement(sql::SQLString(query.c_str(), query.length()));
|
||||
|
@@ -147,85 +147,85 @@ private:
|
||||
|
||||
template<>
|
||||
inline void SetParam(UniquePreppedStmtRef stmt, const int index, const std::string_view param) {
|
||||
// LOG("%s", param.data());
|
||||
// Log::Info("{:s}", param);
|
||||
stmt->setString(index, param.data());
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void SetParam(UniquePreppedStmtRef stmt, const int index, const char* param) {
|
||||
// LOG("%s", param);
|
||||
// Log::Info("{:s}", param);
|
||||
stmt->setString(index, param);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void SetParam(UniquePreppedStmtRef stmt, const int index, const std::string param) {
|
||||
// LOG("%s", param.c_str());
|
||||
stmt->setString(index, param.c_str());
|
||||
// Log::Info("{:s}", param);
|
||||
stmt->setString(index, param);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void SetParam(UniquePreppedStmtRef stmt, const int index, const int8_t param) {
|
||||
// LOG("%u", param);
|
||||
// Log::Info("{:d}", param);
|
||||
stmt->setByte(index, param);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void SetParam(UniquePreppedStmtRef stmt, const int index, const uint8_t param) {
|
||||
// LOG("%d", param);
|
||||
// Log::Info("{:d}", param);
|
||||
stmt->setByte(index, param);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void SetParam(UniquePreppedStmtRef stmt, const int index, const int16_t param) {
|
||||
// LOG("%u", param);
|
||||
// Log::Info("{:d}", param);
|
||||
stmt->setShort(index, param);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void SetParam(UniquePreppedStmtRef stmt, const int index, const uint16_t param) {
|
||||
// LOG("%d", param);
|
||||
// Log::Info("{:d}", param);
|
||||
stmt->setShort(index, param);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void SetParam(UniquePreppedStmtRef stmt, const int index, const uint32_t param) {
|
||||
// LOG("%u", param);
|
||||
// Log::Info("{:d}", param);
|
||||
stmt->setUInt(index, param);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void SetParam(UniquePreppedStmtRef stmt, const int index, const int32_t param) {
|
||||
// LOG("%d", param);
|
||||
// Log::Info("{:d}", param);
|
||||
stmt->setInt(index, param);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void SetParam(UniquePreppedStmtRef stmt, const int index, const int64_t param) {
|
||||
// LOG("%llu", param);
|
||||
// Log::Info("{:d}", param);
|
||||
stmt->setInt64(index, param);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void SetParam(UniquePreppedStmtRef stmt, const int index, const uint64_t param) {
|
||||
// LOG("%llu", param);
|
||||
// Log::Info("{:d}", param);
|
||||
stmt->setUInt64(index, param);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void SetParam(UniquePreppedStmtRef stmt, const int index, const float param) {
|
||||
// LOG("%f", param);
|
||||
// Log::Info({:f}", param);
|
||||
stmt->setFloat(index, param);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void SetParam(UniquePreppedStmtRef stmt, const int index, const double param) {
|
||||
// LOG("%f", param);
|
||||
// Log::Info("{:f}", param);
|
||||
stmt->setDouble(index, param);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void SetParam(UniquePreppedStmtRef stmt, const int index, const bool param) {
|
||||
// LOG("%d", param);
|
||||
// Log::Info("{:d}", param);
|
||||
stmt->setBoolean(index, param);
|
||||
}
|
||||
|
||||
@@ -239,10 +239,10 @@ inline void SetParam(UniquePreppedStmtRef stmt, const int index, const std::istr
|
||||
template<>
|
||||
inline void SetParam(UniquePreppedStmtRef stmt, const int index, const std::optional<uint32_t> param) {
|
||||
if (param) {
|
||||
// LOG("%d", param.value());
|
||||
// Log::Info("{:f}", param.value());
|
||||
stmt->setInt(index, param.value());
|
||||
} else {
|
||||
// LOG("Null");
|
||||
// Log::Info("Null");
|
||||
stmt->setNull(index, sql::DataType::SQLNULL);
|
||||
}
|
||||
}
|
||||
|
@@ -38,8 +38,8 @@ void MySQLDatabase::InsertNewPropertyModel(const LWOOBJID& propertyId, const IPr
|
||||
0, // behavior 4. TODO implement this.
|
||||
0 // behavior 5. TODO implement this.
|
||||
);
|
||||
} catch (sql::SQLException& e) {
|
||||
LOG("Error inserting new property model: %s", e.what());
|
||||
} catch (const sql::SQLException& e) {
|
||||
Log::Warn("Error inserting new property model: {:s}", e.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -45,7 +45,7 @@ void MigrationRunner::RunMigrations() {
|
||||
|
||||
if (Database::Get()->IsMigrationRun(migration.name)) continue;
|
||||
|
||||
LOG("Running migration: %s", migration.name.c_str());
|
||||
Log::Info("Running migration: {:s}", migration.name);
|
||||
if (migration.name == "dlu/5_brick_model_sd0.sql") {
|
||||
runSd0Migrations = true;
|
||||
} else {
|
||||
@@ -56,7 +56,7 @@ void MigrationRunner::RunMigrations() {
|
||||
}
|
||||
|
||||
if (finalSQL.empty() && !runSd0Migrations) {
|
||||
LOG("Server database is up to date.");
|
||||
Log::Info("Server database is up to date.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ void MigrationRunner::RunMigrations() {
|
||||
if (query.empty()) continue;
|
||||
Database::Get()->ExecuteCustomQuery(query.c_str());
|
||||
} catch (sql::SQLException& e) {
|
||||
LOG("Encountered error running migration: %s", e.what());
|
||||
Log::Info("Encountered error running migration: {:s}", e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,9 +75,9 @@ void MigrationRunner::RunMigrations() {
|
||||
// Do this last on the off chance none of the other migrations have been run yet.
|
||||
if (runSd0Migrations) {
|
||||
uint32_t numberOfUpdatedModels = BrickByBrickFix::UpdateBrickByBrickModelsToSd0();
|
||||
LOG("%i models were updated from zlib to sd0.", numberOfUpdatedModels);
|
||||
Log::Info("{:d} models were updated from zlib to sd0.", numberOfUpdatedModels);
|
||||
uint32_t numberOfTruncatedModels = BrickByBrickFix::TruncateBrokenBrickByBrickXml();
|
||||
LOG("%i models were truncated from the database.", numberOfTruncatedModels);
|
||||
Log::Info("{:d} models were truncated from the database.", numberOfTruncatedModels);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,14 +111,14 @@ void MigrationRunner::RunSQLiteMigrations() {
|
||||
|
||||
// Doing these 1 migration at a time since one takes a long time and some may think it is crashing.
|
||||
// This will at the least guarentee that the full migration needs to be run in order to be counted as "migrated".
|
||||
LOG("Executing migration: %s. This may take a while. Do not shut down server.", migration.name.c_str());
|
||||
Log::Info("Executing migration: {:s}. This may take a while. Do not shut down server.", migration.name);
|
||||
CDClientDatabase::ExecuteQuery("BEGIN TRANSACTION;");
|
||||
for (const auto& dml : GeneralUtils::SplitString(migration.data, ';')) {
|
||||
if (dml.empty()) continue;
|
||||
try {
|
||||
CDClientDatabase::ExecuteDML(dml.c_str());
|
||||
} catch (CppSQLite3Exception& e) {
|
||||
LOG("Encountered error running DML command: (%i) : %s", e.errorCode(), e.errorMessage());
|
||||
Log::Warn("Encountered error running DML command: ({:d}) : {:s}", e.errorCode(), e.errorMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,5 +129,5 @@ void MigrationRunner::RunSQLiteMigrations() {
|
||||
CDClientDatabase::ExecuteQuery("COMMIT;");
|
||||
}
|
||||
|
||||
LOG("CDServer database is up to date.");
|
||||
Log::Info("CDServer database is up to date.");
|
||||
}
|
||||
|
Reference in New Issue
Block a user