Skip to content

Commit 1713ce4

Browse files
committed
CourseEdit: add startup notification if still enabled
simplified some ini code
1 parent afa9380 commit 1713ce4

File tree

3 files changed

+9
-45
lines changed

3 files changed

+9
-45
lines changed

src/dllmain.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -146,29 +146,16 @@ namespace Settings
146146
{
147147
spdlog::info("Settings::read - reading INI from {}", iniPath.string());
148148

149-
const std::wstring iniPathStr = iniPath.wstring();
150-
151-
// Read INI via FILE* since INIReader doesn't support wstring
152-
FILE* iniFile;
153-
errno_t result = _wfopen_s(&iniFile, iniPathStr.c_str(), L"r");
154-
if (result != 0 || !iniFile)
155-
{
156-
spdlog::error("Settings::read - INI read failed! Error code {}", result);
157-
return false;
158-
}
159-
160149
inih::INIReader ini;
161150
try
162151
{
163-
ini = inih::INIReader(iniFile);
152+
ini = inih::INIReader(iniPath);
164153
}
165154
catch (...)
166155
{
167-
spdlog::error("Settings::read - INI read failed! The file may be invalid or have duplicate settings inside");
168-
fclose(iniFile);
156+
spdlog::error("Settings::read - INI read failed! The file might not exist, or may have duplicate settings inside");
169157
return false;
170158
}
171-
fclose(iniFile);
172159

173160
FramerateLimit = ini.Get("Performance", "FramerateLimit", FramerateLimit);
174161
FramerateLimitMode = ini.Get("Performance", "FramerateLimitMode", FramerateLimitMode);

src/hooks_drawdistance.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -238,29 +238,16 @@ bool DrawDist_ReadExclusions()
238238

239239
spdlog::info("DrawDist_ReadExclusions - reading INI from {}", iniPath.string());
240240

241-
const std::wstring iniPathStr = iniPath.wstring();
242-
243-
// Read INI via FILE* since INIReader doesn't support wstring
244-
FILE* iniFile;
245-
errno_t result = _wfopen_s(&iniFile, iniPathStr.c_str(), L"r");
246-
if (result != 0 || !iniFile)
247-
{
248-
spdlog::error("DrawDist_ReadExclusions - INI read failed! Error code {}", result);
249-
return false;
250-
}
251-
252241
inih::INIReader ini;
253242
try
254243
{
255-
ini = inih::INIReader(iniFile);
244+
ini = inih::INIReader(iniPath);
256245
}
257246
catch (...)
258247
{
259-
spdlog::error("DrawDist_ReadExclusions - INI read failed! The file may be invalid or have duplicate settings inside");
260-
fclose(iniFile);
248+
spdlog::error("DrawDist_ReadExclusions - INI read failed! The file might not exist, or may have duplicate settings inside");
261249
return false;
262250
}
263-
fclose(iniFile);
264251

265252
for (auto& section : ini.Sections())
266253
{

src/overlay/overlay.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ void Overlay_Init()
141141

142142
Notifications::instance.add("OutRun2006Tweaks v" MODULE_VERSION_STR " by emoose!\nPress F11 to open overlay.");
143143

144+
if (Overlay::CourseReplacementEnabled)
145+
Notifications::instance.add("Note: Course Editor Override is enabled from previous session.");
146+
144147
void ServerNotifications_Init();
145148
ServerNotifications_Init();
146149
}
@@ -199,29 +202,16 @@ namespace Overlay
199202
{
200203
spdlog::info("Overlay::settings_read - reading INI from {}", Module::OverlayIniPath.string());
201204

202-
const std::wstring iniPathStr = Module::OverlayIniPath.wstring();
203-
204-
// Read INI via FILE* since INIReader doesn't support wstring
205-
FILE* iniFile;
206-
errno_t result = _wfopen_s(&iniFile, iniPathStr.c_str(), L"r");
207-
if (result != 0 || !iniFile)
208-
{
209-
spdlog::error("Overlay::settings_read - INI read failed! Error code {}", result);
210-
return false;
211-
}
212-
213205
inih::INIReader ini;
214206
try
215207
{
216-
ini = inih::INIReader(iniFile);
208+
ini = inih::INIReader(Module::OverlayIniPath);
217209
}
218210
catch (...)
219211
{
220-
spdlog::error("Overlay::settings_read - INI read failed! The file may be invalid or have duplicate settings inside");
221-
fclose(iniFile);
212+
spdlog::error("Overlay::settings_read - INI read failed! The file might not exist, or may have duplicate settings inside");
222213
return false;
223214
}
224-
fclose(iniFile);
225215

226216
GlobalFontScale = ini.Get("Overlay", "FontScale", GlobalFontScale);
227217

0 commit comments

Comments
 (0)