Skip to content

Commit

Permalink
Merge pull request #893 from ulteq/gameloop-reordering
Browse files Browse the repository at this point in the history
[Codechange] Reordered network updates in the game loop
  • Loading branch information
ulteq committed May 11, 2016
2 parents b2a0bad + ddb9444 commit 15477b0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 49 deletions.
9 changes: 1 addition & 8 deletions source/main/MainThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ void MainThread::MainMenuLoopUpdate(float seconds_since_last_frame)
{
#ifdef USE_MYGUI
#ifdef USE_SOCKETW
if (BeamFactory::getSingleton().checkStreamsResultsChanged())
if (BeamFactory::getSingleton().checkStreamsResultsChanged() || gEnv->network->getNetQualityChanged())
{
GUI_Multiplayer::getSingleton().update();
}
Expand All @@ -958,13 +958,6 @@ void MainThread::MainMenuLoopUpdate(float seconds_since_last_frame)
#ifdef USE_ANGELSCRIPT
ScriptEngine::getSingleton().framestep(seconds_since_last_frame);
#endif

// update network labels
if (gEnv->network) // TODO: Does this have any sense for menu?
{
CharacterFactory::getSingleton().updateLabels();
}

}

void MainThread::MainMenuLoopUpdateEvents(float seconds_since_last_frame)
Expand Down
55 changes: 17 additions & 38 deletions source/main/gameplay/RoRFrameListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,15 @@ bool RoRFrameListener::frameStarted(const FrameEvent& evt)

BeamFactory::getSingleton().SyncWithSimThread();

#ifdef USE_SOCKETW
if (gEnv->network)
{
// process all packets and streams received
NetworkStreamManager::getSingleton().update();
CharacterFactory::getSingleton().updateLabels();
}
#endif //SOCKETW

RoR::Application::GetInputEngine()->Capture();

//if (gEnv->collisions) printf("> ground model used: %s\n", gEnv->collisions->last_used_ground_model->name);
Expand All @@ -1291,16 +1300,6 @@ bool RoRFrameListener::frameStarted(const FrameEvent& evt)
// update network gui if required, at most every 2 seconds
if (gEnv->network)
{
#ifdef USE_SOCKETW
#ifdef USE_MYGUI
// update net quality icon
if (gEnv->network->getNetQualityChanged())
{
GUI_Multiplayer::getSingleton().update();
}
#endif // USE_MYGUI
#endif // USE_SOCKETW

// now update mumble 3d audio things
#ifdef USE_MUMBLE
if (gEnv->player)
Expand Down Expand Up @@ -1396,6 +1395,8 @@ bool RoRFrameListener::frameStarted(const FrameEvent& evt)
if (m_loading_state == ALL_LOADED)
{
DustManager::getSingleton().update();

if (m_heathaze) m_heathaze->update();
}

if (m_loading_state == ALL_LOADED && !m_is_sim_paused)
Expand Down Expand Up @@ -1423,6 +1424,10 @@ bool RoRFrameListener::frameStarted(const FrameEvent& evt)

RoR::Application::GetGuiManager()->framestep(dt);

#ifdef USE_ANGELSCRIPT
ScriptEngine::getSingleton().framestep(dt);
#endif

// one of the input modes is immediate, so update the movement vector
if (m_loading_state == ALL_LOADED)
{
Expand Down Expand Up @@ -1486,42 +1491,16 @@ bool RoRFrameListener::frameStarted(const FrameEvent& evt)
}
}

#ifdef USE_ANGELSCRIPT
ScriptEngine::getSingleton().framestep(dt);
#endif

// update network labels
if (gEnv->network)
{
CharacterFactory::getSingleton().updateLabels();
}

return true;
}

bool RoRFrameListener::frameEnded(const FrameEvent& evt)
{
// TODO: IMPROVE STATS
if (RoR::Application::GetOverlayWrapper() && m_stats_on) RoR::Application::GetOverlayWrapper()->updateStats();

// moveCamera();

// workaround to be able to show a single waiting sign before working on the files
//if (uiloader && uiloader->hasWork())
// uiloader->dowork();

if (m_heathaze)
{
m_heathaze->update();
}

#ifdef USE_SOCKETW
if (gEnv->network)
if (m_stats_on && RoR::Application::GetOverlayWrapper())
{
// process all packets and streams received
NetworkStreamManager::getSingleton().update();
RoR::Application::GetOverlayWrapper()->updateStats();
}
#endif //SOCKETW

return true;
}
Expand Down
3 changes: 0 additions & 3 deletions source/main/physics/BeamFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,6 @@ bool BeamFactory::RemoveBeam(Beam *b)
this->DeleteTruck(it2->second);
it1->second.erase(it2);
unlockStreams();
#ifdef USE_MYGUI
GUI_MainMenu::getSingleton().triggerUpdateVehicleList();
#endif // USE_MYGUI
return true;
}
}
Expand Down

0 comments on commit 15477b0

Please sign in to comment.