forked from duckman6969/fix-skill-issue
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigLoader.cpp
More file actions
200 lines (175 loc) · 5.86 KB
/
ConfigLoader.cpp
File metadata and controls
200 lines (175 loc) · 5.86 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#pragma once
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
#include <sys/stat.h>
#include "Utils.cpp"
class ConfigLoader
{
private:
const std::string m_fileName = "config.ini";
std::vector<std::string> *lines = new std::vector<std::string>;
long m_lastTimeFileEdited = 0;
// internal
// 0: BR, 1: CONTROL/FREEDM
int m_gameMode = 0;
// features
bool m_featureAimbotOn = false;
bool m_featureNoRecoilOn = false;
bool m_featureSenseOn = false;
// sense
int m_senseMaxRange = 0;
int m_senseMaxRangeOverWall = 0;
// aimbot
int m_aimbotTrigger = 0x0000;
int m_aimbotSmoothing = 999999;
int m_aimbotActivationFOV = 0;
int m_aimbotMaxRange = 0;
// norecoil
double m_norecoilPitchStrength = 0;
double m_norecoilYawStrength = 0;
bool loadFileIntoVector()
{
struct stat result;
if (stat(m_fileName.c_str(), &result) == 0)
{
long modTime = result.st_mtime;
bool fileNeedsReload = modTime > m_lastTimeFileEdited;
m_lastTimeFileEdited = modTime;
if (!fileNeedsReload)
return false;
}
lines->clear();
std::string str;
std::ifstream myFile(m_fileName);
while (getline(myFile, str))
{
utils::trim(str);
if (str.empty())
continue;
if (str.rfind("#", 0) == 0)
continue;
lines->push_back(str);
}
myFile.close();
return true;
}
void parseLines()
{
for (std::size_t i = 0; i < lines->size(); i++)
{
std::vector<std::string> lineParts = utils::split(lines->at(i));
// line key
std::string lineKey(lineParts.at(0));
utils::trim(lineKey);
if (lineKey.empty())
throw "Failed to parse the config";
// line value
std::string lineValue(lineParts.at(1));
utils::trim(lineValue);
if (lineValue.empty())
throw "Failed to parse the config";
// features
m_featureAimbotOn = (lineKey.compare("FEATURE_AIMBOT_ON") != 0) ? m_featureAimbotOn : utils::toBool(lineValue);
m_featureNoRecoilOn = (lineKey.compare("FEATURE_NORECOIL_ON") != 0) ? m_featureNoRecoilOn : utils::toBool(lineValue);
m_featureSenseOn = (lineKey.compare("FEATURE_SENSE_ON") != 0) ? m_featureSenseOn : utils::toBool(lineValue);
m_gameMode = (lineKey.compare("FEATURE_GAME_MODE") != 0) ? m_gameMode : stoi(lineValue);
// sense
m_senseMaxRange = (lineKey.compare("SENSE_MAX_RANGE") != 0) ? m_senseMaxRange : stoi(lineValue);
m_senseMaxRangeOverWall = (lineKey.compare("SENSE_MAX_RANGE_OVER_WALL") != 0) ? m_senseMaxRangeOverWall : stoi(lineValue);
// aimbot
m_aimbotTrigger = (lineKey.compare("AIMBOT_TRIGGER") != 0) ? m_aimbotTrigger : stoi(lineValue, 0, 16);
m_aimbotSmoothing = (lineKey.compare("AIMBOT_SMOOTHING") != 0) ? m_aimbotSmoothing : stoi(lineValue);
m_aimbotActivationFOV = (lineKey.compare("AIMBOT_ACTIVATION_FOV") != 0) ? m_aimbotActivationFOV : stoi(lineValue);
m_aimbotMaxRange = (lineKey.compare("AIMBOT_MAX_RANGE") != 0) ? m_aimbotMaxRange : stoi(lineValue);
// norecoil
m_norecoilPitchStrength = (lineKey.compare("NORECOIL_PITCH_STRENGTH") != 0) ? m_norecoilPitchStrength : stod(lineValue);
m_norecoilYawStrength = (lineKey.compare("NORECOIL_YAW_STRENGTH") != 0) ? m_norecoilYawStrength : stod(lineValue);
}
}
public:
ConfigLoader()
{
reloadFile();
}
void reloadFile()
{
if (loadFileIntoVector())
parseLines();
}
// internal
void setGameMode(int gameMode)
{
m_gameMode = gameMode;
}
int getGameMode()
{
return m_gameMode;
}
// features
bool isAimbotOn()
{
return m_featureAimbotOn;
}
bool isNorecoilOn()
{
return m_featureNoRecoilOn;
}
bool isSenseOn()
{
return m_featureSenseOn;
}
// sense
int getSenseMaxRange()
{
return m_senseMaxRange;
}
int getSenseMaxRangeOverWall()
{
return m_senseMaxRangeOverWall;
}
// aimbot
int getAimbotTrigger()
{
return m_aimbotTrigger;
}
int getAimbotSmoothing()
{
return m_aimbotSmoothing;
}
int getAimbotActivationFOV()
{
return m_aimbotActivationFOV;
}
int getAimbotMaxRange()
{
return m_aimbotMaxRange;
}
// norecoil
double getNorecoilPitchStrength()
{
return m_norecoilPitchStrength;
}
double getNorecoilYawStrength()
{
return m_norecoilYawStrength;
}
void print()
{
printf("\n======================== SETTINGS LOADED ========================\n");
printf("GAME_MODE \t\t\t%d\n", m_gameMode);
printf("FEATURE_AIMBOT_ON \t\t%s\n", m_featureAimbotOn ? "true" : "false");
printf("FEATURE_NORECOIL_ON \t\t%s\n", m_featureNoRecoilOn ? "true" : "false");
printf("FEATURE_SENSE_ON \t\t%s\n", m_featureSenseOn ? "true" : "false");
printf("SENSE_MAX_RANGE \t\t%d\n", m_senseMaxRange);
printf("SENSE_MAX_RANGE_OVER_WALL \t\t%d\n", m_senseMaxRangeOverWall);
printf("AIMBOT_TRIGGER \t\t\t%d\n", m_aimbotTrigger);
printf("AIMBOT_SMOOTHING \t\t%d\n", m_aimbotSmoothing);
printf("AIMBOT_ACTIVATION_FOV \t\t%d\n", m_aimbotActivationFOV);
printf("AIMBOT_MAX_RANGE \t\t%d\n", m_aimbotMaxRange);
printf("NORECOIL_PITCH_STRENGTH \t%.6f\n", m_norecoilPitchStrength);
printf("NORECOIL_YAW_STRENGTH \t\t%.6f\n", m_norecoilYawStrength);
printf("=================================================================\n\n");
}
};