-
Notifications
You must be signed in to change notification settings - Fork 188
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
base: master
Are you sure you want to change the base?
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.38% 12.38% -0.01%
+ Complexity 7246 7244 -2
============================================
Files 1117 1117
Lines 144483 144478 -5
Branches 22276 22276
============================================
- Hits 17898 17890 -8
- Misses 124722 124725 +3
Partials 1863 1863 ☔ 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.
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.