625 case 0xFE: |
625 case 0xFE: |
626 case 0xFF: { |
626 case 0xFF: { |
627 uint16 modflags = 0; |
627 uint16 modflags = 0; |
628 |
628 |
629 if (v->type == VEH_TRAIN) { |
629 if (v->type == VEH_TRAIN) { |
630 /* @todo: There are some other bits that should be implemented: |
|
631 * bit 8: (Maybe?) Toggled whenever the train reverses. |
|
632 */ |
|
633 const Vehicle *u = IsTrainWagon(v) && HasBit(v->vehicle_flags, VRF_POWEREDWAGON) ? v->First() : v; |
630 const Vehicle *u = IsTrainWagon(v) && HasBit(v->vehicle_flags, VRF_POWEREDWAGON) ? v->First() : v; |
634 RailType railtype = GetRailType(v->tile); |
631 RailType railtype = GetRailType(v->tile); |
635 bool powered = IsTrainEngine(v) || (IsTrainWagon(v) && HasBit(v->vehicle_flags, VRF_POWEREDWAGON)); |
632 bool powered = IsTrainEngine(v) || (IsTrainWagon(v) && HasBit(v->vehicle_flags, VRF_POWEREDWAGON)); |
636 bool has_power = powered && HasPowerOnRail(u->u.rail.railtype, railtype); |
633 bool has_power = powered && HasPowerOnRail(u->u.rail.railtype, railtype); |
637 bool is_electric = powered && u->u.rail.railtype == RAILTYPE_ELECTRIC; |
634 bool is_electric = powered && u->u.rail.railtype == RAILTYPE_ELECTRIC; |
|
635 |
638 if (has_power) SetBit(modflags, 5); |
636 if (has_power) SetBit(modflags, 5); |
639 if (is_electric && !has_power) SetBit(modflags, 6); |
637 if (is_electric && !has_power) SetBit(modflags, 6); |
|
638 if (HasBit(v->u.rail.flags, VRF_TOGGLE_REVERSE)) SetBit(modflags, 8); |
640 } |
639 } |
641 if (HasBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE)) SetBit(modflags, 10); |
640 if (HasBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE)) SetBit(modflags, 10); |
642 |
641 |
643 return variable == 0xFE ? modflags : GB(modflags, 8, 8); |
642 return variable == 0xFE ? modflags : GB(modflags, 8, 8); |
644 } |
643 } |