Changeset View
Changeset View
Standalone View
Standalone View
source/main.cpp
Show First 20 Lines • Show All 233 Lines • ▼ Show 20 Lines | |||||
* prevent 100% workload of the currently used CPU core. | * prevent 100% workload of the currently used CPU core. | ||||
*/ | */ | ||||
inline static void LimitFPS() | inline static void LimitFPS() | ||||
{ | { | ||||
if (g_VSync) | if (g_VSync) | ||||
return; | return; | ||||
double fpsLimit = 0.0; | double fpsLimit = 0.0; | ||||
CFG_GET_VAL(g_Game && g_Game->IsGameStarted() ? "adaptivefps.session" : "adaptivefps.menu", fpsLimit); | CFG_GET_VAL(CGame::IsGameInitialised() && CGame::GetGame()->IsGameStarted() ? "adaptivefps.session" : "adaptivefps.menu", fpsLimit); | ||||
// Keep in sync with options.json | // Keep in sync with options.json | ||||
if (fpsLimit < 20.0 || fpsLimit >= 100.0) | if (fpsLimit < 20.0 || fpsLimit >= 100.0) | ||||
return; | return; | ||||
double wait = 1000.0 / fpsLimit - | double wait = 1000.0 / fpsLimit - | ||||
std::chrono::duration_cast<std::chrono::microseconds>( | std::chrono::duration_cast<std::chrono::microseconds>( | ||||
std::chrono::high_resolution_clock::now() - lastFrameTime).count() / 1000.0; | std::chrono::high_resolution_clock::now() - lastFrameTime).count() / 1000.0; | ||||
Show All 19 Lines | try | ||||
case INFO::OK: | case INFO::OK: | ||||
return 0; | return 0; | ||||
// current task didn't complete. we only care about this insofar as the | // current task didn't complete. we only care about this insofar as the | ||||
// load process is therefore not yet finished. | // load process is therefore not yet finished. | ||||
case ERR::TIMED_OUT: | case ERR::TIMED_OUT: | ||||
break; | break; | ||||
// just finished loading | // just finished loading | ||||
case INFO::ALL_COMPLETE: | case INFO::ALL_COMPLETE: | ||||
g_Game->ReallyStartGame(); | CGame::GetGame()->ReallyStartGame(); | ||||
wcscpy_s(description, ARRAY_SIZE(description), L"Game is starting.."); | wcscpy_s(description, ARRAY_SIZE(description), L"Game is starting.."); | ||||
// LDR_ProgressiveLoad returns L""; set to valid text to | // LDR_ProgressiveLoad returns L""; set to valid text to | ||||
// avoid problems in converting to JSString | // avoid problems in converting to JSString | ||||
break; | break; | ||||
// error! | // error! | ||||
default: | default: | ||||
WARN_RETURN_STATUS_IF_ERR(ret); | WARN_RETURN_STATUS_IF_ERR(ret); | ||||
// can't do this above due to legit ERR::TIMED_OUT | // can't do this above due to legit ERR::TIMED_OUT | ||||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | if (g_NetClient) | ||||
g_NetClient->Poll(); | g_NetClient->Poll(); | ||||
ogl_WarnIfError(); | ogl_WarnIfError(); | ||||
g_GUI->TickObjects(); | g_GUI->TickObjects(); | ||||
ogl_WarnIfError(); | ogl_WarnIfError(); | ||||
if (g_Game && g_Game->IsGameStarted() && need_update) | if (CGame::IsGameInitialised() && CGame::GetGame()->IsGameStarted() && need_update) | ||||
{ | { | ||||
g_Game->Update(realTimeSinceLastFrame); | CGame::GetGame()->Update(realTimeSinceLastFrame); | ||||
g_Game->GetView()->Update(float(realTimeSinceLastFrame)); | CGame::GetGame()->GetView()->Update(float(realTimeSinceLastFrame)); | ||||
} | } | ||||
// Immediately flush any messages produced by simulation code | // Immediately flush any messages produced by simulation code | ||||
if (g_NetClient) | if (g_NetClient) | ||||
g_NetClient->Flush(); | g_NetClient->Flush(); | ||||
// Keep us connected to any XMPP servers | // Keep us connected to any XMPP servers | ||||
if (g_XmppClient) | if (g_XmppClient) | ||||
Show All 27 Lines | static void NonVisualFrame() | ||||
g_Profiler2.RecordFrameStart(); | g_Profiler2.RecordFrameStart(); | ||||
PROFILE2("frame"); | PROFILE2("frame"); | ||||
g_Profiler2.IncrementFrameNumber(); | g_Profiler2.IncrementFrameNumber(); | ||||
PROFILE2_ATTR("%d", g_Profiler2.GetFrameNumber()); | PROFILE2_ATTR("%d", g_Profiler2.GetFrameNumber()); | ||||
static u32 turn = 0; | static u32 turn = 0; | ||||
debug_printf("Turn %u (%u)...\n", turn++, DEFAULT_TURN_LENGTH_SP); | debug_printf("Turn %u (%u)...\n", turn++, DEFAULT_TURN_LENGTH_SP); | ||||
g_Game->GetSimulation2()->Update(DEFAULT_TURN_LENGTH_SP); | CGame::GetGame()->GetSimulation2()->Update(DEFAULT_TURN_LENGTH_SP); | ||||
g_Profiler.Frame(); | g_Profiler.Frame(); | ||||
if (g_Game->IsGameFinished()) | if (CGame::GetGame()->IsGameFinished()) | ||||
QuitEngine(); | QuitEngine(); | ||||
} | } | ||||
static void MainControllerInit() | static void MainControllerInit() | ||||
{ | { | ||||
// add additional input handlers only needed by this controller: | // add additional input handlers only needed by this controller: | ||||
// must be registered after gui_handler. Should mayhap even be last. | // must be registered after gui_handler. Should mayhap even be last. | ||||
▲ Show 20 Lines • Show All 236 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator