fix: tidy gamepad/overlay/jfile (statics sense sufix, locals UPPER_CASE)

This commit is contained in:
2026-05-16 14:37:56 +02:00
parent 7789c1c217
commit 1e00f5c3a4
3 changed files with 191 additions and 191 deletions
+26 -26
View File
@@ -15,36 +15,36 @@
namespace {
struct keyvalue {
struct Keyvalue {
std::string key;
std::string value;
};
std::vector<keyvalue> config;
std::vector<Keyvalue> config;
std::string resource_folder;
std::string config_folder;
void load_config_values() {
void loadConfigValues() {
config.clear();
const std::string config_file = config_folder + "/config.txt";
std::ifstream fi(config_file);
const std::string CONFIG_FILE = config_folder + "/config.txt";
std::ifstream fi(CONFIG_FILE);
if (!fi.is_open()) {
return;
}
std::string line;
while (std::getline(fi, line)) {
const auto eq = line.find('=');
if (eq == std::string::npos) {
const auto EQ = line.find('=');
if (EQ == std::string::npos) {
continue;
}
config.push_back({line.substr(0, eq), line.substr(eq + 1)});
config.push_back({line.substr(0, EQ), line.substr(EQ + 1)});
}
}
void save_config_values() {
const std::string config_file = config_folder + "/config.txt";
std::ofstream fo(config_file);
void saveConfigValues() {
const std::string CONFIG_FILE = config_folder + "/config.txt";
std::ofstream fo(CONFIG_FILE);
if (!fo.is_open()) {
return;
}
@@ -103,34 +103,34 @@ void file_setconfigfolder(const char* foldername) {
}
auto file_getconfigfolder() -> const char* {
thread_local std::string folder;
folder = config_folder + "/";
return folder.c_str();
thread_local std::string folder_;
folder_ = config_folder + "/";
return folder_.c_str();
}
auto file_getconfigvalue(const char* key) -> const char* {
if (config.empty()) {
load_config_values();
loadConfigValues();
}
const auto it = std::find_if(config.begin(), config.end(), [key](const keyvalue& pair) { return pair.key == key; });
if (it != config.end()) {
thread_local std::string value_cache;
value_cache = it->value;
return value_cache.c_str();
const auto IT = std::find_if(config.begin(), config.end(), [key](const Keyvalue& pair) { return pair.key == key; });
if (IT != config.end()) {
thread_local std::string value_cache_;
value_cache_ = IT->value;
return value_cache_.c_str();
}
return nullptr;
}
void file_setconfigvalue(const char* key, const char* value) {
if (config.empty()) {
load_config_values();
loadConfigValues();
}
const auto it = std::find_if(config.begin(), config.end(), [key](const keyvalue& pair) { return pair.key == key; });
if (it != config.end()) {
it->value = value;
save_config_values();
const auto IT = std::find_if(config.begin(), config.end(), [key](const Keyvalue& pair) { return pair.key == key; });
if (IT != config.end()) {
IT->value = value;
saveConfigValues();
return;
}
config.push_back({std::string(key), std::string(value)});
save_config_values();
saveConfigValues();
}