Switched to new default userdata

This commit is contained in:
Anonymous-275 2021-03-29 23:29:03 +03:00
parent 1afa81e420
commit 289402a9ba
5 changed files with 19 additions and 13 deletions

View File

@ -6,6 +6,7 @@
/// Created by Anonymous275 on 7/19/2020 /// Created by Anonymous275 on 7/19/2020
/// ///
#include <Security/Init.h>
#include <windows.h> #include <windows.h>
#include "Startup.h" #include "Startup.h"
#include "Logger.h" #include "Logger.h"
@ -30,10 +31,10 @@ std::string GetGamePath(){
sk = R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders)"; sk = R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders)";
openRes = RegOpenKeyEx(HKEY_CURRENT_USER, sk, 0, KEY_ALL_ACCESS, &hKey); openRes = RegOpenKeyEx(HKEY_CURRENT_USER, sk, 0, KEY_ALL_ACCESS, &hKey);
if (openRes != ERROR_SUCCESS){ if (openRes != ERROR_SUCCESS){
fatal("Cannot get Documents directory!"); fatal("Cannot get Local Appdata directory!");
} }
Path = QueryKey(hKey,5); Path = QueryKey(hKey,5);
Path += "\\BeamNG.drive\\"; Path += "\\BeamNG.drive\\" + CheckVer(GetGameDir()) + "\\";
return Path; return Path;
} }

View File

@ -58,7 +58,7 @@ void Parse(std::string Data,SOCKET CSocket){
NetReset(); NetReset();
Terminate = true; Terminate = true;
TCPTerminate = true; TCPTerminate = true;
Data = Code + HTTP::Post("backend.beammp.com/servers", ""); Data = Code + HTTP::Post("backend.beammp.com/servers","");
break; break;
case 'C': case 'C':
ListOfMods.clear(); ListOfMods.clear();

View File

@ -14,6 +14,7 @@
#include "http.h" #include "http.h"
#include <mutex> #include <mutex>
#include <cmath> #include <cmath>
#include <evhttp.h>
#include "winmain-inl.h" #include "winmain-inl.h"
@ -40,8 +41,9 @@ std::string HTTP::Get(const std::string &IP) {
t.Start(true); t.Start(true);
auto pos = IP.find('/'); auto pos = IP.find('/');
std::shared_ptr<evpp::httpc::ConnPool> pool = std::make_shared<evpp::httpc::ConnPool>("www." + IP.substr(0,pos), 443, true, evpp::Duration(10.0)); std::shared_ptr<evpp::httpc::ConnPool> pool = std::make_shared<evpp::httpc::ConnPool>(IP.substr(0, pos), 443, true,
auto* r = new evpp::httpc::Request(pool.get(), t.loop(), IP.substr(pos), ""); evpp::Duration(10.0));
auto *r = new evpp::httpc::Request(pool.get(), t.loop(), IP.substr(pos), "");
r->Execute(Response); r->Execute(Response);
while (!responded) { while (!responded) {
@ -62,10 +64,16 @@ std::string HTTP::Post(const std::string& IP, const std::string& Fields) {
evpp::EventLoopThread t; evpp::EventLoopThread t;
t.Start(true); t.Start(true);
auto pos = IP.find('/'); auto pos = IP.find('/');
std::shared_ptr<evpp::httpc::ConnPool> pool = std::make_shared<evpp::httpc::ConnPool>( IP.substr(0,pos), 443, true, evpp::Duration(10.0)); std::shared_ptr<evpp::httpc::ConnPool> pool = std::make_shared<evpp::httpc::ConnPool>(IP.substr(0, pos), 443,
auto* r = new evpp::httpc::Request(pool.get(), t.loop(), IP.substr(pos), Fields); true,
r->AddHeader("Content-Type","application/json"); evpp::Duration(10.0));
auto *r = new evpp::httpc::Request(pool.get(), t.loop(), IP.substr(pos), Fields);
if(!Fields.empty()) {
r->AddHeader("Content-Type", "application/json");
}
r->set_request_type(EVHTTP_REQ_POST);
r->Execute(Response); r->Execute(Response);
while (!responded) { while (!responded) {
@ -101,7 +109,7 @@ bool HTTP::Download(const std::string &IP, const std::string &Path) {
evpp::EventLoopThread t; evpp::EventLoopThread t;
t.Start(true); t.Start(true);
auto pos = IP.find('/'); auto pos = IP.find('/');
std::shared_ptr<evpp::httpc::ConnPool> pool = std::make_shared<evpp::httpc::ConnPool>("www." + IP.substr(0,pos), 443, true, evpp::Duration(10.0)); std::shared_ptr<evpp::httpc::ConnPool> pool = std::make_shared<evpp::httpc::ConnPool>(IP.substr(0,pos), 443, true, evpp::Duration(10.0));
auto* r = new evpp::httpc::Request(pool.get(), t.loop(), IP.substr(pos), ""); auto* r = new evpp::httpc::Request(pool.get(), t.loop(), IP.substr(pos), "");
r->set_progress_callback(ProgressBar); r->set_progress_callback(ProgressBar);
r->Execute(Response); r->Execute(Response);

View File

@ -120,7 +120,7 @@ std::string QueryKey(HKEY hKey,int ID){
case 2: if(key == "Name" && data == "BeamNG.drive")return data;break; case 2: if(key == "Name" && data == "BeamNG.drive")return data;break;
case 3: if(key == "rootpath")return data;break; case 3: if(key == "rootpath")return data;break;
case 4: if(key == "userpath_override")return data; case 4: if(key == "userpath_override")return data;
case 5: if(key == "Personal")return data; case 5: if(key == "Local AppData")return data;
default: break; default: break;
} }
} }

View File

@ -10,9 +10,6 @@
#include "Network/network.h" #include "Network/network.h"
#include "Security/Init.h" #include "Security/Init.h"
#include <filesystem> #include <filesystem>
#ifndef WIN32
#include <windows.h>
#endif
#include "Startup.h" #include "Startup.h"
#include "Logger.h" #include "Logger.h"
#include <thread> #include <thread>