Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
207 changes: 115 additions & 92 deletions memory-external/classes/config.cpp
Original file line number Diff line number Diff line change
@@ -1,97 +1,113 @@
#include "config.hpp"

namespace config {
bool read() {
if (!updater::file_good(file_path)) {
save();
return false;
}

std::ifstream f(file_path);

json data;
try {
data = json::parse(f);
}
catch (const std::exception& e) {
save();
}

if (data.empty())
return false;

if (data["show_box_esp"].is_boolean())
show_box_esp = data["show_box_esp"];
if (data["show_skeleton_esp"].is_boolean())
show_skeleton_esp = data["show_skeleton_esp"];
if (data["show_head_tracker"].is_boolean())
show_head_tracker = data["show_head_tracker"];
if (data["team_esp"].is_boolean())
team_esp = data["team_esp"];
if (data["automatic_update"].is_boolean())
automatic_update = data["automatic_update"];
if (data["render_distance"].is_number())
render_distance = data["render_distance"];
if (data["flag_render_distance"].is_number())
flag_render_distance = data["flag_render_distance"];
if (data["show_extra_flags"].is_boolean())
show_extra_flags = data["show_extra_flags"];

if (data.find("esp_box_color_team") != data.end()) {
esp_box_color_team = {
data["esp_box_color_team"][0].get<int>(),
data["esp_box_color_team"][1].get<int>(),
data["esp_box_color_team"][2].get<int>()
};
}

if (data.find("esp_box_color_enemy") != data.end()) {
esp_box_color_enemy = {
data["esp_box_color_enemy"][0].get<int>(),
data["esp_box_color_enemy"][1].get<int>(),
data["esp_box_color_enemy"][2].get<int>()
};
}

if (data.find("esp_skeleton_color_team") != data.end()) {
esp_box_color_team = {
data["esp_skeleton_color_team"][0].get<int>(),
data["esp_skeleton_color_team"][1].get<int>(),
data["esp_skeleton_color_team"][2].get<int>()
};
}

if (data.find("esp_skeleton_color_enemy") != data.end()) {
esp_box_color_enemy = {
data["esp_skeleton_color_enemy"][0].get<int>(),
data["esp_skeleton_color_enemy"][1].get<int>(),
data["esp_skeleton_color_enemy"][2].get<int>()
};
}

if (data.find("esp_name_color") != data.end()) {
esp_name_color = {
data["esp_name_color"][0].get<int>(),
data["esp_name_color"][1].get<int>(),
data["esp_name_color"][2].get<int>()
};
}

if (data.find("esp_distance_color") != data.end()) {
esp_distance_color = {
data["esp_distance_color"][0].get<int>(),
data["esp_distance_color"][1].get<int>(),
data["esp_distance_color"][2].get<int>()
};
}

//if (data["rainbow"].is_boolean())
// rainbow = data["rainbow"];
//if (data["rainbow_speed"].is_number())
// rainbow_speed = data["rainbow_speed"];

return true;
}
bool read() {
if (!updater::file_good(file_path)) {
save();
return false;
}

std::ifstream f(file_path);
if (!f.is_open() || f.fail()) {
std::cerr << "[config] Failed to open config file for reading: " << file_path << std::endl;
return false;
}

json data;
try {
data = json::parse(f);
}
catch (const std::exception& e) {
std::cerr << "[config] JSON parse error: " << e.what() << " � saving defaults and aborting read." << std::endl;
save();
return false; // stop here, don't continue with empty data
}

if (data.empty())
return false;

if (data.contains("show_box_esp") && data["show_box_esp"].is_boolean())
show_box_esp = data["show_box_esp"];
if (data.contains("show_skeleton_esp") && data["show_skeleton_esp"].is_boolean())
show_skeleton_esp = data["show_skeleton_esp"];
if (data.contains("show_head_tracker") && data["show_head_tracker"].is_boolean())
show_head_tracker = data["show_head_tracker"];
if (data.contains("team_esp") && data["team_esp"].is_boolean())
team_esp = data["team_esp"];
if (data.contains("automatic_update") && data["automatic_update"].is_boolean())
automatic_update = data["automatic_update"];
if (data.contains("render_distance") && data["render_distance"].is_number())
render_distance = data["render_distance"];
if (data.contains("flag_render_distance") && data["flag_render_distance"].is_number())
flag_render_distance = data["flag_render_distance"];
if (data.contains("show_health_bars") && data["show_health_bars"].is_boolean())
show_health_bars = data["show_health_bars"]; // fixed: previously used wrong var
if (data.contains("show_health_flags") && data["show_health_flags"].is_boolean())
show_health_flags = data["show_health_flags"];
if (data.contains("show_money_flag") && data["show_money_flag"].is_boolean())
show_money_flag = data["show_money_flag"];
if (data.contains("show_distance_flag") && data["show_distance_flag"].is_boolean())
show_distance_flag = data["show_distance_flag"];
if (data.contains("show_name_flag") && data["show_name_flag"].is_boolean())
show_name_flag = data["show_name_flag"];
if (data.contains("show_weapon_flag") && data["show_weapon_flag"].is_boolean())
show_weapon_flag = data["show_weapon_flag"];
if (data.contains("show_defusing_flag") && data["show_defusing_flag"].is_boolean())
show_defusing_flag = data["show_defusing_flag"];
if (data.contains("show_flashed_flag") && data["show_flashed_flag"].is_boolean())
show_flashed_flag = data["show_flashed_flag"];

if (data.find("esp_box_color_team") != data.end() && data["esp_box_color_team"].is_array()) {
esp_box_color_team = {
data["esp_box_color_team"][0].get<int>(),
data["esp_box_color_team"][1].get<int>(),
data["esp_box_color_team"][2].get<int>()
};
}

if (data.find("esp_box_color_enemy") != data.end() && data["esp_box_color_enemy"].is_array()) {
esp_box_color_enemy = {
data["esp_box_color_enemy"][0].get<int>(),
data["esp_box_color_enemy"][1].get<int>(),
data["esp_box_color_enemy"][2].get<int>()
};
}

// Fixed: assign to skeleton colors, not box colors
if (data.find("esp_skeleton_color_team") != data.end() && data["esp_skeleton_color_team"].is_array()) {
esp_skeleton_color_team = {
data["esp_skeleton_color_team"][0].get<int>(),
data["esp_skeleton_color_team"][1].get<int>(),
data["esp_skeleton_color_team"][2].get<int>()
};
}

if (data.find("esp_skeleton_color_enemy") != data.end() && data["esp_skeleton_color_enemy"].is_array()) {
esp_skeleton_color_enemy = {
data["esp_skeleton_color_enemy"][0].get<int>(),
data["esp_skeleton_color_enemy"][1].get<int>(),
data["esp_skeleton_color_enemy"][2].get<int>()
};
}

if (data.find("esp_name_color") != data.end() && data["esp_name_color"].is_array()) {
esp_name_color = {
data["esp_name_color"][0].get<int>(),
data["esp_name_color"][1].get<int>(),
data["esp_name_color"][2].get<int>()
};
}

if (data.find("esp_distance_color") != data.end() && data["esp_distance_color"].is_array()) {
esp_distance_color = {
data["esp_distance_color"][0].get<int>(),
data["esp_distance_color"][1].get<int>(),
data["esp_distance_color"][2].get<int>()
};
}

return true;
}

void save() {
json data;
Expand All @@ -103,7 +119,14 @@ namespace config {
data["automatic_update"] = automatic_update;
data["render_distance"] = render_distance;
data["flag_render_distance"] = flag_render_distance;
data["show_extra_flags"] = show_extra_flags;
data["show_health_bars"] = show_health_bars;
data["show_health_flags"] = show_health_flags;
data["show_money_flag"] = show_money_flag;
data["show_distance_flag"] = show_distance_flag;
data["show_name_flag"] = show_name_flag;
data["show_weapon_flag"] = show_weapon_flag;
data["show_defusing_flag"] = show_defusing_flag;
data["show_flashed_flag"] = show_flashed_flag;

data["esp_box_color_team"] = { esp_box_color_team.r, esp_box_color_team.g, esp_box_color_team.b };
data["esp_box_color_enemy"] = { esp_box_color_enemy.r, esp_box_color_enemy.g, esp_box_color_enemy.b };
Expand Down
11 changes: 10 additions & 1 deletion memory-external/classes/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,23 @@ namespace config {
extern bool read();
extern void save();

inline bool panic = false;

inline bool automatic_update = false;
inline bool team_esp = false;
inline float render_distance = -1.f;
inline int flag_render_distance = 200;
inline bool show_box_esp = true;
inline bool show_skeleton_esp = false;
inline bool show_head_tracker = false;
inline bool show_extra_flags = false;
inline bool show_health_bars = true;
inline bool show_health_flags = true;
inline bool show_money_flag = false;
inline bool show_distance_flag = false;
inline bool show_name_flag = true;
inline bool show_weapon_flag = false;
inline bool show_defusing_flag = false;
inline bool show_flashed_flag = false;

inline RGB esp_box_color_team = { 75, 175, 75 };
inline RGB esp_box_color_enemy = { 225, 75, 75 };
Expand Down
Loading