diff --git a/LiteLoader/BugFix.cpp b/LiteLoader/BugFix.cpp new file mode 100644 index 0000000000..fcf39a1e12 --- /dev/null +++ b/LiteLoader/BugFix.cpp @@ -0,0 +1,11 @@ +#include "pch.h" + +bool isFixDisconnectBug(); + +//Fix disconnect packet crash bug +THook(void, "?handle@ServerNetworkHandler@@UEAAXAEBVNetworkIdentifier@@AEBVDisconnectPacket@@@Z", ServerNetworkHandler* thi, NetworkIdentifier* ni, void* packet) { + if (isFixDisconnectBug()) { + return; + } + return original(thi, ni, packet); +} \ No newline at end of file diff --git a/LiteLoader/CheckUpdate.cpp b/LiteLoader/CheckUpdate.cpp index b4c2e9bda7..dc7078d6b8 100644 --- a/LiteLoader/CheckUpdate.cpp +++ b/LiteLoader/CheckUpdate.cpp @@ -13,7 +13,7 @@ void checkUpdate() { if (res) { json.Parse(res->body.c_str()); if (json.HasParseError()) { - std::cout << "[Liteloader] Failed to get updates(1)\n"; + LOG("Failed to get updates(1)"); return; } auto arr = json.GetArray(); @@ -21,12 +21,12 @@ void checkUpdate() { int latestVersionNum = arr[arr.Size() - 1]["versionNum"].GetInt(); if (latestVersionNum > LITELOADER_VERSION_NUMBER) { std::string content = arr[arr.Size() - 1]["content"].GetString(); - LOG("[Liteloader] Found a new version: ", LatestRelease, " ", content); + LOG("Found a new version: ", LatestRelease, " ", content); } else if (latestVersionNum < LITELOADER_VERSION_NUMBER) { - LOG("[Liteloader] Using preview version: ", LITELOADER_VERSION); + LOG("Using preview version: ", LITELOADER_VERSION); } } else { - std::cout << "[Liteloader] Failed to get updates(0)\n"; + LOG("Failed to get updates(0)"); } }); t.detach(); diff --git a/LiteLoader/Config.cpp b/LiteLoader/Config.cpp index 483694ace9..b6d1921c5f 100644 --- a/LiteLoader/Config.cpp +++ b/LiteLoader/Config.cpp @@ -5,11 +5,16 @@ extern Logger LOG; bool LoaderDebugMode = false; +bool FixDisconnectBug = true; LIAPI bool loaderapi::isDebugMode() { return LoaderDebugMode; } +bool isFixDisconnectBug() { + return FixDisconnectBug; +} + void loadConfig() { std::string config_file = "liteloader.json"; std::ifstream fs; @@ -18,7 +23,7 @@ void loadConfig() { LOG(config_file, " not found, creating configuration file"); std::ofstream of(config_file); if (of) { - of << "{\n \"DebugMode\": false\n}"; + of << "{\n \"DebugMode\": false,\n \"FixDisconnectBug\": true\n}"; } else { LOG("Configuration file creation failed"); } @@ -30,6 +35,15 @@ void loadConfig() { } rapidjson::Document document; document.Parse(json.c_str()); - LoaderDebugMode = document["DebugMode"].GetBool(); + if (!document["DebugMode"].IsNull()) { + LoaderDebugMode = document["DebugMode"].GetBool(); + } else { + LOG("Could not found DebugMoade in config"); + } + if (!document["FixDisconnectBug"].IsNull()) { + FixDisconnectBug = document["FixDisconnectBug"].GetBool(); + } else { + LOG("Could not found FixDisconnectBug in config"); + } } } \ No newline at end of file diff --git a/LiteLoader/LiteLoader.cpp b/LiteLoader/LiteLoader.cpp index 43f6d25674..54701365d1 100644 --- a/LiteLoader/LiteLoader.cpp +++ b/LiteLoader/LiteLoader.cpp @@ -1,6 +1,6 @@ #include "pch.h" using std::vector; -Logger LOG(stdio_commit{"[LL] "}); +Logger LOG(stdio_commit{"[LL] "}); static void printErrorMessage() { DWORD error_message_id = ::GetLastError(); diff --git a/LiteLoader/LiteLoader.vcxproj b/LiteLoader/LiteLoader.vcxproj index fb5cb7ac37..48a8911c11 100644 --- a/LiteLoader/LiteLoader.vcxproj +++ b/LiteLoader/LiteLoader.vcxproj @@ -487,6 +487,9 @@ NotUsing + + Create + diff --git a/LiteLoader/LiteLoader.vcxproj.filters b/LiteLoader/LiteLoader.vcxproj.filters index 9661a1eb4b..4e9cb6e8ef 100644 --- a/LiteLoader/LiteLoader.vcxproj.filters +++ b/LiteLoader/LiteLoader.vcxproj.filters @@ -1106,6 +1106,9 @@ 源文件\api + + 源文件 +