mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-08-16 16:27:15 +00:00
Mingw Compatible
This commit is contained in:
parent
d96f968dde
commit
fbc5e28d25
@ -6,18 +6,22 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
|
||||
file(GLOB source_files "src/*.cpp" "src/*/*.cpp" "src/*/*.hpp" "include/*.h" "include/*/*.h" "include/*/*/*.h")
|
||||
add_executable(${PROJECT_NAME} ${source_files})
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "BeamMP-Launcher")
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(CURL CONFIG REQUIRED)
|
||||
|
||||
# This might cause issues with old windows headers, but it's worth the trouble to keep the code
|
||||
# completely cross platform. For fixes to common issues arising from /permissive- visit:
|
||||
# https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance
|
||||
if (WIN32)
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(CURL REQUIRED)
|
||||
message(STATUS "MSVC -> forcing use of statically-linked runtime.")
|
||||
STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
|
||||
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
|
||||
#-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static
|
||||
set(VcpkgRoot ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET})
|
||||
include_directories(${VcpkgRoot}/include)
|
||||
link_directories(${VcpkgRoot}/lib)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE discord-rpc CURL::libcurl ZLIB::ZLIB)
|
||||
else(WIN32) #MINGW
|
||||
add_definitions("-D_WIN32_WINNT=0x0600")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s -static-libgcc -static-libstdc++ --static")
|
||||
target_link_libraries(${PROJECT_NAME} discord-rpc.a ssp z ws2_32)
|
||||
endif(WIN32)
|
||||
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /permissive-")
|
||||
message(STATUS "MSVC -> forcing use of statically-linked runtime.")
|
||||
STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
|
||||
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
|
||||
#-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE rstrtmgr discord-rpc CURL::libcurl ZLIB::ZLIB)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
|
0
include/Curl/http.h
Normal file → Executable file
0
include/Curl/http.h
Normal file → Executable file
0
include/Discord/discord_info.h
Normal file → Executable file
0
include/Discord/discord_info.h
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
|
||||
// clang-format off
|
||||
|
||||
|
0
include/Json.h
Normal file → Executable file
0
include/Json.h
Normal file → Executable file
0
include/Logger.h
Normal file → Executable file
0
include/Logger.h
Normal file → Executable file
4
include/Network/network.h
Normal file → Executable file
4
include/Network/network.h
Normal file → Executable file
@ -5,6 +5,8 @@
|
||||
///
|
||||
/// Created by Anonymous275 on 7/18/2020
|
||||
///
|
||||
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
void NetReset();
|
||||
@ -18,7 +20,7 @@ extern bool Terminate;
|
||||
extern int DEFAULT_PORT;
|
||||
extern uint64_t UDPSock;
|
||||
extern uint64_t TCPSock;
|
||||
extern std::string Role;
|
||||
extern std::string Branch;
|
||||
extern bool TCPTerminate;
|
||||
extern std::string LastIP;
|
||||
extern std::string MStatus;
|
||||
|
0
include/Security/Game.h
Normal file → Executable file
0
include/Security/Game.h
Normal file → Executable file
0
include/Security/Init.h
Normal file → Executable file
0
include/Security/Init.h
Normal file → Executable file
1
include/Startup.h
Normal file → Executable file
1
include/Startup.h
Normal file → Executable file
@ -12,4 +12,5 @@ std::string GetEP(char*P = nullptr);
|
||||
std::string GetGamePath();
|
||||
std::string GetVer();
|
||||
std::string GetEN();
|
||||
void ConfigInit();
|
||||
extern bool Dev;
|
0
include/Zlib/Compressor.h
Normal file → Executable file
0
include/Zlib/Compressor.h
Normal file → Executable file
0
include/rapidjson/allocators.h
Normal file → Executable file
0
include/rapidjson/allocators.h
Normal file → Executable file
0
include/rapidjson/cursorstreamwrapper.h
Normal file → Executable file
0
include/rapidjson/cursorstreamwrapper.h
Normal file → Executable file
0
include/rapidjson/document.h
Normal file → Executable file
0
include/rapidjson/document.h
Normal file → Executable file
0
include/rapidjson/encodedstream.h
Normal file → Executable file
0
include/rapidjson/encodedstream.h
Normal file → Executable file
0
include/rapidjson/encodings.h
Normal file → Executable file
0
include/rapidjson/encodings.h
Normal file → Executable file
0
include/rapidjson/error/en.h
Normal file → Executable file
0
include/rapidjson/error/en.h
Normal file → Executable file
0
include/rapidjson/error/error.h
Normal file → Executable file
0
include/rapidjson/error/error.h
Normal file → Executable file
0
include/rapidjson/filereadstream.h
Normal file → Executable file
0
include/rapidjson/filereadstream.h
Normal file → Executable file
0
include/rapidjson/filewritestream.h
Normal file → Executable file
0
include/rapidjson/filewritestream.h
Normal file → Executable file
0
include/rapidjson/fwd.h
Normal file → Executable file
0
include/rapidjson/fwd.h
Normal file → Executable file
0
include/rapidjson/internal/biginteger.h
Normal file → Executable file
0
include/rapidjson/internal/biginteger.h
Normal file → Executable file
0
include/rapidjson/internal/clzll.h
Normal file → Executable file
0
include/rapidjson/internal/clzll.h
Normal file → Executable file
0
include/rapidjson/internal/diyfp.h
Normal file → Executable file
0
include/rapidjson/internal/diyfp.h
Normal file → Executable file
0
include/rapidjson/internal/dtoa.h
Normal file → Executable file
0
include/rapidjson/internal/dtoa.h
Normal file → Executable file
0
include/rapidjson/internal/ieee754.h
Normal file → Executable file
0
include/rapidjson/internal/ieee754.h
Normal file → Executable file
0
include/rapidjson/internal/itoa.h
Normal file → Executable file
0
include/rapidjson/internal/itoa.h
Normal file → Executable file
0
include/rapidjson/internal/meta.h
Normal file → Executable file
0
include/rapidjson/internal/meta.h
Normal file → Executable file
0
include/rapidjson/internal/pow10.h
Normal file → Executable file
0
include/rapidjson/internal/pow10.h
Normal file → Executable file
0
include/rapidjson/internal/regex.h
Normal file → Executable file
0
include/rapidjson/internal/regex.h
Normal file → Executable file
0
include/rapidjson/internal/stack.h
Normal file → Executable file
0
include/rapidjson/internal/stack.h
Normal file → Executable file
0
include/rapidjson/internal/strfunc.h
Normal file → Executable file
0
include/rapidjson/internal/strfunc.h
Normal file → Executable file
0
include/rapidjson/internal/strtod.h
Normal file → Executable file
0
include/rapidjson/internal/strtod.h
Normal file → Executable file
0
include/rapidjson/internal/swap.h
Normal file → Executable file
0
include/rapidjson/internal/swap.h
Normal file → Executable file
0
include/rapidjson/istreamwrapper.h
Normal file → Executable file
0
include/rapidjson/istreamwrapper.h
Normal file → Executable file
0
include/rapidjson/memorybuffer.h
Normal file → Executable file
0
include/rapidjson/memorybuffer.h
Normal file → Executable file
0
include/rapidjson/memorystream.h
Normal file → Executable file
0
include/rapidjson/memorystream.h
Normal file → Executable file
0
include/rapidjson/msinttypes/inttypes.h
Normal file → Executable file
0
include/rapidjson/msinttypes/inttypes.h
Normal file → Executable file
0
include/rapidjson/msinttypes/stdint.h
Normal file → Executable file
0
include/rapidjson/msinttypes/stdint.h
Normal file → Executable file
0
include/rapidjson/ostreamwrapper.h
Normal file → Executable file
0
include/rapidjson/ostreamwrapper.h
Normal file → Executable file
0
include/rapidjson/pointer.h
Normal file → Executable file
0
include/rapidjson/pointer.h
Normal file → Executable file
0
include/rapidjson/prettywriter.h
Normal file → Executable file
0
include/rapidjson/prettywriter.h
Normal file → Executable file
0
include/rapidjson/rapidjson.h
Normal file → Executable file
0
include/rapidjson/rapidjson.h
Normal file → Executable file
0
include/rapidjson/reader.h
Normal file → Executable file
0
include/rapidjson/reader.h
Normal file → Executable file
0
include/rapidjson/schema.h
Normal file → Executable file
0
include/rapidjson/schema.h
Normal file → Executable file
0
include/rapidjson/stream.h
Normal file → Executable file
0
include/rapidjson/stream.h
Normal file → Executable file
0
include/rapidjson/stringbuffer.h
Normal file → Executable file
0
include/rapidjson/stringbuffer.h
Normal file → Executable file
0
include/rapidjson/writer.h
Normal file → Executable file
0
include/rapidjson/writer.h
Normal file → Executable file
0
src/Compressor.cpp
Normal file → Executable file
0
src/Compressor.cpp
Normal file → Executable file
60
src/Config.cpp
Executable file
60
src/Config.cpp
Executable file
@ -0,0 +1,60 @@
|
||||
///
|
||||
/// Created by Anonymous275 on 2/23/2021
|
||||
///
|
||||
|
||||
#include "Network/network.h"
|
||||
#include <filesystem>
|
||||
#include "Logger.h"
|
||||
#include <fstream>
|
||||
#include "Json.h"
|
||||
#include <cstdint>
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
std::string Branch;
|
||||
void ParseConfig(const json::Document& d){
|
||||
if(d["Port"].IsInt()){
|
||||
DEFAULT_PORT = d["Port"].GetInt();
|
||||
}
|
||||
|
||||
//Default -1
|
||||
//Release 1
|
||||
//EA 2
|
||||
//Dev 3
|
||||
//Custom 3
|
||||
|
||||
if(d["Build"].IsString()){
|
||||
Branch = d["Build"].GetString();
|
||||
for(char& c : Branch)c = char(tolower(c));
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigInit(){
|
||||
if(fs::exists("Launcher.cfg")){
|
||||
std::ifstream cfg("Launcher.cfg");
|
||||
if(cfg.is_open()){
|
||||
auto Size = fs::file_size("Launcher.cfg");
|
||||
std::string Buffer(Size, 0);
|
||||
cfg.read(&Buffer[0], Size);
|
||||
cfg.close();
|
||||
json::Document d;
|
||||
d.Parse(Buffer.c_str());
|
||||
if(d.HasParseError()){
|
||||
fatal("Config failed to parse make sure it's valid JSON! Code : " + std::to_string(d.GetParseError()));
|
||||
}
|
||||
ParseConfig(d);
|
||||
}else fatal("Failed to open Launcher.cfg!");
|
||||
}else{
|
||||
std::ofstream cfg("Launcher.cfg");
|
||||
if(cfg.is_open()){
|
||||
cfg <<
|
||||
R"({
|
||||
"Port": 4444,
|
||||
"Build": "Default"
|
||||
})";
|
||||
cfg.close();
|
||||
}else{
|
||||
fatal("Failed to write config on disk!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
src/Discord.cpp
Normal file → Executable file
2
src/Discord.cpp
Normal file → Executable file
@ -7,7 +7,7 @@
|
||||
///
|
||||
#include "Discord/discord_rpc.h"
|
||||
#include "Logger.h"
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <thread>
|
||||
#include <ctime>
|
||||
|
||||
|
2
src/GameStart.cpp
Normal file → Executable file
2
src/GameStart.cpp
Normal file → Executable file
@ -6,7 +6,7 @@
|
||||
/// Created by Anonymous275 on 7/19/2020
|
||||
///
|
||||
|
||||
#include <Windows.h>
|
||||
#include <windows.h>
|
||||
#include "Startup.h"
|
||||
#include "Logger.h"
|
||||
#include <iostream>
|
||||
|
0
src/Logger.cpp
Normal file → Executable file
0
src/Logger.cpp
Normal file → Executable file
8
src/Network/Core.cpp
Normal file → Executable file
8
src/Network/Core.cpp
Normal file → Executable file
@ -9,8 +9,8 @@
|
||||
#include "Security/Init.h"
|
||||
|
||||
#include "Curl/http.h"
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include "Startup.h"
|
||||
#include "Logger.h"
|
||||
#include <charconv>
|
||||
@ -242,9 +242,13 @@ int Handle(EXCEPTION_POINTERS *ep){
|
||||
|
||||
void CoreNetwork(){
|
||||
while(TraceBack >= 4){
|
||||
#ifndef __MINGW32__
|
||||
__try{
|
||||
#endif
|
||||
CoreMain();
|
||||
#ifndef __MINGW32__
|
||||
}__except(Handle(GetExceptionInformation())){}
|
||||
#endif
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
}
|
||||
}
|
||||
|
0
src/Network/DNS.cpp
Normal file → Executable file
0
src/Network/DNS.cpp
Normal file → Executable file
6
src/Network/GlobalHandler.cpp
Normal file → Executable file
6
src/Network/GlobalHandler.cpp
Normal file → Executable file
@ -6,15 +6,15 @@
|
||||
/// Created by Anonymous275 on 7/25/2020
|
||||
///
|
||||
#include "Network/network.h"
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include "Logger.h"
|
||||
#include <charconv>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
|
||||
std::chrono::time_point<std::chrono::steady_clock> PingStart,PingEnd;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> PingStart,PingEnd;
|
||||
bool GConnected = false;
|
||||
bool CServer = true;
|
||||
SOCKET CSocket = -1;
|
||||
|
6
src/Network/Http.cpp
Normal file → Executable file
6
src/Network/Http.cpp
Normal file → Executable file
@ -10,6 +10,7 @@
|
||||
#include <iostream>
|
||||
#include <Logger.h>
|
||||
#include <mutex>
|
||||
#include <cmath>
|
||||
|
||||
class CurlManager{
|
||||
public:
|
||||
@ -123,6 +124,7 @@ std::string PostHTTP(const std::string& IP, const std::string& Fields) {
|
||||
CURLcode res;
|
||||
std::string readBuffer;
|
||||
|
||||
|
||||
if (curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, IP.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header);
|
||||
@ -130,9 +132,11 @@ std::string PostHTTP(const std::string& IP, const std::string& Fields) {
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, Fields.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
|
||||
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
||||
//curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
if (res != CURLE_OK)
|
||||
return "-1";
|
||||
}
|
||||
|
7
src/Network/Resources.cpp
Normal file → Executable file
7
src/Network/Resources.cpp
Normal file → Executable file
@ -7,8 +7,7 @@
|
||||
///
|
||||
|
||||
#include "Network/network.h"
|
||||
|
||||
#include <WS2tcpip.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <filesystem>
|
||||
#include "Startup.h"
|
||||
#include "Logger.h"
|
||||
@ -20,6 +19,7 @@
|
||||
#include <atomic>
|
||||
#include <vector>
|
||||
#include <future>
|
||||
#include <cmath>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
std::string ListOfMods;
|
||||
@ -37,8 +37,7 @@ std::vector<std::string> Split(const std::string& String,const std::string& deli
|
||||
}
|
||||
|
||||
void CheckForDir(){
|
||||
struct stat info{};
|
||||
if(stat( "Resources", &info) != 0){
|
||||
if(!fs::exists("Resources")){
|
||||
_wmkdir(L"Resources");
|
||||
}
|
||||
}
|
||||
|
2
src/Network/VehicleData.cpp
Normal file → Executable file
2
src/Network/VehicleData.cpp
Normal file → Executable file
@ -8,7 +8,7 @@
|
||||
#include "Zlib/Compressor.h"
|
||||
#include "Network/network.h"
|
||||
|
||||
#include <WS2tcpip.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include "Logger.h"
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
4
src/Network/VehicleEvent.cpp
Normal file → Executable file
4
src/Network/VehicleEvent.cpp
Normal file → Executable file
@ -10,7 +10,7 @@
|
||||
#include <vector>
|
||||
#include "Logger.h"
|
||||
#include <iostream>
|
||||
#include <WS2tcpip.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <Zlib/Compressor.h>
|
||||
|
||||
#include "Network/network.h"
|
||||
@ -133,7 +133,7 @@ void TCPClientMain(const std::string& IP,int Port){
|
||||
RetCode = connect(TCPSock, (SOCKADDR *) &ServerAddr, sizeof(ServerAddr));
|
||||
if(RetCode != 0){
|
||||
UlStatus = "UlConnection Failed!";
|
||||
std::cout << "Client: connect failed! Error code: " << WSAGetLastError() << std::endl;
|
||||
error("Client: connect failed! Error code: " + std::to_string(WSAGetLastError()));
|
||||
KillSocket(TCPSock);
|
||||
WSACleanup();
|
||||
Terminate = true;
|
||||
|
3
src/Security/BeamNG.cpp
Normal file → Executable file
3
src/Security/BeamNG.cpp
Normal file → Executable file
@ -7,13 +7,12 @@
|
||||
///
|
||||
|
||||
#include <filesystem>
|
||||
#include <Windows.h>
|
||||
#include <windows.h>
|
||||
#include "Logger.h"
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <ShlDisp.h>
|
||||
|
||||
#define MAX_KEY_LENGTH 255
|
||||
#define MAX_VALUE_NAME 16383
|
||||
|
13
src/Security/Login.cpp
Normal file → Executable file
13
src/Security/Login.cpp
Normal file → Executable file
@ -12,7 +12,7 @@
|
||||
#include <fstream>
|
||||
#include "Json.h"
|
||||
|
||||
using namespace std::filesystem;
|
||||
namespace fs = std::filesystem;
|
||||
std::string PublicKey;
|
||||
extern bool LoginAuth;
|
||||
std::string Role;
|
||||
@ -24,7 +24,7 @@ void UpdateKey(const char* newKey){
|
||||
Key << newKey;
|
||||
Key.close();
|
||||
}else fatal("Cannot write to disk!");
|
||||
}else if(exists("key")){
|
||||
}else if(fs::exists("key")){
|
||||
remove("key");
|
||||
}
|
||||
}
|
||||
@ -55,6 +55,7 @@ std::string Login(const std::string& fields){
|
||||
}
|
||||
|
||||
if (Buffer.at(0) != '{' || d.HasParseError()) {
|
||||
error(Buffer);
|
||||
return GetFail("Invalid answer from authentication servers, please try again later!");
|
||||
}
|
||||
if(!d["success"].IsNull() && d["success"].GetBool()){
|
||||
@ -79,17 +80,20 @@ std::string Login(const std::string& fields){
|
||||
}
|
||||
|
||||
void CheckLocalKey(){
|
||||
if(exists("key") && file_size("key") < 100){
|
||||
if(fs::exists("key") && fs::file_size("key") < 100){
|
||||
std::ifstream Key("key");
|
||||
if(Key.is_open()) {
|
||||
auto Size = file_size("key");
|
||||
auto Size = fs::file_size("key");
|
||||
std::string Buffer(Size, 0);
|
||||
Key.read(&Buffer[0], Size);
|
||||
Key.close();
|
||||
|
||||
Buffer = PostHTTP("https://auth.beammp.com/userlogin", R"({"pk":")"+Buffer+"\"}");
|
||||
|
||||
json::Document d;
|
||||
d.Parse(Buffer.c_str());
|
||||
if (Buffer == "-1" || Buffer.at(0) != '{' || d.HasParseError()) {
|
||||
error(Buffer);
|
||||
fatal("Invalid answer from authentication servers, please try again later!");
|
||||
}
|
||||
if(d["success"].GetBool()){
|
||||
@ -97,6 +101,7 @@ void CheckLocalKey(){
|
||||
UpdateKey(d["private_key"].GetString());
|
||||
PublicKey = d["public_key"].GetString();
|
||||
Role = d["role"].GetString();
|
||||
//info(Role);
|
||||
}else{
|
||||
info("Auto-Authentication unsuccessful please re-login!");
|
||||
UpdateKey(nullptr);
|
||||
|
49
src/Startup.cpp
Normal file → Executable file
49
src/Startup.cpp
Normal file → Executable file
@ -5,6 +5,8 @@
|
||||
///
|
||||
/// Created by Anonymous275 on 7/16/2020
|
||||
///
|
||||
|
||||
|
||||
#include "Discord/discord_info.h"
|
||||
#include "Network/network.h"
|
||||
#include "Security/Init.h"
|
||||
@ -23,10 +25,10 @@ std::string GetEN(){
|
||||
return "BeamMP-Launcher.exe";
|
||||
}
|
||||
std::string GetVer(){
|
||||
return "1.81";
|
||||
return "1.80";
|
||||
}
|
||||
std::string GetPatch(){
|
||||
return ".0";
|
||||
return ".95";
|
||||
}
|
||||
std::string GetEP(char*P){
|
||||
static std::string Ret = [&](){
|
||||
@ -59,35 +61,15 @@ void URelaunch(int argc,char* args[]){
|
||||
exit(1);
|
||||
}
|
||||
void CheckName(int argc,char* args[]){
|
||||
struct stat info{};
|
||||
std::string DN = GetEN(),CDir = args[0],FN = CDir.substr(CDir.find_last_of('\\')+1);
|
||||
if(FN != DN){
|
||||
if(stat(DN.c_str(),&info)==0)remove(DN.c_str());
|
||||
if(stat(DN.c_str(),&info)==0)ReLaunch(argc,args);
|
||||
if(fs::exists(DN))remove(DN.c_str());
|
||||
if(fs::exists(DN))ReLaunch(argc,args);
|
||||
std::rename(FN.c_str(), DN.c_str());
|
||||
URelaunch(argc,args);
|
||||
}
|
||||
}
|
||||
|
||||
/// Deprecated
|
||||
void RequestRole(){
|
||||
/*auto NPos = std::string::npos;
|
||||
std::string HTTP_Result = HTTP_REQUEST("https://beammp.com/entitlement?did="+GetDID()+"&t=l",443);
|
||||
if(HTTP_Result == "-1"){
|
||||
HTTP_Result = HTTP_REQUEST("https://backup1.beammp.com/entitlement?did="+GetDID()+"&t=l",443);
|
||||
if(HTTP_Result == "-1") {
|
||||
fatal("Sorry Backend System Outage! Don't worry it will back on soon!");
|
||||
}
|
||||
}
|
||||
if(HTTP_Result.find("\"MDEV\"") != NPos || HTTP_Result.find("\"CON\"") != NPos){
|
||||
Dev = true;
|
||||
}
|
||||
if(HTTP_Result.find("Error") != NPos){
|
||||
fatal("Sorry You need to be in the official BeamMP Discord to proceed! https://discord.gg/beammp");
|
||||
}
|
||||
info("Client Connected!");*/
|
||||
}
|
||||
|
||||
void CheckForUpdates(int argc,char*args[],const std::string& CV){
|
||||
std::string link = "https://beammp.com/builds/launcher?version=true";
|
||||
std::string HTTP = HTTP_REQUEST(link,443);
|
||||
@ -147,13 +129,12 @@ void InitLauncher(int argc, char* argv[]) {
|
||||
SetConsoleTitleA(("BeamMP Launcher v" + std::string(GetVer()) + GetPatch()).c_str());
|
||||
InitLog();
|
||||
CheckName(argc, argv);
|
||||
CheckLocalKey(); //will replace RequestRole
|
||||
Discord_Main();
|
||||
//Dev = true;
|
||||
//RequestRole();
|
||||
|
||||
CheckLocalKey();
|
||||
ConfigInit();
|
||||
CustomPort(argc, argv);
|
||||
Discord_Main();
|
||||
CheckForUpdates(argc, argv, std::string(GetVer()) + GetPatch());
|
||||
|
||||
}
|
||||
size_t DirCount(const std::filesystem::path& path){
|
||||
return (size_t)std::distance(std::filesystem::directory_iterator{path}, std::filesystem::directory_iterator{});
|
||||
@ -179,7 +160,7 @@ void CheckMP(const std::string& Path) {
|
||||
|
||||
}
|
||||
void PreGame(const std::string& GamePath){
|
||||
const std::string CurrVer("0.21.3.0");
|
||||
const std::string CurrVer("0.21.4.0");
|
||||
std::string GameVer = CheckVer(GamePath);
|
||||
info("Game Version : " + GameVer);
|
||||
if(GameVer < CurrVer){
|
||||
@ -198,11 +179,13 @@ void PreGame(const std::string& GamePath){
|
||||
}catch(std::exception&e){
|
||||
fatal(e.what());
|
||||
}
|
||||
|
||||
/* Download("https://backend.beammp.com/builds/client?download=true"
|
||||
"&pk=" + PublicKey +
|
||||
"&branch=" + Branch, GetGamePath() + R"(mods\multiplayer\BeamMP.zip)", true);*/
|
||||
|
||||
Download("https://beammp.com/builds/client", GetGamePath() + R"(mods\multiplayer\BeamMP.zip)", true);
|
||||
info("Download Complete!");
|
||||
}
|
||||
|
||||
/*debug("Name : " + GetDName());
|
||||
debug("Discriminator : " + GetDTag());
|
||||
debug("Unique ID : " + GetDID());*/
|
||||
}
|
0
src/main.cpp
Normal file → Executable file
0
src/main.cpp
Normal file → Executable file
Loading…
x
Reference in New Issue
Block a user