Skip to content

Commit

Permalink
Trivial: Remove unnecessary null checks. (#11820)
Browse files Browse the repository at this point in the history
  • Loading branch information
asvitkine authored Jul 26, 2023
1 parent e2b8b6c commit 8214b62
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ public void start() {
}
if (Properties.getGiveUnitsByTerritory(getData().getProperties())
&& pa != null
&& pa.getGiveUnitControl() != null
&& !pa.getGiveUnitControl().isEmpty()) {
changeUnitOwnership(bridge);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -825,9 +825,7 @@ public String canUnitsBePlaced(
if (!to.isOwnedBy(player)) {
if (GameStepPropertiesHelper.isBid(getData())) {
final PlayerAttachment pa = PlayerAttachment.get(to.getOwner());
if ((pa == null
|| pa.getGiveUnitControl() == null
|| !pa.getGiveUnitControl().contains(player))
if ((pa == null || !pa.getGiveUnitControl().contains(player))
&& !to.anyUnitsMatch(Matches.unitIsOwnedBy(player))) {
return "You don't own " + to.getName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ protected String canProduce(
return "Cant place sea units on land";
} else if (!to.isOwnedBy(player)) {
final PlayerAttachment pa = PlayerAttachment.get(to.getOwner());
if (pa != null
&& pa.getGiveUnitControl() != null
&& pa.getGiveUnitControl().contains(player)) {
if (pa != null && pa.getGiveUnitControl().contains(player)) {
return null;
} else if (to.anyUnitsMatch(Matches.unitIsOwnedBy(player))) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,7 @@ private PlaceableUnits getUnitsToPlace(final Territory territory) {
if (!territory.isWater() && !territory.isOwnedBy(getCurrentPlayer())) {
if (GameStepPropertiesHelper.isBid(getData())) {
final PlayerAttachment pa = PlayerAttachment.get(territory.getOwner());
if ((pa == null
|| pa.getGiveUnitControl() == null
|| !pa.getGiveUnitControl().contains(getCurrentPlayer()))
if ((pa == null || !pa.getGiveUnitControl().contains(getCurrentPlayer()))
&& !territory.anyUnitsMatch(Matches.unitIsOwnedBy(getCurrentPlayer()))) {
return new PlaceableUnits();
}
Expand Down

0 comments on commit 8214b62

Please sign in to comment.