mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-04-09 01:06:31 +00:00
Network, bug fixes, more patters, GELua and a lot more
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include <shellapi.h>
|
||||
#include <ShlObj.h>
|
||||
#include <comutil.h>
|
||||
#include <mutex>
|
||||
|
||||
LONG WINAPI CrashHandler(EXCEPTION_POINTERS* p) {
|
||||
LOG(ERROR) << "CAUGHT EXCEPTION! Code " << p->ExceptionRecord->ExceptionCode;
|
||||
@@ -35,6 +36,9 @@ void Launcher::Abort() {
|
||||
if(DiscordRPC.joinable()) {
|
||||
DiscordRPC.join();
|
||||
}
|
||||
if(IPCSystem.joinable()) {
|
||||
IPCSystem.join();
|
||||
}
|
||||
if(!MPUserPath.empty()) {
|
||||
ResetMods();
|
||||
}
|
||||
@@ -114,8 +118,8 @@ void Launcher::WaitForGame() {
|
||||
throw ShutdownException("Fatal Error");
|
||||
}
|
||||
LOG(INFO) << "Game found! PID " << GamePID;
|
||||
IPCSystem = std::thread(&Launcher::ListenIPC, this);
|
||||
Memory::Inject(GamePID);
|
||||
//TODO: start IPC
|
||||
setDiscordMessage("In menus");
|
||||
while(!Shutdown.load() && Memory::GetBeamNGPID() != 0) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
@@ -123,6 +127,31 @@ void Launcher::WaitForGame() {
|
||||
LOG(INFO) << "Game process was lost";
|
||||
}
|
||||
|
||||
void Launcher::ListenIPC() {
|
||||
while(!Shutdown.load()) {
|
||||
IPCFromGame.receive();
|
||||
if(!IPCFromGame.receive_timed_out()) {
|
||||
auto& MSG = IPCFromGame.msg();
|
||||
if(MSG[0] == 'C') {
|
||||
HandleIPC(IPCFromGame.msg().substr(1));
|
||||
} else {
|
||||
ServerHandler.ServerSend(IPCFromGame.msg().substr(1), false);
|
||||
}
|
||||
IPCFromGame.confirm_receive();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Launcher::SendIPC(const std::string& Data, bool core) {
|
||||
static std::mutex Lock;
|
||||
std::scoped_lock Guard(Lock);
|
||||
if(core) {
|
||||
IPCToGame.send("C" + Data);
|
||||
} else {
|
||||
IPCToGame.send("G" + Data);
|
||||
}
|
||||
}
|
||||
|
||||
std::string QueryValue(HKEY& hKey, const char* Name) {
|
||||
DWORD keySize;
|
||||
BYTE buffer[16384];
|
||||
@@ -194,7 +223,7 @@ const std::string& Launcher::getFullVersion() {
|
||||
return FullVersion;
|
||||
}
|
||||
|
||||
const std::string &Launcher::getVersion() {
|
||||
const std::string& Launcher::getVersion() {
|
||||
return Version;
|
||||
}
|
||||
|
||||
@@ -213,3 +242,11 @@ bool Launcher::getExit() noexcept {
|
||||
void Launcher::setExit(bool exit) noexcept {
|
||||
Exit.store(exit);
|
||||
}
|
||||
|
||||
const std::string& Launcher::getMPUserPath() {
|
||||
return MPUserPath;
|
||||
}
|
||||
|
||||
const std::string &Launcher::getPublicKey() {
|
||||
return PublicKey;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user