| 668 | } |
| 669 | |
| 670 | Vehicle::Vehicle(EntityId _head) |
| 671 | { |
| 672 | auto component = EntityManager::get<VehicleBase>(_head); |
| 673 | if (component == nullptr) |
| 674 | { |
| 675 | throw Exception::RuntimeError("Bad vehicle structure"); |
| 676 | } |
| 677 | head = component->asVehicleHead(); |
| 678 | if (head == nullptr) |
| 679 | { |
| 680 | throw Exception::RuntimeError("Bad vehicle structure"); |
| 681 | } |
| 682 | component = component->nextVehicleComponent(); |
| 683 | if (component == nullptr) |
| 684 | { |
| 685 | throw Exception::RuntimeError("Bad vehicle structure"); |
| 686 | } |
| 687 | veh1 = component->asVehicle1(); |
| 688 | if (veh1 == nullptr) |
| 689 | { |
| 690 | throw Exception::RuntimeError("Bad vehicle structure"); |
| 691 | } |
| 692 | component = component->nextVehicleComponent(); |
| 693 | if (component == nullptr) |
| 694 | { |
| 695 | throw Exception::RuntimeError("Bad vehicle structure"); |
| 696 | } |
| 697 | veh2 = component->asVehicle2(); |
| 698 | if (veh2 == nullptr) |
| 699 | { |
| 700 | throw Exception::RuntimeError("Bad vehicle structure"); |
| 701 | } |
| 702 | component = component->nextVehicleComponent(); |
| 703 | if (component == nullptr) |
| 704 | { |
| 705 | throw Exception::RuntimeError("Bad vehicle structure"); |
| 706 | } |
| 707 | if (component->getSubType() != VehicleEntityType::tail) |
| 708 | { |
| 709 | cars = Cars{ Car{ component } }; |
| 710 | } |
| 711 | while (component->getSubType() != VehicleEntityType::tail) |
| 712 | { |
| 713 | component = component->nextVehicleComponent(); |
| 714 | if (component == nullptr) |
| 715 | { |
| 716 | throw Exception::RuntimeError("Bad vehicle structure"); |
| 717 | } |
| 718 | } |
| 719 | tail = component->asVehicleTail(); |
| 720 | } |
| 721 | |
| 722 | void Vehicle::refreshCars() |
| 723 | { |
nothing calls this directly
no test coverage detected