Improve type safety in GetValueOrDefault

This commit is contained in:
2025-02-07 22:27:57 +01:00
parent 1fd3f05ebd
commit ceb392a198
3 changed files with 6 additions and 3 deletions

View File

@@ -272,7 +272,10 @@ namespace minipp
ValueDataType* value = nullptr;
if (GetValue(key, &value) != EResult::Success)
return defaultValue;
return value->GetValue();
auto casted = dynamic_cast<ValueDataType*>(value);
if (casted == nullptr)
return defaultValue;
return casted->GetValue();
}
public:

View File

@@ -1,6 +1,6 @@
[game]
name = "Test Game\nNext Line"
ver sion = "1.0.0"
version = "1.0.0"
year = 2025
completionPercentage = 50.0f
# Should only be true if completionPercentage is 100