This commit is contained in:
Anonymous275 2020-07-02 00:20:05 +03:00
parent 434cf26b7b
commit 04b5b13ef9
4 changed files with 17 additions and 12 deletions

View File

@ -11,5 +11,4 @@ file(GLOB source_files
"src/Memory/*.hpp" "src/Memory/*.cpp")
add_executable(BeamMP-Launcher ${source_files})
target_link_libraries(BeamMP-Launcher ws2_32 urlmon discord-rpc libcurl_a zlibstatic)

View File

@ -59,7 +59,6 @@ void AckID(int ID){
}
}
}
int PacktID(){
static int ID = -1;
if(ID > 999999)ID = 0;

View File

@ -9,7 +9,7 @@
#include <string>
#include <thread>
#include <vector>
#include <set>
extern std::vector<std::string> GlobalInfo;
void Exit(const std::string& Msg);
namespace fs = std::experimental::filesystem;
@ -96,7 +96,7 @@ void SyncResources(SOCKET Sock){
if(msg.size() < 2 || msg.substr(0,2) != "WS"){
Terminate = true;
TCPTerminate = true;
UlStatus = "UlDisconnected";
UlStatus = "UlDisconnected: outdated server/client";
std::cout << "Terminated!" << std::endl;
return;
}
@ -152,6 +152,7 @@ void SyncResources(SOCKET Sock){
std::ofstream LFS;
do {
STCPSend(Sock, "f" + *FN);
//std::set<std::pair<char*,int>> segments;
do {
auto Pair = STCPRecv(Sock);
Data = Pair.first;
@ -159,18 +160,25 @@ void SyncResources(SOCKET Sock){
if (!LFS.is_open()) {
LFS.open(a.c_str(), std::ios_base::app | std::ios::binary);
}
LFS.write(Data, Pair.second);
float per = LFS.tellp() / std::stof(*FS) * 100;
LFS.write(Data,Pair.second);
/*char* Segment = new char[Pair.second];
memcpy_s(Segment,Pair.second,Data,Pair.second);
segments.insert(std::make_pair(Segment,Pair.second));
total += Pair.second;*/
float per = LFS.tellp()/ std::stof(*FS) * 100;
std::string Percent = std::to_string(truncf(per * 10) / 10);
UlStatus = "UlDownloading Resource: (" + std::to_string(Pos) + "/" + std::to_string(Amount) +
"): " + a.substr(a.find_last_of('/')) + " (" +
Percent.substr(0, Percent.find('.') + 2) + "%)";
} while (LFS.tellp() != std::stoi(*FS) && LFS.tellp() < std::stoi(*FS));
LFS.close();
}while(fs::file_size(a) != std::stoi(*FS));
UlStatus = "UlLoading Resource: (" + std::to_string(Pos) + "/" + std::to_string(Amount) +
"): " + a.substr(a.find_last_of('/'));
std::this_thread::sleep_for(std::chrono::milliseconds(50));
/*for(auto p : segments){
LFS.write(p.first,p.second);
}*/
//segments.clear();
LFS.close();
}while(fs::file_size(a) != std::stoi(*FS));
fs::copy_file(a, "BeamNG/mods"+a.substr(a.find_last_of('/')), fs::copy_options::overwrite_existing);
WaitForConfirm();
}

View File

@ -18,7 +18,7 @@ std::vector<std::string> GetDiscordInfo();
extern std::vector<std::string> SData;
std::vector<std::string> GlobalInfo;
std::string getHardwareID();
std::string ver = "1.41";
std::string ver = "1.43";
int DEFAULT_PORT = 4444;
void Discord_Main();
bool MPDEV = false;
@ -56,7 +56,6 @@ std::string CheckDir(int argc,char*args[]){
if(stat(DN.c_str(),&info)==0)remove(DN.c_str());
SystemExec("rename \""+ FN +"\" " + DN + ">nul");
}
//SystemExec(R"(powershell "$s=(New-Object -COM WScript.Shell).CreateShortcut('%userprofile%\Desktop\BeamMP-Launcher.lnk');$s.TargetPath=')"+AD+"\\"+DN+"';$s.Save()\"");
if(stat("BeamNG",&info))SystemExec("mkdir BeamNG>nul");
if(!stat("BeamNG\\mods",&info))SystemExec("RD /S /Q BeamNG\\mods>nul");
if(!stat("BeamNG\\mods",&info))ReLaunch(argc,args);
@ -130,7 +129,7 @@ int main(int argc, char* argv[]){
std::string ExeDir = GamePath.substr(0,GamePath.find_last_of('\\')) + R"(\Bin64\BeamNG.drive.x64.exe)";
std::string Settings = Path + "\\settings\\uiapps-layouts.json";
if(stat(Settings.c_str(),&info)!=0){
link = "https://beamng-mp.com/client-data";
link = "https://beamng-mp.com/client-ui-data";
std::cout << "Downloading default config..." << std::endl;
Download(link,Settings);
std::cout << "Download Complete!" << std::endl;