MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / init

Function init

TheForceEngine/TFE_Settings/settings.cpp:123–161  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////////////// Implementation /////////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

121 // Implementation
122 //////////////////////////////////////////////////////////////////////////////////
123 bool init(bool& firstRun)
124 {
125 // Clear out game settings.
126 s_gameSettings = {};
127 for (u32 i = 0; i < Game_Count; i++)
128 {
129 strcpy(s_gameSettings.header[i].gameName, c_gameName[i]);
130 }
131 strcpy(s_game.game, s_gameSettings.header[0].gameName);
132
133 TFE_Paths::appendPath(PATH_USER_DOCUMENTS, "settings.ini", s_settingsPath);
134 TFE_Paths::appendPath(PATH_USER_DOCUMENTS, "settings_default.ini", s_defaultSettingsPath);
135
136 // Make a backup of the default game settings.
137 memcpy(&s_defaultGameSettings, &s_gameSettings, sizeof(TFE_Settings_Game));
138
139 // Make a backup of the default settings.
140 if (!FileUtil::exists(s_defaultSettingsPath))
141 {
142 writeToDisk(true);
143 }
144
145 if (FileUtil::exists(s_settingsPath))
146 {
147 // This is still the first run if the settings.ini file is empty.
148 firstRun = settingsFileEmpty();
149
150 if (readFromDisk())
151 {
152 return true;
153 }
154 firstRun = false;
155 TFE_System::logWrite(LOG_WARNING, "Settings", "Cannot parse 'settings.ini' - recreating it.");
156 }
157
158 firstRun = true;
159 autodetectGamePaths();
160 return writeToDisk();
161 }
162
163 void shutdown()
164 {

Callers 1

resetAllSettingsFunction · 0.70

Calls 7

writeToDiskFunction · 0.85
settingsFileEmptyFunction · 0.85
readFromDiskFunction · 0.85
logWriteFunction · 0.85
autodetectGamePathsFunction · 0.85
appendPathFunction · 0.50
existsFunction · 0.50

Tested by

no test coverage detected