Repository navigation
Skip a UTF-8 byte order mark at the start of fs2_open.ini - #7884
Open
dustinspace217 wants to merge 1 commit into
Open
dustinspace217 wants to merge 1 commit into
dustinspace217 wants to merge 1 commit into
Conversation
profile_read did not recognize a section header preceded by a byte order mark, so every key under the first section ([Default]) was dropped. The next settings save wrote the file back without them. Editors such as Notepad can save the file with a mark.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #5543 (its fs2_open.ini part; the multi.cfg part is #7881)
What?
Strips a UTF-8 byte order mark from the first line of fs2_open.ini before it is parsed.
Why?
If fs2_open.ini is saved with a byte order mark (Notepad can do this), the game stops seeing the first section, normally
[Default], and every setting in it is ignored. The next time the game saves a setting it writes the file back without that section, so those settings are lost for good. This is the "using UTF-8 BOM to encode the fs2_open.ini causes FSO to completely delete..." part of #5543.How?
profile_readcompares each trimmed line with[. With the mark in front,[Default]is not seen as a section header, and the keys after it have no section, so they are dropped. On the first line only, if it starts with EF BB BF, those three bytes are removed before parsing. The same reader handles the per-mod settings file, so that is covered too. The saved file is written without the mark.Testing?
Linux Release builds, retail FS2 data, master (a1250d7) against this branch, each run with its own preferences folder:
-porttakes its game port from[Default] ForcePort. With the mark (CRLF or LF, and with a second section after it), master opened the default port 7808 and this branch opened ForcePort. Without the mark, with the mark followed by a blank line, with only a mark, with an empty file and with no file, both builds behaved the same.opt.MultiLoginfrom$On Game Init, which saves the ini. With the mark, master rewrote the file with only[Sound]and[PXO], and[Default]and both of its keys were gone. This branch kept every key. Without the mark, both kept every key.The per-mod settings file uses the same reader but was not run separately.
Anything Else?
Written with Claude Code; the investigation, review and testing ran on my machine.