void CSearchWnd::OnSearchStop() { CQuickLock pLock( m_pMatches->m_pSection ); if ( ( GetAsyncKeyState( VK_SHIFT ) & 0x8000 ) == 0x8000 ) { if ( ! m_bPaused && ! m_bWaitMore ) { // Pause search if ( ! empty() ) { m_oSearches.back()->SetActive( FALSE ); m_bWaitMore = TRUE; m_bUpdate = TRUE; return; } } } for ( iterator pManaged = begin() ; pManaged != end() ; ++pManaged ) { (*pManaged)->Stop(); (*pManaged)->m_bReceive = FALSE; } m_bPaused = TRUE; m_wndPanel.Enable(); UpdateMessages(); SetModified(); }
void CMainWnd::OnTimer(UINT nIDEvent) { // Propagate to children if ( m_bInTimer ) return; m_bInTimer = TRUE; for ( POSITION pos = m_pWindows.GetIterator() ; pos ; ) { CChildWnd* pChild = m_pWindows.GetNext( pos ); pChild->PostMessage( WM_TIMER, 1, 0 ); } m_bInTimer = FALSE; // Menu Bar if ( m_wndMenuBar.IsWindowVisible() == FALSE ) ShowControlBar( &m_wndMenuBar, TRUE, FALSE ); // Update messages if ( m_bInTimer ) return; m_bInTimer = TRUE; UpdateMessages(); m_bInTimer = FALSE; }
void NotificationMessageLayer::update(float delta) { int changed = UpdateMessages(); if (changed > 0) { UpdateMessagesPos(); } }
bool CAgentManager::UpdateAgents() { mSolutionFound = UpdateMessages(); for (int i = 0; i < mAgentList.size() && mSolutionExists&&!mSolutionFound; i++) { mSolutionExists = mAgentList[i]->FindNewAssignment(); } return mSolutionExists; }
void TwitterProto::MessageLoop(void*) { debugLogA( _T("***** Entering Twitter::MessageLoop")); since_id_ = db_pod_get<twitter_id>(0,m_szModuleName,TWITTER_KEY_SINCEID,0); dm_since_id_ = db_pod_get<twitter_id>(0,m_szModuleName,TWITTER_KEY_DMSINCEID,0); bool new_account = db_get_b(0,m_szModuleName,TWITTER_KEY_NEW,1) != 0; bool popups = db_get_b(0,m_szModuleName,TWITTER_KEY_POPUP_SIGNON,1) != 0; // if this isn't set, it will automatically not turn a tweet into a msg. probably should make the default that it does turn a tweet into a message bool tweetToMsg = db_get_b(0,m_szModuleName,TWITTER_KEY_TWEET_TO_MSG,0) != 0; int poll_rate = db_get_dw(0,m_szModuleName,TWITTER_KEY_POLLRATE,80); for(unsigned int i=0;;i++) { if(m_iStatus != ID_STATUS_ONLINE) break; // if(i%10 == 0) // UpdateFriends(); if(m_iStatus != ID_STATUS_ONLINE) break; UpdateStatuses(new_account,popups, tweetToMsg); if(m_iStatus != ID_STATUS_ONLINE) break; if(i%10 == 0) UpdateMessages(new_account); if(new_account) // Not anymore! { new_account = false; db_set_b(0,m_szModuleName,TWITTER_KEY_NEW,0); } if(m_iStatus != ID_STATUS_ONLINE) break; debugLogA( _T("***** TwitterProto::MessageLoop going to sleep...")); if(SleepEx(poll_rate*1000,true) == WAIT_IO_COMPLETION) break; debugLogA( _T("***** TwitterProto::MessageLoop waking up...")); popups = true; } { ScopedLock s(twitter_lock_); twit_.set_credentials("",L"",L"",L"",L"",L"", false); } debugLogA( _T("***** Exiting TwitterProto::MessageLoop")); }
void CBrowseHostWnd::OnSkinChange() { CBaseMatchWnd::OnSkinChange(); Skin.CreateToolBar( _T("CBrowseHostWnd"), &m_wndToolBar ); m_wndFrame.OnSkinChange(); m_wndHeader.OnSkinChange(); m_wndProfile.OnSkinChange(); UpdateMessages(); }
void CSearchWnd::OnTimer(UINT_PTR nIDEvent) { CSearchPtr pManaged; CSingleLock pLock( &m_pMatches->m_pSection ); if ( pLock.Lock( 100 ) ) { if ( ! empty() ) pManaged = m_oSearches.back(); if ( pManaged ) { if ( pManaged->IsActive() && pManaged->m_nQueryCount > m_nMaxQueryCount ) { m_bWaitMore = TRUE; pManaged->SetActive( FALSE ); theApp.Message( MSG_DEBUG, _T("Search Reached Maximum Duration") ); m_bUpdate = TRUE; } // We need to keep the lock for now- release after we update the progress panel } else { // We don't need to hold the lock pLock.Unlock(); } } if ( IsPartiallyVisible() && nIDEvent == 1 ) { if ( m_bSetFocus ) { if ( m_bPanel && m_bPaused ) m_wndPanel.SetSearchFocus(); else m_wndList.SetFocus(); m_bSetFocus = FALSE; } //if ( pManaged && ( m_nCacheHubs != pManaged->m_nHubs || m_nCacheLeaves != pManaged->m_nLeaves ) ) UpdateMessages(); } // Unlock if we were locked if ( pManaged ) pLock.Unlock(); CBaseMatchWnd::OnTimer( nIDEvent ); if ( m_pMatches->m_nFilteredHits == 0 ) m_wndDetails.SetFile( NULL ); }
void CSearchWnd::ExecuteSearch() { CQuickLock pLock( m_pMatches->m_pSection ); CSearchPtr pManaged; if ( ! empty() ) pManaged = m_oSearches.back(); m_wndPanel.ShowSearch( pManaged ); if ( pManaged ) { CQuerySearchPtr pSearch = pManaged->GetSearch(); if ( pSearch && pSearch->m_bAutostart ) { if ( ! pSearch->CheckValid() ) { // Invalid search, open help window CQuerySearch::SearchHelp(); } else if ( AdultFilter.IsSearchFiltered( pSearch->m_sKeywords ) ) { // Adult search blocked, open help window CHelpDlg::Show( _T("SearchHelp.AdultSearch") ); } else { m_bPaused = FALSE; m_bWaitMore = FALSE; m_tSearch = GetTickCount(); pManaged->Stop(); pManaged->Start(); m_nMaxResults = m_pMatches->m_nGnutellaHits + Settings.Gnutella.MaxResults; m_nMaxED2KResults = m_pMatches->m_nED2KHits + Settings.eDonkey.MaxResults; m_nMaxQueryCount = pManaged->m_nQueryCount + Settings.Gnutella2.QueryLimit; m_wndPanel.Disable(); if ( m_bPanel && Settings.Search.HideSearchPanel ) { m_bPanel = FALSE; OnSkinChange(); } } } } UpdateMessages(); }
void TwitterProto::MessageLoop(void*) { LOG("***** Entering Twitter::MessageLoop"); since_id_ = db_pod_get<twitter_id>(0,m_szModuleName,TWITTER_KEY_SINCEID,0); dm_since_id_ = db_pod_get<twitter_id>(0,m_szModuleName,TWITTER_KEY_DMSINCEID,0); bool new_account = db_byte_get(0,m_szModuleName,TWITTER_KEY_NEW,1) != 0; bool popups = db_byte_get(0,m_szModuleName,TWITTER_KEY_POPUP_SIGNON,1) != 0; int poll_rate = db_dword_get(0,m_szModuleName,TWITTER_KEY_POLLRATE,80); for(unsigned int i=0;;i++) { if(m_iStatus != ID_STATUS_ONLINE) goto exit; if(i%4 == 0) UpdateFriends(); if(m_iStatus != ID_STATUS_ONLINE) goto exit; UpdateStatuses(new_account,popups); if(m_iStatus != ID_STATUS_ONLINE) goto exit; UpdateMessages(new_account); if(new_account) // Not anymore! { new_account = false; DBWriteContactSettingByte(0,m_szModuleName,TWITTER_KEY_NEW,0); } if(m_iStatus != ID_STATUS_ONLINE) goto exit; LOG("***** TwitterProto::MessageLoop going to sleep..."); if(SleepEx(poll_rate*1000,true) == WAIT_IO_COMPLETION) goto exit; LOG("***** TwitterProto::MessageLoop waking up..."); popups = true; } exit: { ScopedLock s(twitter_lock_); twit_.set_credentials("","",false); } LOG("***** Exiting TwitterProto::MessageLoop"); }
void CSearchWnd::OnSkinChange() { CBaseMatchWnd::OnSkinChange(); m_wndToolBar.Clear(); if ( ! Skin.CreateToolBar( m_bPanel ? _T("CSearchWnd.Panel") : _T("CSearchWnd.Full"), &m_wndToolBar ) ) Skin.CreateToolBar( _T("CSearchWnd"), &m_wndToolBar ); OnSize( SIZE_INTERNAL, 0, 0 ); UpdateMessages(); m_wndPanel.OnSkinChange(); Skin.Translate( _T("CMatchCtrl"), &m_wndList.m_wndHeader ); }
bool Engine::Update() { BROFILER_FRAME("MainThread") UpdateInput(); UpdateMessages(); UpdateLogic(); UpdateScene(); UpdatePhysics(); Draw(); return true; }
// // Update // void Game::Update() { list<Sprite *>::iterator it; Sprite *curSpr; static bool HPwarning = false; static int chan = NULL; if(showExitConfirm) return; UpdateMessages(); if(player->GetWeapon()==0) RELOAD_TIME = 650; if(player->GetWeapon()==1) RELOAD_TIME = 280; // Update sprites for(it = sprites.begin(); it != sprites.end(); it++) { curSpr = *it; if(curSpr->GetId() == ET_FURBY) { Furby *fb = (Furby *)curSpr; fb->Update(raycaster); } else if(curSpr->GetId() == SHOT_INDEX) { Shot *shot = (Shot *)curSpr; shot->Update(raycaster); if(shot->PointCollWith(raycaster->GetPosX(), raycaster->GetPosY())) { if(player->GetHealth() != 0) { framework->PlaySound(PlayerHurt); } AddMessage("You got hit by a shot from a furby!"); player->DecrementHealth(10); it = sprites.erase(it); } if(shot->IsVanished()) it = sprites.erase(it); } else if(curSpr->GetId() == DEATH_ANIMATION_INDEX) { DeathAnimation *da = (DeathAnimation *)curSpr; da->Update(); if(da->HasEnded()) { float itsX, itsY; itsX = da->GetPosX(); itsY = da->GetPosY(); delete da; it = sprites.erase(it); Sprite *corpse = new Sprite(spriteImgs[2], itsX, itsY, 2); sprites.push_back(corpse); } } if(curSpr->GetId() == ET_SKULL) { Skull *sk = (Skull *)curSpr; sk->Update(raycaster); } else if(curSpr->GetId() == SK_SHOT_INDEX) { SkullShot *skullshot = (SkullShot *)curSpr; skullshot->Update(raycaster); if(skullshot->PointCollWith(raycaster->GetPosX(), raycaster->GetPosY())) { if(player->GetHealth() !=0) { framework->PlaySound(PlayerHurt); } AddMessage("You got hit by a shot from a Skull!"); player->DecrementHealth(20); it = sprites.erase(it); } if(skullshot->IsVanished()) it = sprites.erase(it); } else if(curSpr->GetId() == SKDEATH_ANIMATION_INDEX) { SKDeathAnimation *skda = (SKDeathAnimation *)curSpr; skda->Update(); if(skda->HasEnded()) { float itsX, itsY; itsX = skda->GetPosX(); itsY = skda->GetPosY(); delete skda; it = sprites.erase(it); Sprite *skcorpse = new Sprite(spriteImgs[20], itsX, itsY, 2); sprites.push_back(skcorpse); } } } if(player->GetHealth() <= 30 && HPwarning == false) { chan = framework->PlaySound(HeartBeat, -1); Mix_Volume(chan, MIX_MAX_VOLUME); HPwarning = true; } if(player->GetHealth() > 30 && HPwarning == true) { Mix_HaltChannel(chan); HPwarning = false; } if(player->GetHealth() == 0) { framework->PlaySound(PlayerDead); GameOver(); } if(raycaster->MapChangeNeeded()) NextMap(); }
/** ** Game main loop. ** ** Unit actions. ** Missile actions. ** Players (AI). ** Cyclic events (color cycle,...) ** Display update. ** Input/Network/Sound. */ void GameMainLoop(void) { #ifdef DEBUG // removes the setjmp warnings static bool showtip; #else bool showtip; #endif int player; int RealVideoSyncSpeed; const EventCallback *old_callbacks; InitGameCallbacks(); old_callbacks = GetCallbacks(); SetCallbacks(&GameCallbacks); SetVideoSync(); GameCursor = UI.Point.Cursor; GameRunning = true; showtip = false; RealVideoSyncSpeed = VideoSyncSpeed; MultiPlayerReplayEachCycle(); // StratagusAI MOD GamePaused = true; // Minimap.Update(); while (GameRunning) { // StratagusAI MOD if ((GameCycle - socketInterface->lastPausedCycle) % socketInterface->cyclesPerTransition == 0) { socketInterface->handleInterface(); if (socketInterface->warpSpeed) FastForwardCycle = GameCycle + socketInterface->cyclesPerTransition + 1; } // Can't find a better place. SaveGameLoading = 0; // // Game logic part // if (!GamePaused && NetworkInSync && !SkipGameCycle) { SinglePlayerReplayEachCycle(); ++GameCycle; MultiPlayerReplayEachCycle(); NetworkCommands(); // Get network commands UnitActions(); // handle units MissileActions(); // handle missiles PlayersEachCycle(); // handle players UpdateTimer(); // update game timer // // Work todo each second. // Split into different frames, to reduce cpu time. // Increment mana of magic units. // Update mini-map. // Update map fog of war. // Call AI. // Check game goals. // Check rescue of units. // switch (GameCycle % CYCLES_PER_SECOND) { case 0: // At cycle 0, start all ai players... if (GameCycle == 0) { for (player = 0; player < NumPlayers; ++player) { PlayersEachSecond(player); } } break; case 1: break; case 2: break; case 3: // minimap update UI.Minimap.Update(); break; case 4: break; case 5: break; case 6: // overtaking units RescueUnits(); break; default: // FIXME: assume that NumPlayers < (CYCLES_PER_SECOND - 7) player = (GameCycle % CYCLES_PER_SECOND) - 7; Assert(player >= 0); if (player < NumPlayers) { PlayersEachSecond(player); } } } TriggersEachCycle(); // handle triggers UpdateMessages(); // update messages CheckMusicFinished(); // Check for next song // // Map scrolling // DoScrollArea(MouseScrollState | KeyScrollState, (KeyModifiers & ModifierControl) != 0); if (FastForwardCycle > GameCycle && RealVideoSyncSpeed != VideoSyncSpeed) { RealVideoSyncSpeed = VideoSyncSpeed; VideoSyncSpeed = 3000; } // MOD if (socketInterface->cyclesPerVideoUpdate != -1 && (GameCycle % socketInterface->cyclesPerVideoUpdate == 0 || GamePaused)) { if (FastForwardCycle <= GameCycle || GameCycle <= 10 || !(GameCycle & 0x3f)) { //FIXME: this might be better placed somewhere at front of the // program, as we now still have a game on the background and // need to go through the game-menu or supply a map file UpdateDisplay(); // // If double-buffered mode, we will display the contains of // VideoMemory. If direct mode this does nothing. In X11 it does // XFlush // RealizeVideoMemory(); } } if (FastForwardCycle == GameCycle) { VideoSyncSpeed = RealVideoSyncSpeed; } if (FastForwardCycle <= GameCycle || !(GameCycle & 0x3f)) { WaitEventsOneFrame(); } if (!NetworkInSync) { NetworkRecover(); // recover network } } // // Game over // if (FastForwardCycle > GameCycle) { VideoSyncSpeed = RealVideoSyncSpeed; } NetworkQuit(); EndReplayLog(); FlagRevealMap = 0; ReplayRevealMap = 0; GamePaused = false; GodMode = false; SetCallbacks(old_callbacks); }
/** ** Game main loop. ** ** Unit actions. ** Missile actions. ** Players (AI). ** Cyclic events (color cycle,...) ** Display update. ** Input/Network/Sound. */ void GameMainLoop(void) { int player; const EventCallback *old_callbacks; InitGameCallbacks(); old_callbacks = GetCallbacks(); SetCallbacks(&GameCallbacks); SetVideoSync(); GameCursor = UI.Point.Cursor; GameRunning = true; CParticleManager::init(); MultiPlayerReplayEachCycle(); CclCommand("GameStarting()"); std::ofstream output; std::wstring templ; firstClock = std::clock(); templateClock = 0; int messageNumber = 1; std::ofstream outputEventsPerSec; std::ofstream outputNT; outputEventsPerSec.open("/tmp/boswarseventspersec.csv",std::ios::out); outputNT.open("/tmp/boswarsclocksperevents.csv",std::ios::out); output.open("/tmp/beepbeep.fifo",std::ios::out); templ = templ = L"<message>\n" L" <units>\n" L"{% for unit in units.tabunits %}" L" <unit>\n" L" <id>{$unit.id}</id>\n" L" <type>{$unit.type}</type>\n" L" <isbuilding>{$unit.isbuilding}</isbuilding>\n" L" <player>{$unit.player}</player>\n" L" <order>\n" L" <action>{$unit.action}</action>\n" L" <goal>{$unit.goal}</goal>\n" L" </order>\n" L" <neworder>\n" L" <action>{$unit.neworder}</action>\n" L" <goal>{$unit.newgoal}</goal>\n" L" </neworder>\n" L" </unit>\n" L"{% endfor %}" L" </units>\n" L"<overhead>{$overhead}</overhead>\n" L"</message>\n"; while (GameRunning) { // Can't find a better place. SaveGameLoading = false; // // Game logic part // if (!GamePaused && NetworkInSync && !SkipGameCycle) { SinglePlayerReplayEachCycle(); ++GameCycle; MultiPlayerReplayEachCycle(); NetworkCommands(); // Get network commands UnitActions(); // handle units MissileActions(); // handle missiles PlayersEachCycle(); // handle players UpdateTimer(); // update game timer // // Work todo each second. // Split into different frames, to reduce cpu time. // Increment mana of magic units. // Update mini-map. // Update map fog of war. // Call AI. // Check game goals. // Check rescue of units. // switch (GameCycle % CYCLES_PER_SECOND) { case 0: // At cycle 0, start all ai players... if (GameCycle == 0) { for (player = 0; player < NumPlayers; ++player) { PlayersEachSecond(player); } } break; case 1: break; case 2: break; case 3: // minimap update UI.Minimap.Update(); break; case 4: break; case 5: break; case 6: // overtaking units RescueUnits(); break; default: // FIXME: assume that NumPlayers < (CYCLES_PER_SECOND - 7) player = (GameCycle % CYCLES_PER_SECOND) - 7; Assert(player >= 0); if (player < NumPlayers) { PlayersEachSecond(player); } } ////////////GET INFORMATION FOR MONITORING!!!//////////////////// if(NumUnits > 0) { std::clock_t littleClock = std::clock(); cpptempl::data_list theUnits; std::stringstream ss; for(int i = 0; i < NumUnits; i++) { cpptempl::data_map uni; /////////ID///////// ss.str(""); ss << Units[i]->Slot; std::string theID = ss.str(); std::wstring wTheID; wTheID.assign(theID.begin(),theID.end()); uni[L"id"] = cpptempl::make_data(wTheID); //////UNITTYPE////// ss.str(""); ss << Units[i]->Type->Name; std::string theType = ss.str(); std::wstring wTheType; wTheType.assign(theType.begin(),theType.end()); uni[L"type"] = cpptempl::make_data(wTheType); //////ISBUILDING////// ss.str(""); if (Units[i]->Type->Building == 1) ss << "true"; else ss << "false"; std::string theIsBuilding = ss.str(); std::wstring wTheIsBuilding; wTheIsBuilding.assign(theIsBuilding.begin(),theIsBuilding.end()); uni[L"isbuilding"] = cpptempl::make_data(wTheIsBuilding); //////PLAYER////// ss.str(""); ss << Units[i]->Player; std::string thePlayer = ss.str(); std::wstring wThePlayer; wThePlayer.assign(thePlayer.begin(),thePlayer.end()); uni[L"player"] = cpptempl::make_data(wThePlayer); //////UnitAction////// ss.str(""); switch(Units[i]->Orders[0]->Action) { case UnitActionNone: ss << "UnitActionNone"; break; case UnitActionStill: ss << "UnitActionStill"; break; case UnitActionStandGround: ss << "UnitActionStandGround"; break; case UnitActionFollow: ss << "UnitActionFollow"; break; case UnitActionMove: ss << "UnitActionMove"; break; case UnitActionAttack: ss << "UnitActionAttack"; break; case UnitActionAttackGround: ss << "UnitActionAttackGround"; break; case UnitActionDie: ss << "UnitActionDie"; break; case UnitActionSpellCast: ss << "UnitActionSpellCast"; break; case UnitActionTrain: ss << "UnitActionTrain"; break; case UnitActionBuilt: ss << "UnitActionBuilt"; break; case UnitActionBoard: ss << "UnitActionBoard"; break; case UnitActionUnload: ss << "UnitActionUnload"; break; case UnitActionPatrol: ss << "UnitActionPatrol"; break; case UnitActionBuild: ss << "UnitActionBuild"; break; case UnitActionRepair: ss << "UnitActionRepair"; break; case UnitActionResource: ss << "UnitActionResource"; break; default: ss << "None"; } std::string theAction = ss.str(); std::wstring wTheAction; wTheAction.assign(theAction.begin(),theAction.end()); uni[L"action"] = cpptempl::make_data(wTheAction); //////UnitGoal////// ss.str(""); if(Units[i]->Orders[0]->Goal != NULL) ss << Units[i]->Orders[0]->Goal->Slot; else ss << "None"; std::string theGoal = ss.str(); std::wstring wTheGoal; wTheGoal.assign(theGoal.begin(),theGoal.end()); uni[L"goal"] = cpptempl::make_data(wTheGoal); ///////NEW ORDER///////// ss.str(""); switch(Units[i]->NewOrder.Action) { case UnitActionNone: ss << "UnitActionNone"; break; case UnitActionStill: ss << "UnitActionStill"; break; case UnitActionStandGround: ss << "UnitActionStandGround"; break; case UnitActionFollow: ss << "UnitActionFollow"; break; case UnitActionMove: ss << "UnitActionMove"; break; case UnitActionAttack: ss << "UnitActionAttack"; break; case UnitActionAttackGround: ss << "UnitActionAttackGround"; break; case UnitActionDie: ss << "UnitActionDie"; break; case UnitActionSpellCast: ss << "UnitActionSpellCast"; break; case UnitActionTrain: ss << "UnitActionTrain"; break; case UnitActionBuilt: ss << "UnitActionBuilt"; break; case UnitActionBoard: ss << "UnitActionBoard"; break; case UnitActionUnload: ss << "UnitActionUnload"; break; case UnitActionPatrol: ss << "UnitActionPatrol"; break; case UnitActionBuild: ss << "UnitActionBuild"; break; case UnitActionRepair: ss << "UnitActionRepair"; break; case UnitActionResource: ss << "UnitActionResource"; break; default: ss << "None"; } std::string theNewOrder = ss.str(); std::wstring wTheNewOrder; wTheNewOrder.assign(theNewOrder.begin(),theNewOrder.end()); uni[L"neworder"] = cpptempl::make_data(wTheNewOrder); //////NEW GOAL////// ss.str(""); if(Units[i]->NewOrder.Goal != NULL) ss << Units[i]->NewOrder.Goal->Slot; else ss << "None"; std::string theNewGoal = ss.str(); std::wstring wTheNewGoal; wTheNewGoal.assign(theNewGoal.begin(),theNewGoal.end()); uni[L"newgoal"] = cpptempl::make_data(wTheNewGoal); theUnits.push_back((cpptempl::make_data(uni))); } cpptempl::data_map lesUnits; lesUnits[L"tabunits"] = cpptempl::make_data(theUnits); // Now set this in the data map cpptempl::data_map data; data[L"units"] = cpptempl::make_data(lesUnits); //////////////////TIMESTAMP///////////////////////// std::clock_t t = std::clock() - firstClock; double timeStamp = ((double)t/(double)CLOCKS_PER_SEC); ss.str(""); ss << std::setprecision(8) << timeStamp; std::string sTimeStamp = ss.str(); std::string gnuPlotStringT = ss.str(); std::wstring wTimeStamp; wTimeStamp.assign(sTimeStamp.begin(),sTimeStamp.end()); data[L"timestamp"] = cpptempl::make_data(wTimeStamp); ///OVERHEAD///// templateClock += std::clock()-littleClock; long double overhead = (long double)templateClock / ((long double)std::clock()-(long double)firstClock)*(long double)100.0; ss.str(""); ss << std::setprecision(10) << overhead; std::string sOverhead = ss.str(); std::wstring wOverhead; wOverhead.assign(sOverhead.begin(),sOverhead.end()); data[L"overhead"] = cpptempl::make_data(wOverhead); std::cout << overhead << "% overhead\n"; //std::cout << std::clock() << " clocl\n"; /////////////////MESSAGENUMBER/////////////////////////< ss.str(""); ss << messageNumber; std::string gnuPlotStringN = ss.str(); std::string sMessageNumber = ss.str(); std::wstring wMessageNumber; wMessageNumber.assign(sMessageNumber.begin(),sMessageNumber.end()); data[L"messagenumber"] = cpptempl::make_data(wMessageNumber); std::wstring result = cpptempl::parse(templ, data); ss.str(""); double templateTime = ((double)templateClock/(double)CLOCKS_PER_SEC)*(double)1000; ss << std::setprecision(8) << templateTime; std::string templTime = ss.str(); double totalT = ((std::clock()-firstClock)/(double)CLOCKS_PER_SEC); std::cout << totalT << "totaltime\n"; std::cout << CYCLES_PER_SECOND << "cycles\n"; std::string s; s.assign(result.begin(), result.end()); if (messageNumber == 1) { std::ofstream traceoutput; traceoutput.open("/tmp/traceout.xml",std::ios::out); traceoutput << s; traceoutput.close(); } messageNumber++; /////STATS///// output << s; std::string out = gnuPlotStringN + "," + gnuPlotStringT + "\n"; outputEventsPerSec << out; //OutputNT //std::string theT; out = ""; //ss.str(""); //ss << templTime; //theT = ss.str(); out = templTime + "," + gnuPlotStringN + "\n"; outputNT << out; } ///////////////////////////////////////////////////////////////// } TriggersEachCycle(); // handle triggers UpdateMessages(); // update messages ParticleManager.update(); // handle particles CheckMusicFinished(); // Check for next song // // Map scrolling // DoScrollArea(MouseScrollState | KeyScrollState, (KeyModifiers & ModifierControl) != 0); if (FastForwardCycle <= GameCycle || GameCycle <= 10 || !(GameCycle & 0x3f)) { //FIXME: this might be better placed somewhere at front of the // program, as we now still have a game on the background and // need to go through the game-menu or supply a map file UpdateDisplay(); // // If double-buffered mode, we will display the contains of // VideoMemory. If direct mode this does nothing. In X11 it does // XFlush // RealizeVideoMemory(); } if (FastForwardCycle <= GameCycle || !(GameCycle & 0x3f)) { WaitEventsOneFrame(); } if (!NetworkInSync) { NetworkRecover(); // recover network } } output.close(); outputNT.close(); outputEventsPerSec.close(); // // Game over // NetworkQuit(); EndReplayLog(); CParticleManager::exit(); FlagRevealMap = 0; ReplayRevealMap = 0; GamePaused = false; GodMode = false; SetCallbacks(old_callbacks); }
static void GameLogicLoop() { // Can't find a better place. // FIXME: We need find better place! SaveGameLoading = false; // // Game logic part // if (!GamePaused && NetworkInSync && !SkipGameCycle) { SinglePlayerReplayEachCycle(); ++GameCycle; MultiPlayerReplayEachCycle(); NetworkCommands(); // Get network commands TriggersEachCycle();// handle triggers UnitActions(); // handle units MissileActions(); // handle missiles PlayersEachCycle(); // handle players UpdateTimer(); // update game timer // // Work todo each second. // Split into different frames, to reduce cpu time. // Increment mana of magic units. // Update mini-map. // Update map fog of war. // Call AI. // Check game goals. // Check rescue of units. // switch (GameCycle % CYCLES_PER_SECOND) { case 0: // At cycle 0, start all ai players... if (GameCycle == 0) { for (int player = 0; player < NumPlayers; ++player) { PlayersEachSecond(player); } } break; case 1: break; case 2: break; case 3: // minimap update UI.Minimap.UpdateCache = true; break; case 4: break; case 5: // forest grow Map.RegenerateForest(); break; case 6: // overtaking units RescueUnits(); break; default: { // FIXME: assume that NumPlayers < (CYCLES_PER_SECOND - 7) int player = (GameCycle % CYCLES_PER_SECOND) - 7; Assert(player >= 0); if (player < NumPlayers) { PlayersEachSecond(player); } } } //Wyrmgus start if (GameCycle > 0 && GameCycle % (CYCLES_PER_SECOND * 10 * 3) == 0) { // every 10 seconds of gameplay = 1 hour for time of day calculations, change time of day every three hours if (!GameSettings.Inside) { // only change the time of the day if outdoors GameTimeOfDay += 1; if (GameTimeOfDay == MaxTimesOfDay) { GameTimeOfDay = 1; } } else { // indoors it is always dark (maybe would be better to allow a special setting to have bright indoor places? GameTimeOfDay = NoTimeOfDay; // make indoors have no time of day setting until it is possible to make light sources change their surrounding "time of day" } //update the sight of all units for (CUnitManager::Iterator it = UnitManager.begin(); it != UnitManager.end(); ++it) { CUnit &unit = **it; if (!unit.Destroyed) { MapUnmarkUnitSight(unit); UpdateUnitSightRange(unit); MapMarkUnitSight(unit); } } } //Wyrmgus end //Wyrmgus start // if (Preference.AutosaveMinutes != 0 && !IsNetworkGame() && GameCycle > 0 && (GameCycle % (CYCLES_PER_SECOND * 60 * Preference.AutosaveMinutes)) == 0) { // autosave every X minutes, if the option is enabled if (Preference.AutosaveMinutes != 0 && !IsNetworkGame() && !GrandStrategy && GameCycle > 0 && (GameCycle % (CYCLES_PER_SECOND * 60 * Preference.AutosaveMinutes)) == 0) { // autosave every X minutes, if the option is enabled //Wyrmgus end UI.StatusLine.Set(_("Autosave")); //Wyrmgus start // SaveGame("autosave.sav"); CclCommand("if (RunSaveGame ~= nil) then RunSaveGame(\"autosave.sav\") end;"); //Wyrmgus end } } UpdateMessages(); // update messages ParticleManager.update(); // handle particles CheckMusicFinished(); // Check for next song if (FastForwardCycle <= GameCycle || !(GameCycle & 0x3f)) { WaitEventsOneFrame(); } if (!NetworkInSync) { NetworkRecover(); // recover network } }
void CSearchWnd::OnSearchSearch() { if ( ! Network.IsWellConnected() ) Network.Connect( TRUE ); SetModified(); // The 'Search More' situation if ( ! m_bPaused && m_bWaitMore ) { CQuickLock pLock( m_pMatches->m_pSection ); if ( ! empty() ) { CSearchPtr pManaged = m_oSearches.back(); // Re-activate search window theApp.Message( MSG_DEBUG, _T("Resuming Search") ); pManaged->SetActive( TRUE ); m_bWaitMore = FALSE; // Resume G2 search m_nMaxResults = m_pMatches->m_nGnutellaHits + Settings.Gnutella.MaxResults; m_nMaxQueryCount = pManaged->m_nQueryCount + Settings.Gnutella2.QueryLimit; // Resume ED2K search m_nMaxED2KResults = m_pMatches->m_nED2KHits + Settings.eDonkey.MaxResults; pManaged->m_tLastED2K = GetTickCount(); pManaged->m_tMoreResults = 0; if ( ( GetAsyncKeyState( VK_SHIFT ) & 0x8000 ) == 0x8000 ) pManaged->SetPriority( CManagedSearch::spMedium ); m_bUpdate = TRUE; UpdateMessages(); return; } } // End of 'Search More' // Check if user mistakenly pasted download link to search input box CString strText; m_wndPanel.m_boxSearch.m_wndSearch.GetWindowText( strText ); if ( theApp.OpenURL( strText, TRUE ) ) { m_wndPanel.m_boxSearch.m_wndSearch.SetWindowText( _T("") ); return; } if ( m_pMatches->m_nFiles > 0 ) { if ( MsgBox( IDS_SEARCH_CLEAR_PREVIOUS, MB_ICONQUESTION | MB_YESNO, 0, &Settings.Search.ClearPrevious ) == IDYES ) { CQuickLock oLock( m_pMatches->m_pSection ); m_pMatches->Clear(); m_bUpdate = TRUE; PostMessage( WM_TIMER, 2 ); } } CSearchPtr pManaged; if ( m_wndPanel.m_bSendSearch ) { // Create new search pManaged = m_wndPanel.GetSearch(); CQuerySearchPtr pSearch = pManaged->GetSearch(); if ( m_pMatches->m_nFiles == 0 && pSearch->m_pSchema != NULL ) { CList< CSchemaMember* > pColumns; CSchemaColumnsDlg::LoadColumns( pSearch->m_pSchema, &pColumns ); m_wndList.SelectSchema( pSearch->m_pSchema, &pColumns ); } } else { CNewSearchDlg dlg( NULL, GetLastSearch(), FALSE, TRUE ); if ( dlg.DoModal() != IDOK ) return; pManaged = new CManagedSearch( dlg.GetSearch() ); } pManaged->CreateGUID(); { CQuickLock oLock( m_pMatches->m_pSection ); if ( ( GetAsyncKeyState( VK_SHIFT ) & 0x8000 ) != 0x8000 ) for_each( begin(), end(), std::mem_fun( &CManagedSearch::Stop ) ); m_oSearches.push_back( pManaged ); } ExecuteSearch(); }
void CBaseMatchWnd::OnTimer(UINT nIDEvent) { if ( m_wndFilter.m_hWnd == NULL ) return; DWORD nNow = GetTickCount(); if ( nIDEvent == 1 ) { if ( GetFocus() != &m_wndFilter ) { CString strFilter; m_wndFilter.GetWindowText( strFilter ); if ( strFilter != m_pMatches->m_sFilter ) { m_wndFilter.SetWindowText( m_pMatches->m_sFilter ); } } BOOL bActive = ( GetMDIFrame()->MDIGetActive() == this ); if ( bActive ) { if ( HWND hFore = ::GetForegroundWindow() ) { DWORD nProcessID; GetWindowThreadProcessId( hFore, &nProcessID ); bActive &= ( nProcessID == GetCurrentProcessId() ); } } if ( m_bBMWActive != bActive ) { m_bBMWActive = bActive; if ( ! m_bBMWActive ) { m_pMatches->ClearNew(); m_wndList.Invalidate(); } } if ( m_pMatches->m_nFilteredFiles == 0 ) UpdateMessages( FALSE ); } else if ( ( nIDEvent == 2 && m_bUpdate ) || nIDEvent == 7 ) { CSingleLock pLock( &m_pMatches->m_pSection ); if ( pLock.Lock( 50 ) ) { m_bUpdate = FALSE; m_wndList.Update(); UpdateMessages(); if ( m_pMatches->m_nFilteredFiles != m_nCacheFiles ) { m_nCacheFiles = m_pMatches->m_nFilteredFiles; SetAlert(); } } else { m_bUpdate = TRUE; PostMessage( WM_TIMER, 2 ); } } }
static void GameLogicLoop() { // Can't find a better place. // FIXME: We need find better place! SaveGameLoading = false; // // Game logic part // if (!GamePaused && NetworkInSync && !SkipGameCycle) { SinglePlayerReplayEachCycle(); ++GameCycle; MultiPlayerReplayEachCycle(); NetworkCommands(); // Get network commands TriggersEachCycle();// handle triggers UnitActions(); // handle units MissileActions(); // handle missiles PlayersEachCycle(); // handle players UpdateTimer(); // update game timer // // Work todo each second. // Split into different frames, to reduce cpu time. // Increment mana of magic units. // Update mini-map. // Update map fog of war. // Call AI. // Check game goals. // Check rescue of units. // switch (GameCycle % CYCLES_PER_SECOND) { case 0: // At cycle 0, start all ai players... if (GameCycle == 0) { for (int player = 0; player < NumPlayers; ++player) { PlayersEachSecond(player); } } break; case 1: break; case 2: break; case 3: // minimap update UI.Minimap.UpdateCache = true; break; case 4: break; case 5: // forest grow Map.RegenerateForest(); break; case 6: // overtaking units RescueUnits(); break; default: { // FIXME: assume that NumPlayers < (CYCLES_PER_SECOND - 7) int player = (GameCycle % CYCLES_PER_SECOND) - 7; Assert(player >= 0); if (player < NumPlayers) { PlayersEachSecond(player); } } } } UpdateMessages(); // update messages ParticleManager.update(); // handle particles CheckMusicFinished(); // Check for next song if (FastForwardCycle <= GameCycle || !(GameCycle & 0x3f)) { WaitEventsOneFrame(); } if (!NetworkInSync) { NetworkRecover(); // recover network } }
static void GameLogicLoop() { // Can't find a better place. // FIXME: We need find better place! SaveGameLoading = false; #ifdef USE_OAML if (enableOAML && oaml) { // Time of day can change our main music loop, if the current playing track is set for this SetMusicCondition(OAML_CONDID_MAIN_LOOP, Map.TimeOfDay[CurrentMapLayer]); } #endif // // Game logic part // if (!GamePaused && NetworkInSync && !SkipGameCycle) { SinglePlayerReplayEachCycle(); ++GameCycle; MultiPlayerReplayEachCycle(); NetworkCommands(); // Get network commands TriggersEachCycle();// handle triggers UnitActions(); // handle units MissileActions(); // handle missiles PlayersEachCycle(); // handle players UpdateTimer(); // update game timer // // Work todo each second. // Split into different frames, to reduce cpu time. // Increment mana of magic units. // Update mini-map. // Update map fog of war. // Call AI. // Check game goals. // Check rescue of units. // switch (GameCycle % CYCLES_PER_SECOND) { case 0: // At cycle 0, start all ai players... if (GameCycle == 0) { for (int player = 0; player < NumPlayers; ++player) { PlayersEachSecond(player); } } break; case 1: break; case 2: break; case 3: // minimap update UI.Minimap.UpdateCache = true; break; case 4: break; case 5: // forest grow Map.RegenerateForest(); break; case 6: // overtaking units RescueUnits(); break; //Wyrmgus start /* default: { // FIXME: assume that NumPlayers < (CYCLES_PER_SECOND - 7) int player = (GameCycle % CYCLES_PER_SECOND) - 7; Assert(player >= 0); if (player < NumPlayers) { PlayersEachSecond(player); } } */ //Wyrmgus end } //Wyrmgus start int player = (GameCycle - 1) % CYCLES_PER_SECOND; Assert(player >= 0); if (player < NumPlayers) { PlayersEachSecond(player); if ((player + CYCLES_PER_SECOND) < NumPlayers) { PlayersEachSecond(player + CYCLES_PER_SECOND); } } player = (GameCycle - 1) % CYCLES_PER_MINUTE; Assert(player >= 0); if (player < NumPlayers) { PlayersEachMinute(player); } //Wyrmgus end //Wyrmgus start for (size_t z = 0; z < Map.Fields.size(); ++z) { if (GameSettings.Inside || GameSettings.NoTimeOfDay || !Map.TimeOfDaySeconds[z]) { // indoors it is always dark (maybe would be better to allow a special setting to have bright indoor places? Map.TimeOfDay[z] = NoTimeOfDay; // make indoors have no time of day setting until it is possible to make light sources change their surrounding "time of day" continue; } if (GameCycle > 0 && GameCycle % (CYCLES_PER_SECOND * Map.TimeOfDaySeconds[z]) == 0) { Map.TimeOfDay[z] += 1; if (Map.TimeOfDay[z] == MaxTimesOfDay) { Map.TimeOfDay[z] = 1; } #ifdef USE_OAML if (enableOAML && oaml && z == CurrentMapLayer) { // Time of day can change our main music loop, if the current playing track is set for this SetMusicCondition(OAML_CONDID_MAIN_LOOP, Map.TimeOfDay[z]); } #endif //update the sight of all units for (CUnitManager::Iterator it = UnitManager.begin(); it != UnitManager.end(); ++it) { CUnit *unit = *it; if ( unit && unit->IsAlive() && unit->MapLayer == z && ( ((Map.TimeOfDay[z] == MorningTimeOfDay || Map.TimeOfDay[z] == DuskTimeOfDay) && unit->Variable[DAYSIGHTRANGEBONUS_INDEX].Value != 0) // if has day sight bonus and is entering or exiting day || ((Map.TimeOfDay[z] == FirstWatchTimeOfDay || Map.TimeOfDay[z] == DawnTimeOfDay) && unit->Variable[NIGHTSIGHTRANGEBONUS_INDEX].Value != 0) // if has night sight bonus and is entering or exiting night ) ) { MapUnmarkUnitSight(*unit); UpdateUnitSightRange(*unit); MapMarkUnitSight(*unit); } } } } //Wyrmgus end //Wyrmgus start // if (Preference.AutosaveMinutes != 0 && !IsNetworkGame() && GameCycle > 0 && (GameCycle % (CYCLES_PER_SECOND * 60 * Preference.AutosaveMinutes)) == 0) { // autosave every X minutes, if the option is enabled if (Preference.AutosaveMinutes != 0 && !IsNetworkGame() && !GrandStrategy && GameCycle > 0 && (GameCycle % (CYCLES_PER_MINUTE * Preference.AutosaveMinutes)) == 0) { // autosave every X minutes, if the option is enabled //Wyrmgus end UI.StatusLine.Set(_("Autosave")); //Wyrmgus start // SaveGame("autosave.sav"); CclCommand("if (RunSaveGame ~= nil) then RunSaveGame(\"autosave.sav\") end;"); //Wyrmgus end } } UpdateMessages(); // update messages ParticleManager.update(); // handle particles CheckMusicFinished(); // Check for next song if (FastForwardCycle <= GameCycle || !(GameCycle & 0x3f)) { WaitEventsOneFrame(); } if (!NetworkInSync) { NetworkRecover(); // recover network } }
void CSearchWnd::OnSearchPanel() { Settings.Search.SearchPanel = m_bPanel = ! m_bPanel; OnSkinChange(); UpdateMessages(); }