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

Method Update

src/script/api/script_stationlist.cpp:150–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148
149template <ScriptStationList_Cargo::CargoSelector Tselector>
150void 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
177template <ScriptStationList_Cargo::CargoSelector Tselector>

Callers

nothing calls this directly

Calls 2

SetValueMethod · 0.95
InvalidFunction · 0.85

Tested by

no test coverage detected