equal
deleted
inserted
replaced
11 /* static */ bool AICargo::IsValidCargo(CargoID cargo_type) |
11 /* static */ bool AICargo::IsValidCargo(CargoID cargo_type) |
12 { |
12 { |
13 return (cargo_type < NUM_CARGO && ::GetCargo(cargo_type)->IsValid()); |
13 return (cargo_type < NUM_CARGO && ::GetCargo(cargo_type)->IsValid()); |
14 } |
14 } |
15 |
15 |
16 char *AICargo::GetCargoLabel(CargoID cargo_type) |
16 /* static */ char *AICargo::GetCargoLabel(CargoID cargo_type) |
17 { |
17 { |
18 if (!IsValidCargo(cargo_type)) return NULL; |
18 if (!IsValidCargo(cargo_type)) return NULL; |
19 const CargoSpec *cargo = ::GetCargo(cargo_type); |
19 const CargoSpec *cargo = ::GetCargo(cargo_type); |
20 |
20 |
21 /* cargo->label is a uint32 packing a 4 character non-terminated string, |
21 /* cargo->label is a uint32 packing a 4 character non-terminated string, |
26 } |
26 } |
27 cargo_label[sizeof(cargo->label)] = '\0'; |
27 cargo_label[sizeof(cargo->label)] = '\0'; |
28 return cargo_label; |
28 return cargo_label; |
29 } |
29 } |
30 |
30 |
31 bool AICargo::IsFreight(CargoID cargo_type) |
31 /* static */ bool AICargo::IsFreight(CargoID cargo_type) |
32 { |
32 { |
33 if (!IsValidCargo(cargo_type)) return false; |
33 if (!IsValidCargo(cargo_type)) return false; |
34 const CargoSpec *cargo = ::GetCargo(cargo_type); |
34 const CargoSpec *cargo = ::GetCargo(cargo_type); |
35 return cargo->is_freight; |
35 return cargo->is_freight; |
36 } |
36 } |
37 |
37 |
38 int32 AICargo::GetCargoIncome(uint32 distance, uint32 days_in_transit, CargoID cargo_type) |
38 /* static */ int32 AICargo::GetCargoIncome(uint32 distance, uint32 days_in_transit, CargoID cargo_type) |
39 { |
39 { |
40 if (!IsValidCargo(cargo_type)) return 0; |
40 if (!IsValidCargo(cargo_type)) return 0; |
41 return ::GetTransportedGoodsIncome(1, distance, days_in_transit, cargo_type); |
41 return ::GetTransportedGoodsIncome(1, distance, days_in_transit, cargo_type); |
42 } |
42 } |