mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-04-05 15:26:11 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db1aad37a8 |
@@ -21,14 +21,12 @@
|
||||
#define beammp_fs_string std::wstring
|
||||
#define beammp_fs_char wchar_t
|
||||
#define beammp_wide(str) L##str
|
||||
#define beammp_stdout std::wcout
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#else
|
||||
#define beammp_fs_string std::string
|
||||
#define beammp_fs_char char
|
||||
#define beammp_wide(str) str
|
||||
#define beammp_stdout std::cout
|
||||
#endif
|
||||
|
||||
namespace Utils {
|
||||
@@ -122,6 +120,13 @@ namespace Utils {
|
||||
if (line.empty() || line[0] == ';' || line[0] == '#')
|
||||
continue;
|
||||
|
||||
for (auto& c : line) {
|
||||
if (c == '#' || c == ';') {
|
||||
line = line.substr(0, &c - &line[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
auto invalidLineLog = [&]{
|
||||
debug("Invalid INI line: " + line);
|
||||
debug("Surrounding lines: \n" +
|
||||
|
||||
@@ -148,7 +148,13 @@ void StartGame(std::wstring Dir) {
|
||||
|
||||
debug(L"BeamNG executable path: " + Dir);
|
||||
|
||||
bSuccess = CreateProcessW(nullptr, (wchar_t*)(Dir + gameArgs).c_str(), nullptr, nullptr, TRUE, 0, nullptr, BaseDir.c_str(), &si, &pi);
|
||||
wchar_t* lpApplicationName = Dir.data();
|
||||
wchar_t* lpCommandLine = (Dir + gameArgs).data();
|
||||
|
||||
debug(L"lpApplicationName: " + std::wstring(lpApplicationName));
|
||||
debug(L"lpCommandLine: " + std::wstring(lpCommandLine));
|
||||
|
||||
bSuccess = CreateProcessW(lpApplicationName, lpCommandLine, nullptr, nullptr, TRUE, 0, nullptr, BaseDir.c_str(), &si, &pi);
|
||||
if (bSuccess) {
|
||||
info("Game Launched!");
|
||||
GamePID = pi.dwProcessId;
|
||||
|
||||
@@ -57,36 +57,36 @@ void addToLog(const std::wstring& Line) {
|
||||
}
|
||||
void info(const std::string& toPrint) {
|
||||
std::string Print = getDate() + "[INFO] " + toPrint + "\n";
|
||||
beammp_stdout << Utils::ToWString(Print);
|
||||
std::cout << Print;
|
||||
addToLog(Print);
|
||||
}
|
||||
void debug(const std::string& toPrint) {
|
||||
std::string Print = getDate() + "[DEBUG] " + toPrint + "\n";
|
||||
if (options.verbose) {
|
||||
beammp_stdout << Utils::ToWString(Print);
|
||||
std::cout << Print;
|
||||
}
|
||||
addToLog(Print);
|
||||
}
|
||||
void warn(const std::string& toPrint) {
|
||||
std::string Print = getDate() + "[WARN] " + toPrint + "\n";
|
||||
beammp_stdout << Utils::ToWString(Print);
|
||||
std::cout << Print;
|
||||
addToLog(Print);
|
||||
}
|
||||
void error(const std::string& toPrint) {
|
||||
std::string Print = getDate() + "[ERROR] " + toPrint + "\n";
|
||||
beammp_stdout << Utils::ToWString(Print);
|
||||
std::cout << Print;
|
||||
addToLog(Print);
|
||||
}
|
||||
void fatal(const std::string& toPrint) {
|
||||
std::string Print = getDate() + "[FATAL] " + toPrint + "\n";
|
||||
beammp_stdout << Utils::ToWString(Print);
|
||||
std::cout << Print;
|
||||
addToLog(Print);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
std::exit(1);
|
||||
}
|
||||
void except(const std::string& toPrint) {
|
||||
std::string Print = getDate() + "[EXCEP] " + toPrint + "\n";
|
||||
beammp_stdout << Utils::ToWString(Print);
|
||||
std::cout << Print;
|
||||
addToLog(Print);
|
||||
}
|
||||
|
||||
|
||||
@@ -177,10 +177,6 @@ void LegitimacyCheck() {
|
||||
std::string contents((std::istreambuf_iterator(beamngIni)), std::istreambuf_iterator<char>());
|
||||
beamngIni.close();
|
||||
|
||||
if (contents.size() >= 3 && (unsigned char)contents[0] == 0xEF && (unsigned char)contents[1] == 0xBB && (unsigned char)contents[2] == 0xBF) {
|
||||
contents = contents.substr(3);
|
||||
}
|
||||
|
||||
auto ini = Utils::ParseINI(contents);
|
||||
if (ini.empty())
|
||||
lowExit(3);
|
||||
|
||||
@@ -87,7 +87,7 @@ std::string GetVer() {
|
||||
return "2.6";
|
||||
}
|
||||
std::string GetPatch() {
|
||||
return ".4";
|
||||
return ".3";
|
||||
}
|
||||
|
||||
beammp_fs_string GetEP(const beammp_fs_char* P) {
|
||||
@@ -269,8 +269,6 @@ void LinuxPatch() {
|
||||
|
||||
void InitLauncher() {
|
||||
SetConsoleTitleA(("BeamMP Launcher v" + std::string(GetVer()) + GetPatch()).c_str());
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
_setmode(_fileno(stdout), _O_U8TEXT);
|
||||
debug("Launcher Version : " + GetVer() + GetPatch());
|
||||
CheckName();
|
||||
LinuxPatch();
|
||||
|
||||
Reference in New Issue
Block a user