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

Method GetCargoLoad

src/script/api/script_vehicle.cpp:428–439  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

426}
427
428/* static */ SQInteger ScriptVehicle::GetCargoLoad(VehicleID vehicle_id, CargoType cargo)
429{
430 if (!IsValidVehicle(vehicle_id)) return -1;
431 if (!ScriptCargo::IsValidCargo(cargo)) return -1;
432
433 uint32_t amount = 0;
434 for (const Vehicle *v = ::Vehicle::Get(vehicle_id); v != nullptr; v = v->Next()) {
435 if (v->cargo_type == cargo) amount += v->cargo.StoredCount();
436 }
437
438 return amount;
439}
440
441/* static */ GroupID ScriptVehicle::GetGroupID(VehicleID vehicle_id)
442{

Callers

nothing calls this directly

Calls 2

StoredCountMethod · 0.80
NextMethod · 0.45

Tested by

no test coverage detected