Handle controller the last to avoid slow PC sending actions too late
This commit is contained in:
parent
8b3772470a
commit
db36ee6df6
@ -1850,22 +1850,6 @@ void IrrDriver::doScreenShot()
|
||||
*/
|
||||
void IrrDriver::update(float dt)
|
||||
{
|
||||
// User aborted (e.g. closed window)
|
||||
// =================================
|
||||
if (!m_device->run())
|
||||
{
|
||||
// Don't bother cleaning up GUI, has no use and may result in crashes
|
||||
//GUIEngine::cleanUp();
|
||||
//GUIEngine::deallocate();
|
||||
main_loop->abort();
|
||||
return;
|
||||
}
|
||||
|
||||
// If we quit via the menu the m_device->run() does not return true.
|
||||
// To avoid any other calls, we return here.
|
||||
if(main_loop->isAborted())
|
||||
return;
|
||||
|
||||
// If the resolution should be switched, do it now. This will delete the
|
||||
// old device and create a new one.
|
||||
if (m_resolution_changing!=RES_CHANGE_NONE)
|
||||
|
@ -460,6 +460,20 @@ void MainLoop::run()
|
||||
World::getWorld()->updateTime(1);
|
||||
}
|
||||
} // for i < num_steps
|
||||
|
||||
// Handle controller the last to avoid slow PC sending actions too late
|
||||
if (!m_abort)
|
||||
{
|
||||
if (!ProfileWorld::isNoGraphics())
|
||||
{
|
||||
// User aborted (e.g. closed window)
|
||||
bool abort = !irr_driver->getDevice()->run();
|
||||
if (abort)
|
||||
m_abort = true;
|
||||
}
|
||||
if (auto gp = GameProtocol::lock())
|
||||
gp->sendActions();
|
||||
}
|
||||
PROFILER_POP_CPU_MARKER(); // MainLoop pop
|
||||
PROFILER_SYNC_FRAME();
|
||||
} // while !m_abort
|
||||
|
@ -69,7 +69,7 @@ GameProtocol::~GameProtocol()
|
||||
/** Synchronous update - will send all commands collected during the last
|
||||
* frame (and could optional only send messages every N frames).
|
||||
*/
|
||||
void GameProtocol::update(int ticks)
|
||||
void GameProtocol::sendActions()
|
||||
{
|
||||
if (m_all_actions.size() == 0) return; // nothing to do
|
||||
|
||||
@ -98,7 +98,7 @@ void GameProtocol::update(int ticks)
|
||||
// FIXME: for now send reliable
|
||||
sendToServer(m_data_to_send, /*reliable*/ true);
|
||||
m_all_actions.clear();
|
||||
} // update
|
||||
} // sendActions
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Called when a message from a remote GameProtocol is received.
|
||||
|
@ -81,8 +81,8 @@ public:
|
||||
virtual ~GameProtocol();
|
||||
|
||||
virtual bool notifyEventAsynchronous(Event* event) OVERRIDE;
|
||||
virtual void update(int ticks) OVERRIDE;
|
||||
|
||||
virtual void update(int ticks) OVERRIDE {}
|
||||
void sendActions();
|
||||
void controllerAction(int kart_id, PlayerAction action,
|
||||
int value, int val_l, int val_r);
|
||||
void startNewState();
|
||||
|
Loading…
Reference in New Issue
Block a user