int Spi::sync() { uint32_t timer; int res = 0; if (!m_autoSlaveSelect) return 0; SSP_IntConfig(LPC_SSP1, SSP_INTCFG_RX, DISABLE); setTimer(&timer); while(1) { if(checkIdle()) { res = 1; break; } if (getTimer(timer)>500000) // timeout .5 seconds break; } SSP_IntConfig(LPC_SSP1, SSP_INTCFG_RX, ENABLE); return res; }
bool AutoAway::modules_loaded() { options_i = (OptionsI *)core_i->get_interface(INAME_OPTIONS); QSettings settings; AutoAwayOptions::Settings s; s.enable = settings.value("AutoAway/Enable", true).toBool(); s.min = settings.value("AutoAway/Minutes", 15).toInt(); s.status = (GlobalStatus)settings.value("AutoAway/Status", (int)ST_SHORTAWAY).toInt(); s.restore = settings.value("AutoAway/Restore", true).toBool(); current_settings = s; if(options_i) { opt = new AutoAwayOptions(s); connect(opt, SIGNAL(applied()), this, SLOT(options_applied())); options_i->add_page("Auto Away", opt); } timer.setInterval(5000); connect(&timer, SIGNAL(timeout()), this, SLOT(checkIdle())); timer.start(); last_mouse_pos = QCursor::pos(); idle_time = QDateTime::currentDateTime(); idle = false; return true; }
void DtvDaemon::timerEvent(QTimerEvent *) { bool idle = true; emit checkIdle(&idle); if (idle) { lockfile->close(); server.close(); QCoreApplication::exit(); } }
WebSocket::WebSocket(QWebSocket *sock, QString ID, AuthorizationManager *auth){ SockID = ID; SockAuthToken.clear(); //nothing set initially SOCKET = sock; SendAppCafeEvents = false; AUTHSYSTEM = auth; idletimer = new QTimer(this); idletimer->setInterval(600000); //10-minute timeout idletimer->setSingleShot(true); connect(idletimer, SIGNAL(timeout()), this, SLOT(checkIdle()) ); connect(SOCKET, SIGNAL(textMessageReceived(const QString&)), this, SLOT(EvaluateMessage(const QString&)) ); connect(SOCKET, SIGNAL(binaryMessageReceived(const QByteArray&)), this, SLOT(EvaluateMessage(const QByteArray&)) ); connect(SOCKET, SIGNAL(aboutToClose()), this, SLOT(SocketClosing()) ); idletimer->start(); }
void LibVNCServer::init( uint port ) { uint bpp = (m_screen->size/(m_screen->width()*m_screen->height())); m_screenInfo = rfbGetScreen( 0, 0, m_screen->width(), m_screen->height(), 8, 3, bpp ); m_screenInfo->frameBuffer = new char[m_screen->size]; m_screenInfo->ptrAddEvent = ptrAddEvent; m_screenInfo->kbdAddEvent = kbdAddEvent; m_screenInfo->displayHook = displayHook; m_screenInfo->screenData = this; m_screenInfo->port += port; m_screen->data = reinterpret_cast< uchar* >( m_screenInfo->frameBuffer ); if( !myCursor ) { myCursor = rfbMakeXCursor( 19, 19, (char*) cur, (char*) mask ); } m_screenInfo->cursor = myCursor; rfbInitServer( m_screenInfo ); switch( m_screenInfo->depth ) { case 32: updateServerFormat( m_screenInfo, 8, 8, 8, 16, 8, 0 ); break; //case 24: updateServerFormat( m_screenInfo, 8, 8, 8, 16, 8, 0 ); break; case 16: updateServerFormat( m_screenInfo, 5, 6, 5, 11, 5, 0 ); break; default: qFatal( "Unsupported screen depth %d, %d", m_screenInfo->depth, m_screen->depth() ); } // Effectively this limits updates to 20fps m_screenInfo->deferUpdateTime = 50; if( !qgetenv("TOKEN_PATH").isEmpty() ) { m_screenInfo->authPasswdData = (void*) &passwords; m_screenInfo->passwordCheck = LibVNCServerCheckPasswordByList; } m_timer = new QTimer( this ); m_timer->start( 0 ); connect( m_timer, SIGNAL( timeout() ), this, SLOT( processEvents() ) ); m_timerIdle = new QTimer( this ); m_timerIdle->setSingleShot( true ); m_timerIdle->start( 30000 ); connect( m_timerIdle, SIGNAL( timeout() ), this, SLOT( checkIdle() ) ); }
WebSocket::WebSocket(QWebSocket *sock, QString ID, AuthorizationManager *auth){ SockID = ID; SockAuthToken.clear(); //nothing set initially SOCKET = sock; TSOCKET = 0; AUTHSYSTEM = auth; SockPeerIP = SOCKET->peerAddress().toString(); LogManager::log(LogManager::HOST,"New Connection: "+SockPeerIP); idletimer = new QTimer(this); idletimer->setInterval(IDLETIMEOUTMINS*60000); //connection timout for idle sockets idletimer->setSingleShot(true); connect(idletimer, SIGNAL(timeout()), this, SLOT(checkIdle()) ); connect(SOCKET, SIGNAL(textMessageReceived(const QString&)), this, SLOT(EvaluateMessage(const QString&)) ); connect(SOCKET, SIGNAL(binaryMessageReceived(const QByteArray&)), this, SLOT(EvaluateMessage(const QByteArray&)) ); connect(SOCKET, SIGNAL(aboutToClose()), this, SLOT(SocketClosing()) ); idletimer->start(); }
//======================= // PUBLIC //======================= WebServer::WebServer() : QWebSocketServer("pc-restserver", QWebSocketServer::NonSecureMode){ csock = 0; //no current socket connected //Setup all the various settings idletimer = new QTimer(this); idletimer->setInterval(5000); //every 5 seconds idletimer->setSingleShot(true); //Any SSL changes /*QSslConfiguration ssl = this->sslConfiguration(); ssl.setProtocol(QSsl::SecureProtocols); this->setSslConfiguration(ssl);*/ //Setup Connections connect(idletimer, SIGNAL(timeout()), this, SLOT(checkIdle()) ); connect(this, SIGNAL(closed()), this, SLOT(ServerClosed()) ); connect(this, SIGNAL(serverError(QWebSocketProtocol::CloseCode)), this, SLOT(ServerError(QWebSocketProtocol::CloseCode)) ); connect(this, SIGNAL(newConnection()), this, SLOT(NewSocketConnection()) ); connect(this, SIGNAL(acceptError(QAbstractSocket::SocketError)), this, SLOT(NewConnectError(QAbstractSocket::SocketError)) ); connect(this, SIGNAL(originAuthenticationRequired(QWebSocketCorsAuthenticator*)), this, SLOT(OriginAuthRequired(QWebSocketCorsAuthenticator*)) ); connect(this, SIGNAL(peerVerifyError(const QSslError&)), this, SLOT(PeerVerifyError(const QSslError&)) ); connect(this, SIGNAL(sslErrors(const QList<QSslError>&)), this, SLOT(SslErrors(const QList<QSslError>&)) ); }
WebSocket::WebSocket(QSslSocket *sock, QString ID, AuthorizationManager *auth){ SockID = ID; SockAuthToken.clear(); //nothing set initially TSOCKET = sock; SOCKET = 0; SockPeerIP = TSOCKET->peerAddress().toString(); LogManager::log(LogManager::HOST,"New Connection: "+SockPeerIP); AUTHSYSTEM = auth; idletimer = new QTimer(this); idletimer->setInterval(IDLETIMEOUTMINS*60000); //connection timout for idle sockets idletimer->setSingleShot(true); connect(idletimer, SIGNAL(timeout()), this, SLOT(checkIdle()) ); connect(TSOCKET, SIGNAL(readyRead()), this, SLOT(EvaluateTcpMessage()) ); connect(TSOCKET, SIGNAL(aboutToClose()), this, SLOT(SocketClosing()) ); connect(TSOCKET, SIGNAL(encrypted()), this, SLOT(nowEncrypted()) ); connect(TSOCKET, SIGNAL(peerVerifyError(const QSslError &)), this, SLOT(peerError(const QSslError &)) ); connect(TSOCKET, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(SslError(const QList<QSslError> &)) ); //qDebug() << " - Starting Server Encryption Handshake"; TSOCKET->startServerEncryption(); //qDebug() << " - Socket Encrypted:" << TSOCKET->isEncrypted(); idletimer->start(); }
bool MWMechanics::AiWander::execute (const MWWorld::Ptr& actor) { if(mDuration) { // End package if duration is complete or mid-night hits: MWWorld::TimeStamp currentTime = MWBase::Environment::get().getWorld()->getTimeStamp(); if(currentTime.getHour() >= mStartTime.getHour() + mDuration) { if(!mRepeat) { stopWalking(actor, mPathFinder); return true; } else mStartTime = currentTime; } else if(int(currentTime.getHour()) == 0 && currentTime.getDay() != mStartTime.getDay()) { if(!mRepeat) { stopWalking(actor, mPathFinder); return true; } else mStartTime = currentTime; } } ESM::Position pos = actor.getRefData().getPosition(); if(!mStoredAvailableNodes) { mStoredAvailableNodes = true; mPathgrid = MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().search(*actor.getCell()->mCell); mCellX = actor.getCell()->mCell->mData.mX; mCellY = actor.getCell()->mCell->mData.mY; if(!mPathgrid) mDistance = 0; else if(mPathgrid->mPoints.empty()) mDistance = 0; if(mDistance) { mXCell = 0; mYCell = 0; if(actor.getCell()->mCell->isExterior()) { mXCell = mCellX * ESM::Land::REAL_SIZE; mYCell = mCellY * ESM::Land::REAL_SIZE; } Ogre::Vector3 npcPos(actor.getRefData().getPosition().pos); npcPos[0] = npcPos[0] - mXCell; npcPos[1] = npcPos[1] - mYCell; for(unsigned int counter = 0; counter < mPathgrid->mPoints.size(); counter++) { Ogre::Vector3 nodePos(mPathgrid->mPoints[counter].mX, mPathgrid->mPoints[counter].mY, mPathgrid->mPoints[counter].mZ); if(npcPos.squaredDistance(nodePos) <= mDistance * mDistance) mAllowedNodes.push_back(mPathgrid->mPoints[counter]); } if(!mAllowedNodes.empty()) { Ogre::Vector3 firstNodePos(mAllowedNodes[0].mX, mAllowedNodes[0].mY, mAllowedNodes[0].mZ); float closestNode = npcPos.squaredDistance(firstNodePos); unsigned int index = 0; for(unsigned int counterThree = 1; counterThree < mAllowedNodes.size(); counterThree++) { Ogre::Vector3 nodePos(mAllowedNodes[counterThree].mX, mAllowedNodes[counterThree].mY, mAllowedNodes[counterThree].mZ); float tempDist = npcPos.squaredDistance(nodePos); if(tempDist < closestNode) index = counterThree; } mCurrentNode = mAllowedNodes[index]; mAllowedNodes.erase(mAllowedNodes.begin() + index); } if(mAllowedNodes.empty()) mDistance = 0; } } MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); bool cellChange = actor.getCell()->mCell->mData.mX != mCellX || actor.getCell()->mCell->mData.mY != mCellY; if(actor.getCell()->mCell->mData.mX != player.getCell()->mCell->mData.mX) { int sideX = sgn(actor.getCell()->mCell->mData.mX - player.getCell()->mCell->mData.mX); // Check if actor is near the border of an inactive cell. If so, disable AiWander. // FIXME: This *should* pause the AiWander package instead of terminating it. if(sideX*(pos.pos[0] - actor.getCell()->mCell->mData.mX * ESM::Land::REAL_SIZE) > sideX * (ESM::Land::REAL_SIZE / 2.0 - 200)) { MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0; return true; } } if(actor.getCell()->mCell->mData.mY != player.getCell()->mCell->mData.mY) { int sideY = sgn(actor.getCell()->mCell->mData.mY - player.getCell()->mCell->mData.mY); // Check if actor is near the border of an inactive cell. If so, disable AiWander. // FIXME: This *should* pause the AiWander package instead of terminating it. if(sideY*(pos.pos[1] - actor.getCell()->mCell->mData.mY * ESM::Land::REAL_SIZE) > sideY * (ESM::Land::REAL_SIZE / 2.0 - 200)) { MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0; return true; } } // Don't try to move if you are in a new cell (ie: positioncell command called) but still play idles. if(mDistance && (cellChange || (mCellX != actor.getCell()->mCell->mData.mX || mCellY != actor.getCell()->mCell->mData.mY))) mDistance = 0; if(mChooseAction) { mPlayedIdle = 0; unsigned short idleRoll = 0; for(unsigned int counter = 1; counter < mIdle.size(); counter++) { unsigned short idleChance = mIdleChanceMultiplier * mIdle[counter]; unsigned short randSelect = (int)(rand() / ((double)RAND_MAX + 1) * int(100 / mIdleChanceMultiplier)); if(randSelect < idleChance && randSelect > idleRoll) { mPlayedIdle = counter; idleRoll = randSelect; } } if(!mPlayedIdle && mDistance) { mChooseAction = false; mMoveNow = true; } else { // Play idle animation and recreate vanilla (broken?) behavior of resetting start time of AIWander: MWWorld::TimeStamp currentTime = MWBase::Environment::get().getWorld()->getTimeStamp(); mStartTime = currentTime; playIdle(actor, mPlayedIdle + 1); mChooseAction = false; mIdleNow = true; } } if(mIdleNow) { if(!checkIdle(actor, mPlayedIdle + 1)) { mPlayedIdle = 0; mIdleNow = false; mChooseAction = true; } } if(mMoveNow && mDistance) { if(!mPathFinder.isPathConstructed()) { unsigned int randNode = (int)(rand() / ((double)RAND_MAX + 1) * mAllowedNodes.size()); Ogre::Vector3 destNodePos(mAllowedNodes[randNode].mX, mAllowedNodes[randNode].mY, mAllowedNodes[randNode].mZ); // Remove this node as an option and add back the previously used node (stops NPC from picking the same node): ESM::Pathgrid::Point temp = mAllowedNodes[randNode]; mAllowedNodes.erase(mAllowedNodes.begin() + randNode); mAllowedNodes.push_back(mCurrentNode); mCurrentNode = temp; ESM::Pathgrid::Point dest; dest.mX = destNodePos[0] + mXCell; dest.mY = destNodePos[1] + mYCell; dest.mZ = destNodePos[2]; ESM::Pathgrid::Point start; start.mX = pos.pos[0]; start.mY = pos.pos[1]; start.mZ = pos.pos[2]; mPathFinder.buildPath(start,dest,mPathgrid,mXCell,mYCell); mWalking = true; } } if(mWalking) { float zAngle = mPathFinder.getZAngleToNext(pos.pos[0],pos.pos[1],pos.pos[2]); MWBase::Environment::get().getWorld()->rotateObject(actor,0,0,zAngle,false); MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 1; // Unclog path nodes by allowing the NPC to be a small distance away from the center. This way two NPCs can be // at the same path node at the same time and both will complete instead of endlessly walking into eachother: Ogre::Vector3 destNodePos(mCurrentNode.mX, mCurrentNode.mY, mCurrentNode.mZ); Ogre::Vector3 actorPos(actor.getRefData().getPosition().pos); actorPos[0] = actorPos[0] - mXCell; actorPos[1] = actorPos[1] - mYCell; float distance = actorPos.squaredDistance(destNodePos); if(distance < 1200 || mPathFinder.checkIfNextPointReached(pos.pos[0],pos.pos[1],pos.pos[2])) { stopWalking(actor, mPathFinder); mMoveNow = false; mWalking = false; mChooseAction = true; } } return false; }
bool AiWander::execute (const MWWorld::Ptr& actor,float duration) { if (actor.getClass().isNpc()) actor.getClass().getNpcStats(actor).setDrawState(DrawState_Nothing); MWBase::World *world = MWBase::Environment::get().getWorld(); if(mDuration) { // End package if duration is complete or mid-night hits: MWWorld::TimeStamp currentTime = world->getTimeStamp(); if(currentTime.getHour() >= mStartTime.getHour() + mDuration) { if(!mRepeat) { stopWalking(actor); return true; } else mStartTime = currentTime; } else if(int(currentTime.getHour()) == 0 && currentTime.getDay() != mStartTime.getDay()) { if(!mRepeat) { stopWalking(actor); return true; } else mStartTime = currentTime; } } ESM::Position pos = actor.getRefData().getPosition(); if(!mStoredAvailableNodes) { mStoredAvailableNodes = true; mPathgrid = world->getStore().get<ESM::Pathgrid>().search(*actor.getCell()->mCell); mCellX = actor.getCell()->mCell->mData.mX; mCellY = actor.getCell()->mCell->mData.mY; if(!mPathgrid) mDistance = 0; else if(mPathgrid->mPoints.empty()) mDistance = 0; if(mDistance) { mXCell = 0; mYCell = 0; if(actor.getCell()->mCell->isExterior()) { mXCell = mCellX * ESM::Land::REAL_SIZE; mYCell = mCellY * ESM::Land::REAL_SIZE; } Ogre::Vector3 npcPos(actor.getRefData().getPosition().pos); npcPos[0] = npcPos[0] - mXCell; npcPos[1] = npcPos[1] - mYCell; for(unsigned int counter = 0; counter < mPathgrid->mPoints.size(); counter++) { Ogre::Vector3 nodePos(mPathgrid->mPoints[counter].mX, mPathgrid->mPoints[counter].mY, mPathgrid->mPoints[counter].mZ); if(npcPos.squaredDistance(nodePos) <= mDistance * mDistance) mAllowedNodes.push_back(mPathgrid->mPoints[counter]); } if(!mAllowedNodes.empty()) { Ogre::Vector3 firstNodePos(mAllowedNodes[0].mX, mAllowedNodes[0].mY, mAllowedNodes[0].mZ); float closestNode = npcPos.squaredDistance(firstNodePos); unsigned int index = 0; for(unsigned int counterThree = 1; counterThree < mAllowedNodes.size(); counterThree++) { Ogre::Vector3 nodePos(mAllowedNodes[counterThree].mX, mAllowedNodes[counterThree].mY, mAllowedNodes[counterThree].mZ); float tempDist = npcPos.squaredDistance(nodePos); if(tempDist < closestNode) index = counterThree; } mCurrentNode = mAllowedNodes[index]; mAllowedNodes.erase(mAllowedNodes.begin() + index); } } } if(mAllowedNodes.empty()) mDistance = 0; // Don't try to move if you are in a new cell (ie: positioncell command called) but still play idles. if(mDistance && (mCellX != actor.getCell()->mCell->mData.mX || mCellY != actor.getCell()->mCell->mData.mY)) mDistance = 0; if(mChooseAction) { mPlayedIdle = 0; unsigned short idleRoll = 0; for(unsigned int counter = 0; counter < mIdle.size(); counter++) { unsigned short idleChance = mIdleChanceMultiplier * mIdle[counter]; unsigned short randSelect = (int)(rand() / ((double)RAND_MAX + 1) * int(100 / mIdleChanceMultiplier)); if(randSelect < idleChance && randSelect > idleRoll) { mPlayedIdle = counter+2; idleRoll = randSelect; } } if(!mPlayedIdle && mDistance) { mChooseAction = false; mMoveNow = true; } else { // Play idle animation and recreate vanilla (broken?) behavior of resetting start time of AIWander: MWWorld::TimeStamp currentTime = world->getTimeStamp(); mStartTime = currentTime; playIdle(actor, mPlayedIdle); mChooseAction = false; mIdleNow = true; } } if(mIdleNow) { if(!checkIdle(actor, mPlayedIdle)) { mPlayedIdle = 0; mIdleNow = false; mChooseAction = true; } } if(mMoveNow && mDistance) { if(!mPathFinder.isPathConstructed()) { assert(mAllowedNodes.size()); unsigned int randNode = (int)(rand() / ((double)RAND_MAX + 1) * mAllowedNodes.size()); Ogre::Vector3 destNodePos(mAllowedNodes[randNode].mX, mAllowedNodes[randNode].mY, mAllowedNodes[randNode].mZ); ESM::Pathgrid::Point dest; dest.mX = destNodePos[0] + mXCell; dest.mY = destNodePos[1] + mYCell; dest.mZ = destNodePos[2]; ESM::Pathgrid::Point start; start.mX = pos.pos[0]; start.mY = pos.pos[1]; start.mZ = pos.pos[2]; mPathFinder.buildPath(start, dest, mPathgrid, mXCell, mYCell, false); if(mPathFinder.isPathConstructed()) { // Remove this node as an option and add back the previously used node (stops NPC from picking the same node): ESM::Pathgrid::Point temp = mAllowedNodes[randNode]; mAllowedNodes.erase(mAllowedNodes.begin() + randNode); mAllowedNodes.push_back(mCurrentNode); mCurrentNode = temp; mMoveNow = false; mWalking = true; } // Choose a different node and delete this one from possible nodes because it is uncreachable: else mAllowedNodes.erase(mAllowedNodes.begin() + randNode); } } if(mWalking) { float zAngle = mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1]); // TODO: use movement settings instead of rotating directly world->rotateObject(actor, 0, 0, zAngle, false); MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 1; if(mPathFinder.checkPathCompleted(pos.pos[0], pos.pos[1], pos.pos[2])) { stopWalking(actor); mMoveNow = false; mWalking = false; mChooseAction = true; } } return false; }
void WorkingDetector::internalStart() { disconnect(_timer, SIGNAL(timeout()), this, SLOT(internalStart())); _timer->start(1000); connect(_timer, SIGNAL(timeout()), this, SLOT(checkIdle())); }
void WorkingDetector::stopDetection() { disconnect(_timer, SIGNAL(timeout()), this, SLOT(checkIdle())); disconnect(_timer, SIGNAL(timeout()), this, SLOT(internalStart())); disconnect(_timer, SIGNAL(timeout()), this, SLOT(notify())); }
MainWindow::MainWindow(QWidget *parent, Qt::WFlags flags): QMainWindow(parent, flags), petri_dish(), histogramDialog(0), changed(true), auto_save(false), update_thread(this, this) { setupUi(this); connect(&timer, SIGNAL(timeout()), &petri_dish, SLOT(step())); connect(&petri_dish, SIGNAL(changed()), worldView, SLOT(queueUpdate())); //connect(&petri_dish, SIGNAL(changed()), worldView, SLOT(repaint())); connect(&petri_dish, SIGNAL(changed()), this, SLOT(set_stats())); connect(runButton, SIGNAL(clicked()), this, SLOT(start_stop())); //connect(checkIntegrity, SIGNAL(clicked()), this, SLOT(check_integrity())); connect(stepBtn, SIGNAL(clicked()), this, SLOT(step())); connect(radViewDefault, SIGNAL(clicked()), &petri_dish, SLOT(set_default_view_mode())); connect(radViewBugs, SIGNAL(clicked()), &petri_dish, SLOT(set_bugs_view_mode())); connect(radViewEnergy, SIGNAL(clicked()), &petri_dish, SLOT(set_energy_view_mode())); connect(radViewAge, SIGNAL(clicked()), &petri_dish, SLOT(set_age_view_mode())); connect(radViewSize, SIGNAL(clicked()), &petri_dish, SLOT(set_dna_size_view_mode())); connect(radViewDNA, SIGNAL(clicked()), &petri_dish, SLOT(set_dna_view_mode())); connect(radViewTerrain, SIGNAL(clicked()), &petri_dish, SLOT(set_terrain_view_mode())); connect(actionNew, SIGNAL(triggered()), this, SLOT(new_world())); connect(actionSave, SIGNAL(triggered()), this, SLOT(save_world())); connect(actionOpen, SIGNAL(triggered()), this, SLOT(load_world())); connect(actionSave_As, SIGNAL(triggered()), this, SLOT(save_as_world())); connect(settings, SIGNAL(settingsChanged()), this, SLOT(change_world())); connect(actionAutoSave, SIGNAL(triggered()), this, SLOT(autosave_world())); connect(actionCheck_Integrity, SIGNAL(triggered()), this, SLOT(check_integrity())); connect(worldView, SIGNAL(clicked(int, int)), this, SLOT(edit_bug(int, int))); connect(idleChk, SIGNAL(clicked(bool)), this, SLOT(enableIdleDetect(bool))); connect(&idleTimer, SIGNAL(timeout()), this, SLOT(checkIdle())); autosave_timer.setInterval(1000 * 60 * 2); // every two mins connect(&autosave_timer, SIGNAL(timeout()), this, SLOT(save_world())); petri_dish.set_widget(worldView); petri_dish.init(settings->getParams()); totalEnergy->setText(QString().setNum(petri_dish.get_total_energy())); spinDNAVal->setMaximum(settings->getParams().max_data); set_stats(); last_time = 0; update_time.start(); updates_per_sec = 0; //update_thread.start(); horizontalSlider->setValue(1000); timer.start(0); setAttribute(Qt::WA_QuitOnClose, true); repaint(); if(!qApp->arguments().size() > 1) { bool running; load_from_file(qApp->arguments().at(1), running); if(running) start(); } }