equal
deleted
inserted
replaced
21 #include "cargotype.h" |
21 #include "cargotype.h" |
22 #include "date_func.h" |
22 #include "date_func.h" |
23 #include "vehicle_func.h" |
23 #include "vehicle_func.h" |
24 #include "core/random_func.hpp" |
24 #include "core/random_func.hpp" |
25 #include "direction_func.h" |
25 #include "direction_func.h" |
|
26 #include "rail_map.h" |
|
27 #include "rail.h" |
26 |
28 |
27 |
29 |
28 int _traininfo_vehicle_pitch = 0; |
30 int _traininfo_vehicle_pitch = 0; |
29 int _traininfo_vehicle_width = 29; |
31 int _traininfo_vehicle_width = 29; |
30 |
32 |
622 |
624 |
623 case 0xFE: |
625 case 0xFE: |
624 case 0xFF: { |
626 case 0xFF: { |
625 uint16 modflags = 0; |
627 uint16 modflags = 0; |
626 |
628 |
627 /* @todo: There are some other bits that should be implemented: |
629 if (v->type == VEH_TRAIN) { |
628 * bit 5: Whether the rail vehicle is powered or not (mostly useful for wagons). |
630 /* @todo: There are some other bits that should be implemented: |
629 * bit 6: This is an electrically powered rail vehicle which is running on normal rail. |
631 * bit 8: (Maybe?) Toggled whenever the train reverses. |
630 * bit 8: (Maybe?) Toggled whenever the train reverses. |
632 */ |
631 */ |
633 const Vehicle *u = IsTrainWagon(v) && HasBit(v->vehicle_flags, VRF_POWEREDWAGON) ? v->First() : v; |
632 |
634 RailType railtype = GetRailType(v->tile); |
|
635 bool powered = IsTrainEngine(v) || (IsTrainWagon(v) && HasBit(v->vehicle_flags, VRF_POWEREDWAGON)); |
|
636 bool has_power = powered && HasPowerOnRail(u->u.rail.railtype, railtype); |
|
637 bool is_electric = powered && u->u.rail.railtype == RAILTYPE_ELECTRIC; |
|
638 if (has_power) SetBit(modflags, 5); |
|
639 if (is_electric && !has_power) SetBit(modflags, 6); |
|
640 } |
633 if (HasBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE)) SetBit(modflags, 10); |
641 if (HasBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE)) SetBit(modflags, 10); |
634 |
642 |
635 return variable == 0xFE ? modflags : GB(modflags, 8, 8); |
643 return variable == 0xFE ? modflags : GB(modflags, 8, 8); |
636 } |
644 } |
637 } |
645 } |