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#61 from LiteLDev/dev
Browse files Browse the repository at this point in the history
Add FixListenPort
  • Loading branch information
ShrBox authored Oct 3, 2021
2 parents a5370d5 + 9ff9b5f commit 99fc30b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
16 changes: 16 additions & 0 deletions LiteLoader/BugFix.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
#include "pch.h"

bool isFixDisconnectBug();
bool isFixListenPort();

//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);
}
//Fix the listening port twice
//From /~https://github.com/Redbeanw44602/FixIPLogger
bool a_call = true;
THook(__int64, "?LogIPSupport@RakPeerHelper@@AEAAXXZ",
void* _this) {
if (isFixListenPort()) {
if (a_call) {
a_call = false;
return original(_this);
}
return 0;
} else {
return original(_this);
}
}
20 changes: 15 additions & 5 deletions LiteLoader/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
extern Logger<stdio_commit> LOG;
bool LoaderDebugMode = false;
bool FixDisconnectBug = true;
bool FixListenPort = true;

LIAPI bool loaderapi::isDebugMode() {
return LoaderDebugMode;
Expand All @@ -15,17 +16,21 @@ bool isFixDisconnectBug() {
return FixDisconnectBug;
}

bool isFixListenPort() {
return FixListenPort;
}

void loadConfig() {
std::string config_file = "liteloader.json";
std::ifstream fs;
fs.open(config_file, std::ios::in);
if (!fs) {
LOG(config_file, " not found, creating configuration file");
LOG("", config_file, "not found, creating configuration file");
std::ofstream of(config_file);
if (of) {
of << "{\n \"DebugMode\": false,\n \"FixDisconnectBug\": true\n}";
of << "{\n \"DebugMode\": false,\n \"FixDisconnectBug\": true,\n \"FixListenPort\": true\n}";
} else {
LOG("Configuration file creation failed");
LOG(" Configuration file creation failed");
}
} else {
std::string json;
Expand All @@ -38,12 +43,17 @@ void loadConfig() {
if (!document["DebugMode"].IsNull()) {
LoaderDebugMode = document["DebugMode"].GetBool();
} else {
LOG("Could not found DebugMoade in config");
LOG(" Could not found DebugMoade in config");
}
if (!document["FixDisconnectBug"].IsNull()) {
FixDisconnectBug = document["FixDisconnectBug"].GetBool();
} else {
LOG("Could not found FixDisconnectBug in config");
LOG(" Could not found FixDisconnectBug in config");
}
if (!document["FixListenPort"].IsNull()) {
FixListenPort = document["FixListenPort"].GetBool();
} else {
LOG(" Could not found FixListenPort in config");
}
}
}

0 comments on commit 99fc30b

Please sign in to comment.