* Pack this order into a 16 bits integer as close to the TTD * representation as possible. * @return the TTD-like packed representation. */
| 178 | * @return the TTD-like packed representation. |
| 179 | */ |
| 180 | uint16_t Order::MapOldOrder() const |
| 181 | { |
| 182 | uint16_t order = this->GetType(); |
| 183 | switch (this->GetType()) { |
| 184 | case OT_GOTO_STATION: |
| 185 | if (this->GetUnloadType() == OrderUnloadType::Unload) SetBit(order, 5); |
| 186 | if (this->IsFullLoadOrder()) SetBit(order, 6); |
| 187 | if (this->GetNonStopType().Test(OrderNonStopFlag::NoIntermediate)) SetBit(order, 7); |
| 188 | order |= GB(this->GetDestination().value, 0, 8) << 8; |
| 189 | break; |
| 190 | case OT_GOTO_DEPOT: |
| 191 | if (!this->GetDepotOrderType().Test(OrderDepotTypeFlag::PartOfOrders)) SetBit(order, 6); |
| 192 | SetBit(order, 7); |
| 193 | order |= GB(this->GetDestination().value, 0, 8) << 8; |
| 194 | break; |
| 195 | case OT_LOADING: |
| 196 | if (this->IsFullLoadOrder()) SetBit(order, 6); |
| 197 | /* If both "no load" and "no unload" are set, return nothing order instead */ |
| 198 | if (this->GetLoadType() == OrderLoadType::NoLoad && this->GetUnloadType() == OrderUnloadType::NoUnload) { |
| 199 | order = OT_NOTHING; |
| 200 | } |
| 201 | break; |
| 202 | default: |
| 203 | break; |
| 204 | } |
| 205 | return order; |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * |
no test coverage detected