Functions | Variables

cargomonitor.cpp File Reference

Implementation of the cargo transport monitoring. More...

#include "stdafx.h"
#include "cargomonitor.h"
#include "station_base.h"

Go to the source code of this file.

Functions

void ClearCargoPickupMonitoring ()
 Clear all pick-up cargo monitors.
void ClearCargoDeliveryMonitoring ()
 Clear all delivery cargo monitors.
static uint32 GetAmount (CargoMonitorMap &monitor_map, CargoMonitorID monitor, bool keep_monitoring)
 Get and reset the amount associated with a cargo monitor.
uint32 GetDeliveryAmount (CargoMonitorID monitor, bool keep_monitoring)
 Get the amount of cargo delivered for the given cargo monitor since activation or last query.
uint32 GetPickupAmount (CargoMonitorID monitor, bool keep_monitoring)
 Get the amount of cargo picked up for the given cargo monitor since activation or last query.
void AddCargoDelivery (CargoID cargo_type, CompanyID company, uint32 amount, SourceType src_type, SourceID src, const Station *st)
 Cargo was delivered to its final destination, update the pickup and delivery maps.

Variables

CargoMonitorMap _cargo_pickups
 Map of monitored pick-ups to the amount since last query/activation.
CargoMonitorMap _cargo_deliveries
 Map of monitored deliveries to the amount since last query/activation.

Detailed Description

Implementation of the cargo transport monitoring.

Definition in file cargomonitor.cpp.


Function Documentation

void AddCargoDelivery ( CargoID  cargo_type,
CompanyID  company,
uint32  amount,
SourceType  src_type,
SourceID  src,
const Station st 
)

Cargo was delivered to its final destination, update the pickup and delivery maps.

Parameters:
cargo_type type of cargo.
company company delivering the cargo.
amount Amount of cargo delivered.
src_type type of src.
src index of source.
st station where the cargo is delivered to.

Definition at line 87 of file cargomonitor.cpp.

References _cargo_deliveries, _cargo_pickups, SmallVector< T, S >::Begin(), EncodeCargoIndustryMonitor(), EncodeCargoTownMonitor(), SmallVector< T, S >::End(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Station::industries_near, INVALID_SOURCE, ST_INDUSTRY, ST_TOWN, and BaseStation::town.

Referenced by DeliverGoods().

void ClearCargoDeliveryMonitoring (  ) 

Clear all delivery cargo monitors.

Definition at line 26 of file cargomonitor.cpp.

References _cargo_deliveries.

Referenced by InitializeEconomy(), and LoadDelivery().

void ClearCargoPickupMonitoring (  ) 

Clear all pick-up cargo monitors.

Definition at line 20 of file cargomonitor.cpp.

References _cargo_pickups.

Referenced by InitializeEconomy(), and LoadPickup().

static uint32 GetAmount ( CargoMonitorMap monitor_map,
CargoMonitorID  monitor,
bool  keep_monitoring 
) [static]

Get and reset the amount associated with a cargo monitor.

Parameters:
[in,out] monitor_map Monitoring map to search (and reset for the queried entry).
monitor Cargo monitor to query/reset.
keep_monitoring After returning from this call, continue monitoring.
Returns:
Amount collected since last query/activation for the monitored combination.

Definition at line 38 of file cargomonitor.cpp.

Referenced by GetDeliveryAmount(), and GetPickupAmount().

uint32 GetDeliveryAmount ( CargoMonitorID  monitor,
bool  keep_monitoring 
)

Get the amount of cargo delivered for the given cargo monitor since activation or last query.

Parameters:
monitor Cargo monitor to query.
keep_monitoring After returning from this call, continue monitoring.
Returns:
Amount of delivered cargo for the monitored combination.

Definition at line 61 of file cargomonitor.cpp.

References _cargo_deliveries, and GetAmount().

uint32 GetPickupAmount ( CargoMonitorID  monitor,
bool  keep_monitoring 
)

Get the amount of cargo picked up for the given cargo monitor since activation or last query.

Parameters:
monitor Monitoring number to query.
keep_monitoring After returning from this call, continue monitoring.
Returns:
Amount of picked up cargo for the monitored combination.
Note:
Cargo pick up is counted on final delivery, to prevent users getting credit for picking up cargo without delivering it.

Definition at line 73 of file cargomonitor.cpp.

References _cargo_pickups, and GetAmount().