Always add 1 player when leaving the lobby without splitscreen players added

This commit is contained in:
Benau 2023-06-24 12:42:57 +08:00
parent d5886cf2ef
commit c2840e972b
2 changed files with 12 additions and 1 deletions

View File

@ -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<gui::IGUIStaticText>();
st->setMouseCallback(nullptr);

View File

@ -68,7 +68,6 @@ void OnlineScreen::loadedFromFile()
{
m_enable_splitscreen = getWidget<CheckBoxWidget>("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<RibbonWidget>("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())