|
OpenTTD Source
14.0-beta1
|
Go to the documentation of this file.
10 #ifndef CARGOMONITOR_H
11 #define CARGOMONITOR_H
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
std::map< CargoMonitorID, OverflowSafeInt32 > CargoMonitorMap
Map type for storing and updating active cargo monitor numbers and their amounts.
Town * town
The town this station is associated with.
@ CCB_COMPANY_LENGTH
Number of bits of the company field.
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
CargoMonitorMap _cargo_deliveries
Map of monitored deliveries to the amount since last query/activation.
CargoMonitorID EncodeCargoTownMonitor(CompanyID company, CargoID ctype, TownID town)
Encode a cargo monitoring number for pickup or delivery at a town.
void AddCargoDelivery(CargoID cargo_type, CompanyID company, uint32_t amount, SourceType src_type, SourceID src, const Station *st, IndustryID dest=INVALID_INDUSTRY)
Cargo was delivered to its final destination, update the pickup and delivery maps.
Owner
Enum for all companies/owners.
@ CCB_TOWN_IND_NUMBER_LENGTH
Number of bits of the town or industry number.
CargoMonitorID EncodeCargoIndustryMonitor(CompanyID company, CargoID ctype, IndustryID ind)
Encode a cargo monitor for pickup or delivery at an industry.
@ CCB_CARGO_TYPE_LENGTH
Number of bits of the cargo type field.
@ INVALID_OWNER
An invalid owner.
void ClearCargoPickupMonitoring(CompanyID company=INVALID_OWNER)
Clear all pick-up cargo monitors.
uint16_t SourceID
Contains either industry ID, town ID or company ID (or INVALID_SOURCE)
@ MAX_COMPANIES
Maximum number of companies.
@ CCB_IS_INDUSTRY_BIT
Bit indicating the town/industry number is an industry.
@ CCB_TOWN_IND_NUMBER_START
Start bit of the town or industry number.
@ CCB_CARGO_TYPE_START
Start bit of the cargo type field.
IndustryID DecodeMonitorIndustry(CargoMonitorID num)
Extract the industry number from the cargo monitor.
CargoMonitorMap _cargo_pickups
Map of monitored pick-ups to the amount since last query/activation.
CargoID DecodeMonitorCargoType(CargoMonitorID num)
Extract the cargo type from the cargo monitor.
int32_t GetPickupAmount(CargoMonitorID monitor, bool keep_monitoring)
Get the amount of cargo picked up for the given cargo monitor since activation or last query.
SourceType
Types of cargo source and destination.
@ CCB_IS_INDUSTRY_BIT_VALUE
Value of the CCB_IS_INDUSTRY_BIT bit.
int32_t GetDeliveryAmount(CargoMonitorID monitor, bool keep_monitoring)
Get the amount of cargo delivered for the given cargo monitor since activation or last query.
CompanyID DecodeMonitorCompany(CargoMonitorID num)
Extract the company from the cargo monitor.
TownID DecodeMonitorTown(CargoMonitorID num)
Extract the town number from the cargo monitor.
byte CargoID
Cargo slots to indicate a cargo type within a game.
@ CCB_COMPANY_START
Start bit of the company field.
constexpr T SB(T &x, const uint8_t s, const uint8_t n, const U d)
Set n bits in x starting at bit s to d.
static const CargoID NUM_CARGO
Maximum number of cargo types in a game.
void ClearCargoDeliveryMonitoring(CompanyID company=INVALID_OWNER)
Clear all delivery cargo monitors.
CargoCompanyBits
Constants for encoding and extracting cargo monitors.
uint32_t CargoMonitorID
Unique number for a company / cargo type / (town or industry).
bool MonitorMonitorsIndustry(CargoMonitorID num)
Does the cargo number monitor an industry or a town?
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.