Fix broken network kart selection screen if no addon karts available
This commit is contained in:
parent
1a951b76b9
commit
5ff7db155d
@ -1459,6 +1459,24 @@ void KartSelectionScreen::renumberKarts()
|
|||||||
w->updateItemDisplay();
|
w->updateItemDisplay();
|
||||||
} // renumberKarts
|
} // renumberKarts
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
PtrVector<const KartProperties, REF> KartSelectionScreen::getUsableKarts(
|
||||||
|
const std::string& selected_kart_group)
|
||||||
|
{
|
||||||
|
PtrVector<const KartProperties, REF> karts;
|
||||||
|
for(unsigned int i=0; i<kart_properties_manager->getNumberOfKarts(); i++)
|
||||||
|
{
|
||||||
|
const KartProperties* prop = kart_properties_manager->getKartById(i);
|
||||||
|
// Ignore karts that are not in the selected group
|
||||||
|
if((selected_kart_group != ALL_KART_GROUPS_ID &&
|
||||||
|
!prop->isInGroup(selected_kart_group)) || isIgnored(prop->getIdent()))
|
||||||
|
continue;
|
||||||
|
karts.push_back(prop);
|
||||||
|
}
|
||||||
|
karts.insertionSort();
|
||||||
|
return karts;
|
||||||
|
} // getUsableKarts
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void KartSelectionScreen::setKartsFromCurrentGroup()
|
void KartSelectionScreen::setKartsFromCurrentGroup()
|
||||||
@ -1484,18 +1502,16 @@ void KartSelectionScreen::setKartsFromCurrentGroup()
|
|||||||
w->clearItems();
|
w->clearItems();
|
||||||
|
|
||||||
int usable_kart_count = 0;
|
int usable_kart_count = 0;
|
||||||
PtrVector<const KartProperties, REF> karts;
|
PtrVector<const KartProperties, REF> karts = getUsableKarts(selected_kart_group);
|
||||||
|
|
||||||
for(unsigned int i=0; i<kart_properties_manager->getNumberOfKarts(); i++)
|
if (karts.empty())
|
||||||
{
|
{
|
||||||
const KartProperties* prop = kart_properties_manager->getKartById(i);
|
// In network this will happen if no addons kart on server
|
||||||
// Ignore karts that are not in the selected group
|
PtrVector<const KartProperties, REF> new_karts =
|
||||||
if((selected_kart_group != ALL_KART_GROUPS_ID &&
|
getUsableKarts(DEFAULT_GROUP_NAME);
|
||||||
!prop->isInGroup(selected_kart_group)) || isIgnored(prop->getIdent()))
|
std::swap(karts.m_contents_vector, new_karts.m_contents_vector);
|
||||||
continue;
|
tabs->select(DEFAULT_GROUP_NAME, PLAYER_ID_GAME_MASTER);
|
||||||
karts.push_back(prop);
|
|
||||||
}
|
}
|
||||||
karts.insertionSort();
|
|
||||||
|
|
||||||
for(unsigned int i=0; i<karts.size(); i++)
|
for(unsigned int i=0; i<karts.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -128,6 +128,9 @@ protected:
|
|||||||
|
|
||||||
/** Stores a pointer to the current selection screen */
|
/** Stores a pointer to the current selection screen */
|
||||||
static KartSelectionScreen* m_instance_ptr;
|
static KartSelectionScreen* m_instance_ptr;
|
||||||
|
private:
|
||||||
|
PtrVector<const KartProperties, REF> getUsableKarts(
|
||||||
|
const std::string& selected_kart_group);
|
||||||
public:
|
public:
|
||||||
/** Returns the current instance */
|
/** Returns the current instance */
|
||||||
static KartSelectionScreen* getRunningInstance();
|
static KartSelectionScreen* getRunningInstance();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user