Skip to content

Commit

Permalink
correct NPE in bvReports when player is not on a team
Browse files Browse the repository at this point in the history
  • Loading branch information
kuronekochomusuke committed Sep 8, 2023
1 parent 5dc5bc9 commit 81a7688
Showing 1 changed file with 24 additions and 20 deletions.
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) {
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

0 comments on commit 81a7688

Please sign in to comment.