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

Method MapOldOrder

src/order_cmd.cpp:180–206  ·  view source on GitHub ↗

* Pack this order into a 16 bits integer as close to the TTD * representation as possible. * @return the TTD-like packed representation. */

Source from the content-addressed store, hash-verified

178 * @return the TTD-like packed representation.
179 */
180uint16_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 *

Callers 1

VehicleGetVariableFunction · 0.80

Calls 10

GetTypeMethod · 0.95
GetUnloadTypeMethod · 0.95
IsFullLoadOrderMethod · 0.95
GetNonStopTypeMethod · 0.95
GetDestinationMethod · 0.95
GetDepotOrderTypeMethod · 0.95
GetLoadTypeMethod · 0.95
SetBitFunction · 0.85
GBFunction · 0.85
TestMethod · 0.80

Tested by

no test coverage detected