• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Return-To-The-Roots / s25client / 19047185932

03 Nov 2025 07:42PM UTC coverage: 50.469% (-0.005%) from 50.474%
19047185932

Pull #1817

github

web-flow
Merge 82ee3db19 into 7333cc249
Pull Request #1817: Proposal to turn off/on bird sounds

2 of 34 new or added lines in 4 files covered. (5.88%)

5 existing lines in 3 files now uncovered.

22510 of 44602 relevant lines covered (50.47%)

35645.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

22.06
/libs/s25main/Settings.cpp
1
// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org)
2
//
3
// SPDX-License-Identifier: GPL-2.0-or-later
4

5
#include "Settings.h"
6
#include "DrawPoint.h"
7
#include "RTTR_Version.h"
8
#include "RttrConfig.h"
9
#include "drivers/AudioDriverWrapper.h"
10
#include "drivers/VideoDriverWrapper.h"
11
#include "files.h"
12
#include "helpers/strUtils.h"
13
#include "languages.h"
14
#include "gameData/PortraitConsts.h"
15
#include "gameData/const_gui_ids.h"
16
#include "libsiedler2/ArchivItem_Ini.h"
17
#include "libsiedler2/ArchivItem_Text.h"
18
#include "libsiedler2/libsiedler2.h"
19
#include "s25util/StringConversion.h"
20
#include "s25util/System.h"
21
#include "s25util/error.h"
22
#include <boost/filesystem/operations.hpp>
23

24
const int Settings::VERSION = 13;
25
const std::array<std::string, 10> Settings::SECTION_NAMES = {
26
  {"global", "video", "language", "driver", "sound", "lobby", "server", "proxy", "interface", "addons"}};
27

28
const std::array<short, 13> Settings::SCREEN_REFRESH_RATES = {
29
  {-1, 25, 30, 50, 60, 75, 80, 100, 120, 150, 180, 200, 240}};
30

31
const std::map<GUI_ID, std::string> persistentWindows = {{CGI_CHAT, "wnd_chat"},
32
                                                         {CGI_POSTOFFICE, "wnd_postoffice"},
33
                                                         {CGI_DISTRIBUTION, "wnd_distribution"},
34
                                                         {CGI_BUILDORDER, "wnd_buildorder"},
35
                                                         {CGI_TRANSPORT, "wnd_transport"},
36
                                                         {CGI_MILITARY, "wnd_military"},
37
                                                         {CGI_TOOLS, "wnd_tools"},
38
                                                         {CGI_INVENTORY, "wnd_inventory"},
39
                                                         {CGI_MINIMAP, "wnd_minimap"},
40
                                                         {CGI_BUILDINGS, "wnd_buildings"},
41
                                                         {CGI_BUILDINGSPRODUCTIVITY, "wnd_buildingsproductivity"},
42
                                                         {CGI_MUSICPLAYER, "wnd_musicplayer"},
43
                                                         {CGI_STATISTICS, "wnd_statistics"},
44
                                                         {CGI_ECONOMICPROGRESS, "wnd_economicprogress"},
45
                                                         {CGI_DIPLOMACY, "wnd_diplomacy"},
46
                                                         {CGI_SHIP, "wnd_ship"},
47
                                                         {CGI_MERCHANDISE_STATISTICS, "wnd_merchandise_statistics"}};
48

49
namespace validate {
50
boost::optional<uint16_t> checkPort(const std::string& port)
9✔
51
{
52
    int32_t iPort;
53
    if((helpers::tryFromString(port, iPort) || s25util::tryFromStringClassic(port, iPort)) && checkPort(iPort))
9✔
54
        return static_cast<uint16_t>(iPort);
3✔
55
    else
56
        return boost::none;
6✔
57
}
58
bool checkPort(int port)
7✔
59
{
60
    // Disallow port 0 as it may cause problems
61
    return port > 0 && port <= 65535;
7✔
62
}
63
} // namespace validate
64

65
Settings::Settings() //-V730
5✔
66
{
67
    LoadDefaults();
5✔
68
}
5✔
69

70
void Settings::LoadDefaults()
5✔
71
{
72
    // global
73
    // {
74
    // 0 = ask user at start, 1 = enabled, 2 = always ask
75
    global.submit_debug_data = 0;
5✔
76
    global.use_upnp = false;
5✔
77
    global.smartCursor = true;
5✔
78
    global.debugMode = false;
5✔
79
    global.showGFInfo = false;
5✔
80
    // }
81

82
    // video
83
    // {
84
    if(VIDEODRIVER.IsLoaded())
5✔
85
    {
86
        video.fullscreenSize = VIDEODRIVER.GetWindowSize();
3✔
87
        video.windowedSize = VIDEODRIVER.IsFullscreen() ? VideoMode(800, 600) : video.fullscreenSize;
3✔
88
        video.fullscreen = VIDEODRIVER.IsFullscreen();
3✔
89
    } else
90
    {
91
        video.windowedSize = video.fullscreenSize = VideoMode(800, 600);
2✔
92
        video.fullscreen = false;
2✔
93
    }
94
    video.framerate = 0; // Special value for HW vsync
5✔
95
    video.vbo = true;
5✔
96
    video.shared_textures = true;
5✔
97
    video.guiScale = 0; // special value indicating automatic selection
5✔
98
    // }
99

100
    // language
101
    // {
102
    language.language.clear();
5✔
103
    // }
104

105
    LANGUAGES.setLanguage(language.language);
5✔
106

107
    // driver
108
    // {
109
    driver.audio = AUDIODRIVER.GetName();
5✔
110
    driver.video = VIDEODRIVER.GetName();
5✔
111
    // }
112

113
    // sound
114
    // {
115
    sound.musicEnabled = false;
5✔
116
    sound.musicVolume = 30;
5✔
117
    sound.effectsEnabled = true;
5✔
118
    sound.effectsVolume = 75;
5✔
119
    sound.birdsEnabled = true;
5✔
120
    sound.playlist = s25::files::defaultPlaylist;
5✔
121
    // }
122

123
    // lobby
124
    // {
125

126
    lobby.name = System::getUserName();
5✔
127
    lobby.portraitIndex = 0;
5✔
128
    lobby.password.clear();
5✔
129
    lobby.save_password = false;
5✔
130
    // }
131

132
    // server
133
    // {
134
    server.last_ip.clear();
5✔
135
    server.localPort = 3665;
5✔
136
    server.ipv6 = false;
5✔
137
    // }
138

139
    proxy = ProxySettings();
5✔
140
    proxy.port = 1080;
5✔
141

142
    // interface
143
    // {
144
    interface.autosave_interval = 0;
5✔
145
    interface.invertMouse = false;
5✔
146
    interface.enableWindowPinning = false;
5✔
147
    interface.windowSnapDistance = 8;
5✔
148
    // }
149

150
    // addons
151
    // {
152
    addons.configuration.clear();
5✔
153
    // }
154

155
    LoadIngameDefaults();
5✔
156
}
5✔
157

158
void Settings::LoadIngameDefaults()
5✔
159
{
160
    // ingame
161
    // {
162
    ingame.scale_statistics = false;
5✔
163
    ingame.showBQ = false;
5✔
164
    ingame.showNames = false;
5✔
165
    ingame.showProductivity = false;
5✔
166
    ingame.minimapExtended = false;
5✔
167
    // }
168

169
    // windows
170
    // {
171
    for(const auto& window : persistentWindows)
90✔
172
        windows.persistentSettings[window.first] = PersistentWindowSettings();
85✔
173
    // }
174
}
5✔
175

176
///////////////////////////////////////////////////////////////////////////////
177
// Routine zum Laden der Konfiguration
178
void Settings::Load()
×
179
{
180
    libsiedler2::Archiv settings;
×
181
    const auto settingsPath = RTTRCONFIG.ExpandPath(s25::resources::config);
×
182
    try
183
    {
184
        if(libsiedler2::Load(settingsPath, settings) != 0 || settings.size() < SECTION_NAMES.size())
×
185
            throw std::runtime_error("File missing or invalid");
×
186

187
        const libsiedler2::ArchivItem_Ini* iniGlobal =
188
          static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("global"));
×
189
        const libsiedler2::ArchivItem_Ini* iniVideo = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("video"));
×
190
        const libsiedler2::ArchivItem_Ini* iniLanguage =
191
          static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("language"));
×
192
        const libsiedler2::ArchivItem_Ini* iniDriver =
193
          static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("driver"));
×
194
        const libsiedler2::ArchivItem_Ini* iniSound = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("sound"));
×
195
        const libsiedler2::ArchivItem_Ini* iniLobby = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("lobby"));
×
196
        const libsiedler2::ArchivItem_Ini* iniServer =
197
          static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("server"));
×
198
        const libsiedler2::ArchivItem_Ini* iniProxy = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("proxy"));
×
199
        const libsiedler2::ArchivItem_Ini* iniInterface =
200
          static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("interface"));
×
201
        const libsiedler2::ArchivItem_Ini* iniAddons =
202
          static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("addons"));
×
203

204
        // ist eine der Kategorien nicht vorhanden?
205
        if(!iniGlobal || !iniVideo || !iniLanguage || !iniDriver || !iniSound || !iniLobby || !iniServer || !iniProxy
×
206
           || !iniInterface || !iniAddons)
×
207
        {
208
            throw std::runtime_error("Missing section");
×
209
        }
210
        // stimmt die Settingsversion?
211
        if(iniGlobal->getValue("version", 0) != VERSION)
×
212
            throw std::runtime_error("Wrong version");
×
213

214
        // global
215
        // {
216
        if(iniGlobal->getValue("gameversion") != rttr::version::GetRevision())
×
217
            s25util::warning("Your application version has changed - please recheck your settings!");
×
218

219
        global.submit_debug_data = iniGlobal->getIntValue("submit_debug_data");
×
220
        global.use_upnp = iniGlobal->getBoolValue("use_upnp");
×
221
        global.smartCursor = iniGlobal->getValue("smartCursor", true);
×
222
        global.debugMode = iniGlobal->getValue("debugMode", false);
×
223
        global.showGFInfo = iniGlobal->getValue("showGFInfo", false);
×
224
        // };
225

226
        // video
227
        // {
228
        video.windowedSize.width = iniVideo->getIntValue("windowed_width");
×
229
        video.windowedSize.height = iniVideo->getIntValue("windowed_height");
×
230
        video.fullscreenSize.width = iniVideo->getIntValue("fullscreen_width");
×
231
        video.fullscreenSize.height = iniVideo->getIntValue("fullscreen_height");
×
232
        video.fullscreen = iniVideo->getBoolValue("fullscreen");
×
233
        video.framerate = iniVideo->getValue("framerate", 0);
×
234
        video.vbo = iniVideo->getBoolValue("vbo");
×
235
        video.shared_textures = iniVideo->getBoolValue("shared_textures");
×
236
        video.guiScale = iniVideo->getValue("gui_scale", 0);
×
237
        // };
238

239
        if(video.fullscreenSize.width == 0 || video.fullscreenSize.height == 0 || video.windowedSize.width == 0
×
240
           || video.windowedSize.height == 0)
×
241
            throw std::runtime_error("Invalid video settings");
×
242

243
        // language
244
        // {
245
        language.language = iniLanguage->getValue("language");
×
246
        // }
247

248
        LANGUAGES.setLanguage(language.language);
×
249

250
        // driver
251
        // {
252
        driver.video = iniDriver->getValue("video");
×
253
        driver.audio = iniDriver->getValue("audio");
×
254
        // }
255

256
        // sound
257
        // {
258
        sound.musicEnabled = iniSound->getBoolValue("musik");
×
259
        sound.musicVolume = iniSound->getIntValue("musik_volume");
×
260
        sound.effectsEnabled = iniSound->getBoolValue("effekte");
×
261
        sound.effectsVolume = iniSound->getIntValue("effekte_volume");
×
NEW
262
        sound.birdsEnabled = iniSound->getBoolValue("bird_sounds");
×
UNCOV
263
        sound.playlist = iniSound->getValue("playlist");
×
264
        // }
265

266
        // lobby
267
        // {
268
        lobby.name = iniLobby->getValue("name");
×
269
        lobby.portraitIndex = iniLobby->getIntValue("portrait_index");
×
270
        lobby.password = iniLobby->getValue("password");
×
271
        lobby.save_password = iniLobby->getBoolValue("save_password");
×
272
        // }
273

274
        if(lobby.name.empty())
×
275
            lobby.name = System::getUserName();
×
276

277
        if(lobby.portraitIndex >= Portraits.size())
×
278
        {
279
            lobby.portraitIndex = 0;
×
280
        }
281

282
        // server
283
        // {
284
        server.last_ip = iniServer->getValue("last_ip");
×
285
        boost::optional<uint16_t> port = validate::checkPort(iniServer->getValue("local_port"));
×
286
        server.localPort = port.value_or(3665);
×
287
        server.ipv6 = iniServer->getBoolValue("ipv6");
×
288
        // }
289

290
        // proxy
291
        // {
292
        proxy.hostname = iniProxy->getValue("proxy");
×
293
        port = validate::checkPort(iniProxy->getValue("port"));
×
294
        proxy.port = port.value_or(1080);
×
295
        proxy.type = ProxyType(iniProxy->getIntValue("typ"));
×
296
        // }
297

298
        // leere proxyadresse deaktiviert proxy komplett
299
        // deaktivierter proxy entfernt proxyadresse
300
        if(proxy.hostname.empty() || (proxy.type != ProxyType::Socks4 && proxy.type != ProxyType::Socks5))
×
301
        {
302
            proxy.type = ProxyType::None;
×
303
            proxy.hostname.clear();
×
304
        }
305
        // aktivierter Socks v4 deaktiviert ipv6
306
        else if(proxy.type == ProxyType::Socks4 && server.ipv6)
×
307
            server.ipv6 = false;
×
308

309
        // interface
310
        // {
311
        interface.autosave_interval = iniInterface->getIntValue("autosave_interval");
×
312
        interface.invertMouse = iniInterface->getValue("invert_mouse", false);
×
313
        interface.enableWindowPinning = iniInterface->getValue("enable_window_pinning", false);
×
314
        interface.windowSnapDistance = iniInterface->getValue("window_snap_distance", 8);
×
315
        // }
316

317
        // addons
318
        // {
319
        for(unsigned addon = 0; addon < iniAddons->size(); ++addon)
×
320
        {
321
            const auto* item = dynamic_cast<const libsiedler2::ArchivItem_Text*>(iniAddons->get(addon));
×
322

323
            if(item)
×
324
                addons.configuration.insert(std::make_pair(s25util::fromStringClassic<unsigned>(item->getName()),
×
325
                                                           s25util::fromStringClassic<unsigned>(item->getText())));
×
326
        }
327

328
        LoadIngame();
×
329
        // }
330
    } catch(const std::runtime_error& e)
×
331
    {
332
        s25util::warning(std::string("Could not use settings from \"") + settingsPath.string()
×
333
                         + "\", using default values. Reason: " + e.what());
×
334
        LoadDefaults();
×
335
        Save();
×
336
    }
337
}
×
338

339
void Settings::LoadIngame()
×
340
{
341
    libsiedler2::Archiv settingsIngame;
×
342
    const auto settingsPathIngame = RTTRCONFIG.ExpandPath(s25::resources::ingameOptions);
×
343
    try
344
    {
345
        if(libsiedler2::Load(settingsPathIngame, settingsIngame) != 0)
×
346
            throw std::runtime_error("File missing");
×
347

348
        const libsiedler2::ArchivItem_Ini* iniIngame =
349
          static_cast<libsiedler2::ArchivItem_Ini*>(settingsIngame.find("ingame"));
×
350
        if(!iniIngame)
×
351
            throw std::runtime_error("Missing section");
×
352
        // ingame
353
        // {
354
        ingame.scale_statistics = iniIngame->getBoolValue("scale_statistics");
×
355
        ingame.showBQ = iniIngame->getBoolValue("show_building_quality");
×
356
        ingame.showNames = iniIngame->getBoolValue("show_names");
×
357
        ingame.showProductivity = iniIngame->getBoolValue("show_productivity");
×
358
        ingame.minimapExtended = iniIngame->getBoolValue("minimap_extended");
×
359
        // }
360
        // ingame windows
361
        for(const auto& window : persistentWindows)
×
362
        {
363
            const auto* iniWindow = static_cast<const libsiedler2::ArchivItem_Ini*>(settingsIngame.find(window.second));
×
364
            if(!iniWindow)
×
365
                continue;
×
366
            auto& settings = windows.persistentSettings[window.first];
×
367
            const auto lastPos = settings.lastPos =
×
368
              DrawPoint(iniWindow->getIntValue("pos_x"), iniWindow->getIntValue("pos_y"));
×
369
            settings.restorePos = DrawPoint(iniWindow->getValue("restore_pos_x", lastPos.x),
×
370
                                            iniWindow->getValue("restore_pos_y", lastPos.y));
×
371
            settings.isOpen = iniWindow->getIntValue("is_open");
×
372
            settings.isPinned = iniWindow->getValue("is_pinned", false);
×
373
            settings.isMinimized = iniWindow->getValue("is_minimized", false);
×
374
        }
375
    } catch(const std::runtime_error& e)
×
376
    {
377
        s25util::warning(std::string("Could not use ingame settings from \"") + settingsPathIngame.string()
×
378
                         + "\", using default values. Reason: " + e.what());
×
379
        LoadIngameDefaults();
×
380
        SaveIngame();
×
381
    }
382
}
×
383

384
///////////////////////////////////////////////////////////////////////////////
385
// Routine zum Speichern der Konfiguration
386
void Settings::Save()
×
387
{
388
    libsiedler2::Archiv settings;
×
389
    settings.alloc(SECTION_NAMES.size());
×
390
    for(unsigned i = 0; i < SECTION_NAMES.size(); ++i)
×
391
        settings.set(i, std::make_unique<libsiedler2::ArchivItem_Ini>(SECTION_NAMES[i]));
×
392

393
    libsiedler2::ArchivItem_Ini* iniGlobal = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("global"));
×
394
    libsiedler2::ArchivItem_Ini* iniVideo = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("video"));
×
395
    libsiedler2::ArchivItem_Ini* iniLanguage = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("language"));
×
396
    libsiedler2::ArchivItem_Ini* iniDriver = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("driver"));
×
397
    libsiedler2::ArchivItem_Ini* iniSound = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("sound"));
×
398
    libsiedler2::ArchivItem_Ini* iniLobby = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("lobby"));
×
399
    libsiedler2::ArchivItem_Ini* iniServer = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("server"));
×
400
    libsiedler2::ArchivItem_Ini* iniProxy = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("proxy"));
×
401
    libsiedler2::ArchivItem_Ini* iniInterface = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("interface"));
×
402
    libsiedler2::ArchivItem_Ini* iniAddons = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("addons"));
×
403

404
    // ist eine der Kategorien nicht vorhanden?
405
    RTTR_Assert(iniGlobal && iniVideo && iniLanguage && iniDriver && iniSound && iniLobby && iniServer && iniProxy
×
406
                && iniInterface && iniAddons);
407

408
    // global
409
    // {
410
    iniGlobal->setValue("version", VERSION);
×
411
    iniGlobal->setValue("gameversion", rttr::version::GetRevision());
×
412
    iniGlobal->setValue("submit_debug_data", global.submit_debug_data);
×
413
    iniGlobal->setValue("use_upnp", global.use_upnp);
×
414
    iniGlobal->setValue("smartCursor", global.smartCursor);
×
415
    iniGlobal->setValue("debugMode", global.debugMode);
×
416
    iniGlobal->setValue("showGFInfo", global.showGFInfo);
×
417
    // };
418

419
    // video
420
    // {
421
    iniVideo->setValue("fullscreen_width", video.fullscreenSize.width);
×
422
    iniVideo->setValue("fullscreen_height", video.fullscreenSize.height);
×
423
    iniVideo->setValue("windowed_width", video.windowedSize.width);
×
424
    iniVideo->setValue("windowed_height", video.windowedSize.height);
×
425
    iniVideo->setValue("fullscreen", video.fullscreen);
×
426
    iniVideo->setValue("framerate", video.framerate);
×
427
    iniVideo->setValue("vbo", video.vbo);
×
428
    iniVideo->setValue("shared_textures", video.shared_textures);
×
429
    iniVideo->setValue("gui_scale", video.guiScale);
×
430
    // };
431

432
    // language
433
    // {
434
    iniLanguage->setValue("language", language.language);
×
435
    // }
436

437
    // driver
438
    // {
439
    iniDriver->setValue("video", driver.video);
×
440
    iniDriver->setValue("audio", driver.audio);
×
441
    // }
442

443
    // sound
444
    // {
445
    iniSound->setValue("musik", sound.musicEnabled);
×
446
    iniSound->setValue("musik_volume", sound.musicVolume);
×
447
    iniSound->setValue("effekte", sound.effectsEnabled);
×
448
    iniSound->setValue("effekte_volume", sound.effectsVolume);
×
NEW
449
    iniSound->setValue("bird_sounds", sound.birdsEnabled);
×
UNCOV
450
    iniSound->setValue("playlist", sound.playlist);
×
451
    // }
452

453
    // lobby
454
    // {
455
    iniLobby->setValue("name", lobby.name);
×
456
    iniLobby->setValue("portrait_index", lobby.portraitIndex);
×
457
    iniLobby->setValue("password", lobby.password);
×
458
    iniLobby->setValue("save_password", lobby.save_password);
×
459
    // }
460

461
    // server
462
    // {
463
    iniServer->setValue("last_ip", server.last_ip);
×
464
    iniServer->setValue("local_port", server.localPort);
×
465
    iniServer->setValue("ipv6", server.ipv6);
×
466
    // }
467

468
    // proxy
469
    // {
470
    iniProxy->setValue("proxy", proxy.hostname);
×
471
    iniProxy->setValue("port", proxy.port);
×
472
    iniProxy->setValue("typ", static_cast<int>(proxy.type));
×
473
    // }
474

475
    // interface
476
    // {
477
    iniInterface->setValue("autosave_interval", interface.autosave_interval);
×
478
    iniInterface->setValue("invert_mouse", interface.invertMouse);
×
479
    iniInterface->setValue("enable_window_pinning", interface.enableWindowPinning);
×
480
    iniInterface->setValue("window_snap_distance", interface.windowSnapDistance);
×
481
    // }
482

483
    // addons
484
    // {
485
    iniAddons->clear();
×
486
    for(const auto& it : addons.configuration)
×
487
        iniAddons->setValue(s25util::toStringClassic(it.first), s25util::toStringClassic(it.second));
×
488
    // }
489

490
    bfs::path settingsPath = RTTRCONFIG.ExpandPath(s25::resources::config);
×
491
    if(libsiedler2::Write(settingsPath, settings) == 0)
×
492
        bfs::permissions(settingsPath, bfs::owner_read | bfs::owner_write);
×
493

494
    SaveIngame();
×
495
}
×
496

497
void Settings::SaveIngame()
×
498
{
499
    libsiedler2::Archiv settingsIngame;
×
500
    settingsIngame.alloc(1 + persistentWindows.size());
×
501
    settingsIngame.set(0, std::make_unique<libsiedler2::ArchivItem_Ini>("ingame"));
×
502
    unsigned i = 1;
×
503
    for(const auto& window : persistentWindows)
×
504
    {
505
        settingsIngame.set(i, std::make_unique<libsiedler2::ArchivItem_Ini>(window.second));
×
506
        i++;
×
507
    }
508

509
    auto* iniIngame = static_cast<libsiedler2::ArchivItem_Ini*>(settingsIngame.find("ingame"));
×
510

511
    RTTR_Assert(iniIngame);
×
512

513
    // ingame
514
    // {
515
    iniIngame->setValue("scale_statistics", ingame.scale_statistics);
×
516
    iniIngame->setValue("show_building_quality", ingame.showBQ);
×
517
    iniIngame->setValue("show_names", ingame.showNames);
×
518
    iniIngame->setValue("show_productivity", ingame.showProductivity);
×
519
    iniIngame->setValue("minimap_extended", ingame.minimapExtended);
×
520
    // }
521

522
    // ingame windows
523
    for(const auto& window : persistentWindows)
×
524
    {
525
        auto* iniWindow = static_cast<libsiedler2::ArchivItem_Ini*>(settingsIngame.find(window.second));
×
526
        if(!iniWindow)
×
527
            continue;
×
528
        const auto& settings = windows.persistentSettings[window.first];
×
529
        iniWindow->setValue("pos_x", settings.lastPos.x);
×
530
        iniWindow->setValue("pos_y", settings.lastPos.y);
×
531
        if(settings.restorePos != settings.lastPos)
×
532
        {
533
            // only save if different; defaults to lastPos on load
534
            iniWindow->setValue("restore_pos_x", settings.restorePos.x);
×
535
            iniWindow->setValue("restore_pos_y", settings.restorePos.y);
×
536
        }
537
        iniWindow->setValue("is_open", settings.isOpen);
×
538
        iniWindow->setValue("is_pinned", settings.isPinned);
×
539
        iniWindow->setValue("is_minimized", settings.isMinimized);
×
540
    }
541

542
    bfs::path settingsPathIngame = RTTRCONFIG.ExpandPath(s25::resources::ingameOptions);
×
543
    if(libsiedler2::Write(settingsPathIngame, settingsIngame) == 0)
×
544
        bfs::permissions(settingsPathIngame, bfs::owner_read | bfs::owner_write);
×
545
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc