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

Method CountCargoPlanned

src/script/api/script_station.cpp:98–116  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

96
97template <bool Tfrom, bool Tvia>
98/* static */ SQInteger ScriptStation::CountCargoPlanned(StationID station_id,
99 StationID from_station_id, StationID via_station_id, CargoType cargo_type)
100{
101 if (!ScriptStation::IsCargoRequestValid<Tfrom, Tvia>(station_id, from_station_id,
102 via_station_id, cargo_type)) {
103 return -1;
104 }
105
106 const ::GoodsEntry &goods = ::Station::Get(station_id)->goods[cargo_type];
107 if (!goods.HasData()) return 0;
108
109 const FlowStatMap &flows = goods.GetData().flows;
110 if (Tfrom) {
111 return Tvia ? flows.GetFlowFromVia(from_station_id, via_station_id) :
112 flows.GetFlowFrom(from_station_id);
113 } else {
114 return Tvia ? flows.GetFlowVia(via_station_id) : flows.GetFlow();
115 }
116}
117
118/* static */ SQInteger ScriptStation::GetCargoPlanned(StationID station_id, CargoType cargo_type)
119{

Callers

nothing calls this directly

Calls 5

GetFlowFromViaMethod · 0.80
GetFlowFromMethod · 0.80
GetFlowViaMethod · 0.80
HasDataMethod · 0.45
GetFlowMethod · 0.45

Tested by

no test coverage detected