MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / CheckSubsidyDistance

Function CheckSubsidyDistance

src/subsidy.cpp:159–165  ·  view source on GitHub ↗

* Checks if the source and destination of a subsidy are inside the distance limit. * @param src Source of cargo. * @param dst Destination of cargo. * @return True if they are inside the distance limit. */

Source from the content-addressed store, hash-verified

157 * @return True if they are inside the distance limit.
158 */
159static bool CheckSubsidyDistance(Source src, Source dst)
160{
161 TileIndex tile_src = (src.type == SourceType::Town) ? Town::Get(src.ToTownID())->xy : Industry::Get(src.ToIndustryID())->location.tile;
162 TileIndex tile_dst = (dst.type == SourceType::Town) ? Town::Get(dst.ToTownID())->xy : Industry::Get(dst.ToIndustryID())->location.tile;
163
164 return (DistanceManhattan(tile_src, tile_dst) <= SUBSIDY_MAX_DISTANCE);
165}
166
167/**
168 * Creates a subsidy with the given parameters.

Callers 1

Calls 3

DistanceManhattanFunction · 0.85
ToTownIDMethod · 0.80
ToIndustryIDMethod · 0.80

Tested by

no test coverage detected