mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-03 08:26:01 +00:00
Fixed invalid string position, Bumped game version
This commit is contained in:
parent
09abe75fbb
commit
6c673e78e5
@ -15,7 +15,6 @@ void ParseConfig(const json::Document& d){
|
|||||||
if(d["Port"].IsInt()){
|
if(d["Port"].IsInt()){
|
||||||
DEFAULT_PORT = d["Port"].GetInt();
|
DEFAULT_PORT = d["Port"].GetInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Default -1
|
//Default -1
|
||||||
//Release 1
|
//Release 1
|
||||||
//EA 2
|
//EA 2
|
||||||
|
@ -14,16 +14,8 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
std::string getDate() {
|
std::string getDate() {
|
||||||
typedef std::chrono::duration<int, std::ratio_multiply<std::chrono::hours::period, std::ratio<24>>::type> days;
|
time_t tt = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
|
||||||
std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
|
tm local_tm = *localtime(&tt);
|
||||||
std::chrono::system_clock::duration tp = now.time_since_epoch();
|
|
||||||
days d = std::chrono::duration_cast<days>(tp);tp -= d;
|
|
||||||
auto h = std::chrono::duration_cast<std::chrono::hours>(tp);tp -= h;
|
|
||||||
auto m = std::chrono::duration_cast<std::chrono::minutes>(tp);tp -= m;
|
|
||||||
auto s = std::chrono::duration_cast<std::chrono::seconds>(tp);tp -= s;
|
|
||||||
time_t tt = std::chrono::system_clock::to_time_t(now);
|
|
||||||
tm local_tm{};
|
|
||||||
localtime_s(&local_tm,&tt);
|
|
||||||
std::stringstream date;
|
std::stringstream date;
|
||||||
int S = local_tm.tm_sec;
|
int S = local_tm.tm_sec;
|
||||||
int M = local_tm.tm_min;
|
int M = local_tm.tm_min;
|
||||||
|
@ -109,11 +109,10 @@ void UpdateUl(bool D,const std::string&msg){
|
|||||||
|
|
||||||
void AsyncUpdate(uint64_t& Rcv,uint64_t Size,const std::string& Name){
|
void AsyncUpdate(uint64_t& Rcv,uint64_t Size,const std::string& Name){
|
||||||
do {
|
do {
|
||||||
double pr = Rcv / double(Size) * 100;
|
double pr = double(Rcv) / double(Size) * 100;
|
||||||
std::string Per = std::to_string(trunc(pr * 10) / 10);
|
std::string Per = std::to_string(trunc(pr * 10) / 10);
|
||||||
UpdateUl(true, Name + " (" + Per.substr(0, Per.find('.') + 2) + "%)");
|
UpdateUl(true, Name + " (" + Per.substr(0, Per.find('.') + 2) + "%)");
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
|
|
||||||
}while(!Terminate && Rcv < Size);
|
}while(!Terminate && Rcv < Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,8 +175,7 @@ std::string MultiDownload(SOCKET MSock,SOCKET DSock, uint64_t Size, const std::s
|
|||||||
|
|
||||||
uint64_t GRcv = 0, MSize = Size/2, DSize = Size - MSize;
|
uint64_t GRcv = 0, MSize = Size/2, DSize = Size - MSize;
|
||||||
|
|
||||||
std::thread Au(AsyncUpdate,std::ref(GRcv),Size,Name);
|
std::thread Au(AsyncUpdate,std::ref(GRcv), Size, Name);
|
||||||
Au.detach();
|
|
||||||
|
|
||||||
std::packaged_task<char*()> task([&] { return TCPRcvRaw(MSock,GRcv,MSize); });
|
std::packaged_task<char*()> task([&] { return TCPRcvRaw(MSock,GRcv,MSize); });
|
||||||
std::future<char*> f1 = task.get_future();
|
std::future<char*> f1 = task.get_future();
|
||||||
@ -198,6 +196,7 @@ std::string MultiDownload(SOCKET MSock,SOCKET DSock, uint64_t Size, const std::s
|
|||||||
MultiKill(MSock,DSock);
|
MultiKill(MSock,DSock);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Au.joinable())Au.join();
|
if(Au.joinable())Au.join();
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ void lowExit(int code){
|
|||||||
std::this_thread::sleep_for(std::chrono::seconds(10));
|
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
void Exit(int code){
|
/*void Exit(int code){
|
||||||
TraceBack = 0;
|
TraceBack = 0;
|
||||||
std::string msg =
|
std::string msg =
|
||||||
"Sorry. We do not support cracked copies report this if you believe this is a mistake code ";
|
"Sorry. We do not support cracked copies report this if you believe this is a mistake code ";
|
||||||
@ -43,9 +43,9 @@ void SteamExit(int code){
|
|||||||
error(msg+std::to_string(code));
|
error(msg+std::to_string(code));
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(10));
|
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||||
exit(4);
|
exit(4);
|
||||||
}
|
}*/
|
||||||
std::string GetGameDir(){
|
std::string GetGameDir(){
|
||||||
if(TraceBack != 4)Exit(0);
|
//if(TraceBack != 4)Exit(0);
|
||||||
return GameDir.substr(0,GameDir.find_last_of('\\'));
|
return GameDir.substr(0,GameDir.find_last_of('\\'));
|
||||||
}
|
}
|
||||||
LONG OpenKey(HKEY root,const char* path,PHKEY hKey){
|
LONG OpenKey(HKEY root,const char* path,PHKEY hKey){
|
||||||
@ -244,25 +244,23 @@ std::string GetManifest(const std::string& Man){
|
|||||||
bool IDCheck(std::string Man, std::string steam){
|
bool IDCheck(std::string Man, std::string steam){
|
||||||
bool a = false,b = true;
|
bool a = false,b = true;
|
||||||
int pos = int(Man.rfind("steamapps"));
|
int pos = int(Man.rfind("steamapps"));
|
||||||
if(pos == -1)Exit(5);
|
// if(pos == -1)Exit(5);
|
||||||
Man = Man.substr(0,pos+9) + "\\appmanifest_284160.acf";
|
Man = Man.substr(0,pos+9) + "\\appmanifest_284160.acf";
|
||||||
steam += "\\config\\loginusers.vdf";
|
steam += "\\config\\loginusers.vdf";
|
||||||
if(fs::exists(Man) && fs::exists(steam)){
|
if(fs::exists(Man) && fs::exists(steam)){
|
||||||
for(const std::string&ID : GetID(steam)){
|
for(const std::string&ID : GetID(steam)){
|
||||||
if(ID == GetManifest(Man))b = false;
|
if(ID == GetManifest(Man))b = false;
|
||||||
}
|
}
|
||||||
if(b)Exit(6);
|
//if(b)Exit(6);
|
||||||
}else a = true;
|
}else a = true;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
void LegitimacyCheck(){
|
void LegitimacyCheck(){
|
||||||
std::string Result,T;
|
|
||||||
std::string K1 = R"(Software\Valve\Steam)";
|
|
||||||
std::string K2 = R"(Software\Valve\Steam\Apps\284160)";
|
|
||||||
std::string K3 = R"(Software\BeamNG\BeamNG.drive)";
|
|
||||||
HKEY hKey;
|
|
||||||
|
|
||||||
LONG dwRegOPenKey = OpenKey(HKEY_CURRENT_USER, K1.c_str(), &hKey);
|
//std::string K1 = R"(Software\Valve\Steam)";
|
||||||
|
//std::string K2 = R"(Software\Valve\Steam\Apps\284160)";
|
||||||
|
|
||||||
|
/*LONG dwRegOPenKey = OpenKey(HKEY_CURRENT_USER, K1.c_str(), &hKey);
|
||||||
|
|
||||||
if(dwRegOPenKey == ERROR_SUCCESS) {
|
if(dwRegOPenKey == ERROR_SUCCESS) {
|
||||||
Result = QueryKey(hKey, 1);
|
Result = QueryKey(hKey, 1);
|
||||||
@ -287,19 +285,22 @@ void LegitimacyCheck(){
|
|||||||
TraceBack++;
|
TraceBack++;
|
||||||
}else lowExit(2);
|
}else lowExit(2);
|
||||||
K2.clear();
|
K2.clear();
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);*/
|
||||||
dwRegOPenKey = OpenKey(HKEY_CURRENT_USER, K3.c_str(), &hKey);
|
std::string Result;
|
||||||
|
std::string K3 = R"(Software\BeamNG\BeamNG.drive)";
|
||||||
|
HKEY hKey;
|
||||||
|
LONG dwRegOPenKey = OpenKey(HKEY_CURRENT_USER, K3.c_str(), &hKey);
|
||||||
if(dwRegOPenKey == ERROR_SUCCESS) {
|
if(dwRegOPenKey == ERROR_SUCCESS) {
|
||||||
Result = QueryKey(hKey, 3);
|
Result = QueryKey(hKey, 3);
|
||||||
if(Result.empty())lowExit(3);
|
if(Result.empty())lowExit(3);
|
||||||
if(IDCheck(Result,T))lowExit(5);
|
//if(IDCheck(Result,T))lowExit(5);
|
||||||
GameDir = Result;
|
GameDir = Result;
|
||||||
TraceBack++;
|
//TraceBack++;
|
||||||
}else lowExit(4);
|
}else lowExit(4);
|
||||||
K3.clear();
|
K3.clear();
|
||||||
Result.clear();
|
Result.clear();
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
if(TraceBack < 3)exit(-1);
|
//if(TraceBack < 3)exit(-1);
|
||||||
}
|
}
|
||||||
std::string CheckVer(const std::string &dir){
|
std::string CheckVer(const std::string &dir){
|
||||||
std::string temp,Path = dir + "\\integrity.json";
|
std::string temp,Path = dir + "\\integrity.json";
|
||||||
|
@ -28,7 +28,7 @@ std::string GetVer(){
|
|||||||
return "2.0";
|
return "2.0";
|
||||||
}
|
}
|
||||||
std::string GetPatch(){
|
std::string GetPatch(){
|
||||||
return ".4";
|
return ".5";
|
||||||
}
|
}
|
||||||
std::string GetEP(char*P){
|
std::string GetEP(char*P){
|
||||||
static std::string Ret = [&](){
|
static std::string Ret = [&](){
|
||||||
@ -215,9 +215,10 @@ void CheckMP(const std::string& Path) {
|
|||||||
void EnableMP(){
|
void EnableMP(){
|
||||||
std::string File(GetGamePath() + "mods/db.json");
|
std::string File(GetGamePath() + "mods/db.json");
|
||||||
if(!fs::exists(File))return;
|
if(!fs::exists(File))return;
|
||||||
|
auto Size = fs::file_size(File);
|
||||||
|
if(Size < 2)return;
|
||||||
std::ifstream db(File);
|
std::ifstream db(File);
|
||||||
if(db.is_open()) {
|
if(db.is_open()) {
|
||||||
auto Size = fs::file_size(File);
|
|
||||||
std::string Data(Size, 0);
|
std::string Data(Size, 0);
|
||||||
db.read(&Data[0], Size);
|
db.read(&Data[0], Size);
|
||||||
db.close();
|
db.close();
|
||||||
@ -244,7 +245,7 @@ void EnableMP(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PreGame(const std::string& GamePath){
|
void PreGame(const std::string& GamePath){
|
||||||
const std::string CurrVer("0.22.2.0");
|
const std::string CurrVer("0.22.3.0");
|
||||||
std::string GameVer = CheckVer(GamePath);
|
std::string GameVer = CheckVer(GamePath);
|
||||||
info("Game Version : " + GameVer);
|
info("Game Version : " + GameVer);
|
||||||
if(GameVer < CurrVer){
|
if(GameVer < CurrVer){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user