From 7e2747a2d2dc286cf5dcb3c90769c607b1a6c741 Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Fri, 4 Aug 2023 17:48:45 -0500 Subject: [PATCH] fix: load fdbchecksum to verify, even on character selection (world 0) (#1176) --- dWorldServer/WorldServer.cpp | 81 ++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/dWorldServer/WorldServer.cpp b/dWorldServer/WorldServer.cpp index f07c17e3..644e6ce8 100644 --- a/dWorldServer/WorldServer.cpp +++ b/dWorldServer/WorldServer.cpp @@ -262,50 +262,51 @@ int main(int argc, char** argv) { Game::zoneManager->Initialize(LWOZONEID(zoneID, instanceID, cloneID)); g_CloneID = cloneID; - // pre calculate the FDB checksum - if (Game::config->GetValue("check_fdb") == "1") { - std::ifstream fileStream; - - static const std::vector aliases = { - "CDServers.fdb", - "cdserver.fdb", - "CDClient.fdb", - "cdclient.fdb", - }; - - for (const auto& file : aliases) { - fileStream.open(Game::assetManager->GetResPath() / file, std::ios::binary | std::ios::in); - if (fileStream.is_open()) { - break; - } - } - - const int32_t bufferSize = 1024; - MD5* md5 = new MD5(); - - char fileStreamBuffer[1024] = {}; - - while (!fileStream.eof()) { - memset(fileStreamBuffer, 0, bufferSize); - fileStream.read(fileStreamBuffer, bufferSize); - md5->update(fileStreamBuffer, fileStream.gcount()); - } - - fileStream.close(); - - const char* nullTerminateBuffer = "\0"; - md5->update(nullTerminateBuffer, 1); // null terminate the data - md5->finalize(); - databaseChecksum = md5->hexdigest(); - - delete md5; - - Game::logger->Log("WorldServer", "FDB Checksum calculated as: %s", databaseChecksum.c_str()); - } } else { Game::entityManager->Initialize(); } + // pre calculate the FDB checksum + if (Game::config->GetValue("check_fdb") == "1") { + std::ifstream fileStream; + + static const std::vector aliases = { + "CDServers.fdb", + "cdserver.fdb", + "CDClient.fdb", + "cdclient.fdb", + }; + + for (const auto& file : aliases) { + fileStream.open(Game::assetManager->GetResPath() / file, std::ios::binary | std::ios::in); + if (fileStream.is_open()) { + break; + } + } + + const int32_t bufferSize = 1024; + MD5* md5 = new MD5(); + + char fileStreamBuffer[1024] = {}; + + while (!fileStream.eof()) { + memset(fileStreamBuffer, 0, bufferSize); + fileStream.read(fileStreamBuffer, bufferSize); + md5->update(fileStreamBuffer, fileStream.gcount()); + } + + fileStream.close(); + + const char* nullTerminateBuffer = "\0"; + md5->update(nullTerminateBuffer, 1); // null terminate the data + md5->finalize(); + databaseChecksum = md5->hexdigest(); + + delete md5; + + Game::logger->Log("WorldServer", "FDB Checksum calculated as: %s", databaseChecksum.c_str()); + } + uint32_t currentFrameDelta = highFrameDelta; // These values are adjust them selves to the current framerate should it update. uint32_t logFlushTime = 15 * currentFramerate; // 15 seconds in frames