- debug state

- new fail message from pull/58
This commit is contained in:
Anonymous-275 2023-08-04 20:57:52 +01:00
parent a504114809
commit f1d960d062
5 changed files with 38 additions and 19 deletions

View File

@ -79,6 +79,7 @@ class Launcher {
fs::path LauncherCache{"Resources"}; fs::path LauncherCache{"Resources"};
int64_t DiscordTime{}; int64_t DiscordTime{};
bool LoginAuth = false; bool LoginAuth = false;
bool DebugMode = false;
fs::path CurrentPath{}; fs::path CurrentPath{};
std::string BeamRoot{}; std::string BeamRoot{};
std::string UserRole{}; std::string UserRole{};

View File

@ -14,7 +14,8 @@ class Memory {
static uint32_t GetLauncherPID(const std::set<uint32_t>& BL); static uint32_t GetLauncherPID(const std::set<uint32_t>& BL);
static uint64_t GetModuleBase(const char* Name); static uint64_t GetModuleBase(const char* Name);
static void Print(const std::string& msg); static void Print(const std::string& msg);
static std::string GetHex(uint64_t num); static std::string GetHex(uint64_t num);
static inline bool DebugMode = false;
static void Inject(uint32_t PID); static void Inject(uint32_t PID);
static uint32_t GetTickCount(); static uint32_t GetTickCount();
static uint32_t EntryPoint(); static uint32_t EntryPoint();

View File

@ -32,8 +32,15 @@ Launcher::Launcher(int argc, char* argv[]) :
WindowsInit(); WindowsInit();
SetUnhandledExceptionFilter(CrashHandler); SetUnhandledExceptionFilter(CrashHandler);
LOG(INFO) << "Starting Launcher v" << FullVersion; LOG(INFO) << "Starting Launcher v" << FullVersion;
if (argc > 1) LoadConfig(fs::current_path() / argv[1]); if (argc > 1) {
else LoadConfig(fs::current_path() / "Launcher.toml"); if(std::string(argv[1]).find('0') != std::string::npos) {
DebugMode = true;
Memory::DebugMode = true;
LoadConfig(fs::current_path() / "Launcher.toml");
} else {
LoadConfig(fs::current_path() / argv[1]);
}
} else LoadConfig(fs::current_path() / "Launcher.toml");
} }
void Launcher::Abort() { void Launcher::Abort() {

View File

@ -171,10 +171,12 @@ void Memory::Print(const std::string& msg) {
} }
uint32_t Memory::EntryPoint() { uint32_t Memory::EntryPoint() {
AllocConsole(); if (Memory::DebugMode) {
SetConsoleTitleA("BeamMP Console"); AllocConsole();
BeamNG::EntryPoint(); SetConsoleTitleA("BeamMP Console");
return 0; }
BeamNG::EntryPoint();
return 0;
} }
uint32_t Memory::GetTickCount() { uint32_t Memory::GetTickCount() {

View File

@ -41,19 +41,23 @@ size_t DirCount(const std::filesystem::path& path) {
} }
void Launcher::ResetMods() { void Launcher::ResetMods() {
if (!fs::exists(MPUserPath)) { try {
fs::create_directories(MPUserPath); if (!fs::exists(MPUserPath)) {
return; fs::create_directories(MPUserPath);
} return;
if (DirCount(MPUserPath) > 3) {
LOG(WARNING)
<< "mods/multiplayer will be cleared in 15 seconds, close to abort";
std::this_thread::sleep_for(std::chrono::seconds(15));
}
for (auto &de: std::filesystem::directory_iterator(MPUserPath)) {
if (de.path().filename() != "BeamMP.zip") {
std::filesystem::remove(de.path());
} }
if (DirCount(MPUserPath) > 3) {
LOG(WARNING)
<< "mods/multiplayer will be cleared in 15 seconds, close to abort";
std::this_thread::sleep_for(std::chrono::seconds(15));
}
for (auto &de: std::filesystem::directory_iterator(MPUserPath)) {
if (de.path().filename() != "BeamMP.zip") {
std::filesystem::remove(de.path());
}
}
} catch (...) {
throw ShutdownException("We were unable to clean the multiplayer mods folder! Is the game still running or do you have something open in that folder?");
} }
} }
@ -103,6 +107,10 @@ void Launcher::SetupMOD() {
} }
void Launcher::UpdateCheck() { void Launcher::UpdateCheck() {
if(DebugMode){
LOG(DEBUG) << "Debug mode active skipping update checks";
return;
}
std::string LatestHash = HTTP::Get("https://backend.beammp.com/sha/launcher?branch=" + TargetBuild + "&pk=" + PublicKey); std::string LatestHash = HTTP::Get("https://backend.beammp.com/sha/launcher?branch=" + TargetBuild + "&pk=" + PublicKey);
transform(LatestHash.begin(), LatestHash.end(), LatestHash.begin(), ::tolower); transform(LatestHash.begin(), LatestHash.end(), LatestHash.begin(), ::tolower);