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

Codechange: Use already-known distance between town and airport instead of recalculating it. #7427

Merged
merged 1 commit into from Mar 29, 2019

Conversation

@PeterN
Copy link
Member

PeterN commented Mar 27, 2019

Previously the distance was thrown away, only to be expensively recalculated again.

…ound, so use it.

Previously the distance was thrown away, only to be expensively recalculated again.
@PeterN PeterN changed the title Codechange: Distance between town and airport has already just been found, so use it. Codechange: Use already-known distance between town and airport instead of recalculating it. Mar 28, 2019
@SamuXarick

This comment has been minimized.

Copy link
Contributor

SamuXarick commented Mar 29, 2019

local noise = AIAirport.GetNoiseLevelIncrease(tile, a);
local allowed_noise = AITown.GetAllowedNoise(AIAirport.GetNearestTown(tile, a));
if (noise > allowed_noise) continue;

This is how I use it in an AI. Both ScriptAirport::GetNoiseLevelIncrease and ScriptAirport::GetNearestTown call AirportGetNearestTown. I would think a better way was to combine the whole thing and create a new function that does the same but avoids repetition. Something like bool ScriptAirport::IsNoiseLevelAllowed(tile, a).

Copy link
Contributor

planetmaker left a comment

yes please

@PeterN PeterN merged commit b6e3e30 into OpenTTD:master Mar 29, 2019
8 checks passed
8 checks passed
OpenTTD CI Build #20190327.12 succeeded
Details
OpenTTD CI (Linux commit-checker) Linux commit-checker succeeded
Details
OpenTTD CI (Linux linux-amd64-clang-3.8) Linux linux-amd64-clang-3.8 succeeded
Details
OpenTTD CI (Linux linux-amd64-gcc-6) Linux linux-amd64-gcc-6 succeeded
Details
OpenTTD CI (Linux linux-i386-gcc-6) Linux linux-i386-gcc-6 succeeded
Details
OpenTTD CI (MacOS) MacOS succeeded
Details
OpenTTD CI (Windows Win32) Windows Win32 succeeded
Details
OpenTTD CI (Windows Win64) Windows Win64 succeeded
Details
@PeterN PeterN deleted the PeterN:simplify-airport-noise branch Mar 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.