Skip to content

Commit

Permalink
Populate defaultIniData sooner
Browse files Browse the repository at this point in the history
If settings.ini exists but is completely blank, it will freeze game as defaults are never loaded.
Populate defaultIniData at the start so defaults are available in the edge case of an empty settings file.
  • Loading branch information
Interkarma committed Dec 14, 2023
1 parent f887334 commit d1e3391
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Assets/Scripts/SettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -737,10 +737,6 @@ void CreateDefaultSettingsFile(string userIniPath)
{
// Load defaults.ini
TextAsset asset = Resources.Load<TextAsset>(defaultsIniName);
MemoryStream stream = new MemoryStream(asset.bytes);
StreamReader reader = new StreamReader(stream);
defaultIniData = iniParser.ReadData(reader);
reader.Close();

// Create file
File.WriteAllBytes(userIniPath, asset.bytes);
Expand All @@ -750,6 +746,14 @@ void CreateDefaultSettingsFile(string userIniPath)

void ReadSettingsFile()
{
// Load defaults.ini
// This is required for fallback sync if everything else goes wrong
TextAsset asset = Resources.Load<TextAsset>(defaultsIniName);
MemoryStream stream = new MemoryStream(asset.bytes);
StreamReader reader = new StreamReader(stream);
defaultIniData = iniParser.ReadData(reader);
reader.Close();

// Must have settings.ini in persistent data path
string userIniPath = Path.Combine(PersistentDataPath, SettingsName());
if (!File.Exists(userIniPath))
Expand Down

0 comments on commit d1e3391

Please sign in to comment.