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

3 strange code fragments #103

Closed
mjunix opened this issue Feb 20, 2022 · 1 comment
Closed

3 strange code fragments #103

mjunix opened this issue Feb 20, 2022 · 1 comment
Assignees

Comments

@mjunix
Copy link

mjunix commented Feb 20, 2022

(I don't have any experience with this codebase so maybe these are not bugs.)

  1. } if (unit.isAtLocation(destination)) {

    The formatting is strange, the if-statement start on same line as a closing brace, is an else missing before the if? If no else is missing then the if-statement should probably moved to a line of its own.
  2. if (expert != null
    && u.getUnitChange(UnitChangeType.EXPERIENCE, expert) != null) {
    score += 10000;
    } else if (expert != null
    && u.getUnitChange(UnitChangeType.EXPERIENCE, expert) != null) {
    score -= 10000;
    }

    The two if-statements have the same condition.
  3. / ((tcb.getBottomRightDirtyTile().getX()-tcb.getTopLeftDirtyTile().getX()) * (tcb.getBottomRightDirtyTile().getY()-tcb.getBottomRightDirtyTile().getY()));

    Identical expressions (tcb.getBottomRightDirtyTile().getY()) on both sides of subtraction operator.
@mpope042
Copy link
Member

Correct on all counts I think. #1 is a typo/omission, #2 is a logic error (long time since I wrote that code, glad I put a comment above), and #3 looks like the second getY is on the wrong corner of the box. All three are fixed in commits 56e3d26, 4b418cd, 5c4bafb respectively (note: sourceforge git repository commits, SF is the freecol development master, github merely contains a mirror, please prefer the SF bug tracker for further such issues).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants