Skip to content

Replace settings.dat with a toml file#4619

Merged
Loobinex merged 2 commits intodkfans:masterfrom
PieterVdc:settings_tomlk
Mar 19, 2026
Merged

Replace settings.dat with a toml file#4619
Loobinex merged 2 commits intodkfans:masterfrom
PieterVdc:settings_tomlk

Conversation

@PieterVdc
Copy link
Member

needed to not need to worry about backwards compatibility when updating what's stored in settings

@PieterVdc PieterVdc marked this pull request as ready for review March 18, 2026 17:55
Copilot AI review requested due to automatic review settings March 18, 2026 17:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces the binary settings.dat persistence with a human-editable settings.toml, with the goal of making future settings changes easier without strict binary compatibility concerns.

Changes:

  • Switch settings load/save from settings.dat (binary struct) to settings.toml (TOML via value_util / toml_parse).
  • Add TOML serialization/deserialization for video/audio/display/gameplay settings plus keybinds.
  • Introduce keycode/modifier string mappings to represent keybinds in TOML.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +372 to +376
char *fname = prepare_file_path(FGrp_Save, "settings.toml");
VALUE root;
if (!load_toml_file(fname, &root, CnfLd_IgnoreErrors))
{
if (LbFileLoadAt(fname, &settings) == sizeof(struct GameSettings))
{
// sanity checks
settings.video_shadows = clamp(settings.video_shadows, 0, 3);
settings.view_distance = clamp(settings.view_distance, 0, 3);
settings.video_rotate_mode = clamp(settings.video_rotate_mode, 0, 2);
settings.video_textures = clamp(settings.video_textures, 0, 1);
settings.video_cluedo_mode = clamp(settings.video_cluedo_mode, 0, 1);
settings.sound_volume = clamp(settings.sound_volume, 0, FULL_LOUDNESS);
settings.music_volume = clamp(settings.music_volume, 0, FULL_LOUDNESS);
settings.mentor_volume = clamp(settings.mentor_volume, 0, FULL_LOUDNESS);
settings.gamma_correction = clamp(settings.gamma_correction, 0, GAMMA_LEVELS_COUNT);
settings.switching_vidmodes_index = clamp(settings.switching_vidmodes_index, 0, MAX_GAME_VIDMODE_COUNT);
settings.first_person_move_sensitivity = clamp(settings.first_person_move_sensitivity, 0, 1000);
settings.minimap_zoom = clamp(settings.minimap_zoom, 256, 2048);
settings.isometric_view_zoom_level = clamp(settings.isometric_view_zoom_level, CAMERA_ZOOM_MIN, CAMERA_ZOOM_MAX);
settings.frontview_zoom_level = clamp(settings.frontview_zoom_level, FRONTVIEW_CAMERA_ZOOM_MIN, FRONTVIEW_CAMERA_ZOOM_MAX);
settings.isometric_tilt = clamp(settings.isometric_tilt, CAMERA_TILT_MIN, CAMERA_TILT_MAX);
settings.highlight_mode = clamp(settings.highlight_mode, false, true);
return true;
}
save_settings();
@Loobinex Loobinex merged commit 1c1a869 into dkfans:master Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants