MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / updateCargoDistribution

Method updateCargoDistribution

src/OpenLoco/src/World/Station.cpp:818–854  ·  view source on GitHub ↗

0x004929DB

Source from the content-addressed store, hash-verified

816
817 // 0x004929DB
818 void Station::updateCargoDistribution()
819 {
820 invalidateWindow();
821 WindowManager::invalidate(Ui::WindowType::stationList);
822 bool hasChanged = false;
823 for (uint8_t i = 0; i < kMaxCargoStats; ++i)
824 {
825 auto& stationCargo = cargoStats[i];
826 auto newDensity = 0;
827 if (stationCargo.quantity != 0)
828 {
829 if (stationTileSize != 0)
830 {
831 newDensity = stationCargo.quantity / stationTileSize;
832 auto* cargoObj = ObjectManager::get<CargoObject>(i);
833 newDensity += (1 << cargoObj->stationCargoDensity) - 1;
834 newDensity >>= cargoObj->stationCargoDensity;
835
836 newDensity = std::min<int32_t>(newDensity, Limits::kMaxStationCargoDensity);
837 }
838 }
839 if (stationCargo.densityPerTile != newDensity)
840 {
841 stationCargo.densityPerTile = newDensity;
842 hasChanged = true;
843 }
844 }
845
846 if (hasChanged)
847 {
848 for (auto i = 0; i < stationTileSize; ++i)
849 {
850 const auto& tile = stationTiles[i];
851 Ui::ViewportManager::invalidate({ tile.x, tile.y }, World::heightFloor(tile.z), World::heightFloor(tile.z) + 32, ZoomLevel::full);
852 }
853 }
854 }
855
856 struct StationBorder
857 {

Callers 2

Calls 3

invalidateWindowFunction · 0.85
heightFloorFunction · 0.85
invalidateFunction · 0.50

Tested by

no test coverage detected