equal
deleted
inserted
replaced
14 #include "../../vehicle_func.h" |
14 #include "../../vehicle_func.h" |
15 #include "../../core/alloc_func.hpp" |
15 #include "../../core/alloc_func.hpp" |
16 #include "../../economy_func.h" |
16 #include "../../economy_func.h" |
17 #include "../../core/bitmath_func.hpp" |
17 #include "../../core/bitmath_func.hpp" |
18 #include "../../settings_type.h" |
18 #include "../../settings_type.h" |
|
19 #include "../../articulated_vehicles.h" |
19 #include "table/strings.h" |
20 #include "table/strings.h" |
20 |
21 |
21 /* static */ bool AIEngine::IsValidEngine(EngineID engine_id) |
22 /* static */ bool AIEngine::IsValidEngine(EngineID engine_id) |
22 { |
23 { |
23 return ::IsEngineIndex(engine_id) && HasBit(::GetEngine(engine_id)->player_avail, _current_player); |
24 return ::IsEngineIndex(engine_id) && HasBit(::GetEngine(engine_id)->player_avail, _current_player); |
76 /* static */ uint32 AIEngine::GetCapacity(EngineID engine_id) |
77 /* static */ uint32 AIEngine::GetCapacity(EngineID engine_id) |
77 { |
78 { |
78 if (!IsValidEngine(engine_id)) return 0; |
79 if (!IsValidEngine(engine_id)) return 0; |
79 |
80 |
80 switch (::GetEngine(engine_id)->type) { |
81 switch (::GetEngine(engine_id)->type) { |
81 case VEH_ROAD: { |
82 case VEH_ROAD: |
82 const RoadVehicleInfo *vi = ::RoadVehInfo(engine_id); |
83 case VEH_TRAIN: { |
83 return vi->capacity; |
84 uint16 *capacities = GetCapacityOfArticulatedParts(engine_id, ::GetEngine(engine_id)->type); |
84 } break; |
85 for (CargoID c = 0; c < NUM_CARGO; c++) { |
85 |
86 if (capacities[c] == 0) continue; |
86 case VEH_TRAIN: { |
87 return capacities[c]; |
87 const RailVehicleInfo *vi = ::RailVehInfo(engine_id); |
88 } |
88 return vi->capacity; |
89 return 0; |
89 } break; |
90 } break; |
90 |
91 |
91 case VEH_SHIP: { |
92 case VEH_SHIP: { |
92 const ShipVehicleInfo *vi = ::ShipVehInfo(engine_id); |
93 const ShipVehicleInfo *vi = ::ShipVehInfo(engine_id); |
93 return vi->capacity; |
94 return vi->capacity; |