Skip to content

Commit 9d71a62

Browse files
committed
2 parents 07f9d78 + 9617de5 commit 9d71a62

File tree

7 files changed

+62
-23
lines changed

7 files changed

+62
-23
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1212

1313
- `Lerp` can now be used on Vectors and Matrices/Rotations, not just numbers.
1414

15+
- Added `HDFirearm` lua bindings `EjectionOffset` (R/W) and `EjectionPos` (R). Work similarly to their Muzzle variants.
16+
1517
</details>
1618

1719
<details><summary><b>Changed</b></summary>
@@ -60,6 +62,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6062

6163
- Fixed Decision Day camera potentially getting stuck at the start if player 1 wasn't present.
6264

65+
- Fixed Conquest tech selection dropdown getting repeatedly repopulated with duplicated entries, which could cause a crash.
66+
6367
</details>
6468

6569
<details><summary><b>Removed</b></summary>

Source/Entities/HDFirearm.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,10 @@ Vector HDFirearm::GetMuzzlePos() const {
531531
return m_Pos + RotateOffset(m_MuzzleOff);
532532
}
533533

534+
Vector HDFirearm::GetEjectionPos() const {
535+
return m_Pos + RotateOffset(m_EjectOff);
536+
}
537+
534538
void HDFirearm::RestDetection() {
535539
HeldDevice::RestDetection();
536540

Source/Entities/HDFirearm.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,23 @@ namespace RTE {
273273

274274
/// Sets the unrotated relative offset from the position to the muzzle or
275275
/// other equivalent point of this.
276-
/// @param newOffset Bew ofsset value.
276+
/// @param newOffset New offset value.
277277
void SetMuzzleOffset(Vector newOffset) override { m_MuzzleOff = newOffset; }
278278

279+
/// Gets the absolute position of the Shell ejection point.
280+
/// @return A vector describing the absolute world coordinates for the Shell
281+
/// ejection point of this
282+
Vector GetEjectionPos() const;
283+
284+
/// Gets the unrotated relative offset from the position to the Shell ejection point.
285+
/// @return A unrotated vector describing the relative for the Shell ejection point of
286+
/// this from this' position.
287+
Vector GetEjectionOffset() const { return m_EjectOff; }
288+
289+
/// Sets the unrotated relative offset from the position to the Shell ejection point.
290+
/// @param newOffset New offset value.
291+
void SetEjectionOffset(Vector newOffset) { m_EjectOff = newOffset; }
292+
279293
/// Gets this HDFirearm's pre fire sound. Ownership is NOT transferred!
280294
/// @return The SoundContainer for this HDFirearm's pre fire sound.
281295
SoundContainer* GetPreFireSound() const { return m_PreFireSound; }

Source/Lua/LuaBindingsEntities.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,8 @@ LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, HDFirearm) {
607607
return ConcreteTypeLuaClassDefinition(HDFirearm, HeldDevice)
608608

609609
.property("ReloadEndOffset", &HDFirearm::GetReloadEndOffset, &HDFirearm::SetReloadEndOffset)
610+
.property("EjectionPos", &HDFirearm::GetEjectionPos)
611+
.property("EjectionOffset", &HDFirearm::GetEjectionOffset, &HDFirearm::SetEjectionOffset)
610612
.property("RateOfFire", &HDFirearm::GetRateOfFire, &HDFirearm::SetRateOfFire)
611613
.property("MSPerRound", &HDFirearm::GetMSPerRound)
612614
.property("FullAuto", &HDFirearm::IsFullAuto, &HDFirearm::SetFullAuto)

Source/Menus/MetagameGUI.cpp

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ int MetagameGUI::Create(Controller* pController) {
582582

583583
// Hide all screens, the appropriate screen will reappear on next update
584584
HideAllScreens();
585+
m_TechAndFlagListFetched = false;
585586
return 0;
586587
}
587588

@@ -717,33 +718,43 @@ void MetagameGUI::SetEnabled(bool enable) {
717718
g_GUISound.ExitMenuSound()->Play();
718719
}
719720

720-
// Populate the tech comboboxes with the available tech modules
721-
for (int team = Activity::Teams::TeamOne; team < Activity::Teams::MaxTeamCount; ++team) {
722-
m_apPlayerTechSelect[team]->GetListPanel()->AddItem("-Random-", "", nullptr, nullptr, -1);
723-
m_apPlayerTechSelect[team]->SetSelectedIndex(0);
724-
}
725-
for (int moduleID = 0; moduleID < g_PresetMan.GetTotalModuleCount(); ++moduleID) {
726-
if (const DataModule* dataModule = g_PresetMan.GetDataModule(moduleID)) {
727-
if (dataModule->IsFaction()) {
728-
for (int team = Activity::Teams::TeamOne; team < Activity::Teams::MaxTeamCount; ++team) {
729-
m_apPlayerTechSelect[team]->GetListPanel()->AddItem(dataModule->GetFriendlyName(), "", nullptr, nullptr, moduleID);
730-
m_apPlayerTechSelect[team]->GetListPanel()->ScrollToTop();
721+
if (!m_TechAndFlagListFetched) {
722+
m_TechAndFlagListFetched = true;
723+
// Populate the tech comboboxes with the available tech modules
724+
for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) {
725+
m_apPlayerTechSelect[player]->GetListPanel()->AddItem("-Random-", "", nullptr, nullptr, -1);
726+
m_apPlayerTechSelect[player]->SetSelectedIndex(0);
727+
}
728+
for (int moduleID = 0; moduleID < g_PresetMan.GetTotalModuleCount(); ++moduleID) {
729+
if (const DataModule* dataModule = g_PresetMan.GetDataModule(moduleID)) {
730+
if (dataModule->IsFaction()) {
731+
for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) {
732+
m_apPlayerTechSelect[player]->GetListPanel()->AddItem(dataModule->GetFriendlyName(), "", nullptr, nullptr, moduleID);
733+
}
731734
}
732735
}
733736
}
734-
}
737+
// Start scrolled to the top.
738+
for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) {
739+
m_apPlayerTechSelect[player]->GetListPanel()->ScrollToTop();
740+
}
735741

736-
std::list<Entity*> flagList;
737-
g_PresetMan.GetAllOfGroup(flagList, "Flags", "Icon");
738-
for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) {
739-
for (std::list<Entity*>::iterator itr = flagList.begin(); itr != flagList.end(); ++itr) {
740-
if (const Icon* pIcon = dynamic_cast<Icon*>(*itr)) {
741-
m_apPlayerTeamSelect[player]->AddItem("", "", new AllegroBitmap(pIcon->GetBitmaps32()[0]), pIcon);
742+
// Populate team selection flags.
743+
std::list<Entity*> flagList;
744+
g_PresetMan.GetAllOfGroup(flagList, "Flags", "Icon");
745+
for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) {
746+
for (std::list<Entity*>::iterator itr = flagList.begin(); itr != flagList.end(); ++itr) {
747+
if (const Icon* pIcon = dynamic_cast<Icon*>(*itr)) {
748+
m_apPlayerTeamSelect[player]->AddItem("", "", new AllegroBitmap(pIcon->GetBitmaps32()[0]), pIcon);
749+
}
742750
}
743751
}
744752
}
745-
if (m_apPlayerTeamSelect[Players::PlayerOne]->GetSelectedIndex() < 0) {
746-
m_apPlayerTeamSelect[Players::PlayerOne]->SetSelectedIndex(0);
753+
// If a player has no team selected, default to the same team as their player index.
754+
for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) {
755+
if (m_apPlayerTeamSelect[player]->GetSelectedIndex() < 0) {
756+
m_apPlayerTeamSelect[player]->SetSelectedIndex(player);
757+
}
747758
}
748759

749760
m_ScreenChange = true;

Source/Menus/MetagameGUI.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,8 @@ namespace RTE {
772772
// The scene currently being played, NOT OWNED
773773
Scene* m_pPlayingScene;
774774

775+
bool m_TechAndFlagListFetched; //!< Whether the tech list was fetched and each team's ComboBox was populated with it, even if no valid tech modules were added. The team flags are also populated at the same time.
776+
775777
// NEW GAME DIALOG
776778
// Game size label and slider
777779
GUILabel* m_pSizeLabel;

Source/Menus/ScenarioActivityConfigGUI.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,20 @@ void ScenarioActivityConfigGUI::PopulateTechComboBoxes() {
7373
for (int team = Activity::Teams::TeamOne; team < Activity::Teams::MaxTeamCount; ++team) {
7474
m_TeamTechComboBoxes[team]->GetListPanel()->AddItem("-All-", "", nullptr, nullptr, -2);
7575
m_TeamTechComboBoxes[team]->GetListPanel()->AddItem("-Random-", "", nullptr, nullptr, -1);
76+
m_TeamTechComboBoxes[team]->SetSelectedIndex(0);
7677
}
7778
for (int moduleID = 0; moduleID < g_PresetMan.GetTotalModuleCount(); ++moduleID) {
7879
if (const DataModule* dataModule = g_PresetMan.GetDataModule(moduleID)) {
7980
if (dataModule->IsFaction()) {
8081
for (int team = Activity::Teams::TeamOne; team < Activity::Teams::MaxTeamCount; ++team) {
8182
m_TeamTechComboBoxes[team]->GetListPanel()->AddItem(dataModule->GetFriendlyName(), "", nullptr, nullptr, moduleID);
82-
m_TeamTechComboBoxes[team]->GetListPanel()->ScrollToTop();
83-
m_TeamTechComboBoxes[team]->SetSelectedIndex(0);
8483
}
8584
}
8685
}
8786
}
87+
for (int team = Activity::Teams::TeamOne; team < Activity::Teams::MaxTeamCount; ++team) {
88+
m_TeamTechComboBoxes[team]->GetListPanel()->ScrollToTop();
89+
}
8890
m_TechListFetched = true;
8991
}
9092

0 commit comments

Comments
 (0)