Skip to content

Commit af3fe48

Browse files
committed
Merge pull request #79 from MegaMek/issue-68_advance_day_indexOOB
Issue #68: IndexOutOfBoundsException when advancing day
2 parents 72c1771 + ca441e7 commit af3fe48

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

MekHQ/docs/history.txt

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ v0.3.28-git
1515
+ Bug [#925]: Issues with reload of MHQ and Settings
1616
+ [AtB] When failure to deploy results in defeat, replace generated entities with stubs.
1717
+ Issue #40: [ATB] 3.25 : Enemy reinforcements incorrectly set to deploy at the start of the game
18+
+ Issue #68: IndexOutOfBoundsException when advancing day
1819

1920
v0.3.27 (2016-04-16 00:30 UTC)
2021
+ Updated MegaMek.jar to 0.41.17

MekHQ/src/mekhq/gui/CampaignGUI.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -6683,7 +6683,11 @@ protected ArrayList<Person> getSelectedUnassignedPatients() {
66836683
return patients;
66846684
}
66856685
for (int idx : indices) {
6686-
patients.add((Person) unassignedPatientModel.getElementAt(idx));
6686+
Person p = assignedPatientModel.getElementAt(idx);
6687+
if (p == null) {
6688+
continue;
6689+
}
6690+
patients.add(p);
66876691
}
66886692
return patients;
66896693
}
@@ -6695,7 +6699,11 @@ protected ArrayList<Person> getSelectedAssignedPatients() {
66956699
return patients;
66966700
}
66976701
for (int idx : indices) {
6698-
patients.add((Person) assignedPatientModel.getElementAt(idx));
6702+
Person p = assignedPatientModel.getElementAt(idx);
6703+
if (p == null) {
6704+
continue;
6705+
}
6706+
patients.add(p);
66996707
}
67006708
return patients;
67016709
}

MekHQ/src/mekhq/gui/model/PatientTableModel.java

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public void setData(ArrayList<Person> data) {
3535

3636
@Override
3737
public Person getElementAt(int index) {
38+
if (index < 0 || index >= patients.size()) {
39+
return null;
40+
}
3841
return patients.get(index);
3942
}
4043

0 commit comments

Comments
 (0)