BOOLEAN InitializeGame(void) { UINT32 uiIndex; giStartingMemValue = MemGetFree( ); ClearAllDebugTopics(); RegisterJA2DebugTopic( TOPIC_JA2OPPLIST, "Reg" ); //RegisterJA2DebugTopic( TOPIC_MEMORY_MANAGER, "Reg" ); // Initlaize mouse subsystems MSYS_Init( ); InitButtonSystem(); InitCursors( ); // Init Fonts if ( !InitializeFonts( ) ) { // Send debug message and quit DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "COULD NOT INUT FONT SYSTEM..."); return( ERROR_SCREEN ); } //Deletes all the Temp files in the Maps\Temp directory InitTacticalSave( TRUE ); // Initialize Game Screens. for (uiIndex = 0; uiIndex < MAX_SCREENS; uiIndex++) { if ((*(GameScreens[uiIndex].InitializeScreen))() == FALSE) { // Failed to initialize one of the screens. return FALSE; } } //Init the help screen system InitHelpScreenSystem(); //Loads the saved (if any) general JA2 game settings LoadGameSettings(); //Initialize the Game options ( Gun nut, scifi and dif. levels InitGameOptions(); // preload mapscreen graphics HandlePreloadOfMapGraphics( ); guiCurrentScreen = INIT_SCREEN; return TRUE; }
int Initialize (int argc, char *argv[]) { /*---*/PrintLog ("Initializing data\n"); gameData.time.xGameTotal = 0; signal (SIGABRT, D2SignalHandler); signal (SIGFPE, D2SignalHandler); signal (SIGILL, D2SignalHandler); signal (SIGINT, D2SignalHandler); signal (SIGSEGV, D2SignalHandler); signal (SIGTERM, D2SignalHandler); #ifdef _WIN32 SDL_SetSpecialKeyHandling (0); #endif hogFileManager.Init ("", ""); InitGameStates (); gameData.Init (); InitExtraGameInfo (); InitNetworkData (); InitGameOptions (0); InitArgs (argc, argv); GetAppFolders (); if (FindArg ("-debug-printlog") || FindArg ("-printlog")) { char fnErr [FILENAME_LEN]; #ifdef __unix__ sprintf (fnErr, "%s/d2x.log", getenv ("HOME")); fErr = fopen (fnErr, "wt"); #else sprintf (fnErr, "%s/d2x.log", gameFolders.szGameDir); fErr = fopen (fnErr, "wt"); #endif } PrintLog ("%s\n", DESCENT_VERSION); InitArgs (argc, argv); GetAppFolders (); #ifdef D2X_MEM_HANDLER MemInit (); #endif error_init (NULL, NULL); *szAutoHogFile = *szAutoMission = '\0'; EvalArgs (); InitGameOptions (1); DefaultAllSettings (); gameOpts->render.nMathFormat = gameOpts->render.nDefMathFormat; /*---*/PrintLog ("Loading text resources\n"); /*---*/PrintLog ("Loading main hog file\n"); if (!(hogFileManager.Init ("descent2.hog", gameFolders.szDataDir) || (gameStates.app.bDemoData = hogFileManager.Init ("d2demo.hog", gameFolders.szDataDir)))) { /*---*/PrintLog ("Descent 2 data not found\n"); Error (TXT_NO_HOG2); } LoadGameTexts (); /*---*/PrintLog ("Reading configuration file\n"); ReadConfigFile (); if (!InitGraphics ()) return 1; console.Setup (SMALL_FONT, &screen, CON_NUM_LINES, 0, 0, screen.Width (), screen.Height () / 2); if (gameStates.app.bProgressBars && gameOpts->menus.nStyle) InitializeGauge (); else { CMenu m (1); int key = 0; m.AddGauge ("", -1, 1000); // dummy for InitializePoll() messageBox.Show (TXT_INITIALIZING); for (loadOp = 0; loadOp < InitGaugeSize (); ) InitializePoll (m, key, 0, 0); } messageBox.Clear (); PrintBanner (); if (!gameStates.app.bAutoRunMission) { /*---*/PrintLog ("Showing title screens\n"); if (!ShowTitleScreens ()) ShowLoadingScreen (); } if (FindArg ("-norun")) return 0; /*---*/PrintLog ("Loading hires models\n"); LoadHiresModels (0); LoadModelData (); ogl.InitShaders (); //required for some menus to show all possible choices return 0; }