MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GameLoop

Method GameLoop

src/game/game_core.cpp:31–55  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

29/* static */ std::unique_ptr<GameScannerLibrary> Game::scanner_library = nullptr;
30
31/* static */ void Game::GameLoop()
32{
33 if (_networking && !_network_server) {
34 PerformanceMeasurer::SetInactive(PFE_GAMESCRIPT);
35 return;
36 }
37 if (Game::instance == nullptr) {
38 PerformanceMeasurer::SetInactive(PFE_GAMESCRIPT);
39 return;
40 }
41
42 PerformanceMeasurer framerate(PFE_GAMESCRIPT);
43
44 Game::frame_counter++;
45
46 Backup<CompanyID> cur_company(_current_company);
47 cur_company.Change(OWNER_DEITY);
48 Game::instance->GameLoop();
49 cur_company.Restore();
50
51 /* Occasionally collect garbage */
52 if ((Game::frame_counter & 255) == 0) {
53 Game::instance->CollectGarbage();
54 }
55}
56
57/* static */ void Game::Initialize()
58{

Callers

nothing calls this directly

Calls 3

ChangeMethod · 0.45
RestoreMethod · 0.45
CollectGarbageMethod · 0.45

Tested by

no test coverage detected