| 472 | } |
| 473 | |
| 474 | uint8_t swapAdjacentOrders(Order& a, Order& b) |
| 475 | { |
| 476 | // Currently the use of std:: algorithms is not feasible due to variable order lengths |
| 477 | // TODO: simplify this after the changing the data structure for the order table |
| 478 | |
| 479 | const auto rawOrderA = a.getRaw(); |
| 480 | const auto rawOrderB = b.getRaw(); |
| 481 | const auto lengthOrderA = kOrderSizes[enumValue(a.getType())]; |
| 482 | const auto lengthOrderB = kOrderSizes[enumValue(b.getType())]; |
| 483 | |
| 484 | // Ensure the two orders are indeed adjacent |
| 485 | assert(&a + lengthOrderA == &b); |
| 486 | |
| 487 | // Copy B over A, and append B right after |
| 488 | const auto dest = reinterpret_cast<uint8_t*>(&a); |
| 489 | std::memcpy(dest, &rawOrderB, lengthOrderB); |
| 490 | std::memcpy(dest + lengthOrderB, &rawOrderA, lengthOrderA); |
| 491 | |
| 492 | // Return the length with which to offset |
| 493 | return lengthOrderB; |
| 494 | } |
| 495 | |
| 496 | // 0x0047062B |
| 497 | void removeOrdersForStation(const StationId stationId) |
no test coverage detected