Skip to content

Commit 9fa8d23

Browse files
committed
xrEngine/main.cpp: cleanup RunApplication() a bit
1 parent 3291f1a commit 9fa8d23

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

src/xrEngine/main.cpp

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Entry point is in xr_3da/entry_point.cpp
22
#include "stdafx.h"
33
#include "main.h"
4-
#include "xr_3da/resource.h"
54

65
#include <process.h>
76
#include <locale.h>
@@ -33,6 +32,7 @@ ENGINE_API string_path g_sLaunchWorkingFolder;
3332

3433
namespace
3534
{
35+
bool CheckBenchmark();
3636
void RunBenchmark(pcstr name);
3737
}
3838

@@ -231,26 +231,8 @@ ENGINE_API int RunApplication()
231231
InitConsole();
232232
Engine.External.CreateRendererList();
233233

234-
pcstr benchName = "-batch_benchmark ";
235-
if (strstr(Core.Params, benchName))
236-
{
237-
u32 sz = xr_strlen(benchName);
238-
string64 benchmarkName;
239-
sscanf(strstr(Core.Params, benchName) + sz, "%[^ ] ", benchmarkName);
240-
RunBenchmark(benchmarkName);
241-
return 0;
242-
}
243-
244-
pcstr sashName = "-openautomate ";
245-
if (strstr(Core.Params, sashName))
246-
{
247-
u32 sz = xr_strlen(sashName);
248-
string512 sashArg;
249-
sscanf(strstr(Core.Params, sashName) + sz, "%[^ ] ", sashArg);
250-
g_SASH.Init(sashArg);
251-
g_SASH.MainLoop();
234+
if (CheckBenchmark())
252235
return 0;
253-
}
254236

255237
if (!GEnv.isDedicatedServer)
256238
{
@@ -295,13 +277,38 @@ ENGINE_API int RunApplication()
295277

296278
namespace
297279
{
280+
bool CheckBenchmark()
281+
{
282+
pcstr benchName = "-batch_benchmark ";
283+
if (strstr(Core.Params, benchName))
284+
{
285+
const u32 sz = xr_strlen(benchName);
286+
string64 benchmarkName;
287+
sscanf(strstr(Core.Params, benchName) + sz, "%[^ ] ", benchmarkName);
288+
RunBenchmark(benchmarkName);
289+
return true;
290+
}
291+
292+
pcstr sashName = "-openautomate ";
293+
if (strstr(Core.Params, sashName))
294+
{
295+
const u32 sz = xr_strlen(sashName);
296+
string512 sashArg;
297+
sscanf(strstr(Core.Params, sashName) + sz, "%[^ ] ", sashArg);
298+
g_SASH.Init(sashArg);
299+
g_SASH.MainLoop();
300+
return true;
301+
}
302+
303+
return false;
304+
}
298305
void RunBenchmark(pcstr name)
299306
{
300307
g_bBenchmark = true;
301308
string_path cfgPath;
302309
FS.update_path(cfgPath, "$app_data_root$", name);
303310
CInifile ini(cfgPath);
304-
u32 benchmarkCount = ini.line_count("benchmark");
311+
const u32 benchmarkCount = ini.line_count("benchmark");
305312
for (u32 i = 0; i < benchmarkCount; i++)
306313
{
307314
LPCSTR benchmarkName, t;

0 commit comments

Comments
 (0)