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

Function AirportHasBlock

src/aircraft_cmd.cpp:1872–1894  ·  view source on GitHub ↗

returns true if the road ahead is busy, eg. you must wait before proceeding. */

Source from the content-addressed store, hash-verified

1870
1871/** returns true if the road ahead is busy, eg. you must wait before proceeding. */
1872static bool AirportHasBlock(Aircraft *v, const AirportFTA *current_pos, const AirportFTAClass *apc)
1873{
1874 const AirportFTA *reference = &apc->layout[v->pos];
1875 const AirportFTA *next = &apc->layout[current_pos->next_position];
1876
1877 /* same block, then of course we can move */
1878 if (apc->layout[current_pos->position].blocks != next->blocks) {
1879 const Station *st = Station::Get(v->targetairport);
1880 AirportBlocks blocks = next->blocks;
1881
1882 /* check additional possible extra blocks */
1883 if (current_pos != reference && current_pos->blocks != AirportBlock::Nothing) {
1884 blocks.Set(current_pos->blocks);
1885 }
1886
1887 if (st->airport.blocks.Any(blocks)) {
1888 v->cur_speed = 0;
1889 v->subspeed = 0;
1890 return true;
1891 }
1892 }
1893 return false;
1894}
1895
1896/**
1897 * "reserve" a block for the plane

Calls 2

AnyMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected