static */
| 45 | |
| 46 | template <bool Tfrom, bool Tvia> |
| 47 | /* static */ SQInteger ScriptStation::CountCargoWaiting(StationID station_id, |
| 48 | StationID from_station_id, StationID via_station_id, CargoType cargo_type) |
| 49 | { |
| 50 | if (!ScriptStation::IsCargoRequestValid<Tfrom, Tvia>(station_id, from_station_id, |
| 51 | via_station_id, cargo_type)) { |
| 52 | return -1; |
| 53 | } |
| 54 | |
| 55 | const ::GoodsEntry &goods = ::Station::Get(station_id)->goods[cargo_type]; |
| 56 | if (!goods.HasData()) return 0; |
| 57 | |
| 58 | const StationCargoList &cargo_list = goods.GetData().cargo; |
| 59 | if (!Tfrom && !Tvia) return cargo_list.TotalCount(); |
| 60 | |
| 61 | uint16_t cargo_count = 0; |
| 62 | std::pair<StationCargoList::ConstIterator, StationCargoList::ConstIterator> range = Tvia ? |
| 63 | cargo_list.Packets()->equal_range(via_station_id) : |
| 64 | std::make_pair(StationCargoList::ConstIterator(cargo_list.Packets()->begin()), |
| 65 | StationCargoList::ConstIterator(cargo_list.Packets()->end())); |
| 66 | for (StationCargoList::ConstIterator it = range.first; it != range.second; it++) { |
| 67 | const CargoPacket *cp = *it; |
| 68 | if (!Tfrom || cp->GetFirstStation() == from_station_id) cargo_count += cp->Count(); |
| 69 | } |
| 70 | |
| 71 | return cargo_count; |
| 72 | } |
| 73 | |
| 74 | /* static */ SQInteger ScriptStation::GetCargoWaiting(StationID station_id, CargoType cargo_type) |
| 75 | { |
nothing calls this directly
no test coverage detected