forked from Snoogens101/ApexDMA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfig.hpp
95 lines (87 loc) · 3.04 KB
/
Config.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Config.hpp
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include "Aimbot.hpp"
#include "Camera.hpp"
class Config {
public:
Config(const std::string& filePath, Aimbot* aimAssistance, Camera* gameCamera)
: configFilePath(filePath), AimAssistance(aimAssistance), GameCamera(gameCamera) {}
void Update() {
std::ifstream configFile(configFilePath);
std::string line;
if (!configFile.is_open()) {
std::cerr << "Failed to open config file: " << configFilePath << std::endl;
return;
}
while (getline(configFile, line)) {
std::istringstream lineStream(line);
std::string key, value;
if (getline(lineStream, key, '=') && getline(lineStream, value)) {
updateVariable(key, value);
}
}
}
void UpdateOnDemand() {
while (true) {
if (!mem.GetKeyboard()->IsKeyDown(0x2D)) {
Sleep(1000);
continue;
}
std::cout << "Updating config..." << std::endl;
Update();
std::cout << "Config updated." << std::endl;
Sleep(1000);
}
}
private:
std::string configFilePath;
Aimbot* AimAssistance;
Camera* GameCamera;
void updateVariable(const std::string& key, const std::string& value) {
if (key == "AimFOV") {
AimAssistance->FOV = std::stof(value);
}
if (key == "AimSmooth") {
AimAssistance->Smooth = std::stof(value);
}
if (key == "AimSmoothMaxIncrease") {
AimAssistance->MaxSmoothIncrease = std::stof(value);
}
if (key == "ResolutionX") {
GameCamera->ScreenSize.x = std::stoi(value);
}
if (key == "ResolutionY") {
GameCamera->ScreenSize.y = std::stoi(value);
}
if (key == "FOV") {
GameCamera->FOV = std::stof(value);
}
if (key == "KmboxType") {
AimAssistance->KmboxType = value;
}
if (key == "KmboxIP") {
// Ensure we don't exceed the buffer size, including space for the null terminator
std::strncpy(AimAssistance->KmboxIP, value.c_str(), sizeof(AimAssistance->KmboxIP) - 1);
// Ensure null termination
AimAssistance->KmboxIP[sizeof(AimAssistance->KmboxIP) - 1] = '\0';
}
if (key == "KmboxPort") {
// Ensure we don't exceed the buffer size, including space for the null terminator
std::strncpy(AimAssistance->KmboxPort, value.c_str(), sizeof(AimAssistance->KmboxPort) - 1);
// Ensure null termination
AimAssistance->KmboxPort[sizeof(AimAssistance->KmboxPort) - 1] = '\0';
}
if (key == "KmboxUUID") {
// Ensure we don't exceed the buffer size, including space for the null terminator
std::strncpy(AimAssistance->KmboxUUID, value.c_str(), sizeof(AimAssistance->KmboxUUID) - 1);
// Ensure null termination
AimAssistance->KmboxUUID[sizeof(AimAssistance->KmboxUUID) - 1] = '\0';
}
if (key == "KmboxComPort") {
AimAssistance->KmboxComPort = std::stoi(value);
}
}
};