From c2840e972b814851cfc9c1d597496acee31a24c9 Mon Sep 17 00:00:00 2001 From: Benau Date: Sat, 24 Jun 2023 12:42:57 +0800 Subject: [PATCH] Always add 1 player when leaving the lobby without splitscreen players added --- src/states_screens/online/networking_lobby.cpp | 10 ++++++++++ src/states_screens/online/online_screen.cpp | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/states_screens/online/networking_lobby.cpp b/src/states_screens/online/networking_lobby.cpp index fe90bf883..a25a52ee8 100644 --- a/src/states_screens/online/networking_lobby.cpp +++ b/src/states_screens/online/networking_lobby.cpp @@ -875,6 +875,16 @@ void NetworkingLobby::unloaded() // ---------------------------------------------------------------------------- void NetworkingLobby::tearDown() { + if (m_state == LS_ADD_PLAYERS) + { + UserConfigParams::m_enable_network_splitscreen = false; + NetworkConfig::get()->cleanNetworkPlayers(); + NetworkConfig::get()->addNetworkPlayer( + input_manager->getDeviceManager()->getLatestUsedDevice(), + PlayerManager::getCurrentPlayer(), HANDICAP_NONE); + NetworkConfig::get()->doneAddingNetworkPlayers(); + } + gui::IGUIStaticText* st = m_text_bubble->getIrrlichtElement(); st->setMouseCallback(nullptr); diff --git a/src/states_screens/online/online_screen.cpp b/src/states_screens/online/online_screen.cpp index 12cb2fcd7..308c8b2d3 100644 --- a/src/states_screens/online/online_screen.cpp +++ b/src/states_screens/online/online_screen.cpp @@ -68,7 +68,6 @@ void OnlineScreen::loadedFromFile() { m_enable_splitscreen = getWidget("enable-splitscreen"); assert(m_enable_splitscreen); - m_enable_splitscreen->setState(UserConfigParams::m_enable_network_splitscreen); } // loadedFromFile // ---------------------------------------------------------------------------- @@ -92,6 +91,8 @@ void OnlineScreen::init() RibbonWidget* r = getWidget("menu_toprow"); r->setFocusForPlayer(PLAYER_ID_GAME_MASTER); + m_enable_splitscreen->setState( + UserConfigParams::m_enable_network_splitscreen); // Pre-add a default single player profile in network if (!m_enable_splitscreen->getState() && NetworkConfig::get()->getNetworkPlayers().empty())