* Swap the two up/down flags in two ways: * - Swap values of \a swap_flag1 and \a swap_flag2, and * - If going up previously (#GVF_GOINGUP_BIT set), the #GVF_GOINGDOWN_BIT is set, and vice versa. * @param[in,out] swap_flag1 First train flag. * @param[in,out] swap_flag2 Second train flag. */
| 1582 | * @param[in,out] swap_flag2 Second train flag. |
| 1583 | */ |
| 1584 | static void SwapTrainFlags(uint16_t *swap_flag1, uint16_t *swap_flag2) |
| 1585 | { |
| 1586 | uint16_t flag1 = *swap_flag1; |
| 1587 | uint16_t flag2 = *swap_flag2; |
| 1588 | |
| 1589 | /* Clear the flags */ |
| 1590 | ClrBit(*swap_flag1, GVF_GOINGUP_BIT); |
| 1591 | ClrBit(*swap_flag1, GVF_GOINGDOWN_BIT); |
| 1592 | ClrBit(*swap_flag2, GVF_GOINGUP_BIT); |
| 1593 | ClrBit(*swap_flag2, GVF_GOINGDOWN_BIT); |
| 1594 | |
| 1595 | /* Reverse the rail-flags (if needed) */ |
| 1596 | if (HasBit(flag1, GVF_GOINGUP_BIT)) { |
| 1597 | SetBit(*swap_flag2, GVF_GOINGDOWN_BIT); |
| 1598 | } else if (HasBit(flag1, GVF_GOINGDOWN_BIT)) { |
| 1599 | SetBit(*swap_flag2, GVF_GOINGUP_BIT); |
| 1600 | } |
| 1601 | if (HasBit(flag2, GVF_GOINGUP_BIT)) { |
| 1602 | SetBit(*swap_flag1, GVF_GOINGDOWN_BIT); |
| 1603 | } else if (HasBit(flag2, GVF_GOINGDOWN_BIT)) { |
| 1604 | SetBit(*swap_flag1, GVF_GOINGUP_BIT); |
| 1605 | } |
| 1606 | } |
| 1607 | |
| 1608 | /** |
| 1609 | * Updates some variables after swapping the vehicle. |
no test coverage detected