mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-01-09 22:37:07 +00:00
update cdclient.fdb file check (#1699)
This commit is contained in:
parent
0c948a8df6
commit
08a168de88
@ -267,8 +267,6 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
// pre calculate the FDB checksum
|
// pre calculate the FDB checksum
|
||||||
if (Game::config->GetValue("check_fdb") == "1") {
|
if (Game::config->GetValue("check_fdb") == "1") {
|
||||||
std::ifstream fileStream;
|
|
||||||
|
|
||||||
static const std::vector<std::string> aliases = {
|
static const std::vector<std::string> aliases = {
|
||||||
"CDServers.fdb",
|
"CDServers.fdb",
|
||||||
"cdserver.fdb",
|
"cdserver.fdb",
|
||||||
@ -277,31 +275,33 @@ int main(int argc, char** argv) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (const auto& file : aliases) {
|
for (const auto& file : aliases) {
|
||||||
fileStream.open(Game::assetManager->GetResPath() / file, std::ios::binary | std::ios::in);
|
auto cdclient = Game::assetManager->GetFile("cdclient.fdb");
|
||||||
if (fileStream.is_open()) {
|
if (cdclient) {
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const int32_t bufferSize = 1024;
|
const int32_t bufferSize = 1024;
|
||||||
MD5 md5;
|
MD5 md5;
|
||||||
|
|
||||||
char fileStreamBuffer[1024] = {};
|
char fileStreamBuffer[1024] = {};
|
||||||
|
|
||||||
while (!fileStream.eof()) {
|
while (!cdclient.eof()) {
|
||||||
memset(fileStreamBuffer, 0, bufferSize);
|
memset(fileStreamBuffer, 0, bufferSize);
|
||||||
fileStream.read(fileStreamBuffer, bufferSize);
|
cdclient.read(fileStreamBuffer, bufferSize);
|
||||||
md5.update(fileStreamBuffer, fileStream.gcount());
|
md5.update(fileStreamBuffer, cdclient.gcount());
|
||||||
}
|
}
|
||||||
|
|
||||||
fileStream.close();
|
|
||||||
|
|
||||||
const char* nullTerminateBuffer = "\0";
|
const char* nullTerminateBuffer = "\0";
|
||||||
md5.update(nullTerminateBuffer, 1); // null terminate the data
|
md5.update(nullTerminateBuffer, 1); // null terminate the data
|
||||||
md5.finalize();
|
md5.finalize();
|
||||||
databaseChecksum = md5.hexdigest();
|
databaseChecksum = md5.hexdigest();
|
||||||
|
|
||||||
LOG("FDB Checksum calculated as: %s", databaseChecksum.c_str());
|
LOG("FDB Checksum calculated as: %s", databaseChecksum.c_str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (databaseChecksum.empty()) {
|
||||||
|
LOG("check_fdb is on but no fdb file found.");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t currentFrameDelta = highFrameDelta;
|
uint32_t currentFrameDelta = highFrameDelta;
|
||||||
|
Loading…
Reference in New Issue
Block a user