Skip to content

Commit e27ffde

Browse files
Simplify fullscreen load; use ref cast in SaveSettings
1 parent 151e8d2 commit e27ffde

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

CGame.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,17 @@ void CGame::LoadSettings()
169169
return;
170170
GameResolution.x = ini->getValue("width", static_cast<int>(GameResolution.x));
171171
GameResolution.y = ini->getValue("height", static_cast<int>(GameResolution.y));
172-
fullscreen = ini->getValue("fullscreen", static_cast<int>(fullscreen)) != 0;
172+
fullscreen = ini->getValue("fullscreen", fullscreen);
173173
}
174174

175175
void CGame::SaveSettings() const
176176
{
177177
libsiedler2::Archiv settings;
178178
settings.push(std::make_unique<libsiedler2::ArchivItem_Ini>("editor"));
179-
auto* ini = dynamic_cast<libsiedler2::ArchivItem_Ini*>(settings.find("editor"));
180-
if(!ini)
181-
return;
182-
ini->setValue("width", GameResolution.x);
183-
ini->setValue("height", GameResolution.y);
184-
ini->setValue("fullscreen", static_cast<int>(fullscreen));
179+
auto& ini = dynamic_cast<libsiedler2::ArchivItem_Ini&>(*settings.find("editor"));
180+
ini.setValue("width", GameResolution.x);
181+
ini.setValue("height", GameResolution.y);
182+
ini.setValue("fullscreen", static_cast<int>(fullscreen));
185183
const bfs::path settingsPath = RTTRCONFIG.ExpandPath("<RTTR_USERDATA>/s25edit.ini");
186184
libsiedler2::Write(settingsPath, settings);
187185
}

0 commit comments

Comments
 (0)