mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 10:46:45 +01:00
refactor(ai): the orders of the AI are DriverOrder and DriverOrders, not the bits of TOrders
The orders of the AI driver (TOrders) were unscoped bits, summed (an order
carries Change_direction on top of Shunt), masked, and compared as numbers
(order < Obey_train, order >= Shunt).
- vehicle/driverorders.h: enum class DriverOrder (waitForOrders,
prepareEngine, releaseEngine, changeDirection, connect, disconnect, shunt,
looseShunt, obeyTrain, bank, jumpToFirstOrder) and DriverOrders, an
EnumSet of them. A small header, so brakesetting.h names the orders without
Driver.h.
- the comparisons of the numbers are the sets they meant: the orders from
shunt up are movingOrders, those from obeyTrain up trainOrders;
SingleOrder() gives the order to a switch, where a sum of several matches
no case, as it did
- the texts of the scenery commands (Shunt, Obey_train...) and of the
translations are unchanged; only the C++ names changed
No change in behaviour: 1144/1144 tests, golden traces exact against staging
62f7a29b.
This commit is contained in:
@@ -436,8 +436,8 @@ void blackbox_recorder::write_cab() {
|
||||
sample.lateral_acceleration = static_cast<float>(occupied->AccN);
|
||||
if (owner != nullptr && owner->is_train()) {
|
||||
auto const order{owner->order_current()};
|
||||
sample.movement = (order & Obey_train) != 0 ? blackbox::movements::train :
|
||||
(order & (Shunt | Loose_shunt | Connect)) != 0 ? blackbox::movements::shunting : blackbox::movements::other;
|
||||
sample.movement = order.HasAny(DriverOrder::obeyTrain) ? blackbox::movements::train :
|
||||
order.HasAny(DriverOrder::shunt | DriverOrder::looseShunt | DriverOrder::connect) ? blackbox::movements::shunting : blackbox::movements::other;
|
||||
sample.light_hint_head = static_cast<std::int16_t>(owner->light_hint(end::front));
|
||||
sample.light_hint_tail = static_cast<std::int16_t>(owner->light_hint(end::rear));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user