/** * \brief This is the function where CG beings * * \param argc number of arguments * \param argv pointer to char arrays where * where the passed arguments are stored * in the process * \return This always returns 0. If * some errors appear, take a look * at the Logfile. * */ int main(int argc, char *argv[]) { #if SDL_VERSION_ATLEAST(2, 0, 0) #ifdef ANDROID SDL_SetMainReady( ); #endif #endif // Check if CG should look into a given directory if(argc >= 1) { binary_dir = argv[0]; size_t slashpos = findLastPathSep(binary_dir); if(slashpos != std::string::npos) { binary_dir.erase(slashpos); binary_dir = SystemNativeToUtf8(binary_dir); } else { binary_dir = "."; } } else { warnings << "Binary-argument not given, assuming current dir" << endl; binary_dir = "."; } binary_dir = GetAbsolutePath(binary_dir); InitThreadPool(); InitSearchPaths(); g_pLogFile->CreateLogfile("CGLog.html"); // The Game Class instance is the main class managing whole // interpreter instance. TODO: It should be a singleton CGame Game; //////////////////////////// // Initialize Game Engine // //////////////////////////// if( Game.init( argc, argv ) ) { /////////////////////// // Start Game Engine // /////////////////////// Game.run(); } std::cout << "Thank you very much for playing this game!" << std::endl; UnInitThreadPool(); return 0; }
/** * \brief This is the function where CG beings * * \param argc number of arguments * \param argv pointer to char arrays where * where the passed arguments are stored * in the process * \return This always returns 0. If * some errors appear, take a look * at the Logfile. * */ int main(int argc, char *argv[]) { #if SDL_VERSION_ATLEAST(2, 0, 0) #ifdef ANDROID SDL_SetMainReady( ); #endif #endif // Check if CG should look into a given directory std::string binary_dir; if(argc >= 1) { binary_dir = argv[0]; size_t slashpos = findLastPathSep(binary_dir); if(slashpos != std::string::npos) { binary_dir.erase(slashpos); binary_dir = SystemNativeToUtf8(binary_dir); } else { binary_dir = "."; } } else { warnings << "Binary-argument not given, assuming current dir" << endl; binary_dir = "."; } SetBinaryDir( GetAbsolutePath(binary_dir) ); InitThreadPool(); InitSearchPaths(g_pSettings->getConfigFileName()); gLogging.CreateLogfile("CGLog.html", APP_NAME, CGVERSION); // Check if there are settings on the PC, otherwise use defaults. if(!g_pSettings->loadDrvCfg()) { //m_firsttime = true; gLogging.textOut(RED,"First time message: CG didn't find the driver config file. "); gLogging.textOut(RED,"However, it generated some default values and will save them now.\n"); g_pSettings->saveDrvCfg(); } gLogging.textOut(GREEN,"Loading game options...\n"); if(!g_pSettings->loadGameOptions()) { gLogging.textOut(RED,"Cannot do loading defaults...\n"); g_pSettings->loadDefaultGameCfg(); } // Init the Game sound g_pSound->init(); //////////////////////////////////////////////////// // Initialize CG and run the main cycle if worthy // //////////////////////////////////////////////////// if( gApp.init( argc, argv ) ) { //////////////////////////////// // Set GameLauncher as Engine // //////////////////////////////// gApp.setEngine(new CGameLauncher(false)); ////////////////////////////// // Run the Commander Genius // ////////////////////////////// gApp.runMainCycle(); } g_pSettings->saveDispCfg(); UnInitThreadPool(); return 0; }