* Load/unload the vehicles in this station according to the order * they entered. * @param st the station to do the loading/unloading for */
| 1927 | * @param st the station to do the loading/unloading for |
| 1928 | */ |
| 1929 | void LoadUnloadStation(Station *st) |
| 1930 | { |
| 1931 | /* No vehicle is here... */ |
| 1932 | if (st->loading_vehicles.empty()) return; |
| 1933 | |
| 1934 | Vehicle *last_loading = nullptr; |
| 1935 | |
| 1936 | /* Check if anything will be loaded at all. Otherwise we don't need to reserve either. */ |
| 1937 | for (Vehicle *v : st->loading_vehicles) { |
| 1938 | if (v->vehstatus.Any({VehState::Stopped, VehState::Crashed})) continue; |
| 1939 | |
| 1940 | assert(v->load_unload_ticks != 0); |
| 1941 | if (--v->load_unload_ticks == 0) last_loading = v; |
| 1942 | } |
| 1943 | |
| 1944 | /* We only need to reserve and load/unload up to the last loading vehicle. |
| 1945 | * Anything else will be forgotten anyway after returning from this function. |
| 1946 | * |
| 1947 | * Especially this means we do _not_ need to reserve cargo for a single |
| 1948 | * consist in a station which is not allowed to load yet because its |
| 1949 | * load_unload_ticks is still not 0. |
| 1950 | */ |
| 1951 | if (last_loading == nullptr) return; |
| 1952 | |
| 1953 | for (Vehicle *v : st->loading_vehicles) { |
| 1954 | if (!v->vehstatus.Any({VehState::Stopped, VehState::Crashed})) LoadUnloadVehicle(v); |
| 1955 | if (v == last_loading) break; |
| 1956 | } |
| 1957 | |
| 1958 | /* Call the production machinery of industries */ |
| 1959 | for (Industry *iid : _cargo_delivery_destinations) { |
| 1960 | TriggerIndustryProduction(iid); |
| 1961 | } |
| 1962 | _cargo_delivery_destinations.clear(); |
| 1963 | } |
| 1964 | |
| 1965 | /** |
| 1966 | * Every calendar month update of inflation. |
no test coverage detected