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

Function AircraftHandleDestTooFar

src/aircraft_cmd.cpp:2075–2096  ·  view source on GitHub ↗

* Handle the 'dest too far' flag and the corresponding news message for aircraft. * @param v The aircraft. * @param too_far True if the current destination is too far away. */

Source from the content-addressed store, hash-verified

2073 * @param too_far True if the current destination is too far away.
2074 */
2075static void AircraftHandleDestTooFar(Aircraft *v, bool too_far)
2076{
2077 if (too_far) {
2078 if (!HasBit(v->flags, VAF_DEST_TOO_FAR)) {
2079 SetBit(v->flags, VAF_DEST_TOO_FAR);
2080 SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP);
2081 AI::NewEvent(v->owner, new ScriptEventAircraftDestTooFar(v->index));
2082 if (v->owner == _local_company) {
2083 /* Post a news message. */
2084 AddVehicleAdviceNewsItem(AdviceType::AircraftDestinationTooFar, GetEncodedString(STR_NEWS_AIRCRAFT_DEST_TOO_FAR, v->index), v->index);
2085 }
2086 }
2087 return;
2088 }
2089
2090 if (HasBit(v->flags, VAF_DEST_TOO_FAR)) {
2091 /* Not too far anymore, clear flag and message. */
2092 ClrBit(v->flags, VAF_DEST_TOO_FAR);
2093 SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP);
2094 DeleteVehicleNews(v->index, AdviceType::AircraftDestinationTooFar);
2095 }
2096}
2097
2098static bool AircraftEventHandler(Aircraft *v, int loop)
2099{

Callers 1

AircraftEventHandlerFunction · 0.85

Calls 7

HasBitFunction · 0.85
SetBitFunction · 0.85
SetWindowWidgetDirtyFunction · 0.85
AddVehicleAdviceNewsItemFunction · 0.85
ClrBitFunction · 0.85
DeleteVehicleNewsFunction · 0.85
GetEncodedStringFunction · 0.70

Tested by

no test coverage detected