Skip to content

Commit

Permalink
Merge 3956acc into f4581e4
Browse files Browse the repository at this point in the history
  • Loading branch information
Violet-Nonbloosom committed Apr 3, 2024
2 parents f4581e4 + 3956acc commit afc7325
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,13 @@ public int getTeleportationTime(int complexity, @Nonnull Location source, @Nonnu
if (complexity < 100) {
return 100;
}
else if (complexity >= 12246) { // 50_000 + c^2 >= 150_000_000 => c >= 12246
return 1;
}

int speed = 50_000 + complexity * complexity;
int unsafeTime = Math.min(4 * distanceSquared(source, destination) / speed, 40);

// Fixes #3573 - Using Math.max is a safer way to ensure values > 0 than relying on addition.
return Math.max(1, unsafeTime);
int distance = 4 * distanceSquared(source, destination);
return Math.min(distance / speed, 40);
}

@ParametersAreNonnullByDefault
Expand Down

0 comments on commit afc7325

Please sign in to comment.