mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-06-22 08:31:07 +00:00
works but linux build is broken and this is an old version of the source
This commit is contained in:
+46
-1
@@ -6,13 +6,25 @@
|
||||
/// Created by Anonymous275 on 7/19/2020
|
||||
///
|
||||
|
||||
#include <Security/Init.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#elif defined(__linux__)
|
||||
#include "vdf_parser.hpp"
|
||||
#include <pwd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#include <Security/Init.h>
|
||||
#include <filesystem>
|
||||
#include "Startup.h"
|
||||
#include "Logger.h"
|
||||
#include <thread>
|
||||
|
||||
unsigned long GamePID = 0;
|
||||
#if defined(_WIN32)
|
||||
std::string QueryKey(HKEY hKey,int ID);
|
||||
std::string GetGamePath(){
|
||||
static std::string Path;
|
||||
@@ -40,7 +52,21 @@ std::string GetGamePath(){
|
||||
Path += Ver + "\\";
|
||||
return Path;
|
||||
}
|
||||
#elif defined(__linux__)
|
||||
std::string GetGamePath(){
|
||||
// Right now only steam is supported
|
||||
struct passwd *pw = getpwuid(getuid());
|
||||
std::string homeDir = pw->pw_dir;
|
||||
|
||||
std::string Path = homeDir + "/.local/share/BeamNG.drive/";
|
||||
std::string Ver = CheckVer(GetGameDir());
|
||||
Ver = Ver.substr(0,Ver.find('.',Ver.find('.')+1));
|
||||
Path += Ver + "/";
|
||||
return Path;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
void StartGame(std::string Dir){
|
||||
BOOL bSuccess = FALSE;
|
||||
PROCESS_INFORMATION pi;
|
||||
@@ -61,6 +87,25 @@ void StartGame(std::string Dir){
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
exit(2);
|
||||
}
|
||||
#elif defined(__linux__)
|
||||
void StartGame(std::string Dir){
|
||||
int status;
|
||||
pid_t pid = fork();
|
||||
if (pid >= 0){
|
||||
if (pid == 0){
|
||||
execl((Dir + "/BinLinux/BeamNG.drive.x64").c_str(), "", NULL);
|
||||
} else if (pid > 0){
|
||||
waitpid(pid, &status, 0);
|
||||
error("Game Closed! launcher closing soon");
|
||||
}
|
||||
} else {
|
||||
error("Failed to Launch the game! launcher closing soon");
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
exit(2);
|
||||
}
|
||||
#endif
|
||||
|
||||
void InitGame(const std::string& Dir){
|
||||
if(!Dev){
|
||||
std::thread Game(StartGame, Dir);
|
||||
|
||||
Reference in New Issue
Block a user