summaryrefslogtreecommitdiffstats
path: root/src/frontend_common/config.cpp
diff options
context:
space:
mode:
authort895 <clombardo169@gmail.com>2023-11-22 02:46:27 +0100
committert895 <clombardo169@gmail.com>2023-11-22 03:01:46 +0100
commitd8f380961e2c7165ba296c246e002d16598942d4 (patch)
treedc89bc0bdf1fd0b11c5b90f9f9033039210a8d1d /src/frontend_common/config.cpp
parentfrontend_common: Set config array size to 0 if the array is ended without changing its index (diff)
downloadyuzu-d8f380961e2c7165ba296c246e002d16598942d4.tar
yuzu-d8f380961e2c7165ba296c246e002d16598942d4.tar.gz
yuzu-d8f380961e2c7165ba296c246e002d16598942d4.tar.bz2
yuzu-d8f380961e2c7165ba296c246e002d16598942d4.tar.lz
yuzu-d8f380961e2c7165ba296c246e002d16598942d4.tar.xz
yuzu-d8f380961e2c7165ba296c246e002d16598942d4.tar.zst
yuzu-d8f380961e2c7165ba296c246e002d16598942d4.zip
Diffstat (limited to '')
-rw-r--r--src/frontend_common/config.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/frontend_common/config.cpp b/src/frontend_common/config.cpp
index 40a44ae12..a68a9cb4b 100644
--- a/src/frontend_common/config.cpp
+++ b/src/frontend_common/config.cpp
@@ -284,7 +284,7 @@ void Config::ReadDisabledAddOnValues() {
const int size = BeginArray(std::string(""));
for (int i = 0; i < size; ++i) {
SetArrayIndex(i);
- const auto title_id = ReadIntegerSetting(std::string("title_id"), 0);
+ const auto title_id = ReadUnsignedIntegerSetting(std::string("title_id"), 0);
std::vector<std::string> out;
const int d_size = BeginArray("disabled");
for (int j = 0; j < d_size; ++j) {
@@ -664,6 +664,33 @@ s64 Config::ReadIntegerSetting(const std::string& key, const std::optional<s64>
return result;
}
+u64 Config::ReadUnsignedIntegerSetting(const std::string& key,
+ const std::optional<u64> default_value) {
+ std::string full_key = GetFullKey(key, false);
+ if (!default_value.has_value()) {
+ try {
+ return std::stoull(
+ std::string(config->GetValue(GetSection().c_str(), full_key.c_str(), "0")));
+ } catch (...) {
+ return 0;
+ }
+ }
+
+ u64 result = 0;
+ if (config->GetBoolValue(GetSection().c_str(),
+ std::string(full_key).append("\\default").c_str(), true)) {
+ result = default_value.value();
+ } else {
+ try {
+ result = std::stoull(std::string(config->GetValue(
+ GetSection().c_str(), full_key.c_str(), ToString(default_value.value()).c_str())));
+ } catch (...) {
+ result = default_value.value();
+ }
+ }
+ return result;
+}
+
double Config::ReadDoubleSetting(const std::string& key,
const std::optional<double> default_value) {
std::string full_key = GetFullKey(key, false);