diff --git a/include/http.h b/include/Http.h similarity index 98% rename from include/http.h rename to include/Http.h index 79a3976..fc298f0 100755 --- a/include/http.h +++ b/include/Http.h @@ -8,7 +8,7 @@ #pragma once #include #include "Logger.h" -class HTTP{ +class HTTP { public: static bool Download(const std::string &IP, const std::string &Path); static std::string Post(const std::string& IP, const std::string& Fields); diff --git a/src/Network/Core.cpp b/src/Network/Core.cpp index 96b98bf..432f6b8 100755 --- a/src/Network/Core.cpp +++ b/src/Network/Core.cpp @@ -8,7 +8,7 @@ #include "Network/network.h" #include "Security/Init.h" -#include "http.h" +#include "Http.h" #include #include #include "Startup.h" diff --git a/src/Network/Http.cpp b/src/Network/Http.cpp index 4410dd5..0ea4b95 100755 --- a/src/Network/Http.cpp +++ b/src/Network/Http.cpp @@ -10,7 +10,7 @@ #include #include #include -#include "http.h" +#include "Http.h" #include #include #include diff --git a/src/Security/Login.cpp b/src/Security/Login.cpp index 3efc6e9..370d25c 100755 --- a/src/Security/Login.cpp +++ b/src/Security/Login.cpp @@ -6,7 +6,7 @@ /// Created by Anonymous275 on 11/26/2020 /// -#include "http.h" +#include "Http.h" #include #include "Logger.h" #include diff --git a/src/Startup.cpp b/src/Startup.cpp index 70539a7..1867f08 100755 --- a/src/Startup.cpp +++ b/src/Startup.cpp @@ -5,6 +5,7 @@ /// /// Created by Anonymous275 on 7/16/2020 /// +#include "zip_file.h" #include #include "Discord/discord_info.h" #include "Network/network.h" @@ -14,7 +15,7 @@ #include "Logger.h" #include #include -#include "http.h" +#include "Http.h" #include "Json.h" extern int TraceBack; @@ -28,7 +29,7 @@ std::string GetVer(){ return "2.0"; } std::string GetPatch(){ - return ".5"; + return ".6"; } std::string GetEP(char*P){ static std::string Ret = [&](){ @@ -245,7 +246,7 @@ void EnableMP(){ } void PreGame(const std::string& GamePath){ - const std::string CurrVer("0.22.3.0"); + const std::string CurrVer("0.23.0.0"); std::string GameVer = CheckVer(GamePath); info("Game Version : " + GameVer); if(GameVer < CurrVer){ @@ -265,10 +266,41 @@ void PreGame(const std::string& GamePath){ }catch(std::exception&e){ fatal(e.what()); } + std::string ZipPath(GetGamePath() + R"(mods\multiplayer\BeamMP.zip)"); - HTTP::Download("https://backend.beammp.com/builds/client?download=true" - "&pk=" + PublicKey + - "&branch=" + Branch, GetGamePath() + R"(mods\multiplayer\BeamMP.zip)"); + HTTP::Download("https://backend.beammp.com/builds/client?download=true" + "&pk=" + PublicKey + "&branch=" + Branch, ZipPath); + + std::string Target(GetGamePath() + "mods/unpacked/beammp"); + info("check1"); + if(fs::is_directory(Target)) { + fs::remove_all(Target); + } + info("check2"); + fs::create_directories(Target); + info("check3"); + if (fs::exists(ZipPath)) { + info("check4"); + miniz_cpp::zip_file zip{ ZipPath }; + info("check5"); + fs::create_directories(Target); + info("check6"); + for(auto name : zip.namelist()){ + info("check7"); + if(name.back() == '/' || name.back() == '\\') { + info("check8"); + name.erase(std::prev(name.end())); + info("check9"); + fs::create_directories(Target + "/" + name); + info("check10"); + } + } + info("check11"); + zip.extractall(Target); + info("check12"); + fs::remove(ZipPath); + info("check13"); + } //HTTP::Download("beammp.com/builds/client", GetGamePath() + R"(mods\multiplayer\BeamMP.zip)"); } diff --git a/src/main.cpp b/src/main.cpp index a04dab4..26e61ed 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,7 +11,7 @@ #include #include "Logger.h" #include -#include "http.h" +#include "Http.h" [[noreturn]] void flush(){ while(true){