mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-27 01:45:35 -05:00
force ModImpl::m_saved to an object when loading saved.json
This commit is contained in:
parent
eb7576e6ea
commit
28b26220c8
1 changed files with 4 additions and 4 deletions
|
@ -124,8 +124,6 @@ Result<> Mod::Impl::loadData() {
|
||||||
if (ghc::filesystem::exists(settingPath)) {
|
if (ghc::filesystem::exists(settingPath)) {
|
||||||
GEODE_UNWRAP_INTO(auto settingData, utils::file::readString(settingPath));
|
GEODE_UNWRAP_INTO(auto settingData, utils::file::readString(settingPath));
|
||||||
try {
|
try {
|
||||||
std::string err;
|
|
||||||
|
|
||||||
// parse settings.json
|
// parse settings.json
|
||||||
auto json = json::parse(settingData);
|
auto json = json::parse(settingData);
|
||||||
|
|
||||||
|
@ -169,13 +167,15 @@ Result<> Mod::Impl::loadData() {
|
||||||
if (ghc::filesystem::exists(savedPath)) {
|
if (ghc::filesystem::exists(savedPath)) {
|
||||||
GEODE_UNWRAP_INTO(auto data, utils::file::readString(savedPath));
|
GEODE_UNWRAP_INTO(auto data, utils::file::readString(savedPath));
|
||||||
|
|
||||||
std::string err;
|
|
||||||
try {
|
try {
|
||||||
m_saved = json::parse(data);
|
m_saved = json::parse(data);
|
||||||
} catch (std::exception& err) {
|
} catch (std::exception& err) {
|
||||||
return Err(std::string("Unable to parse saved values: ") + err.what());
|
return Err(std::string("Unable to parse saved values: ") + err.what());
|
||||||
}
|
}
|
||||||
|
if (!m_saved.is_object()) {
|
||||||
|
log::warn("saved.json was somehow not an object, forcing it to one");
|
||||||
|
m_saved = json::Object();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
|
|
Loading…
Reference in a new issue