-
Notifications
You must be signed in to change notification settings - Fork 190
Fix: Fixed Processing of Profession Salaries in the Event New Profession Added Since Campaign Last Loaded #7059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ion Added Since Campaign Last Loaded
} else if (nodeName.equalsIgnoreCase("salaryTypeBase")) { | ||
Money[] defaultSalaries = retVal.getRoleBaseSalaries(); | ||
Money[] newSalaries = Utilities.readMoneyArray(wn2); | ||
Money[] defaultSalaries = campaignOptions.getRoleBaseSalaries(); | ||
Money[] newSalaries = Utilities.readMoneyArray(childNode); | ||
|
||
Money[] mergedSalaries = new Money[PersonnelRole.values().length]; | ||
for (int i = 0; i < mergedSalaries.length; i++) { | ||
mergedSalaries[i] = (newSalaries[i] != null) ? newSalaries[i] : defaultSalaries[i]; | ||
try { | ||
mergedSalaries[i] = (newSalaries[i] != null) ? newSalaries[i] : defaultSalaries[i]; | ||
} catch (Exception e) { | ||
// This will happen if we ever add a new profession, as it will exceed the entries in | ||
// the child node | ||
mergedSalaries[i] = defaultSalaries[i]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I was in this neck of the woods I took the opportunity to clean up xml parsing. This is the only section with actual functionality changes.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #7059 +/- ##
============================================
- Coverage 12.43% 12.42% -0.01%
Complexity 7243 7243
============================================
Files 1116 1117 +1
Lines 143957 144014 +57
Branches 22163 22166 +3
============================================
+ Hits 17897 17898 +1
- Misses 124224 124279 +55
- Partials 1836 1837 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
# Conflicts: # MekHQ/src/mekhq/campaign/CampaignOptions.java
When we load a campaign we transcribe profession salaries to the campaign. If a new profession were added this could potentially fail. The end result would be the remaining professions would all receive default salaries.
This isn't a huge issue currently as, concerning the recent addition of professions, we want them to have default salaries anyway. However, this would become a problem if a new profession was added in the middle of the profession enum, rather than at the end.
This PR resolves the problem.