Skip to content
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

correct NPE in bvReports when player is not on a team #4761

Merged
merged 2 commits into from
Sep 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 24 additions & 20 deletions megamek/src/megamek/server/GameManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1682,26 +1682,30 @@ private void bvReports(boolean checkBlind) {

playerReport.addAll(bvReport(player.getColorForPlayer(), player.getId(), bvcPlayer, checkBlind));

BVCountHelper bvcTeam = teamsInfo.get(player.getTeam());
bvcTeam.bv += bvcPlayer.bv;
bvcTeam.bvInitial += bvcPlayer.bvInitial;
bvcTeam.bvFled += bvcPlayer.bvFled;
bvcTeam.unitsCount += bvcPlayer.unitsCount;
bvcTeam.unitsInitialCount += bvcPlayer.unitsInitialCount;
bvcTeam.unitsLightDamageCount += bvcPlayer.unitsLightDamageCount;
bvcTeam.unitsModerateDamageCount += bvcPlayer.unitsModerateDamageCount;
bvcTeam.unitsHeavyDamageCount += bvcPlayer.unitsHeavyDamageCount;
bvcTeam.unitsCrippledCount += bvcPlayer.unitsCrippledCount;
bvcTeam.unitsDestroyedCount += bvcPlayer.unitsDestroyedCount;
bvcTeam.unitsCrewEjectedCount += bvcPlayer.unitsCrewEjectedCount;
bvcTeam.unitsCrewTrappedCount += bvcPlayer.unitsCrewTrappedCount;
bvcTeam.unitsCrewKilledCount += bvcPlayer.unitsCrewKilledCount;
bvcTeam.unitsFledCount += bvcPlayer.unitsFledCount;
bvcTeam.ejectedCrewActiveCount += bvcPlayer.ejectedCrewActiveCount;
bvcTeam.ejectedCrewPickedUpByTeamCount += bvcPlayer.ejectedCrewPickedUpByTeamCount;
bvcTeam.ejectedCrewPickedUpByEnemyTeamCount += bvcPlayer.ejectedCrewPickedUpByEnemyTeamCount;
bvcTeam.ejectedCrewKilledCount += bvcPlayer.ejectedCrewKilledCount;
bvcTeam.ejectedCrewFledCount += bvcPlayer.ejectedCrewFledCount;
int playerTeam = player.getTeam();

if (playerTeam != Player.TEAM_UNASSIGNED && playerTeam != Player.TEAM_NONE) {
kuronekochomusuke marked this conversation as resolved.
Show resolved Hide resolved
BVCountHelper bvcTeam = teamsInfo.get(playerTeam);
bvcTeam.bv += bvcPlayer.bv;
bvcTeam.bvInitial += bvcPlayer.bvInitial;
bvcTeam.bvFled += bvcPlayer.bvFled;
bvcTeam.unitsCount += bvcPlayer.unitsCount;
bvcTeam.unitsInitialCount += bvcPlayer.unitsInitialCount;
bvcTeam.unitsLightDamageCount += bvcPlayer.unitsLightDamageCount;
bvcTeam.unitsModerateDamageCount += bvcPlayer.unitsModerateDamageCount;
bvcTeam.unitsHeavyDamageCount += bvcPlayer.unitsHeavyDamageCount;
bvcTeam.unitsCrippledCount += bvcPlayer.unitsCrippledCount;
bvcTeam.unitsDestroyedCount += bvcPlayer.unitsDestroyedCount;
bvcTeam.unitsCrewEjectedCount += bvcPlayer.unitsCrewEjectedCount;
bvcTeam.unitsCrewTrappedCount += bvcPlayer.unitsCrewTrappedCount;
bvcTeam.unitsCrewKilledCount += bvcPlayer.unitsCrewKilledCount;
bvcTeam.unitsFledCount += bvcPlayer.unitsFledCount;
bvcTeam.ejectedCrewActiveCount += bvcPlayer.ejectedCrewActiveCount;
bvcTeam.ejectedCrewPickedUpByTeamCount += bvcPlayer.ejectedCrewPickedUpByTeamCount;
bvcTeam.ejectedCrewPickedUpByEnemyTeamCount += bvcPlayer.ejectedCrewPickedUpByEnemyTeamCount;
bvcTeam.ejectedCrewKilledCount += bvcPlayer.ejectedCrewKilledCount;
bvcTeam.ejectedCrewFledCount += bvcPlayer.ejectedCrewFledCount;
}
}

// Show teams BVs
Expand Down