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

Function loadReplayWrapper

TheForceEngine/TFE_Input/replay.cpp:1010–1070  ·  view source on GitHub ↗

This is a replay wrapper that handles agents and replay configuration

Source from the content-addressed store, hash-verified

1008
1009 // This is a replay wrapper that handles agents and replay configuration
1010 void loadReplayWrapper(string replayFile, string modName, string levelId)
1011 {
1012 TFE_System::logWrite(LOG_MSG, "Replay", "Loading Replay File = %s Modname = %s Levelid = %s", replayFile.c_str(), modName.c_str(), levelId.c_str());
1013
1014 // If you are replaying a demo, you should not be recording.
1015
1016 TFE_Settings::getGameSettings()->df_enableRecording = false;
1017 TFE_Settings::getGameSettings()->df_enableReplay = true;
1018
1019 // Ensure you exit the current game in case you are running
1020 task_freeAll();
1021 TFE_FrontEndUI::exitToMenu();
1022
1023 // Handle Agent
1024 agentMenu_setAgentCount(agent_loadData());
1025
1026 // Handle starting parameters
1027 char selectedModCmd[TFE_MAX_PATH];
1028 sprintf(selectedModCmd, "-u%s", modName.c_str());
1029
1030 std::vector<std::string> modOverrides;
1031 modOverrides.push_back("-c0"); // No cutscenes
1032
1033 // Override level
1034 if (strlen(levelId.c_str()) > 0)
1035 {
1036 string levelOverride = "-l" + levelId;
1037 modOverrides.push_back(levelOverride);
1038 }
1039
1040 // Set the replay parameters
1041 TFE_FrontEndUI::setModOverrides(modOverrides);
1042
1043
1044 sprintf(s_replayPath, "%s", replayFile.c_str());
1045
1046
1047 // Load the replay header so we can get the agent data
1048 replayFilehandler = serializeHeaderAgentInfo(&s_replayFile, false);
1049
1050 // Make sure you read all the mods before setting the selected mod
1051 TFE_FrontEndUI::modLoader_read();
1052
1053 // Set the selected mod and GAME state
1054 TFE_FrontEndUI::setSelectedMod(selectedModCmd);
1055 TFE_FrontEndUI::setState(APP_STATE_GAME);
1056
1057 // Preserve cutscene setting and disable them for the replay
1058 cutscenesEnabled = getCutscenesEnabled();
1059 enableCutscenes(JFALSE);
1060
1061 // Wipe any current game that may be running and wipe the menu
1062 IGame* curGame = TFE_FrontEndUI::getCurrentGame();
1063 curGame = nullptr;
1064 TFE_FrontEndUI::clearMenuState();
1065
1066 // This is needed to check if the replay is initialized in Dark Forces Main
1067 replayInitialized = true;

Callers 2

loadReplayFromPathFunction · 0.85
replayDialogFunction · 0.85

Calls 15

logWriteFunction · 0.85
getGameSettingsFunction · 0.85
task_freeAllFunction · 0.85
exitToMenuFunction · 0.85
agentMenu_setAgentCountFunction · 0.85
agent_loadDataFunction · 0.85
setModOverridesFunction · 0.85
serializeHeaderAgentInfoFunction · 0.85
modLoader_readFunction · 0.85
setSelectedModFunction · 0.85
setStateFunction · 0.85
getCutscenesEnabledFunction · 0.85

Tested by

no test coverage detected