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 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
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 planetmaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes please

@PeterN PeterN merged commit b6e3e30 into OpenTTD:master Mar 29, 2019
@PeterN PeterN deleted the simplify-airport-noise branch March 29, 2019 17:43
douiwby pushed a commit to douiwby/OpenTTD that referenced this pull request Apr 16, 2020
…ound, so use it. (OpenTTD#7427)

Previously the distance was thrown away, only to be expensively recalculated again.
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

Successfully merging this pull request may close these issues.

None yet

3 participants