OpenTTD Source 20241224-master-gf74b0cf984
CargoRemoval< Tsource > Class Template Reference

Abstract action of removing cargo from a vehicle or a station. More...

#include <cargoaction.h>

Public Member Functions

 CargoRemoval (Tsource *source, uint max_move)
 
uint MaxMove ()
 Returns how much more cargo can be removed with this action.
 
bool operator() (CargoPacket *cp)
 
bool operator() (CargoPacket *cp)
 Removes some cargo from a StationCargoList.
 

Protected Member Functions

uint Preprocess (CargoPacket *cp)
 Determines the amount of cargo to be removed from a packet and removes that from the metadata of the list.
 
bool Postprocess (CargoPacket *cp, uint remove)
 Finalize cargo removal.
 

Protected Attributes

Tsource * source
 Source of the cargo.
 
uint max_move
 Maximum amount of cargo to be removed with this action.
 

Detailed Description

template<class Tsource>
class CargoRemoval< Tsource >

Abstract action of removing cargo from a vehicle or a station.

Template Parameters
TsourceCargoList subclass to remove cargo from.

Definition at line 20 of file cargoaction.h.

Constructor & Destructor Documentation

◆ CargoRemoval()

template<class Tsource >
CargoRemoval< Tsource >::CargoRemoval ( Tsource *  source,
uint  max_move 
)
inline

Definition at line 27 of file cargoaction.h.

Member Function Documentation

◆ MaxMove()

template<class Tsource >
uint CargoRemoval< Tsource >::MaxMove ( )
inline

Returns how much more cargo can be removed with this action.

Returns
Amount of cargo this action can still remove.

Definition at line 33 of file cargoaction.h.

References CargoRemoval< Tsource >::max_move.

◆ operator()()

bool CargoRemoval< StationCargoList >::operator() ( CargoPacket cp)

Removes some cargo from a StationCargoList.

Parameters
cpPacket to be removed.
Returns
True if the packet was completely delivered, false if only part of it was.

Definition at line 79 of file cargoaction.cpp.

◆ Postprocess()

template<class Tsource >
template bool CargoRemoval< Tsource >::Postprocess ( CargoPacket cp,
uint  remove 
)
protected

Finalize cargo removal.

Either delete the packet or reduce it.

Parameters
cpPacket to be removed or reduced.
removeAmount of cargo to be removed.
Returns
True if the packet was deleted, False if it was reduced.

Definition at line 61 of file cargoaction.cpp.

References CargoPacket::Count(), and CargoPacket::Reduce().

◆ Preprocess()

template<class Tsource >
template uint CargoRemoval< Tsource >::Preprocess ( CargoPacket cp)
protected

Determines the amount of cargo to be removed from a packet and removes that from the metadata of the list.

Parameters
cpPacket to be removed completely or partially.
Returns
Amount of cargo to be removed.

Definition at line 42 of file cargoaction.cpp.

References CargoPacket::Count().

Field Documentation

◆ max_move

template<class Tsource >
uint CargoRemoval< Tsource >::max_move
protected

Maximum amount of cargo to be removed with this action.

Definition at line 23 of file cargoaction.h.

Referenced by CargoRemoval< Tsource >::MaxMove().

◆ source

template<class Tsource >
Tsource* CargoRemoval< Tsource >::source
protected

Source of the cargo.

Definition at line 22 of file cargoaction.h.


The documentation for this class was generated from the following files: