| 339 | } |
| 340 | |
| 341 | void ClientApplication::update() { |
| 342 | float dt = GlobalTimestep * GlobalTimescale; |
| 343 | auto& app = appController(); |
| 344 | if (m_state >= MainAppState::Title) { |
| 345 | if (auto p2pNetworkingService = app->p2pNetworkingService()) { |
| 346 | if (auto join = p2pNetworkingService->pullPendingJoin()) { |
| 347 | m_pendingMultiPlayerConnection = PendingMultiPlayerConnection{join.takeValue(), {}, {}, false}; |
| 348 | changeState(MainAppState::Title); |
| 349 | } |
| 350 | |
| 351 | if (auto req = p2pNetworkingService->pullJoinRequest()) |
| 352 | m_mainInterface->queueJoinRequest(*req); |
| 353 | |
| 354 | p2pNetworkingService->update(); |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | if (!m_errorScreen->accepted()) |
| 359 | m_errorScreen->update(dt); |
| 360 | |
| 361 | if (m_state == MainAppState::Mods) |
| 362 | updateMods(dt); |
| 363 | else if (m_state == MainAppState::ModsWarning) |
| 364 | updateModsWarning(dt); |
| 365 | |
| 366 | if (m_state == MainAppState::Splash) |
| 367 | updateSplash(dt); |
| 368 | else if (m_state == MainAppState::Error) |
| 369 | updateError(dt); |
| 370 | else if (m_state == MainAppState::Title) |
| 371 | updateTitle(dt); |
| 372 | else if (m_state > MainAppState::Title) |
| 373 | updateRunning(dt); |
| 374 | |
| 375 | // Swallow leftover encoded voice data if we aren't in-game to allow mic read to continue for settings. |
| 376 | if (m_state <= MainAppState::Title) { |
| 377 | DataStreamBuffer ext; |
| 378 | m_voice->send(ext); |
| 379 | } // TODO: directly disable encoding at menu so we don't have to do this |
| 380 | |
| 381 | m_guiContext->cleanup(); |
| 382 | m_edgeKeyEvents.clear(); |
| 383 | m_input->update(); |
| 384 | ++m_framesSkipped; |
| 385 | } |
| 386 | |
| 387 | void ClientApplication::render() { |
| 388 | m_framesSkipped = 0; |
no test coverage detected