| 148 | |
| 149 | template <ScriptStationList_Cargo::CargoSelector Tselector> |
| 150 | void CargoCollector::Update(StationID from, StationID via, uint amount) |
| 151 | { |
| 152 | StationID key = StationID::Invalid(); |
| 153 | switch (Tselector) { |
| 154 | case ScriptStationList_Cargo::CS_VIA_BY_FROM: |
| 155 | if (via != this->other_station) return; |
| 156 | [[fallthrough]]; |
| 157 | case ScriptStationList_Cargo::CS_BY_FROM: |
| 158 | key = from; |
| 159 | break; |
| 160 | case ScriptStationList_Cargo::CS_FROM_BY_VIA: |
| 161 | if (from != this->other_station) return; |
| 162 | [[fallthrough]]; |
| 163 | case ScriptStationList_Cargo::CS_BY_VIA: |
| 164 | key = via; |
| 165 | break; |
| 166 | } |
| 167 | if (key == this->last_key) { |
| 168 | this->amount += amount; |
| 169 | } else { |
| 170 | this->SetValue(); |
| 171 | this->amount = amount; |
| 172 | this->last_key = key; |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | |
| 177 | template <ScriptStationList_Cargo::CargoSelector Tselector> |