OpenTTD GameScript API 20241221-master-g2176d49a39
Static Public Member Functions
GSCargoMonitor Class Reference

Class that handles all cargo movement monitoring related functions. More...

#include <script_cargomonitor.hpp>

Inheritance diagram for GSCargoMonitor:

Static Public Member Functions

static int GetTownDeliveryAmount (GSCompany::CompanyID company, CargoID cargo, TownID town_id, bool keep_monitoring)
 Get the amount of cargo delivered to a town by a company since the last query, and update the monitoring state.
 
static int GetIndustryDeliveryAmount (GSCompany::CompanyID company, CargoID cargo, IndustryID industry_id, bool keep_monitoring)
 Get the amount of cargo delivered to an industry by a company since the last query, and update the monitoring state.
 
static int GetTownPickupAmount (GSCompany::CompanyID company, CargoID cargo, TownID town_id, bool keep_monitoring)
 Get the amount of cargo picked up (and delivered) from a town by a company since the last query, and update the monitoring state.
 
static int GetIndustryPickupAmount (GSCompany::CompanyID company, CargoID cargo, IndustryID industry_id, bool keep_monitoring)
 Get the amount of cargo picked up (and delivered) from an industry by a company since the last query, and update the monitoring state.
 
static void StopAllMonitoring ()
 Stop monitoring everything.
 

Detailed Description

Class that handles all cargo movement monitoring related functions.

To get an understanding of what users are transporting, this class provides cargo pick-up and delivery monitoring functions. It works as follows:

In the same way you can monitor town deliveries, and you can monitor pick-up from towns and industries. The latter get added at the moment the cargo is delivered. This prevents users from getting credit for picking up cargo without delivering it.

The active monitors are saved and loaded. Upon bankruptcy or company takeover, the cargo monitors are automatically stopped for that company. You can reset to the empty state with StopAllMonitoring.

Member Function Documentation

◆ GetIndustryDeliveryAmount()

static int GSCargoMonitor::GetIndustryDeliveryAmount ( GSCompany::CompanyID  company,
CargoID  cargo,
IndustryID  industry_id,
bool  keep_monitoring 
)
static

Get the amount of cargo delivered to an industry by a company since the last query, and update the monitoring state.

Parameters
companyCompany to query.
cargoCargo type to query.
industry_idIndustry to query.
keep_monitoringIf true, the given combination continues to be monitored for the next call. If false, monitoring ends.
Returns
Amount of delivered cargo of the given cargo type to the given industry by the given company since the last call, or -1 if a parameter is out-of-bound.

◆ GetIndustryPickupAmount()

static int GSCargoMonitor::GetIndustryPickupAmount ( GSCompany::CompanyID  company,
CargoID  cargo,
IndustryID  industry_id,
bool  keep_monitoring 
)
static

Get the amount of cargo picked up (and delivered) from an industry by a company since the last query, and update the monitoring state.

Parameters
companyCompany to query.
cargoCargo type to query.
industry_idIndustry to query.
keep_monitoringIf true, the given combination continues to be monitored for the next call. If false, monitoring ends.
Returns
Amount of picked up cargo of the given cargo type to the given industry by the given company since the last call, or -1 if a parameter is out-of-bound.
Note
Amounts of picked-up cargo are added during final delivery of it, to prevent users from getting credit for picking up without delivering it.

◆ GetTownDeliveryAmount()

static int GSCargoMonitor::GetTownDeliveryAmount ( GSCompany::CompanyID  company,
CargoID  cargo,
TownID  town_id,
bool  keep_monitoring 
)
static

Get the amount of cargo delivered to a town by a company since the last query, and update the monitoring state.

Parameters
companyCompany to query.
cargoCargo type to query.
town_idTown to query.
keep_monitoringIf true, the given combination continues to be monitored for the next call. If false, monitoring ends.
Returns
Amount of delivered cargo of the given cargo type to the given town by the given company since the last call, or -1 if a parameter is out-of-bound.

◆ GetTownPickupAmount()

static int GSCargoMonitor::GetTownPickupAmount ( GSCompany::CompanyID  company,
CargoID  cargo,
TownID  town_id,
bool  keep_monitoring 
)
static

Get the amount of cargo picked up (and delivered) from a town by a company since the last query, and update the monitoring state.

Parameters
companyCompany to query.
cargoCargo type to query.
town_idTown to query.
keep_monitoringIf true, the given combination continues to be monitored for the next call. If false, monitoring ends.
Returns
Amount of picked up cargo of the given cargo type to the given town by the given company since the last call, or -1 if a parameter is out-of-bound.
Note
Amounts of picked-up cargo are added during final delivery of it, to prevent users from getting credit for picking up without delivering it.