@@ -1096,36 +1096,25 @@ bool MetagameGUI::StartNewGame()
1096
1096
g_MetaMan.m_TeamCount ++;
1097
1097
}
1098
1098
1099
- // Get the tech selection and apply it to the metaplayer
1100
- GUIListPanel::Item *pTechItem = m_apPlayerTechSelect[player]->GetSelectedItem ();
1101
- if (pTechItem)
1102
- {
1103
- // If the "random" selection, choose one from the list of loaded techs
1104
- if (m_apPlayerTechSelect[player]->GetSelectedIndex () <= 0 )// pTechItem->m_ExtraIndex < 0)
1105
- {
1106
- int selection = RandomNum<int >(1 , m_apPlayerTechSelect[player]->GetListPanel ()->GetItemList ()->size () - 1 );
1107
-
1108
- // Don't let the game to chose the same faction twice
1099
+ if (const GUIListPanel::Item *selectedTech = m_apPlayerTechSelect[player]->GetSelectedItem ()) {
1100
+ // If the "random" selection, choose one from the list of loaded techs.
1101
+ if (m_apPlayerTechSelect[player]->GetSelectedIndex () <= 0 ) {
1102
+ int randomSelection = 0 ;
1103
+
1104
+ // Don't let the game to chose the same faction twice.
1109
1105
bool ok = false ;
1110
- while (!ok)
1111
- {
1106
+ while (!ok) {
1107
+ randomSelection = RandomNum< int >( 1 , m_apPlayerTechSelect[player]-> GetListPanel ()-> GetItemList ()-> size () - 1 );
1112
1108
ok = true ;
1113
- selection = RandomNum<int >(1 , m_apPlayerTechSelect[player]->GetListPanel ()->GetItemList ()->size () - 1 );
1114
-
1115
- for (int p = 0 ; p < player; p++)
1116
- if (selection == m_apPlayerTechSelect[p]->GetSelectedIndex ())
1117
- ok = false ;
1109
+ for (int p = 0 ; p < player; p++) {
1110
+ if (randomSelection == m_apPlayerTechSelect[p]->GetSelectedIndex ()) { ok = false ; }
1111
+ }
1118
1112
}
1113
+ selectedTech = m_apPlayerTechSelect[player]->GetItem (randomSelection);
1114
+ }
1115
+ if (selectedTech) { newPlayer.m_NativeTechModule = selectedTech->m_ExtraIndex ; }
1116
+ }
1119
1117
1120
- m_apPlayerTechSelect[player]->SetSelectedIndex (selection);
1121
- pTechItem = m_apPlayerTechSelect[player]->GetSelectedItem ();
1122
- }
1123
-
1124
- // Now set the selected tech's module index as what the metaplayer is going to use
1125
- if (pTechItem)
1126
- newPlayer.m_NativeTechModule = pTechItem->m_ExtraIndex ;
1127
- }
1128
-
1129
1118
// Set the starting brains for this player
1130
1119
// Start with the baseline setting
1131
1120
newPlayer.m_BrainPool = m_pLengthSlider->GetValue ();
0 commit comments