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