mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-02-16 02:30:44 +00:00
tweaked connection logic | launcher now retries to auto update
This commit is contained in:
@@ -87,7 +87,7 @@ void WaitForConfirm(){
|
||||
|
||||
void SyncResources(SOCKET Sock){
|
||||
std::cout << "Checking Resources..." << std::endl;
|
||||
std::string HandShakeVer = "1.43";
|
||||
std::string HandShakeVer = "1.46";
|
||||
CheckForDir();
|
||||
STCPSend(Sock,"NR" + GlobalInfo.at(0) + ":" +GlobalInfo.at(2));
|
||||
STCPSend(Sock,"VC" + HandShakeVer);
|
||||
@@ -96,7 +96,7 @@ void SyncResources(SOCKET Sock){
|
||||
if(msg.size() < 2 || msg.substr(0,2) != "WS"){
|
||||
Terminate = true;
|
||||
TCPTerminate = true;
|
||||
UlStatus = "UlDisconnected: outdated server/client";
|
||||
UlStatus = "UlDisconnected: full or outdated server";
|
||||
std::cout << "Terminated!" << std::endl;
|
||||
return;
|
||||
}
|
||||
@@ -158,7 +158,10 @@ void SyncResources(SOCKET Sock){
|
||||
auto Pair = STCPRecv(Sock);
|
||||
char* Data = Pair.first;
|
||||
size_t BytesRcv = Pair.second;
|
||||
if (strcmp(Data, "Cannot Open") == 0 || Terminate)break;
|
||||
if (strcmp(Data, "Cannot Open") == 0 || Terminate){
|
||||
delete[] Data;
|
||||
break;
|
||||
}
|
||||
memcpy_s(File+Recv,BytesRcv,Data,BytesRcv);
|
||||
Recv += BytesRcv;
|
||||
float per = float(Recv)/std::stof(*FS) * 100;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
///
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <thread>
|
||||
int Download(const std::string& URL,const std::string& path);
|
||||
std::string HTTP_REQUEST(const std::string&url,int port);
|
||||
std::string HTA(const std::string& hex);
|
||||
@@ -21,12 +21,20 @@ void CheckForUpdates(int argc,char*args[],const std::string& CV){
|
||||
struct stat buffer{};
|
||||
if(stat ("BeamMP-Launcher.back", &buffer) == 0)remove("BeamMP-Launcher.back");
|
||||
if(HTTP > CV){
|
||||
ReLaunch(argc,args);
|
||||
system("cls");
|
||||
std::cout << "Update found!" << std::endl;
|
||||
std::cout << "Updating..." << std::endl;
|
||||
SystemExec("rename BeamMP-Launcher.exe BeamMP-Launcher.back>nul");
|
||||
Download(link, "BeamMP-Launcher.exe");
|
||||
if(int i = Download(link, "BeamMP-Launcher.exe") != -1){
|
||||
std::cout << "Launcher Update failed! trying again... code : " << i << std::endl;
|
||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
if(int i2 = Download(link, "BeamMP-Launcher.exe") != -1){
|
||||
std::cout << "Launcher Update failed! code : " << i2 << std::endl;
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
ReLaunch(argc,args);
|
||||
}
|
||||
|
||||
}
|
||||
WinExec("BeamMP-Launcher.exe");
|
||||
exit(1);
|
||||
}else{
|
||||
|
||||
@@ -18,7 +18,7 @@ std::vector<std::string> GetDiscordInfo();
|
||||
extern std::vector<std::string> SData;
|
||||
std::vector<std::string> GlobalInfo;
|
||||
std::string getHardwareID();
|
||||
char* ver = (char*)"1.45";
|
||||
char* ver = (char*)"1.46";
|
||||
int DEFAULT_PORT = 4444;
|
||||
void Discord_Main();
|
||||
bool Dev = false;
|
||||
@@ -136,6 +136,7 @@ int main(int argc, char* argv[]){
|
||||
link = "https://beamng-mp.com/client-ui-data";
|
||||
std::cout << "Downloading default config..." << std::endl;
|
||||
if(int i = Download(link,DUI) != -1){
|
||||
remove(DUI.c_str());
|
||||
std::cout << "Error! Failed to download code : " << i << std::endl;
|
||||
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||
ReLaunch(argc,argv);
|
||||
|
||||
Reference in New Issue
Block a user