added client version control
+ nlohmann/json library was included in the project. + VersionControl class was created and it checks if the client is up to date. + CLIENT_VERSION macro defined.
This commit is contained in:
@@ -353,6 +353,9 @@ void DrawMiscTab() {
|
||||
}
|
||||
|
||||
void DrawPlayersTab() {
|
||||
ImGui::Checkbox("Fly", &settings::fly);
|
||||
ImGui::SliderFloat("Speed: ", &settings::fly_speed, 5.f, 20.f);
|
||||
|
||||
ImGui::Checkbox("Change player speed", &settings::change_player_speed);
|
||||
ImGui::SliderInt("Multiplier", &settings::new_speed, 0, 10);
|
||||
|
||||
|
||||
@@ -15,10 +15,14 @@
|
||||
#include "Wrapper.h"
|
||||
#include "ClientHelper.h"
|
||||
#include "hooks/hooks.hpp"
|
||||
#include "color.hpp"
|
||||
#include "UnityCore.h"
|
||||
#include "color.hpp"
|
||||
#include "features/misc/misc.h"
|
||||
#include "utils/utils.hpp"
|
||||
#include "network/VersionControl.h"
|
||||
|
||||
|
||||
#define CLIENT_VERSION "4.1"
|
||||
|
||||
// Set the name of your log file here
|
||||
extern const LPCWSTR LOG_FILE = L"DevourClient.txt";
|
||||
@@ -42,7 +46,9 @@ void Run()
|
||||
// If you would like to output to a new console window, use il2cppi_new_console() to open one and redirect stdout
|
||||
il2cppi_new_console();
|
||||
|
||||
std::cout << dye::green("\n\tDevourClient v2.0\n\t") << __DATE__ << " - " << __TIME__ << std::endl;
|
||||
|
||||
std::cout << dye::green("\n\tDevourClient v") << dye::green(CLIENT_VERSION) << "\n\t" << __DATE__ << " - " << __TIME__ << std::endl;
|
||||
|
||||
std::cout << "\tDevour Version ";
|
||||
|
||||
if (app::Application_get_version != nullptr)
|
||||
@@ -59,6 +65,39 @@ void Run()
|
||||
std::cout << "[DevourClient]: " << "Note: " << dye::light_red("if you payed for this you most likely got scammed.\n\n");
|
||||
std::cout << "[DevourClient]: Logged in as " << dye::yellow(steamName) << " (" << steamUserID << ")\n\n";
|
||||
|
||||
// DevourClient version control
|
||||
VersionControl client(CLIENT_VERSION, L"https://api.github.com/repos/ALittlePatate/DevourClient/releases/latest");
|
||||
il2cppi_log_write("[DevourClient]: Update check successful, client is up-to-date.\n");
|
||||
std::cout << "[DevourClient]: " << dye::light_aqua("Checking for updates..\n");
|
||||
client.CheckForUpdate();
|
||||
|
||||
if (client.IsUpToDate()) {
|
||||
il2cppi_log_write("[DevourClient]: Update check successful, client is up-to-date.\n");
|
||||
std::cout << "[DevourClient]: " << dye::light_green("Client is up to date.") << "\n\n";
|
||||
}
|
||||
else {
|
||||
il2cppi_log_write("[DevourClient]: Client is out of date!\n");
|
||||
std::cout << "[DevourClient]: " << dye::red_on_black("Client is out of date!") << "\n\n";
|
||||
|
||||
const char* latestDownloadLink = client.GetLatestDownloadLink();
|
||||
app::String* str = reinterpret_cast<app::String*>(il2cpp_string_new(latestDownloadLink));
|
||||
|
||||
const int result = MessageBox(NULL, L"Version is not up to date! Would you like to download the new version?", L"DevourClient", MB_YESNO | MB_ICONERROR);
|
||||
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case IDYES:
|
||||
app::Application_OpenURL(str, nullptr);
|
||||
break;
|
||||
case IDNO:
|
||||
MessageBox(NULL, L"You can download the new version at any time to benefit from new features, improvements, and bug fixes", L"DevourClient", MB_OK | MB_ICONEXCLAMATION);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "[DevourClient]: " << dye::aqua("Initializing..\n");
|
||||
il2cppi_log_write("Initializing..");
|
||||
|
||||
@@ -86,14 +125,6 @@ void Run()
|
||||
return;
|
||||
}
|
||||
|
||||
// create settings.ini
|
||||
std::string filename = "settings.ini";
|
||||
std::string key = "open_menu";
|
||||
std::string defaultValue = "INSERT"; // default value
|
||||
|
||||
// null file??
|
||||
std::string keyValue = ReadValueFromIni(filename, key, defaultValue);
|
||||
|
||||
std::cout << "[DevourClient]: " << dye::light_green("Done!:)\n\n");
|
||||
|
||||
std::string scene = SceneName();
|
||||
|
||||
95
user/network/VersionControl.cpp
Normal file
95
user/network/VersionControl.cpp
Normal file
@@ -0,0 +1,95 @@
|
||||
#include "pch-il2cpp.h"
|
||||
|
||||
#include "VersionControl.h"
|
||||
|
||||
#include <Windows.h>
|
||||
#include <iostream>
|
||||
#include <wininet.h>
|
||||
|
||||
#include "json.hpp"
|
||||
|
||||
#pragma comment(lib, "wininet.lib")
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
VersionControl::VersionControl(const char* version_tag, const wchar_t* url)
|
||||
{
|
||||
current_version_tag = version_tag;
|
||||
requestUrl = url;
|
||||
isUpToDate = false;
|
||||
latestDownloadLink = nullptr;
|
||||
}
|
||||
|
||||
const char* VersionControl::GetCurrentVersionTag()
|
||||
{
|
||||
return current_version_tag;
|
||||
}
|
||||
|
||||
bool VersionControl::IsUpToDate()
|
||||
{
|
||||
return isUpToDate;
|
||||
}
|
||||
|
||||
const char* VersionControl::GetLatestDownloadLink()
|
||||
{
|
||||
return latestDownloadLink;
|
||||
}
|
||||
|
||||
void VersionControl::SetIsUpToDate(bool value)
|
||||
{
|
||||
isUpToDate = value;
|
||||
}
|
||||
|
||||
void VersionControl::CheckForUpdate()
|
||||
{
|
||||
HINTERNET hInternet = InternetOpen(L"DevourClient_Version_Control", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
|
||||
|
||||
if (hInternet) {
|
||||
HINTERNET hConnect = InternetOpenUrl(hInternet, requestUrl, NULL, 0, INTERNET_FLAG_RELOAD, 0);
|
||||
|
||||
if (hConnect) {
|
||||
std::vector<char> buffer(4096);
|
||||
DWORD bytesRead;
|
||||
std::string responseData;
|
||||
|
||||
while (InternetReadFile(hConnect, &buffer[0], buffer.size(), &bytesRead) && bytesRead > 0) {
|
||||
responseData.append(&buffer[0], bytesRead);
|
||||
}
|
||||
|
||||
json data = json::parse(responseData);
|
||||
|
||||
if (data.find("tag_name") != data.end() && data["tag_name"].is_string()) {
|
||||
std::string latestTagName = data["tag_name"];
|
||||
|
||||
if (strcmp(latestTagName.c_str(), current_version_tag) == 0) {
|
||||
SetIsUpToDate(true);
|
||||
}
|
||||
else {
|
||||
SetIsUpToDate(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.find("assets") != data.end() && data["assets"].is_array() && !data["assets"].empty()) {
|
||||
if (data["assets"][0].find("browser_download_url") != data["assets"][0].end() && data["assets"][0]["browser_download_url"].is_string()) {
|
||||
std::string downloadUrl = data["assets"][0]["browser_download_url"];
|
||||
latestDownloadLink = _strdup(downloadUrl.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
InternetCloseHandle(hConnect);
|
||||
}
|
||||
else {
|
||||
std::cout << "[DevourClient]: URL opening error! Skipping update check..." << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
std::cout << "[DevourClient]: Unable to establish an internet connection! Skipping update check..." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
VersionControl::~VersionControl()
|
||||
{
|
||||
current_version_tag = nullptr;
|
||||
requestUrl = nullptr;
|
||||
}
|
||||
19
user/network/VersionControl.h
Normal file
19
user/network/VersionControl.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
class VersionControl {
|
||||
public:
|
||||
VersionControl(const char* version_tag, const wchar_t* url);
|
||||
~VersionControl();
|
||||
|
||||
const char* GetCurrentVersionTag();
|
||||
void CheckForUpdate();
|
||||
bool IsUpToDate();
|
||||
const char* GetLatestDownloadLink();
|
||||
private:
|
||||
const char* latestDownloadLink;
|
||||
bool isUpToDate;
|
||||
const char* current_version_tag;
|
||||
const wchar_t* requestUrl;
|
||||
private:
|
||||
void SetIsUpToDate(bool value);
|
||||
};
|
||||
Reference in New Issue
Block a user