| 725 | } |
| 726 | |
| 727 | static void AddRearEngineToMultiheadedTrain(Train *v) |
| 728 | { |
| 729 | Train *u = new Train(); |
| 730 | v->value >>= 1; |
| 731 | u->value = v->value; |
| 732 | u->direction = v->direction; |
| 733 | u->owner = v->owner; |
| 734 | u->tile = v->tile; |
| 735 | u->x_pos = v->x_pos; |
| 736 | u->y_pos = v->y_pos; |
| 737 | u->z_pos = v->z_pos; |
| 738 | u->track = TRACK_BIT_DEPOT; |
| 739 | u->vehstatus = v->vehstatus; |
| 740 | u->vehstatus.Reset(VehState::Stopped); |
| 741 | u->spritenum = v->spritenum + 1; |
| 742 | u->cargo_type = v->cargo_type; |
| 743 | u->cargo_subtype = v->cargo_subtype; |
| 744 | u->cargo_cap = v->cargo_cap; |
| 745 | u->refit_cap = v->refit_cap; |
| 746 | u->railtypes = v->railtypes; |
| 747 | u->engine_type = v->engine_type; |
| 748 | u->date_of_last_service = v->date_of_last_service; |
| 749 | u->date_of_last_service_newgrf = v->date_of_last_service_newgrf; |
| 750 | u->build_year = v->build_year; |
| 751 | u->sprite_cache.sprite_seq.Set(SPR_IMG_QUERY); |
| 752 | u->random_bits = Random(); |
| 753 | v->SetMultiheaded(); |
| 754 | u->SetMultiheaded(); |
| 755 | v->SetNext(u); |
| 756 | auto prob = TestVehicleBuildProbability(u, u->engine_type, BuildProbabilityType::Reversed); |
| 757 | if (prob.has_value()) u->flags.Set(VehicleRailFlag::Flipped, prob.value()); |
| 758 | u->UpdatePosition(); |
| 759 | |
| 760 | /* Now we need to link the front and rear engines together */ |
| 761 | v->other_multiheaded_part = u; |
| 762 | u->other_multiheaded_part = v; |
| 763 | } |
| 764 | |
| 765 | /** |
| 766 | * Build a railroad vehicle. |
no test coverage detected