mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-04-03 06:16:15 +00:00
v1.48
This commit is contained in:
72
src/main.cpp
72
src/main.cpp
@@ -14,17 +14,19 @@ int Download(const std::string& URL,const std::string& OutFileName);
|
||||
void StartGame(const std::string&ExeDir,const std::string&Current);
|
||||
std::string HTTP_REQUEST(const std::string&url,int port);
|
||||
void CheckForUpdates(int argc,char*args[],const std::string& CV);
|
||||
std::vector<std::string> GetDiscordInfo();
|
||||
char*EName = (char*)"4265616d4d502d4c61756e636865722e657865";
|
||||
extern std::vector<std::string> GlobalInfo;
|
||||
std::string HTA(const std::string& hex);
|
||||
extern std::vector<std::string> SData;
|
||||
std::vector<std::string> GlobalInfo;
|
||||
std::string getHardwareID();
|
||||
char* ver = (char*)"1.46";
|
||||
char* ver = (char*)"312e3438"; //1.48
|
||||
int DEFAULT_PORT = 4444;
|
||||
void Discord_Main();
|
||||
bool Dev = false;
|
||||
void ProxyStart();
|
||||
void ExitError();
|
||||
void Check();
|
||||
|
||||
void SystemExec(const std::string& cmd){
|
||||
system(cmd.c_str());
|
||||
}
|
||||
@@ -46,16 +48,12 @@ void ReLaunch(int argc,char*args[]){
|
||||
Arg += args[c-1];
|
||||
}
|
||||
system("cls");
|
||||
ShellExecute(nullptr,"runas","BeamMP-Launcher.exe",Arg.c_str(),nullptr,SW_SHOWNORMAL);
|
||||
ShellExecute(nullptr,"runas",HTA(EName).c_str(),Arg.c_str(),nullptr,SW_SHOWNORMAL);
|
||||
exit(1);
|
||||
}
|
||||
std::string CheckDir(int argc,char*args[]){
|
||||
struct stat info{};
|
||||
std::string DN = "BeamMP-Launcher.exe",CDir = args[0],FN = CDir.substr(CDir.find_last_of('\\')+1);
|
||||
if(FN != DN){
|
||||
if(stat(DN.c_str(),&info)==0)remove(DN.c_str());
|
||||
SystemExec("rename \""+ FN +"\" " + DN + ">nul");
|
||||
}
|
||||
std::string CDir = args[0];
|
||||
if(stat("BeamNG",&info)){
|
||||
SystemExec("mkdir BeamNG>nul");
|
||||
if(stat("BeamNG",&info))ReLaunch(argc,args);
|
||||
@@ -82,23 +80,48 @@ std::string CheckVer(const std::string &path){
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
std::string HTA(const std::string& hex);
|
||||
|
||||
void URelaunch(int argc,char* args[]){
|
||||
std::string Arg;
|
||||
for(int c = 2; c <= argc; c++){
|
||||
Arg += " ";
|
||||
Arg += args[c-1];
|
||||
}
|
||||
ShellExecute(nullptr,"open",HTA(EName).c_str(),Arg.c_str(),nullptr,SW_SHOWNORMAL);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void CheckName(int argc,char* args[]){
|
||||
struct stat info{};
|
||||
std::string DN = HTA(EName),CDir = args[0],FN = CDir.substr(CDir.find_last_of('\\')+1);
|
||||
if(FN != DN){
|
||||
if(stat(DN.c_str(),&info)==0)remove(DN.c_str());
|
||||
if(stat(DN.c_str(),&info)==0)ReLaunch(argc,args);
|
||||
SystemExec("rename \""+ FN +"\" " + DN + ">nul");
|
||||
URelaunch(argc,args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char* argv[]){
|
||||
const unsigned long long NPos = std::string::npos;
|
||||
struct stat info{};
|
||||
system("cls");
|
||||
SetWindowTextA(GetConsoleWindow(),("BeamMP Launcher v" + HTA(ver)).c_str());
|
||||
CheckName(argc,argv);
|
||||
DWORD prev_mode;
|
||||
GetConsoleMode(GetCurrentProcess(), &prev_mode);
|
||||
SetConsoleMode(GetCurrentProcess(), ENABLE_EXTENDED_FLAGS | (prev_mode & ~ENABLE_QUICK_EDIT_MODE));
|
||||
|
||||
std::string link, HTTP_Result;
|
||||
SetWindowTextA(GetConsoleWindow(),("BeamMP Launcher v" + std::string(ver)).c_str());
|
||||
std::thread t1(Discord_Main);
|
||||
t1.detach();
|
||||
std::cout << "Connecting to discord client..." << std::endl;
|
||||
while(GlobalInfo.empty()){
|
||||
GlobalInfo = GetDiscordInfo();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
}
|
||||
|
||||
while(GlobalInfo.empty())std::this_thread::sleep_for(std::chrono::milliseconds(300));
|
||||
std::cout << "Client Connected!" << std::endl;
|
||||
link = "https://beamng-mp.com/entitlement?did="+GlobalInfo.at(2);
|
||||
link = HTA("68747470733a2f2f6265616d6e672d6d702e636f6d2f656e7469746c656d656e743f6469643d")+
|
||||
HTA(GlobalInfo.at(2));
|
||||
//https://beamng-mp.com/entitlement?did=
|
||||
HTTP_Result = HTTP_REQUEST(link,443);
|
||||
/*if (HTTP_Result.find("\"MOD\"") == NPos && HTTP_Result.find("\"EA\"") == NPos){
|
||||
if (HTTP_Result.find("\"SUPPORT\"") == NPos && HTTP_Result.find("\"YT\"") == NPos){
|
||||
@@ -110,9 +133,9 @@ int main(int argc, char* argv[]){
|
||||
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||
exit(-1);
|
||||
}
|
||||
if(HTTP_Result.find("\"MDEV\"") != NPos)Dev = true;
|
||||
if(HTTP_Result.find(HTA("224d44455622")) != NPos)Dev = true;
|
||||
std::string Path = CheckDir(argc,argv);
|
||||
std::thread CFU(CheckForUpdates,argc,argv,std::string(ver));
|
||||
std::thread CFU(CheckForUpdates,argc,argv,HTA(ver));
|
||||
CFU.join();
|
||||
|
||||
if(argc > 1){
|
||||
@@ -132,7 +155,6 @@ int main(int argc, char* argv[]){
|
||||
delete Sec;
|
||||
if(SData.size() != 3)ExitError();
|
||||
std::string GamePath = SData.at(2);
|
||||
if(Dev)std::cout << "You own BeamNG on this machine!" << std::endl;
|
||||
std::cout << "Game Version : " << CheckVer(GamePath) << std::endl;
|
||||
std::string ExeDir = GamePath.substr(0,GamePath.find_last_of('\\')) + R"(\Bin64\BeamNG.drive.x64.exe)";
|
||||
std::string DUI = Path + R"(\settings\uiapps-layouts.json)";
|
||||
@@ -154,7 +176,9 @@ int main(int argc, char* argv[]){
|
||||
GS.clear();
|
||||
if(!Dev){
|
||||
std::cout << "Downloading mod..." << std::endl;
|
||||
link = "https://beamng-mp.com/builds/client?did="+GlobalInfo.at(2);
|
||||
//https://beamng-mp.com/builds/client?did=
|
||||
link = HTA("68747470733a2f2f6265616d6e672d6d702e636f6d2f6275696c64732f636c69656e743f6469643d")
|
||||
+HTA(GlobalInfo.at(2));
|
||||
Download(link,Path + R"(\mods\BeamMP.zip)");
|
||||
std::cout << "Download Complete!" << std::endl;
|
||||
link.clear();
|
||||
@@ -162,9 +186,9 @@ int main(int argc, char* argv[]){
|
||||
Game.detach();
|
||||
}else{
|
||||
std::cout << "Name : " << GlobalInfo.at(0) << std::endl;
|
||||
std::cout << "Discriminator : " << GlobalInfo.at(1) << std::endl;
|
||||
std::cout << "Unique ID : " << GlobalInfo.at(2) << std::endl;
|
||||
std::cout << "HWID : " << getHardwareID() << std::endl;
|
||||
std::cout << "Discriminator : " << HTA(GlobalInfo.at(1)) << std::endl;
|
||||
std::cout << "Unique ID : " << HTA(GlobalInfo.at(2)) << std::endl;
|
||||
//std::cout << "HWID : " << getHardwareID() << std::endl;
|
||||
std::cout << "you have : " << HTTP_Result << std::endl;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user