Skip to content

Commit

Permalink
Initialize counter equipment list.
Browse files Browse the repository at this point in the history
  • Loading branch information
neoancient committed Apr 25, 2024
1 parent 77bd255 commit a846587
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package megamek.common.actions;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;

Expand Down Expand Up @@ -64,6 +65,9 @@ public boolean getPDOverheated() {
* This is for AMS assignment to manual tele-operated missiles
*/
public List<WeaponMounted> getCounterEquipment() {
if (vCounterEquipment == null) {
vCounterEquipment = new ArrayList<>();
}
return vCounterEquipment;
}

Expand Down
9 changes: 2 additions & 7 deletions megamek/src/megamek/common/equipment/WeaponMounted.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public List<WeaponMounted> getBayWeapons() {
*/
public WeaponMounted getBayWeapon(int index) {
if ((index >= 0) && (index < bayWeapons.size())) {
return (WeaponMounted) getEntity().getEquipment(index);
return getEntity().getWeapon(index);
} else {
return null;
}
Expand Down Expand Up @@ -271,12 +271,7 @@ public List<AmmoMounted> getBayAmmo() {
* @return whether the ammo is in this weapon's bay
*/
public boolean ammoInBay(int mAmmoId) {
for (int nextAmmoId : bayAmmo) {
if (nextAmmoId == mAmmoId) {
return true;
}
}
return false;
return bayAmmo.contains(mAmmoId);
}

/**
Expand Down

0 comments on commit a846587

Please sign in to comment.