diff --git a/src/states_screens/kart_selection.cpp b/src/states_screens/kart_selection.cpp index ce040c839..cee0cdd56 100644 --- a/src/states_screens/kart_selection.cpp +++ b/src/states_screens/kart_selection.cpp @@ -1204,6 +1204,8 @@ void KartSelectionScreen::onUpdate(float delta, irr::video::IVideoDriver*) } } +// ----------------------------------------------------------------------------- + void KartSelectionScreen::playerConfirm(const int playerID) { DynamicRibbonWidget* w = getWidget("karts"); @@ -1220,19 +1222,25 @@ void KartSelectionScreen::playerConfirm(const int playerID) UserConfigParams::m_default_kart = selection; } - // make sure no other player selected the same identity or kart const int amount = m_kart_widgets.size(); + + // Check if we have enough karts for everybody. If there are more players than + // karts then just allow duplicates + const int availableKartCount = w->getItems().size(); + const bool willNeedDuplicates = (amount > availableKartCount); + + // make sure no other player selected the same identity or kart for (int n=0; ngetProfile()->isGuestAccount() && - m_kart_widgets[n].getAssociatedPlayer()->getProfile() == - m_kart_widgets[playerID].getAssociatedPlayer()->getProfile(); + m_kart_widgets[n].getAssociatedPlayer()->getProfile() == + m_kart_widgets[playerID].getAssociatedPlayer()->getProfile(); const bool kart_conflict = sameKart(m_kart_widgets[n], m_kart_widgets[playerID]); - if (player_ready && (ident_conflict || kart_conflict)) + if (player_ready && (ident_conflict || kart_conflict) && !willNeedDuplicates) { printf("\n***\n*** You can't select this identity or kart, someone already took it!! ***\n***\n\n"); @@ -1437,7 +1445,7 @@ void KartSelectionScreen::allPlayersDone() // mark the item as taken for (int i=0; iunsetBadge(BAD_BADGE); } + // Check if we have enough karts for everybody. If there are more players than + // karts then just allow duplicates + DynamicRibbonWidget* w = getWidget("karts"); + assert( w != NULL ); + const int availableKartCount = w->getItems().size(); + if (amount > availableKartCount) return true; + + // Check everyone for duplicates for (int n=0; n