Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Settings saved before a settings file exists overwrite each other

Aperta Adatta ai principianti
#7,899 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
desktop-dev

Direzione di ricerca

Ispeziona os_config_write_string e os_config_write_uint in osregistry.cpp, poi traccia dove vengono inizializzati e letti Osreg_profile e Mod_settings_profile. La correzione dovrebbe aggiornare la globale rilevante dopo la scrittura, e i test o la riproduzione dovrebbero confermare che più impostazioni persistono invece di sostituirsi a vicenda. Controlla anche il percorso di perdita intorno a profile_update.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem

When there's no settings file yet, every setting the game saves replaces the whole file with just that one setting. On a fresh install without fs2_open.ini, changing several options in the in-game options menu and saving keeps only the last one written, and the pilot name, PXO login and similar settings overwrite each other the same way. Once a file exists, from the next launch on, saving should work normally, since the profile is read from it at startup.

In os_config_write_string and os_config_write_uint (osregistry.cpp), the profile is copied into a local, updated and saved, but the result is never stored back into Osreg_profile or Mod_settings_profile. When those start out null (no file at startup), each write builds a fresh one-entry profile, saves it over the file and leaks it. From reading the code (not tested on Windows): on Windows the main settings fall back to the registry when there's no file, so only the in-game options' mod settings file would be affected there; on Linux and macOS both are.

Steps to reproduce

  1. Start FSO (master at 12a36dc1a, Linux) with an empty preferences folder: no fs2_open.ini and no mod settings file.
  2. Create a pilot and go to the main hall.
  3. In the in-game options, change three settings (I used Lightshafts, Use Mouse and 3D Shockwaves) and save.
  4. Look at fs2_open.ini and the mod's data/<mod>_settings.ini.

Also reproducible with three settings written one after another (pilot select writes LastPlayer, then setting the PXO login and squad from Lua): after each write the file holds only that one key.

Expected vs. actual behavior

Expected: the settings file contains every setting saved during the session.

Actual: after saving three in-game options, the mod settings file contained one unrelated entry ([Graphics] SmallDebris=4) and none of the three changes. fs2_open.ini likewise ends up holding only the last key written. AddressSanitizer also reports the discarded profiles as leaks (profile_update, osregistry.cpp:720 and 776).

Proposed fixes

Ranked by simplicity, then maintainability, then thoroughness.

  1. In both write functions, store the updated profile back into the global it came from (Osreg_profile or Mod_settings_profile). A couple of lines, and it fixes the overwriting and the leak.
  2. Move the "pick the profile, update it, store it back, save it" steps into one helper both write functions call, so the uint and string paths can't drift apart again.
  3. Create empty profiles at startup when the files don't exist, so neither global is ever null, and drop the null-dependent branches.
Lingua principale
C++
Stelle
488
Fork
184
Merge medio
2g 9h
PR unite (30g)
43

Preparare l'ambiente

Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di scp-fs2open/fs2open.github.com

Tutte le issue di scp-fs2open/fs2open.github.com

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.