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

Function removeAllCargo

src/OpenLoco/src/Vehicles/Vehicle.cpp:755–772  ·  view source on GitHub ↗

0x004AF16A

Source from the content-addressed store, hash-verified

753
754 // 0x004AF16A
755 void removeAllCargo(CarComponent& carComponent)
756 {
757 carComponent.front->secondaryCargo.qty = 0;
758 carComponent.back->secondaryCargo.qty = 0;
759 carComponent.body->primaryCargo.qty = 0;
760
761 auto* head = EntityManager::get<VehicleHead>(carComponent.front->head);
762 if (head == nullptr)
763 {
764 throw Exception::RuntimeError("Invalid Vehicle head");
765 }
766 head->updateTrainProperties();
767
768 Ui::WindowManager::invalidate(Ui::WindowType::vehicle, enumValue(head->id));
769
770 // Vanilla called updateCargoSprite on the bogies but that does nothing so skipping that.
771 carComponent.body->updateCargoSprite();
772 }
773
774 // 0x004AFFF3
775 // esi: frontBogie

Callers 4

liftUpVehicleMethod · 0.85
vehiclePickupAirFunction · 0.85
vehiclePickupWaterFunction · 0.85
vehicleRearrangeFunction · 0.85

Calls 4

enumValueFunction · 0.85
updateTrainPropertiesMethod · 0.80
updateCargoSpriteMethod · 0.80
invalidateFunction · 0.50

Tested by

no test coverage detected