Skip to content

Commit

Permalink
xrEngine/main.cpp: cleanup RunApplication() a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed May 20, 2018
1 parent 3291f1a commit 9fa8d23
Showing 1 changed file with 28 additions and 21 deletions.
49 changes: 28 additions & 21 deletions src/xrEngine/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Entry point is in xr_3da/entry_point.cpp
#include "stdafx.h"
#include "main.h"
#include "xr_3da/resource.h"

#include <process.h>
#include <locale.h>
Expand Down Expand Up @@ -33,6 +32,7 @@ ENGINE_API string_path g_sLaunchWorkingFolder;

namespace
{
bool CheckBenchmark();
void RunBenchmark(pcstr name);
}

Expand Down Expand Up @@ -231,26 +231,8 @@ ENGINE_API int RunApplication()
InitConsole();
Engine.External.CreateRendererList();

pcstr benchName = "-batch_benchmark ";
if (strstr(Core.Params, benchName))
{
u32 sz = xr_strlen(benchName);
string64 benchmarkName;
sscanf(strstr(Core.Params, benchName) + sz, "%[^ ] ", benchmarkName);
RunBenchmark(benchmarkName);
return 0;
}

pcstr sashName = "-openautomate ";
if (strstr(Core.Params, sashName))
{
u32 sz = xr_strlen(sashName);
string512 sashArg;
sscanf(strstr(Core.Params, sashName) + sz, "%[^ ] ", sashArg);
g_SASH.Init(sashArg);
g_SASH.MainLoop();
if (CheckBenchmark())
return 0;
}

if (!GEnv.isDedicatedServer)
{
Expand Down Expand Up @@ -295,13 +277,38 @@ ENGINE_API int RunApplication()

namespace
{
bool CheckBenchmark()
{
pcstr benchName = "-batch_benchmark ";
if (strstr(Core.Params, benchName))
{
const u32 sz = xr_strlen(benchName);
string64 benchmarkName;
sscanf(strstr(Core.Params, benchName) + sz, "%[^ ] ", benchmarkName);
RunBenchmark(benchmarkName);
return true;
}

pcstr sashName = "-openautomate ";
if (strstr(Core.Params, sashName))
{
const u32 sz = xr_strlen(sashName);
string512 sashArg;
sscanf(strstr(Core.Params, sashName) + sz, "%[^ ] ", sashArg);
g_SASH.Init(sashArg);
g_SASH.MainLoop();
return true;
}

return false;
}
void RunBenchmark(pcstr name)
{
g_bBenchmark = true;
string_path cfgPath;
FS.update_path(cfgPath, "$app_data_root$", name);
CInifile ini(cfgPath);
u32 benchmarkCount = ini.line_count("benchmark");
const u32 benchmarkCount = ini.line_count("benchmark");
for (u32 i = 0; i < benchmarkCount; i++)
{
LPCSTR benchmarkName, t;
Expand Down

0 comments on commit 9fa8d23

Please sign in to comment.