mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-04-05 07:16:29 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2789a8524 | ||
|
|
6f84b56f1b | ||
|
|
6f5197217c | ||
|
|
d1d2b3414b | ||
|
|
a669557726 | ||
|
|
be1f5c04f7 | ||
|
|
1209ff88e2 | ||
|
|
c40af681bf |
@@ -38,6 +38,7 @@ extern std::string MStatus;
|
|||||||
extern std::string UlStatus;
|
extern std::string UlStatus;
|
||||||
extern std::string PublicKey;
|
extern std::string PublicKey;
|
||||||
extern std::string PrivateKey;
|
extern std::string PrivateKey;
|
||||||
|
extern std::string magic;
|
||||||
int KillSocket(uint64_t Dead);
|
int KillSocket(uint64_t Dead);
|
||||||
void UUl(const std::string& R);
|
void UUl(const std::string& R);
|
||||||
void UDPSend(std::string Data);
|
void UDPSend(std::string Data);
|
||||||
|
|||||||
@@ -21,12 +21,14 @@
|
|||||||
#define beammp_fs_string std::wstring
|
#define beammp_fs_string std::wstring
|
||||||
#define beammp_fs_char wchar_t
|
#define beammp_fs_char wchar_t
|
||||||
#define beammp_wide(str) L##str
|
#define beammp_wide(str) L##str
|
||||||
|
#define beammp_stdout std::wcout
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
#define beammp_fs_string std::string
|
#define beammp_fs_string std::string
|
||||||
#define beammp_fs_char char
|
#define beammp_fs_char char
|
||||||
#define beammp_wide(str) str
|
#define beammp_wide(str) str
|
||||||
|
#define beammp_stdout std::cout
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
@@ -120,13 +122,6 @@ namespace Utils {
|
|||||||
if (line.empty() || line[0] == ';' || line[0] == '#')
|
if (line.empty() || line[0] == ';' || line[0] == '#')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (auto& c : line) {
|
|
||||||
if (c == '#' || c == ';') {
|
|
||||||
line = line.substr(0, &c - &line[0]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto invalidLineLog = [&]{
|
auto invalidLineLog = [&]{
|
||||||
debug("Invalid INI line: " + line);
|
debug("Invalid INI line: " + line);
|
||||||
debug("Surrounding lines: \n" +
|
debug("Surrounding lines: \n" +
|
||||||
|
|||||||
@@ -57,36 +57,36 @@ void addToLog(const std::wstring& Line) {
|
|||||||
}
|
}
|
||||||
void info(const std::string& toPrint) {
|
void info(const std::string& toPrint) {
|
||||||
std::string Print = getDate() + "[INFO] " + toPrint + "\n";
|
std::string Print = getDate() + "[INFO] " + toPrint + "\n";
|
||||||
std::cout << Print;
|
beammp_stdout << Utils::ToWString(Print);
|
||||||
addToLog(Print);
|
addToLog(Print);
|
||||||
}
|
}
|
||||||
void debug(const std::string& toPrint) {
|
void debug(const std::string& toPrint) {
|
||||||
std::string Print = getDate() + "[DEBUG] " + toPrint + "\n";
|
std::string Print = getDate() + "[DEBUG] " + toPrint + "\n";
|
||||||
if (options.verbose) {
|
if (options.verbose) {
|
||||||
std::cout << Print;
|
beammp_stdout << Utils::ToWString(Print);
|
||||||
}
|
}
|
||||||
addToLog(Print);
|
addToLog(Print);
|
||||||
}
|
}
|
||||||
void warn(const std::string& toPrint) {
|
void warn(const std::string& toPrint) {
|
||||||
std::string Print = getDate() + "[WARN] " + toPrint + "\n";
|
std::string Print = getDate() + "[WARN] " + toPrint + "\n";
|
||||||
std::cout << Print;
|
beammp_stdout << Utils::ToWString(Print);
|
||||||
addToLog(Print);
|
addToLog(Print);
|
||||||
}
|
}
|
||||||
void error(const std::string& toPrint) {
|
void error(const std::string& toPrint) {
|
||||||
std::string Print = getDate() + "[ERROR] " + toPrint + "\n";
|
std::string Print = getDate() + "[ERROR] " + toPrint + "\n";
|
||||||
std::cout << Print;
|
beammp_stdout << Utils::ToWString(Print);
|
||||||
addToLog(Print);
|
addToLog(Print);
|
||||||
}
|
}
|
||||||
void fatal(const std::string& toPrint) {
|
void fatal(const std::string& toPrint) {
|
||||||
std::string Print = getDate() + "[FATAL] " + toPrint + "\n";
|
std::string Print = getDate() + "[FATAL] " + toPrint + "\n";
|
||||||
std::cout << Print;
|
beammp_stdout << Utils::ToWString(Print);
|
||||||
addToLog(Print);
|
addToLog(Print);
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||||
std::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
void except(const std::string& toPrint) {
|
void except(const std::string& toPrint) {
|
||||||
std::string Print = getDate() + "[EXCEP] " + toPrint + "\n";
|
std::string Print = getDate() + "[EXCEP] " + toPrint + "\n";
|
||||||
std::cout << Print;
|
beammp_stdout << Utils::ToWString(Print);
|
||||||
addToLog(Print);
|
addToLog(Print);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ bool GConnected = false;
|
|||||||
bool CServer = true;
|
bool CServer = true;
|
||||||
SOCKET CSocket = -1;
|
SOCKET CSocket = -1;
|
||||||
SOCKET GSocket = -1;
|
SOCKET GSocket = -1;
|
||||||
|
std::string magic;
|
||||||
|
|
||||||
int KillSocket(uint64_t Dead) {
|
int KillSocket(uint64_t Dead) {
|
||||||
if (Dead == (SOCKET)-1) {
|
if (Dead == (SOCKET)-1) {
|
||||||
@@ -218,6 +219,8 @@ void ParserAsync(std::string_view Data) {
|
|||||||
MStatus = Data;
|
MStatus = Data;
|
||||||
UlStatus = "Uldone";
|
UlStatus = "Uldone";
|
||||||
return;
|
return;
|
||||||
|
case 'U':
|
||||||
|
magic = Data.substr(1);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ void UDPClientMain(const std::string& IP, int Port) {
|
|||||||
ToServer->sin_port = htons(Port);
|
ToServer->sin_port = htons(Port);
|
||||||
inet_pton(AF_INET, IP.c_str(), &ToServer->sin_addr);
|
inet_pton(AF_INET, IP.c_str(), &ToServer->sin_addr);
|
||||||
UDPSock = socket(AF_INET, SOCK_DGRAM, 0);
|
UDPSock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
|
if (!magic.empty())
|
||||||
|
UDPSend(magic);
|
||||||
GameSend("P" + std::to_string(ClientID));
|
GameSend("P" + std::to_string(ClientID));
|
||||||
TCPSend("H", TCPSock);
|
TCPSend("H", TCPSock);
|
||||||
UDPSend("p");
|
UDPSend("p");
|
||||||
|
|||||||
@@ -177,6 +177,10 @@ void LegitimacyCheck() {
|
|||||||
std::string contents((std::istreambuf_iterator(beamngIni)), std::istreambuf_iterator<char>());
|
std::string contents((std::istreambuf_iterator(beamngIni)), std::istreambuf_iterator<char>());
|
||||||
beamngIni.close();
|
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);
|
auto ini = Utils::ParseINI(contents);
|
||||||
if (ini.empty())
|
if (ini.empty())
|
||||||
lowExit(3);
|
lowExit(3);
|
||||||
|
|||||||
@@ -84,10 +84,10 @@ beammp_fs_string GetEN() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string GetVer() {
|
std::string GetVer() {
|
||||||
return "2.6";
|
return "2.7";
|
||||||
}
|
}
|
||||||
std::string GetPatch() {
|
std::string GetPatch() {
|
||||||
return ".3";
|
return ".0";
|
||||||
}
|
}
|
||||||
|
|
||||||
beammp_fs_string GetEP(const beammp_fs_char* P) {
|
beammp_fs_string GetEP(const beammp_fs_char* P) {
|
||||||
@@ -269,6 +269,8 @@ void LinuxPatch() {
|
|||||||
|
|
||||||
void InitLauncher() {
|
void InitLauncher() {
|
||||||
SetConsoleTitleA(("BeamMP Launcher v" + std::string(GetVer()) + GetPatch()).c_str());
|
SetConsoleTitleA(("BeamMP Launcher v" + std::string(GetVer()) + GetPatch()).c_str());
|
||||||
|
SetConsoleOutputCP(CP_UTF8);
|
||||||
|
_setmode(_fileno(stdout), _O_U8TEXT);
|
||||||
debug("Launcher Version : " + GetVer() + GetPatch());
|
debug("Launcher Version : " + GetVer() + GetPatch());
|
||||||
CheckName();
|
CheckName();
|
||||||
LinuxPatch();
|
LinuxPatch();
|
||||||
|
|||||||
Reference in New Issue
Block a user