MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / loopGame

Method loopGame

TheForceEngine/TFE_DarkForces/darkForcesMain.cpp:566–720  ·  view source on GitHub ↗

The basic structure of the Dark Forces main loop is as follows:*************** while (1) // <- This will be replaced by the function call from the main TFE loop. { // TFE: This becomes a game state in TFE - where runAgentMenu() gets an update function - it can't loop forever. s32 levelIndex = runAgentMenu(); <- this loops internally until complete and returns the level to load. updateAge

Source from the content-addressed store, hash-verified

564 } // Outer Loop
565 ****************************************************/
566 void DarkForces::loopGame()
567 {
568 updateTime();
569
570 switch (s_runGameState.state)
571 {
572 case GSTATE_STARTUP_CUTSCENES:
573 {
574 s_runGameState.state = GSTATE_CUTSCENE;
575 s_invalidLevelIndex = JTRUE;
576
577 // Always force cutscenes off for demo playbac for cutscenes.
578 if (isDemoPlayback())
579 {
580 s_runGameState.cutscenesEnabled = JFALSE;
581 }
582
583 if (s_runGameState.cutscenesEnabled && !s_runGameState.startLevel)
584 {
585 cutscene_play(10);
586 }
587 else
588 {
589 startNextMode();
590 }
591 } break;
592 case GSTATE_AGENT_MENU:
593 {
594 bool levelSelected = false;
595 if (s_runGameState.startLevel)
596 {
597 s_runGameState.abortLevel = JFALSE;
598 s_runGameState.levelIndex = s_runGameState.startLevel;
599 s_runGameState.startLevel = 0;
600 levelSelected = true;
601 }
602 else if (!agentMenu_update(&s_runGameState.levelIndex))
603 {
604 agent_updateAgentSavedData();
605 levelSelected = true;
606 }
607
608 if (levelSelected)
609 {
610 s_invalidLevelIndex = JTRUE;
611 for (s32 i = 0; i < TFE_ARRAYSIZE(s_cutsceneData); i++)
612 {
613 if (s_cutsceneData[i].levelIndex >= 0 && s_cutsceneData[i].levelIndex == s_runGameState.levelIndex)
614 {
615 s_runGameState.cutsceneIndex = i;
616 s_invalidLevelIndex = JFALSE;
617 break;
618 }
619 }
620
621 lmusic_reset();
622 s_runGameState.abortLevel = JFALSE;
623 agent_setNextLevelByIndex(s_runGameState.levelIndex);

Callers 1

mainFunction · 0.80

Calls 15

updateTimeFunction · 0.85
isDemoPlaybackFunction · 0.85
cutscene_playFunction · 0.85
startNextModeFunction · 0.85
agentMenu_updateFunction · 0.85
lmusic_resetFunction · 0.85
cutscene_updateFunction · 0.85
cutsceneCaptionsEnabledFunction · 0.85
drawCaptionsFunction · 0.85
clearActiveCaptionsFunction · 0.85

Tested by

no test coverage detected