diff --git a/src/Logger.cpp b/src/Logger.cpp index 557cec0..a714b55 100644 --- a/src/Logger.cpp +++ b/src/Logger.cpp @@ -75,7 +75,7 @@ void fatal(const std::string& toPrint) { std::cout << Print; addToLog(Print); std::this_thread::sleep_for(std::chrono::seconds(5)); - _Exit(-1); + std::exit(1); } void except(const std::string& toPrint) { std::string Print = getDate() + "[EXCEP] " + toPrint + "\n"; diff --git a/src/Security/BeamNG.cpp b/src/Security/BeamNG.cpp index 0ec69d9..ca53361 100644 --- a/src/Security/BeamNG.cpp +++ b/src/Security/BeamNG.cpp @@ -290,36 +290,6 @@ bool IDCheck(std::string Man, std::string steam) { return a; } void LegitimacyCheck() { - -// std::string K1 = R"(Software\Valve\Steam)"; -// std::string K2 = R"(Software\Valve\Steam\Apps\284160)"; - -/*LONG dwRegOPenKey = OpenKey(HKEY_CURRENT_USER, K1.c_str(), &hKey); - -if(dwRegOPenKey == ERROR_SUCCESS) { - Result = QueryKey(hKey, 1); - if(Result.empty())Exit(1); - - if(fs::exists(Result)){ - if(!Find("284160.json",Result))Exit(2); - if(FindHack(Result))SteamExit(1); - }else Exit(3); - - T = Result; - Result.clear(); - TraceBack++; -}else Exit(4); - -K1.clear(); -RegCloseKey(hKey); -dwRegOPenKey = OpenKey(HKEY_CURRENT_USER, K2.c_str(), &hKey); -if(dwRegOPenKey == ERROR_SUCCESS) { - Result = QueryKey(hKey, 2); - if(Result.empty())lowExit(1); - TraceBack++; -}else lowExit(2); -K2.clear(); -RegCloseKey(hKey);*/ #if defined(_WIN32) std::string Result; std::string K3 = R"(Software\BeamNG\BeamNG.drive)"; @@ -329,15 +299,12 @@ RegCloseKey(hKey);*/ Result = QueryKey(hKey, 3); if (Result.empty()) lowExit(3); - // if(IDCheck(Result,T))lowExit(5); GameDir = Result; - // TraceBack++; } else lowExit(4); K3.clear(); Result.clear(); RegCloseKey(hKey); -// if(TraceBack < 3)exit(-1); #elif defined(__linux__) struct passwd* pw = getpwuid(getuid()); std::string homeDir = pw->pw_dir; diff --git a/src/main.cpp b/src/main.cpp index 8c0dfe9..f748574 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,7 +20,7 @@ } } -int main(int argc, char* argv[]) { +int main(int argc, char** argv) try { #ifdef DEBUG std::thread th(flush); th.detach(); @@ -40,13 +40,20 @@ int main(int argc, char* argv[]) { try { LegitimacyCheck(); } catch (std::exception& e) { - fatal("Main 1 : " + std::string(e.what())); + error("Failure in LegitimacyCheck: " + std::string(e.what())); + throw; } - HTTP::StartProxy(); + try { + HTTP::StartProxy(); + } catch (const std::exception& e) { + error(std::string("Failed to start HTTP proxy: Some in-game functions may not work. Error: ") + e.what()); + } PreGame(GetGameDir()); InitGame(GetGameDir()); CoreNetwork(); - - /// TODO: make sure to use argv[0] for everything that should be in the same dir (mod down ect...) +} catch (const std::exception& e) { + error(std::string("Exception in main(): ") + e.what()); + info("Closing in 5 seconds"); + std::this_thread::sleep_for(std::chrono::seconds(5)); }