From e21c6a94ebbbd2e853260c006e5dd5a37895c05c Mon Sep 17 00:00:00 2001 From: wookieejedi Date: Tue, 15 Sep 2026 10:21:16 -0400 Subject: [PATCH] Update freespace.cpp Bug: "No matter what value I'm setting in default_settings table with the entry below, it doesn't affect any new pilots I create." Cause: The skill option's table parser only sets Game_skill_level directly. Every other place that asks for "the default" ignores it and uses the hard-coded DEFAULT_SKILL_LEVEL (1, which is "Easy"), so the tabled value gets overwritten twice: At startup (freespace.cpp:1919-1920): default_settings_init() sets Game_skill_level from your table. Then loadInitialValues() runs right after. If Game.SkillLevel isn't saved in the ini yet, it falls back to default_func. That returned the constant 1, and bind_to wrote it back over your value. When a pilot is created (managepilot.cpp:100): init_new_pilot() does Game_skill_level = game_get_default_skill_level(), which also just returned the constant. This PR follows the same strategy of settings like sound volume to allow modders to specify a default setting for difficulty. --- freespace2/freespace.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/freespace2/freespace.cpp b/freespace2/freespace.cpp index a04e5097ba9..98a2ada5c36 100644 --- a/freespace2/freespace.cpp +++ b/freespace2/freespace.cpp @@ -257,6 +257,7 @@ struct big_expl_flash { #define FRAME_FILTER 16 #define DEFAULT_SKILL_LEVEL 1 +static int Default_skill_level = DEFAULT_SKILL_LEVEL; // can be overridden by default_settings.tbl int Game_skill_level = DEFAULT_SKILL_LEVEL; static SCP_string skill_level_display(int value) @@ -272,6 +273,7 @@ static void parse_skill_func() value -= 1; // Parse 1-5 for the skill levels but convert to our internal 0-4 CLAMP(value, 0, 4); + Default_skill_level = value; Game_skill_level = value; } @@ -282,7 +284,7 @@ static auto GameSkillOption __UNUSED = options::OptionBuilder("Game.SkillLe .category(std::make_pair("Game", 1824)) .range(0, 4) .level(options::ExpertLevel::Beginner) - .default_func([]() { return DEFAULT_SKILL_LEVEL; }) + .default_func([]() { return Default_skill_level; }) .bind_to(&Game_skill_level) .display(skill_level_display) .importance(1) @@ -620,7 +622,7 @@ const fs_builtin_mission *game_find_builtin_mission(const char *filename) int game_get_default_skill_level() { - return DEFAULT_SKILL_LEVEL; + return Default_skill_level; } // Resets the flash