mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-04-13 11:16:18 +00:00
works but linux build is broken and this is an old version of the source
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <zlib.h>
|
||||
#ifdef __linux__
|
||||
#include <cstring>
|
||||
#endif
|
||||
|
||||
#define Biggest 30000
|
||||
std::string Comp(std::string Data){
|
||||
@@ -27,7 +30,7 @@ std::string Comp(std::string Data){
|
||||
deflateEnd(&defstream);
|
||||
int TO = defstream.total_out;
|
||||
std::string Ret(TO,0);
|
||||
memcpy_s(&Ret[0],TO,C,TO);
|
||||
memcpy(&Ret[0],C,TO);
|
||||
delete [] C;
|
||||
return Ret;
|
||||
}
|
||||
@@ -48,7 +51,7 @@ std::string DeComp(std::string Compressed){
|
||||
inflateEnd(&infstream);
|
||||
int TO = infstream.total_out;
|
||||
std::string Ret(TO,0);
|
||||
memcpy_s(&Ret[0],TO,C,TO);
|
||||
memcpy(&Ret[0],C,TO);
|
||||
delete [] C;
|
||||
return Ret;
|
||||
}
|
||||
@@ -5,6 +5,9 @@
|
||||
///
|
||||
/// Created by Anonymous275 on 7/16/2020
|
||||
///
|
||||
|
||||
#ifndef __linux__
|
||||
|
||||
#include "Discord/discord_rpc.h"
|
||||
#include "Logger.h"
|
||||
#include <cstring>
|
||||
@@ -109,3 +112,5 @@ void Discord_Main(){
|
||||
}
|
||||
if(DiscordInfo == nullptr)ErrorAboard();*/
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -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);
|
||||
|
||||
@@ -9,8 +9,18 @@
|
||||
#include "Security/Init.h"
|
||||
|
||||
#include "Http.h"
|
||||
#if defined(_WIN32)
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
#elif defined(__linux__)
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <cstring>
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#include "Startup.h"
|
||||
#include "Logger.h"
|
||||
#include <charconv>
|
||||
@@ -177,13 +187,18 @@ void localRes(){
|
||||
}
|
||||
void CoreMain() {
|
||||
debug("Core Network on start!");
|
||||
WSADATA wsaData;
|
||||
SOCKET LSocket,CSocket;
|
||||
struct addrinfo *res = nullptr;
|
||||
struct addrinfo hints{};
|
||||
int iRes = WSAStartup(514, &wsaData); //2.2
|
||||
int iRes;
|
||||
#ifdef _WIN32
|
||||
WSADATA wsaData;
|
||||
iRes = WSAStartup(514, &wsaData); //2.2
|
||||
if (iRes)debug("WSAStartup failed with error: " + std::to_string(iRes));
|
||||
#endif
|
||||
|
||||
ZeroMemory(&hints, sizeof(hints));
|
||||
|
||||
hints.ai_family = AF_INET;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
@@ -231,24 +246,40 @@ void CoreMain() {
|
||||
KillSocket(LSocket);
|
||||
WSACleanup();
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
int Handle(EXCEPTION_POINTERS *ep){
|
||||
char* hex = new char[100];
|
||||
sprintf_s(hex,100, "%lX", ep->ExceptionRecord->ExceptionCode);
|
||||
sprintf(hex,100, "%lX", ep->ExceptionRecord->ExceptionCode);
|
||||
except("(Core) Code : " + std::string(hex));
|
||||
delete [] hex;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
[[noreturn]] void CoreNetwork(){
|
||||
while(true) {
|
||||
#ifndef __MINGW32__
|
||||
// #ifndef __MINGW32__
|
||||
// __try{
|
||||
// #endif
|
||||
// CoreMain();
|
||||
// #ifndef __MINGW32__
|
||||
// }__except(Handle(GetExceptionInformation())){}
|
||||
// #endif
|
||||
#if not defined(__MINGW32__)
|
||||
__try{
|
||||
#endif
|
||||
CoreMain();
|
||||
#ifndef __MINGW32__
|
||||
#endif
|
||||
|
||||
CoreMain();
|
||||
|
||||
#if not defined(__MINGW32__) and not defined(__linux__)
|
||||
}__except(Handle(GetExceptionInformation())){}
|
||||
#endif
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
#elif not defined(__MINGW32__) and defined(__linux__)
|
||||
} catch(...){
|
||||
except("(Core) Code : " + std::string(strerror(errno)));
|
||||
}
|
||||
#endif
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,18 +7,27 @@
|
||||
///
|
||||
|
||||
#include <string>
|
||||
#if defined(_WIN32)
|
||||
#include <winsock2.h>
|
||||
#elif defined(__linux__)
|
||||
#include "linuxfixes.h"
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#include "Logger.h"
|
||||
|
||||
std::string GetAddr(const std::string&IP){
|
||||
if(IP.find_first_not_of("0123456789.") == -1)return IP;
|
||||
WSADATA wsaData;
|
||||
hostent *host;
|
||||
#ifdef _WIN32
|
||||
WSADATA wsaData;
|
||||
if(WSAStartup(514, &wsaData) != 0){
|
||||
error("WSA Startup Failed!");
|
||||
WSACleanup();
|
||||
return "";
|
||||
}
|
||||
#endif
|
||||
|
||||
host = gethostbyname(IP.c_str());
|
||||
if(!host){
|
||||
error("DNS lookup failed! on " + IP);
|
||||
|
||||
@@ -6,8 +6,19 @@
|
||||
/// Created by Anonymous275 on 7/25/2020
|
||||
///
|
||||
#include "Network/network.hpp"
|
||||
#if defined(_WIN32)
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#elif defined(__linux__)
|
||||
#include "linuxfixes.h"
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <cstring>
|
||||
#endif
|
||||
|
||||
#include "Logger.h"
|
||||
#include <charconv>
|
||||
#include <string>
|
||||
@@ -117,12 +128,16 @@ SOCKET SetupListener(){
|
||||
if(GSocket != -1)return GSocket;
|
||||
struct addrinfo *result = nullptr;
|
||||
struct addrinfo hints{};
|
||||
int iRes;
|
||||
#ifdef _WIN32
|
||||
WSADATA wsaData;
|
||||
int iRes = WSAStartup(514, &wsaData); //2.2
|
||||
iRes = WSAStartup(514, &wsaData); //2.2
|
||||
if (iRes != 0) {
|
||||
error("(Proxy) WSAStartup failed with error: " + std::to_string(iRes));
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
ZeroMemory(&hints, sizeof(hints));
|
||||
hints.ai_family = AF_INET;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
|
||||
@@ -7,7 +7,18 @@
|
||||
///
|
||||
|
||||
#include "Network/network.hpp"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <ws2tcpip.h>
|
||||
#elif defined(__linux__)
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <cstring>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#include <filesystem>
|
||||
#include "Startup.h"
|
||||
#include "Logger.h"
|
||||
@@ -38,7 +49,12 @@ std::vector<std::string> Split(const std::string& String,const std::string& deli
|
||||
|
||||
void CheckForDir(){
|
||||
if(!fs::exists("Resources")){
|
||||
// Could we just use fs::create_directory instead?
|
||||
#if defined(_WIN32)
|
||||
_wmkdir(L"Resources");
|
||||
#elif defined(__linux__)
|
||||
fs::create_directory(L"Resources");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
void WaitForConfirm(){
|
||||
@@ -202,12 +218,16 @@ std::string MultiDownload(SOCKET MSock,SOCKET DSock, uint64_t Size, const std::s
|
||||
|
||||
///omg yes very ugly my god but i was in a rush will revisit
|
||||
std::string Ret(Size,0);
|
||||
memcpy_s(&Ret[0],MSize,MData,MSize);
|
||||
memcpy(&Ret[0],MData,MSize);
|
||||
delete[]MData;
|
||||
|
||||
memcpy_s(&Ret[MSize],DSize,DData,DSize);
|
||||
memcpy(&Ret[MSize],DData,DSize);
|
||||
delete[]DData;
|
||||
|
||||
// std::string Ret = std::string(MData) + std::string(DData);
|
||||
// delete []MData;
|
||||
// delete []DData;
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,18 @@
|
||||
#include "Zlib/Compressor.h"
|
||||
#include "Network/network.hpp"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <ws2tcpip.h>
|
||||
#elif defined(__linux__)
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <cstring>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#include "linuxfixes.h"
|
||||
#endif
|
||||
|
||||
#include "Logger.h"
|
||||
#include <string>
|
||||
#include <set>
|
||||
@@ -44,7 +55,11 @@ void UDPParser(std::string Packet){
|
||||
}
|
||||
void UDPRcv(){
|
||||
sockaddr_in FromServer{};
|
||||
#if defined(_WIN32)
|
||||
int clientLength = sizeof(FromServer);
|
||||
#elif defined(__linux__)
|
||||
socklen_t clientLength = sizeof(FromServer);
|
||||
#endif
|
||||
ZeroMemory(&FromServer, clientLength);
|
||||
std::string Ret(10240,0);
|
||||
if(UDPSock == -1)return;
|
||||
@@ -53,11 +68,14 @@ void UDPRcv(){
|
||||
UDPParser(Ret.substr(0,Rcv));
|
||||
}
|
||||
void UDPClientMain(const std::string& IP,int Port){
|
||||
#ifdef _WIN32
|
||||
WSADATA data;
|
||||
if (WSAStartup(514, &data)){
|
||||
error("Can't start Winsock!");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
delete ToServer;
|
||||
ToServer = new sockaddr_in;
|
||||
ToServer->sin_family = AF_INET;
|
||||
|
||||
@@ -10,11 +10,20 @@
|
||||
#include <vector>
|
||||
#include "Logger.h"
|
||||
#include <iostream>
|
||||
#include <ws2tcpip.h>
|
||||
#include <Zlib/Compressor.h>
|
||||
|
||||
#include "Network/network.hpp"
|
||||
#if defined(_WIN32)
|
||||
#include <ws2tcpip.h>
|
||||
#elif defined(__linux__)
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <cstring>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#include "Network/network.hpp"
|
||||
|
||||
int LastPort;
|
||||
std::string LastIP;
|
||||
@@ -116,10 +125,12 @@ std::string TCPRcv(SOCKET Sock){
|
||||
void TCPClientMain(const std::string& IP,int Port){
|
||||
LastIP = IP;
|
||||
LastPort = Port;
|
||||
WSADATA wsaData;
|
||||
SOCKADDR_IN ServerAddr;
|
||||
int RetCode;
|
||||
#ifdef _WIN32
|
||||
WSADATA wsaData;
|
||||
WSAStartup(514, &wsaData); //2.2
|
||||
#endif
|
||||
TCPSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
||||
if(TCPSock == -1){
|
||||
@@ -127,6 +138,7 @@ void TCPClientMain(const std::string& IP,int Port){
|
||||
WSACleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
ServerAddr.sin_family = AF_INET;
|
||||
ServerAddr.sin_port = htons(Port);
|
||||
inet_pton(AF_INET, IP.c_str(), &ServerAddr.sin_addr);
|
||||
@@ -152,6 +164,9 @@ void TCPClientMain(const std::string& IP,int Port){
|
||||
if(KillSocket(TCPSock) != 0)
|
||||
debug("(TCP) Cannot close socket. Error code: " + std::to_string(WSAGetLastError()));
|
||||
|
||||
#ifdef _WIN32
|
||||
if(WSACleanup() != 0)
|
||||
debug("(TCP) Client: WSACleanup() failed!...");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,14 @@
|
||||
///
|
||||
|
||||
#include <filesystem>
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#elif defined(__linux__)
|
||||
#include "vdf_parser.hpp"
|
||||
#include <vector>
|
||||
#include <pwd.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include "Logger.h"
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
@@ -46,8 +53,13 @@ void SteamExit(int code){
|
||||
}*/
|
||||
std::string GetGameDir(){
|
||||
//if(TraceBack != 4)Exit(0);
|
||||
#if defined(_WIN32)
|
||||
return GameDir.substr(0,GameDir.find_last_of('\\'));
|
||||
#elif defined(__linux__)
|
||||
return GameDir.substr(0,GameDir.find_last_of('/'));
|
||||
#endif
|
||||
}
|
||||
#ifdef _WIN32
|
||||
LONG OpenKey(HKEY root,const char* path,PHKEY hKey){
|
||||
return RegOpenKeyEx(root, reinterpret_cast<LPCSTR>(path), 0, KEY_READ, hKey);
|
||||
}
|
||||
@@ -129,6 +141,8 @@ std::string QueryKey(HKEY hKey,int ID){
|
||||
delete [] buffer;
|
||||
return "";
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
bool NameValid(const std::string& N){
|
||||
@@ -286,6 +300,7 @@ void LegitimacyCheck(){
|
||||
}else lowExit(2);
|
||||
K2.clear();
|
||||
RegCloseKey(hKey);*/
|
||||
#if defined(_WIN32)
|
||||
std::string Result;
|
||||
std::string K3 = R"(Software\BeamNG\BeamNG.drive)";
|
||||
HKEY hKey;
|
||||
@@ -301,9 +316,27 @@ void LegitimacyCheck(){
|
||||
Result.clear();
|
||||
RegCloseKey(hKey);
|
||||
//if(TraceBack < 3)exit(-1);
|
||||
#elif defined(__linux__)
|
||||
struct passwd *pw = getpwuid(getuid());
|
||||
std::string homeDir = pw->pw_dir;
|
||||
// Right now only steam is supported
|
||||
std::ifstream libraryFolders(homeDir + "/.steam/root/steamapps/libraryfolders.vdf");
|
||||
auto root = tyti::vdf::read(libraryFolders);
|
||||
|
||||
for (auto folderInfo: root.childs){
|
||||
if (std::filesystem::exists(folderInfo.second->attribs["path"] + "/steamapps/common/BeamNG.drive/")){
|
||||
GameDir = folderInfo.second->attribs["path"] + "/steamapps/common/BeamNG.drive/";
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
std::string CheckVer(const std::string &dir){
|
||||
#if defined(_WIN32)
|
||||
std::string temp,Path = dir + "\\integrity.json";
|
||||
#elif defined(__linux__)
|
||||
std::string temp,Path = dir + "/integrity.json";
|
||||
#endif
|
||||
std::ifstream f(Path.c_str(), std::ios::binary);
|
||||
int Size = int(std::filesystem::file_size(Path));
|
||||
std::string vec(Size,0);
|
||||
|
||||
@@ -47,7 +47,7 @@ std::string Login(const std::string& fields){
|
||||
return "";
|
||||
}
|
||||
info("Attempting to authenticate...");
|
||||
std::string Buffer = HTTP::Post("https://auth.beammp.com/userlogin", fields);
|
||||
std::string Buffer = HTTP::Post("https://auth.beammp.com/userlogin", fields) + "\n";
|
||||
json::Document d;
|
||||
d.Parse(Buffer.c_str());
|
||||
if(Buffer == "-1"){
|
||||
|
||||
@@ -6,7 +6,12 @@
|
||||
/// Created by Anonymous275 on 7/16/2020
|
||||
///
|
||||
#include "zip_file.h"
|
||||
#include <string>
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#elif defined(__linux__)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include "Discord/discord_info.h"
|
||||
#include "Network/network.hpp"
|
||||
#include "Security/Init.h"
|
||||
@@ -22,9 +27,16 @@ extern int TraceBack;
|
||||
bool Dev = false;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
#if defined(_WIN32)
|
||||
std::string GetEN(){
|
||||
return "BeamMP-Launcher.exe";
|
||||
}
|
||||
#elif defined(__linux__)
|
||||
std::string GetEN(){
|
||||
return "BeamMP-Launcher";
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string GetVer(){
|
||||
return "2.0";
|
||||
}
|
||||
@@ -39,6 +51,7 @@ std::string GetEP(char*P){
|
||||
} ();
|
||||
return Ret;
|
||||
}
|
||||
#if defined(_WIN32)
|
||||
void ReLaunch(int argc,char*args[]){
|
||||
std::string Arg;
|
||||
for(int c = 2; c <= argc; c++){
|
||||
@@ -62,8 +75,36 @@ void URelaunch(int argc,char* args[]){
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
exit(1);
|
||||
}
|
||||
#elif defined(__linux__)
|
||||
void ReLaunch(int argc,char*args[]){
|
||||
std::string Arg;
|
||||
for(int c = 2; c <= argc; c++){
|
||||
Arg += " ";
|
||||
Arg += args[c-1];
|
||||
}
|
||||
system("clear");
|
||||
execl((GetEP() + GetEN()).c_str(), Arg.c_str(), NULL);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
exit(1);
|
||||
}
|
||||
void URelaunch(int argc,char* args[]){
|
||||
std::string Arg;
|
||||
for(int c = 2; c <= argc; c++){
|
||||
Arg += " ";
|
||||
Arg += args[c-1];
|
||||
}
|
||||
execl((GetEP() + GetEN()).c_str(), Arg.c_str(), NULL);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
void CheckName(int argc,char* args[]){
|
||||
#if defined(_WIN32)
|
||||
std::string DN = GetEN(),CDir = args[0],FN = CDir.substr(CDir.find_last_of('\\')+1);
|
||||
#elif defined(__linux__)
|
||||
std::string DN = GetEN(),CDir = args[0],FN = CDir.substr(CDir.find_last_of('/')+1);
|
||||
#endif
|
||||
if(FN != DN){
|
||||
if(fs::exists(DN))remove(DN.c_str());
|
||||
if(fs::exists(DN))ReLaunch(argc,args);
|
||||
@@ -92,7 +133,11 @@ void CheckForUpdates(int argc,char*args[],const std::string& CV){
|
||||
if(fs::exists(Back))remove(Back.c_str());
|
||||
|
||||
if(HTTP > CV){
|
||||
#if defined(_WIN32)
|
||||
system("cls");
|
||||
#elif defined(__linux__)
|
||||
system("clear");
|
||||
#endif
|
||||
info("Update found!");
|
||||
info("Updating...");
|
||||
if(std::rename(EP.c_str(), Back.c_str()))error("failed creating a backup!");
|
||||
@@ -125,6 +170,7 @@ void CustomPort(int argc, char* argv[]){
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
void LinuxPatch(){
|
||||
HKEY hKey = nullptr;
|
||||
LONG result = RegOpenKeyEx(HKEY_CURRENT_USER, R"(Software\Wine)", 0, KEY_READ, &hKey);
|
||||
@@ -175,7 +221,9 @@ void LinuxPatch(){
|
||||
|
||||
info("Patched!");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
void InitLauncher(int argc, char* argv[]) {
|
||||
system("cls");
|
||||
SetConsoleTitleA(("BeamMP Launcher v" + std::string(GetVer()) + GetPatch()).c_str());
|
||||
@@ -188,6 +236,17 @@ void InitLauncher(int argc, char* argv[]) {
|
||||
Discord_Main();
|
||||
CheckForUpdates(argc, argv, std::string(GetVer()) + GetPatch());
|
||||
}
|
||||
#elif defined(__linux__)
|
||||
void InitLauncher(int argc, char* argv[]) {
|
||||
system("clear");
|
||||
InitLog();
|
||||
CheckName(argc, argv);
|
||||
CheckLocalKey();
|
||||
ConfigInit();
|
||||
CustomPort(argc, argv);
|
||||
CheckForUpdates(argc, argv, std::string(GetVer()) + GetPatch());
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t DirCount(const std::filesystem::path& path){
|
||||
return (size_t)std::distance(std::filesystem::directory_iterator{path}, std::filesystem::directory_iterator{});
|
||||
@@ -258,7 +317,12 @@ void PreGame(const std::string& GamePath){
|
||||
}catch(std::exception&e){
|
||||
fatal(e.what());
|
||||
}
|
||||
#if defined(_WIN32)
|
||||
std::string ZipPath(GetGamePath() + R"(mods\multiplayer\BeamMP.zip)");
|
||||
#elif defined(__linux__)
|
||||
// Linux version of the game cant handle mods with uppercase names
|
||||
std::string ZipPath(GetGamePath() + R"(mods/multiplayer/beammp.zip)");
|
||||
#endif
|
||||
|
||||
HTTP::Download("https://backend.beammp.com/builds/client?download=true"
|
||||
"&pk=" + PublicKey + "&branch=" + Branch, ZipPath);
|
||||
|
||||
Reference in New Issue
Block a user