Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request LiteLDev#60 from LiteLDev/dev
Browse files Browse the repository at this point in the history
DisconnectPacket Patch
  • Loading branch information
ShrBox authored Oct 3, 2021
2 parents ee8c5b0 + da9fc15 commit a5370d5
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
11 changes: 11 additions & 0 deletions LiteLoader/BugFix.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
8 changes: 4 additions & 4 deletions LiteLoader/CheckUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ 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();
std::string LatestRelease = arr[arr.Size() - 1]["name"].GetString();
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();
Expand Down
18 changes: 16 additions & 2 deletions LiteLoader/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@

extern Logger<stdio_commit> 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;
Expand All @@ -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");
}
Expand All @@ -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");
}
}
}
2 changes: 1 addition & 1 deletion LiteLoader/LiteLoader.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "pch.h"
using std::vector;
Logger<stdio_commit> LOG(stdio_commit{"[LL] "});
Logger<stdio_commit> LOG(stdio_commit{"[LL] "});

static void printErrorMessage() {
DWORD error_message_id = ::GetLastError();
Expand Down
3 changes: 3 additions & 0 deletions LiteLoader/LiteLoader.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,9 @@
<ClCompile Include="api\WPlayer.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="BugFix.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="CheckUpdate.cpp" />
<ClCompile Include="Config.cpp" />
<ClCompile Include="debug\MSearch.cpp">
Expand Down
3 changes: 3 additions & 0 deletions LiteLoader/LiteLoader.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,9 @@
<ClCompile Include="api\Packet.cpp">
<Filter>源文件\api</Filter>
</ClCompile>
<ClCompile Include="BugFix.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Library Include="..\lib\libssl.lib">
Expand Down

0 comments on commit a5370d5

Please sign in to comment.