int main (){ printf("Start game\n"); initBoard(); /*ボードの初期化*/ showBoard(); /*ボードの表示*/ initStone(); /*石の初期化*/ initPlayer(); /*プレーヤーの初期化*/ cont = 1; /*継続判定の初期化*/ judge = 0; /*勝ち判定初期化*/ printf("\n"); while (cont == 1){ input(); /*マス目の選択受付*/ showBoard(); checkWin(); /*勝ち判定*/ if (judge == 1){ break; /*勝ち判定ありの場合、ループ脱出*/ } else { check(); /*ゲーム継続可能性(空きマスがあるか)の判定*/ changeStone(); changePlayer(); printf("\n"); } } printf("\n"); dispWinner(); /*judgeの値により勝者表示OR引分宣言*/ return 0; }
int main( int argc, char * argv[] ) { #ifdef Q_WS_X11 bool useGUI = getenv( "DISPLAY" ) != 0; #else bool useGUI = true; #endif // Q_WS_X11 #ifdef Q_OS_WIN QDir::setCurrent( QFileInfo(currentExecutableFilePath()).path() ); #endif QApplication a( argc, argv, useGUI ); if( !initConfig( "classmaker.ini" ) ) return -1; Schema * schema = 0; QString fileName; for( int i=1; i<argc; i++ ) { QString arg( argv[i] ); if( arg == "--schema" || arg == "-s" ){ if( i+1==argc ) { usage(); return 1; } fileName = QString( argv[i+1] ); if( i<argc && QFile::exists( fileName ) ){ schema = Schema::createFromXmlSchema( fileName, /*isfilename=*/true, /*ignoreDocs=*/false ); }else{ LOG_1( "File not found: " + fileName ); return 1; } i++; } else if( arg == "--output" || arg == "-o" ) { if( i+1==argc ) { usage(); return 1; } if( !schema ) LOG_1( "Must first specify the schema to load with --schema" ); else if( i >= argc || !QDir( argv[i+1] ).exists() ) LOG_1( "Output Directory not found" ); else { writeSource( schema, argv[i+1] ); return 0; } return 1; } else if ( arg == "--help" || arg == "-h" ) { usage(); return 1; } } initStone( argc, argv ); if( useGUI ) { MainWindow * mw = new MainWindow( schema ); if( !fileName.isEmpty() ) mw->setFileName( fileName ); if( schema ) mw->setSchema( schema ); mw->show(); int i = a.exec(); shutdown(); return 0; } else { qWarning( "Classmaker usage without xserver is limited to the -s -o options" ); } shutdown(); return 0; }
int main( int argc, char * argv[] ) { int result=0; #ifdef Q_OS_WIN hMutex = CreateMutex( NULL, true, L"FreezerSingleProcessMutex"); if (hMutex == NULL) { LOG_5( "Error: Couldn't create mutex, exiting" ); return false; } if( GetLastError() == ERROR_ALREADY_EXISTS ) { LOG_5( "Error: Another process owns the mutex, exiting" ); QList<int> pids; if( pidsByName( "freezer.exe", &pids ) ) { int otherProcessId = pids[0]; if( otherProcessId == processID() ) { if( pids.size() < 2 ) return false; otherProcessId = pids[1]; } LOG_5( "Trying to find window with process pid of " + QString::number( otherProcessId ) ); EnumWindows( AFEnumWindowsProc, LPARAM(otherProcessId) ); } return false; } QLibrary excdll( "exchndl.dll" ); if( !excdll.load() ) { qWarning( excdll.errorString().toLatin1().constData() ); } disableWindowsErrorReporting( "assburner.exe" ); #endif signal(SIGSEGV, oops_handler); signal(SIGABRT, oops_handler); QApplication a(argc, argv); if( !initConfig( "freezer.ini" ) ) { #ifndef Q_OS_WIN // Fallback if the config file does not exist in the current folder if( !initConfig( "/etc/ab/freezer.ini" ) ) #endif return -1; } #ifdef Q_OS_WIN QString cp = "h:/public/" + getUserName() + "/Blur"; if( !QDir( cp ).exists() ) cp = "C:/Documents and Settings/" + getUserName(); initUserConfig( cp + "/freezer.ini" ); #else initUserConfig( QDir::homePath() + "/.freezer" ); #endif initStone( argc, argv ); classes_loader(); initStoneGui(); { JobList showJobs; bool showTime = false; QString currentView; QStringList loadViewFiles; for( int i = 1; i<argc; i++ ){ QString arg( argv[i] ); if( arg == "-h" || arg == "--help" ) { LOG_1( QString("Freezer v") + VERSION ); LOG_1( "Options:" ); LOG_1( "-current-render" ); LOG_1( "\tShow the current job that is rendering on this machine\n" ); LOG_1( "-show-time" ); LOG_1( "\tOutputs summary of time executed for all sql statement at program close\n" ); LOG_1( "-user USER" ); LOG_1( "\tSet the logged in user to USER: Requires Admin Privs" ); LOG_1( "-current-view VIEWNAME" ); LOG_1( "\tMake VIEWNAME the active view, once they are all loaded" ); LOG_1( "-load-view FILE" ); LOG_1( "\tRead a saved view config from FILE" ); LOG_1( stoneOptionsHelp() ); return 0; } else if( arg.endsWith("-show-time") ) showTime = true; else if( arg.endsWith( "-current-render" ) ) { showJobs = Host::currentHost().activeAssignments().jobs(); } else if( arg.endsWith("-user") && (i+1 < argc) ) { QString impersonate( argv[++i] ); if( User::hasPerms( "User", true ) ) // If you can edit users, you can login as anyone User::setCurrentUser( impersonate ); } else if( arg.endsWith("-current-view") && (i+1 < argc) ) { currentView = QString( argv[++i] ); } else if( arg.endsWith("-load-view") && (i+1 < argc) ) { loadViewFiles << QString(argv[++i]); } } // Share the database across threads, each with their own connection FreezerCore::setDatabaseForThread( classesDb(), Connection::createFromIni( config(), "Database" ) ); { loadPythonPlugins(); MainWindow m; IniConfig & cfg = userConfig(); cfg.pushSection( "MainWindow" ); QStringList fg = cfg.readString( "FrameGeometry", "" ).split(','); cfg.popSection(); if( fg.size()==4 ) { m.resize( QSize( fg[2].toInt(), fg[3].toInt() ) ); m.move( QPoint( fg[0].toInt(), fg[1].toInt() ) ); } if( showJobs.size() ) m.jobPage()->setJobList( showJobs ); foreach( QString viewFile, loadViewFiles ) m.loadViewFromFile( viewFile ); if( !currentView.isEmpty() ) m.setCurrentView( currentView ); m.show(); result = a.exec(); if( showTime ){ Database * tm = Database::current(); LOG_5( " Sql Time Elapsed" ); LOG_5( "| Select | Update | Insert | Delete | Total |" ); LOG_5( "-----------------------------------------------" ); LOG_5( QString( "| %1 | %2 | %3 | %4 | %5 |\n") .arg( tm->elapsedSqlTime( Table::SqlSelect ) ) .arg( tm->elapsedSqlTime( Table::SqlUpdate ) ) .arg( tm->elapsedSqlTime( Table::SqlInsert ) ) .arg( tm->elapsedSqlTime( Table::SqlDelete ) ) .arg( tm->elapsedSqlTime() ) ); LOG_5( " Index Time Elapsed" ); LOG_5( "| Added | Updated | Incoming | Deleted | Search | Total |" ); LOG_5( "-----------------------------------------------" ); LOG_5( QString( "| %1 | %2 | %3 | %4 | %5 | %6 |\n") .arg( tm->elapsedIndexTime( Table::IndexAdded ) ) .arg( tm->elapsedIndexTime( Table::IndexUpdated ) ) .arg( tm->elapsedIndexTime( Table::IndexIncoming ) ) .arg( tm->elapsedIndexTime( Table::IndexRemoved ) ) .arg( tm->elapsedIndexTime( Table::IndexSearch ) ) .arg( tm->elapsedIndexTime() ) ); tm->printStats(); } } } shutdown(); #ifdef Q_OS_WIN CloseHandle( hMutex ); #endif return result; }