Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 328a400

Browse files
committed
Don't change the tech combobox selection to the resulting tech when "-Random-" is selected. Resolve #409
1 parent f4ae69b commit 328a400

File tree

2 files changed

+16
-28
lines changed

2 files changed

+16
-28
lines changed

Menus/MetagameGUI.cpp

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,36 +1096,25 @@ bool MetagameGUI::StartNewGame()
10961096
g_MetaMan.m_TeamCount++;
10971097
}
10981098

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.
11091105
bool ok = false;
1110-
while (!ok)
1111-
{
1106+
while (!ok) {
1107+
randomSelection = RandomNum<int>(1, m_apPlayerTechSelect[player]->GetListPanel()->GetItemList()->size() - 1);
11121108
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+
}
11181112
}
1113+
selectedTech = m_apPlayerTechSelect[player]->GetItem(randomSelection);
1114+
}
1115+
if (selectedTech) { newPlayer.m_NativeTechModule = selectedTech->m_ExtraIndex; }
1116+
}
11191117

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-
11291118
// Set the starting brains for this player
11301119
// Start with the baseline setting
11311120
newPlayer.m_BrainPool = m_pLengthSlider->GetValue();

Menus/ScenarioActivityConfigGUI.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ namespace RTE {
212212
if (techItem->m_ExtraIndex == -2) {
213213
gameActivity->SetTeamTech(team, "-All-");
214214
} else if (techItem->m_ExtraIndex == -1) {
215-
m_TeamTechComboBoxes.at(team)->SetSelectedIndex(RandomNum<int>(2, m_TeamTechComboBoxes.at(team)->GetListPanel()->GetItemList()->size() - 1));
216-
gameActivity->SetTeamTech(team, g_PresetMan.GetDataModuleName(m_TeamTechComboBoxes.at(team)->GetSelectedItem()->m_ExtraIndex));
215+
gameActivity->SetTeamTech(team, g_PresetMan.GetDataModuleName(m_TeamTechComboBoxes.at(team)->GetItem(RandomNum<int>(2, m_TeamTechComboBoxes.at(team)->GetListPanel()->GetItemList()->size() - 1))->m_ExtraIndex));
217216
} else {
218217
gameActivity->SetTeamTech(team, g_PresetMan.GetDataModuleName(techItem->m_ExtraIndex));
219218
}

0 commit comments

Comments
 (0)