MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / IsEngineCountable

Method IsEngineCountable

src/vehicle.cpp:685–696  ·  view source on GitHub ↗

* Check if a vehicle is counted in num_engines in each company struct * @return true if the vehicle is counted in num_engines */

Source from the content-addressed store, hash-verified

683 * @return true if the vehicle is counted in num_engines
684 */
685bool Vehicle::IsEngineCountable() const
686{
687 switch (this->type) {
688 case VEH_AIRCRAFT: return Aircraft::From(this)->IsNormalAircraft(); // don't count plane shadows and helicopter rotors
689 case VEH_TRAIN:
690 return !this->IsArticulatedPart() && // tenders and other articulated parts
691 !Train::From(this)->IsRearDualheaded(); // rear parts of multiheaded engines
692 case VEH_ROAD: return RoadVehicle::From(this)->IsFrontEngine();
693 case VEH_SHIP: return true;
694 default: return false; // Only count company buildable vehicles
695 }
696}
697
698/**
699 * Check whether Vehicle::engine_type has any meaning.

Callers 6

PreDestructorMethod · 0.95
UpdateAfterLoadMethod · 0.80
AddVehicleToGroupFunction · 0.80
SetTrainGroupIDFunction · 0.80
UpdateTrainGroupIDFunction · 0.80

Calls 4

IsArticulatedPartMethod · 0.95
IsNormalAircraftMethod · 0.80
IsRearDualheadedMethod · 0.80
IsFrontEngineMethod · 0.80

Tested by

no test coverage detected