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

Function main

TheForceEngine/main.cpp:500–1016  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

498}
499
500int main(int argc, char* argv[])
501{
502 #if INSTALL_CRASH_HANDLER
503 TFE_CrashHandler::setProcessExceptionHandlers();
504 TFE_CrashHandler::setThreadExceptionHandlers();
505 #endif
506
507 // Paths
508 bool pathsSet = true;
509 pathsSet &= TFE_Paths::setProgramPath();
510 pathsSet &= TFE_Paths::setProgramDataPath("TheForceEngine");
511 pathsSet &= TFE_Paths::setUserDocumentsPath("TheForceEngine");
512 TFE_System::openRotatingLog("the_force_engine_log.txt");
513 TFE_System::logWrite(LOG_MSG, "Main", "The Force Engine %s", c_gitVersion);
514 if (!pathsSet)
515 {
516 TFE_System::logWrite(LOG_ERROR, "Main", "Cannot set paths.");
517 return PROGRAM_ERROR;
518 }
519
520 // Before loading settings, read in the Input key lists.
521 if (!TFE_Input::loadKeyNames("UI_Text/KeyText.txt"))
522 {
523 TFE_System::logWrite(LOG_ERROR, "Main", "Cannot load key names.");
524 return PROGRAM_ERROR;
525 }
526
527 if (!TFE_System::loadMessages("UI_Text/TfeMessages.txt"))
528 {
529 TFE_System::logWrite(LOG_ERROR, "Main", "Cannot load TFE messages.");
530 return PROGRAM_ERROR;
531 }
532
533 // Initialize settings so that the paths can be read.
534 bool firstRun;
535 if (!TFE_Settings::init(firstRun))
536 {
537 TFE_System::logWrite(LOG_ERROR, "Main", "Cannot load settings.");
538 return PROGRAM_ERROR;
539 }
540
541 // Override settings with command line options.
542 parseCommandLine(argc, argv);
543
544 // Setup game paths.
545 // Get the current game.
546 const TFE_Game* game = TFE_Settings::getGame();
547 const TFE_GameHeader* gameHeader = TFE_Settings::getGameHeader(game->game);
548 TFE_Paths::setPath(PATH_SOURCE_DATA, gameHeader->sourcePath);
549 TFE_Paths::setPath(PATH_EMULATOR, gameHeader->emulatorPath);
550 TFE_Paths::setRemasterDocsPath(game->id);
551
552 // Validate the current game path.
553 validatePath();
554
555 TFE_System::logWrite(LOG_MSG, "Paths", "Program Path: \"%s\"", TFE_Paths::getPath(PATH_PROGRAM));
556 TFE_System::logWrite(LOG_MSG, "Paths", "Program Data: \"%s\"", TFE_Paths::getPath(PATH_PROGRAM_DATA));
557 TFE_System::logWrite(LOG_MSG, "Paths", "User Documents: \"%s\"", TFE_Paths::getPath(PATH_USER_DOCUMENTS));

Callers

nothing calls this directly

Calls 15

openRotatingLogFunction · 0.85
logWriteFunction · 0.85
loadKeyNamesFunction · 0.85
loadMessagesFunction · 0.85
parseCommandLineFunction · 0.85
getGameFunction · 0.85
getGameHeaderFunction · 0.85
generateScreenshotTimeFunction · 0.85
initReplaysFunction · 0.85
sdlInitFunction · 0.85
logCloseFunction · 0.85
getWindowSettingsFunction · 0.85

Tested by

no test coverage detected