mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-06-16 11:44:22 +00:00
Compare commits
3 Commits
entity-cle
...
v3.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b9f7e44c7 | ||
|
|
08a168de88 | ||
|
|
0c948a8df6 |
@@ -72,7 +72,7 @@ std::string FdbToSqlite::Convert::ReadString(std::istream& cdClientBuffer) {
|
||||
const auto readString = BinaryIO::ReadU8String(cdClientBuffer);
|
||||
|
||||
cdClientBuffer.seekg(prevPosition);
|
||||
return GeneralUtils::Latin1ToWTF8(readString);
|
||||
return GeneralUtils::Latin1ToUTF8(readString);
|
||||
}
|
||||
|
||||
int32_t FdbToSqlite::Convert::SeekPointer(std::istream& cdClientBuffer) {
|
||||
|
||||
@@ -167,11 +167,18 @@ std::u16string GeneralUtils::ASCIIToUTF16(const std::string_view string, const s
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string GeneralUtils::Latin1ToUTF8(const std::u8string_view string, const size_t size) {
|
||||
std::string toReturn{};
|
||||
|
||||
//! Converts a (potentially-ill-formed) Latin1 string to UTF-8
|
||||
for (const auto u : string) {
|
||||
PushUTF8CodePoint(toReturn, u);
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
//! Converts a (potentially-ill-formed) UTF-16 string to UTF-8
|
||||
//! See: <http://simonsapin.github.io/wtf-8/#decoding-ill-formed-utf-16>
|
||||
template<typename StringType>
|
||||
std::string ToWTF8(const StringType string, const size_t size) {
|
||||
std::string GeneralUtils::UTF16ToWTF8(const std::u16string_view string, const size_t size) {
|
||||
const size_t newSize = MinSize(size, string);
|
||||
std::string ret;
|
||||
ret.reserve(newSize);
|
||||
@@ -196,13 +203,6 @@ std::string ToWTF8(const StringType string, const size_t size) {
|
||||
|
||||
return ret;
|
||||
}
|
||||
std::string GeneralUtils::Latin1ToWTF8(const std::u8string_view string, const size_t size) {
|
||||
return ToWTF8(string, size);
|
||||
}
|
||||
|
||||
std::string GeneralUtils::UTF16ToWTF8(const std::u16string_view string, const size_t size) {
|
||||
return ToWTF8(string, size);
|
||||
}
|
||||
|
||||
bool GeneralUtils::CaseInsensitiveStringCompare(const std::string_view a, const std::string_view b) {
|
||||
return std::equal(a.begin(), a.end(), b.begin(), b.end(), [](char a, char b) { return tolower(a) == tolower(b); });
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace GeneralUtils {
|
||||
\param size A size to trim the string to. Default is SIZE_MAX (No trimming)
|
||||
\return An UTF-8 representation of the string
|
||||
*/
|
||||
std::string Latin1ToWTF8(const std::u8string_view string, const size_t size = SIZE_MAX);
|
||||
std::string Latin1ToUTF8(const std::u8string_view string, const size_t size = SIZE_MAX);
|
||||
|
||||
//! Converts a UTF-16 string to a UTF-8 string
|
||||
/*!
|
||||
|
||||
@@ -267,35 +267,20 @@ int main(int argc, char** argv) {
|
||||
|
||||
// pre calculate the FDB checksum
|
||||
if (Game::config->GetValue("check_fdb") == "1") {
|
||||
std::ifstream fileStream;
|
||||
|
||||
static const std::vector<std::string> 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;
|
||||
}
|
||||
}
|
||||
auto cdclient = Game::assetManager->GetFile("cdclient.fdb");
|
||||
if (cdclient) {
|
||||
|
||||
const int32_t bufferSize = 1024;
|
||||
MD5 md5;
|
||||
|
||||
char fileStreamBuffer[1024] = {};
|
||||
char fileStreamBuffer[bufferSize] = {};
|
||||
|
||||
while (!fileStream.eof()) {
|
||||
while (!cdclient.eof()) {
|
||||
memset(fileStreamBuffer, 0, bufferSize);
|
||||
fileStream.read(fileStreamBuffer, bufferSize);
|
||||
md5.update(fileStreamBuffer, fileStream.gcount());
|
||||
cdclient.read(fileStreamBuffer, bufferSize);
|
||||
md5.update(fileStreamBuffer, cdclient.gcount());
|
||||
}
|
||||
|
||||
fileStream.close();
|
||||
|
||||
const char* nullTerminateBuffer = "\0";
|
||||
md5.update(nullTerminateBuffer, 1); // null terminate the data
|
||||
md5.finalize();
|
||||
@@ -303,6 +288,11 @@ int main(int argc, char** argv) {
|
||||
|
||||
LOG("FDB Checksum calculated as: %s", databaseChecksum.c_str());
|
||||
}
|
||||
if (databaseChecksum.empty()) {
|
||||
LOG("check_fdb is on but no fdb file found.");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t currentFrameDelta = highFrameDelta;
|
||||
// These values are adjust them selves to the current framerate should it update.
|
||||
|
||||
Reference in New Issue
Block a user