Config: Make the setting tables constexpr

SETTING now takes offsets with offsetof and passes them along with the
setting's type, instead of the block and member pointers, and the
ConfigSetting constructors are constexpr. So the tables are built at compile
time, and later per-setting metadata can be checked by the compiler too.

Defaults that weren't constants had to change:
- AutoFrameSkip called IsVREnabled() during static initialization, before VR
  is set up. It's now a default callback, evaluated when the config is
  loaded or reset, which can turn it on by default on VR devices.
- DisplayRefreshRate read g_Config's own initial value, which is 60.

Path defaults now share the string member of the default union.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-22 15:34:47 +02:00
1 parent 71b38e58e6
commit 729047d449
3 files changed
+115 -150

No files matched your search

+3 -3
View File
@@ -139,7 +139,7 @@ bool ConfigSetting::ReadFromIniSection(ConfigBlock *configBlock, const Section *
if (defaultCallback_.p) {
*target = defaultCallback_.p();
} else {
*target = Path(default_.p);
*target = Path(default_.s);
}
}
return false;
@@ -351,8 +351,8 @@ bool ConfigSetting::RestoreToDefault(ConfigBlock *configBlock, bool log) const {
if (defaultCallback_.p) {
*ptr_path = defaultCallback_.p();
break;
} else if (default_.p) {
*ptr_path = Path(default_.p);
} else if (default_.s) {
*ptr_path = Path(default_.s);
} else {
ptr_path->clear();
}