* 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. */
| 2073 | * @param too_far True if the current destination is too far away. |
| 2074 | */ |
| 2075 | static 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 | |
| 2098 | static bool AircraftEventHandler(Aircraft *v, int loop) |
| 2099 | { |
no test coverage detected