Skip to content

Commit

Permalink
💥 Load settings from filesystem
Browse files Browse the repository at this point in the history
  • Loading branch information
47PADO47 committed Feb 9, 2024
1 parent 2e94c93 commit 44f022b
Show file tree
Hide file tree
Showing 10 changed files with 175 additions and 46 deletions.
3 changes: 2 additions & 1 deletion Internal/Internal.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,18 @@
<ClInclude Include="cheat\Hook.h" />
<ClInclude Include="cheat\Features.h" />
<ClInclude Include="discord\DiscordRPC.h" />
<ClInclude Include="settings\Settings.h" />
<ClInclude Include="utils\Logger.h" />
<ClInclude Include="cheat\UnrealEngine\UObjects.h" />
<ClInclude Include="utils\Util.h" />
<ClInclude Include="menu\Menu.h" />
<ClInclude Include="menu\Settings.h" />
<ClInclude Include="gui\ZeroGUI.h" />
<ClInclude Include="gui\ZeroInput.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="cheat\UnrealEngine\Engine.cpp" />
<ClCompile Include="settings\Settings.cpp" />
<ClCompile Include="utils\Util.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Expand Down
9 changes: 6 additions & 3 deletions Internal/Internal.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
<ClInclude Include="utils\Util.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="menu\Settings.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="gui\ZeroGUI.h">
<Filter>File di intestazione</Filter>
</ClInclude>
Expand All @@ -48,6 +45,9 @@
<ClInclude Include="discord\DiscordRPC.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="settings\Settings.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
Expand All @@ -59,5 +59,8 @@
<ClCompile Include="utils\Util.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="settings\Settings.cpp">
<Filter>File di origine</Filter>
</ClCompile>
</ItemGroup>
</Project>
21 changes: 12 additions & 9 deletions Internal/cheat/Features.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include "UnrealEngine/Engine.h"
#include "../menu/Settings.h"
#include "../settings/Settings.h"
#include "../utils/Logger.h"
#include "../discord/DiscordRPC.h"

Expand All @@ -13,15 +13,18 @@ class Features {

void handle(APlayerController* PlayerController) {
do {
//if (Settings::DestroyConsole) logger->DestroyConsole();
//if (Settings.MISC.DestroyConsole) logger->DestroyConsole();

PlayerController->SetName(L"SplitgateDevelopement");
PlayerController->FOV(Settings::FOV);
std::string name = Settings.MISC.PlayerName;
LPCWSTR playerName = std::wstring(name.begin(), name.end()).c_str();

if (Settings::LoadIntoMap) {
PlayerController->SetName(playerName);
PlayerController->FOV(Settings.EXPLOITS.FOV);

if (Settings.MISC.LoadIntoMap) {
logger->log("INFO", "Loading into map");
PlayerController->SwitchLevel(L"Simulation_Alpha");
Settings::LoadIntoMap = false;
Settings.MISC.LoadIntoMap = false;
};

if (!isIngame(PlayerController)) {
Expand All @@ -34,21 +37,21 @@ class Features {
USkeletalMeshComponent* Mesh = Player->Mesh;

collision = false;
if (GetAsyncKeyState(Settings::NoClip)) collision = !collision;
if (GetAsyncKeyState(Settings.EXPLOITS.NoClip)) collision = !collision;

if (collision && Player->GetActorEnableCollision()) Player->SetActorEnableCollision(false);
else if (!collision && !Player->GetActorEnableCollision()) Player->SetActorEnableCollision(true);


if (Settings::GodMode && Player->Health != 0) {
if (Settings.EXPLOITS.GodMode && Player->Health != 0) {
float health = 999999;
if (Player->MaxHealth != health) Player->MaxHealth = health;
if (Player->Health != health) Player->Health = health;

//Instigator->healthRechargeDelay = 0.1f;
};

if (Settings::SpinBot && Mesh) {
if (Settings.EXPLOITS.SpinBot && Mesh) {
if (spin_yaw > 360.f) spin_yaw = 0.f;

Mesh->K2_SetRelativeRotation(FRotator(0.f, spin_yaw, 0.f), true, false);
Expand Down
6 changes: 4 additions & 2 deletions Internal/cheat/Hook.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ class Hook {
PostRenderVTable = ViewPortClientVTable;
ProcessEventVTable = World->VFTable;

if (SettingsHelper::Init()) logger->log("SUCCESS", std::string("Loaded settings from ").append(SettingsHelper::GetPath()));

UPortalWarsSaveGame* UserSave = ((UPortalWarsLocalPlayer*)LocalPlayer)->GetUserSaveGame();
if (UserSave) {
logger->log("SUCCESS", "Got user save game");
Settings::FOV = UserSave->FOV;
Settings.EXPLOITS.FOV = UserSave->FOV;
};

logger->log("INFO", format("Found [{:d}] Objects", ObjObjects->NumElements));;
logger->log("INFO", format("Found [{:d}] Objects", ObjObjects->NumElements));

return TRUE;
}
Expand Down
4 changes: 2 additions & 2 deletions Internal/discord/DiscordRPC.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ class DiscordRPC {

memset(&discordPresence, 0, sizeof(discordPresence));
discordPresence.state = "Injected";
discordPresence.details = Settings::Watermark;
discordPresence.details = Settings.MENU.Watermark.data();
discordPresence.startTimestamp = StartTime;
discordPresence.endTimestamp = NULL;
discordPresence.largeImageKey = "icon";
discordPresence.largeImageText = Settings::Watermark;
discordPresence.largeImageText = Settings.MENU.Watermark.data();
discordPresence.instance = 1;
discordPresence.partySize = 1;
discordPresence.partyMax = 1;
Expand Down
3 changes: 1 addition & 2 deletions Internal/dllmain.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// dllmain.cpp : Definisce il punto di ingresso per l'applicazione DLL.
#include <Windows.h>
#include <iostream>
#include <format>
Expand All @@ -12,7 +11,7 @@ Menu* menu = new Menu();
void PostRender(UGameViewportClient* UGameViewportClient, Canvas* canvas)
{
do {
if (Settings::Unload) return hook->UnHook();
if (Settings.MISC.Unload) return hook->UnHook();

ZeroGUI::SetupCanvas(canvas);
menu->Tick();
Expand Down
40 changes: 27 additions & 13 deletions Internal/menu/Menu.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "../gui/ZeroGUI.h"
#include "Settings.h"
#include "../settings/Settings.h"

class Menu {
private:
Expand All @@ -11,9 +11,9 @@ class Menu {
{
ZeroGUI::Input::Handle();

if (GetAsyncKeyState(VK_INSERT) & 1) Settings::ShowMenu = !Settings::ShowMenu;
if (GetAsyncKeyState(VK_INSERT) & 1) Settings.MENU.ShowMenu = !Settings.MENU.ShowMenu;

if (ZeroGUI::Window("Splitgate Internal", &pos, FVector2D{ 500.0f, 400.0f }, Settings::ShowMenu))
if (ZeroGUI::Window("Splitgate Internal", &pos, FVector2D{ 500.0f, 400.0f }, Settings.MENU.ShowMenu))
{
static int tab = 0;
if (ZeroGUI::ButtonTab("Misc", FVector2D{ 110, 25 }, tab == 0)) tab = 0;
Expand All @@ -22,30 +22,44 @@ class Menu {

if (tab == 0)
{
ZeroGUI::SliderFloat("Player FOV", &Settings::FOV, 80.0f, 160.0f);
ZeroGUI::Checkbox("God Mode", &Settings::GodMode);
ZeroGUI::Checkbox("Spin Bot", &Settings::SpinBot);
ZeroGUI::SliderFloat("Player FOV", &Settings.EXPLOITS.FOV, 80.0f, 160.0f);
ZeroGUI::Checkbox("God Mode", &Settings.EXPLOITS.GodMode);
ZeroGUI::Checkbox("Spin Bot", &Settings.EXPLOITS.SpinBot);

ZeroGUI::Text("No Clip", false, true);
ZeroGUI::SameLine();
ZeroGUI::Hotkey("No Clip", FVector2D{ 110, 25 }, &Settings::NoClip);
if (ZeroGUI::Button("Load in map", FVector2D{ 110, 25 })) Settings::LoadIntoMap = true;
ZeroGUI::Hotkey("No Clip", FVector2D{ 110, 25 }, &Settings.EXPLOITS.NoClip);
if (ZeroGUI::Button("Load in map", FVector2D{ 110, 25 })) Settings.MISC.LoadIntoMap = true;
}
else if (tab == 1)
{
ZeroGUI::Checkbox("Watermark", &Settings::ShowWatermark);
//if (ZeroGUI::Button("Destroy Console", FVector2D{ 110, 25 })) Settings::DestroyConsole = true;
//ZeroGUI::Checkbox("Watermark", &Settings.MENU.ShowWatermark);

if (ZeroGUI::Button("Save", FVector2D{ 110, 25 })) {
SettingsHelper::Save();
};

ZeroGUI::SameLine();

if (ZeroGUI::Button("Reset", FVector2D{ 110, 25 })) {
SettingsHelper::Reset();
};

//if (ZeroGUI::Button("Destroy Console", FVector2D{ 110, 25 })) Settings.MISC.DestroyConsole = true;
//ZeroGUI::SameLine();
//if (ZeroGUI::Button("Unload", FVector2D{ 110, 25 })) Settings::Unload = true;
//if (ZeroGUI::Button("Unload", FVector2D{ 110, 25 })) Settings.MISC.Unload = true;
};
}
ZeroGUI::Render();
};

void DrawWatermark(Canvas* canvas) {
if (!Settings::ShowWatermark) return;
if (!Settings.MENU.ShowWatermark) return;

std::string str = Settings.MENU.Watermark;
LPCWSTR watermark = std::wstring(str.begin(), str.end()).c_str();

canvas->K2_DrawText(L"github.com/SplitgateDevelopment", { 15.f, 15.f }, { 1.f, 1.f }, ZeroGUI::Colors::Window_Header, 1.f, { 0.f, 0.f, 0.f, 0.f }, { 0.f, 0.f }, false, false, true, ZeroGUI::Colors::Window_Header);
canvas->K2_DrawText(watermark, {15.f, 15.f}, {1.f, 1.f}, ZeroGUI::Colors::Window_Header, 1.f, {0.f, 0.f, 0.f, 0.f}, {0.f, 0.f}, false, false, true, ZeroGUI::Colors::Window_Header);
return;
};;
};
14 changes: 0 additions & 14 deletions Internal/menu/Settings.h

This file was deleted.

89 changes: 89 additions & 0 deletions Internal/settings/Settings.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#include <Windows.h>
#include <iostream>
#include <string>
#include "Settings.h"
#include <errno.h>
#include <stdio.h>

SETTINGS Settings = { 0 };

namespace SettingsHelper {

std::string GetPath() {
std::string filename = "splitgate.settings";
/*
WCHAR szPath[MAX_PATH];
GetModuleFileName(NULL, szPath, MAX_PATH);
std::wstring ws(szPath);
std::string path(ws.begin(), ws.end());
path += filename;
*/

CHAR path[0xFF] = { 0 };
GetTempPathA(sizeof(path) / sizeof(path[0]), path);

return std::string(path).append(filename);
}

VOID Save() {
std::string path = GetPath();
FILE* file;
errno_t error = fopen_s(&file, path.data(), "wb");

if (error == 0) {
fwrite(&Settings, sizeof(Settings), 1, file);
fclose(file);
//free(path.data());
}
}

bool Init() {
std::string path = GetPath();
FILE* file;
errno_t error = fopen_s(&file, path.data(), "wb");

if (error == 0) {
fseek(file, 0, SEEK_END);
auto size = ftell(file);

if (size == sizeof(Settings)) {
fseek(file, 0, SEEK_SET);
fread(&Settings, sizeof(Settings), 1, file);
fclose(file);

//free(path.data());

printf("abc");
return true;
}

fclose(file);
}

//free(path.data());
Reset();
return false;
}

VOID Reset() {
Settings = { 0 };

Settings.MENU.ShowMenu = true;
Settings.MENU.ShowWatermark = true;
Settings.MENU.Watermark = "github.com/SplitgateDevelopment/Launcher";

Settings.EXPLOITS.FOV = 80;
Settings.EXPLOITS.GodMode = false;
Settings.EXPLOITS.SpinBot = false;
Settings.EXPLOITS.NoClip = VK_OEM_PLUS;

Settings.MISC.LoadIntoMap = false;
Settings.MISC.Unload = false;
Settings.MISC.DestroyConsole = false;
Settings.MISC.PlayerName = "SplitgateDevelopement";

Save();
}
}
32 changes: 32 additions & 0 deletions Internal/settings/Settings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

typedef struct {
struct {
bool ShowMenu;
bool ShowWatermark;
std::string Watermark;
} MENU;

struct {
float FOV;
bool GodMode;
bool SpinBot;
int NoClip;
} EXPLOITS;

struct {
bool LoadIntoMap;
float Unload;
bool DestroyConsole;
std::string PlayerName;
} MISC;
} SETTINGS;

extern SETTINGS Settings;

namespace SettingsHelper {
std::string GetPath();
bool Init();
VOID Save();
VOID Reset();
}

0 comments on commit 44f022b

Please sign in to comment.