Fixed invalid string position, Bumped game version

This commit is contained in:
Anonymous-275 2021-05-11 22:19:42 +03:00
parent 09abe75fbb
commit 6c673e78e5
5 changed files with 26 additions and 34 deletions

View File

@ -15,7 +15,6 @@ void ParseConfig(const json::Document& d){
if(d["Port"].IsInt()){
DEFAULT_PORT = d["Port"].GetInt();
}
//Default -1
//Release 1
//EA 2

View File

@ -14,16 +14,8 @@
#include <thread>
std::string getDate() {
typedef std::chrono::duration<int, std::ratio_multiply<std::chrono::hours::period, std::ratio<24>>::type> days;
std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
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);
time_t tt = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
tm local_tm = *localtime(&tt);
std::stringstream date;
int S = local_tm.tm_sec;
int M = local_tm.tm_min;

View File

@ -109,11 +109,10 @@ void UpdateUl(bool D,const std::string&msg){
void AsyncUpdate(uint64_t& Rcv,uint64_t Size,const std::string& Name){
do {
double pr = Rcv / double(Size) * 100;
double pr = double(Rcv) / double(Size) * 100;
std::string Per = std::to_string(trunc(pr * 10) / 10);
UpdateUl(true, Name + " (" + Per.substr(0, Per.find('.') + 2) + "%)");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}while(!Terminate && Rcv < Size);
}
@ -177,7 +176,6 @@ std::string MultiDownload(SOCKET MSock,SOCKET DSock, uint64_t Size, const std::s
uint64_t GRcv = 0, MSize = Size/2, DSize = Size - MSize;
std::thread Au(AsyncUpdate,std::ref(GRcv), Size, Name);
Au.detach();
std::packaged_task<char*()> task([&] { return TCPRcvRaw(MSock,GRcv,MSize); });
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);
return "";
}
if(Au.joinable())Au.join();

View File

@ -28,7 +28,7 @@ void lowExit(int code){
std::this_thread::sleep_for(std::chrono::seconds(10));
exit(2);
}
void Exit(int code){
/*void Exit(int code){
TraceBack = 0;
std::string msg =
"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));
std::this_thread::sleep_for(std::chrono::seconds(10));
exit(4);
}
}*/
std::string GetGameDir(){
if(TraceBack != 4)Exit(0);
//if(TraceBack != 4)Exit(0);
return GameDir.substr(0,GameDir.find_last_of('\\'));
}
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 a = false,b = true;
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";
steam += "\\config\\loginusers.vdf";
if(fs::exists(Man) && fs::exists(steam)){
for(const std::string&ID : GetID(steam)){
if(ID == GetManifest(Man))b = false;
}
if(b)Exit(6);
//if(b)Exit(6);
}else a = true;
return a;
}
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) {
Result = QueryKey(hKey, 1);
@ -287,19 +285,22 @@ void LegitimacyCheck(){
TraceBack++;
}else lowExit(2);
K2.clear();
RegCloseKey(hKey);
dwRegOPenKey = OpenKey(HKEY_CURRENT_USER, K3.c_str(), &hKey);
RegCloseKey(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) {
Result = QueryKey(hKey, 3);
if(Result.empty())lowExit(3);
if(IDCheck(Result,T))lowExit(5);
//if(IDCheck(Result,T))lowExit(5);
GameDir = Result;
TraceBack++;
//TraceBack++;
}else lowExit(4);
K3.clear();
Result.clear();
RegCloseKey(hKey);
if(TraceBack < 3)exit(-1);
//if(TraceBack < 3)exit(-1);
}
std::string CheckVer(const std::string &dir){
std::string temp,Path = dir + "\\integrity.json";

View File

@ -28,7 +28,7 @@ std::string GetVer(){
return "2.0";
}
std::string GetPatch(){
return ".4";
return ".5";
}
std::string GetEP(char*P){
static std::string Ret = [&](){
@ -215,9 +215,10 @@ void CheckMP(const std::string& Path) {
void EnableMP(){
std::string File(GetGamePath() + "mods/db.json");
if(!fs::exists(File))return;
auto Size = fs::file_size(File);
if(Size < 2)return;
std::ifstream db(File);
if(db.is_open()) {
auto Size = fs::file_size(File);
std::string Data(Size, 0);
db.read(&Data[0], Size);
db.close();
@ -244,7 +245,7 @@ void EnableMP(){
}
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);
info("Game Version : " + GameVer);
if(GameVer < CurrVer){