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

Function GetVehiclePosOnBuild

src/airport.cpp:197–212  ·  view source on GitHub ↗

* Get the vehicle position when an aircraft is build at the given tile * @param hangar_tile The tile on which the vehicle is build * @return The position (index in airport node array) where the aircraft ends up */

Source from the content-addressed store, hash-verified

195 * @return The position (index in airport node array) where the aircraft ends up
196 */
197uint8_t GetVehiclePosOnBuild(TileIndex hangar_tile)
198{
199 const Station *st = Station::GetByTile(hangar_tile);
200 const AirportFTAClass *apc = st->airport.GetFTA();
201 /* When we click on hangar we know the tile it is on. By that we know
202 * its position in the array of depots the airport has.....we can search
203 * layout for #th position of depot. Since layout must start with a listing
204 * of all depots, it is simple */
205 for (uint i = 0;; i++) {
206 if (st->airport.GetHangarTile(i) == hangar_tile) {
207 assert(apc->layout[i].heading == HANGAR);
208 return apc->layout[i].position;
209 }
210 }
211 NOT_REACHED();
212}

Callers 1

CmdBuildAircraftFunction · 0.85

Calls 3

NOT_REACHEDFunction · 0.85
GetFTAMethod · 0.80
GetHangarTileMethod · 0.80

Tested by

no test coverage detected