OpenTTD AI API  20240416-master-g8e2ccddd77
Public Types | Public Member Functions
AIStationList_Cargo Class Reference

Creates a list of stations associated with cargo at a station. More...

Inheritance diagram for AIStationList_Cargo:
AIList AIStationList_CargoPlanned AIStationList_CargoWaiting AIStationList_CargoPlannedByFrom AIStationList_CargoPlannedByVia AIStationList_CargoPlannedFromByVia AIStationList_CargoPlannedViaByFrom AIStationList_CargoWaitingByFrom AIStationList_CargoWaitingByVia AIStationList_CargoWaitingFromByVia AIStationList_CargoWaitingViaByFrom

Public Types

enum  CargoSelector {
  CS_BY_FROM,
  CS_VIA_BY_FROM,
  CS_BY_VIA,
  CS_FROM_BY_VIA
}
 Criteria of selecting and grouping cargo at a station. More...
 
enum  CargoMode {
  CM_WAITING,
  CM_PLANNED
}
 Ways of associating cargo to stations. More...
 
- Public Types inherited from AIList
enum  SorterType {
  SORT_BY_VALUE,
  SORT_BY_ITEM
}
 Type of sorter. More...
 

Public Member Functions

 AIStationList_Cargo (AIStationList_Cargo::CargoMode mode, AIStationList_Cargo::CargoSelector selector, StationID station_id, CargoID cargo, StationID other_station)
 Creates a list of stations associated with cargo in the specified way, selected and grouped by the chosen criteria. More...
 
- Public Member Functions inherited from AIList
void AddItem (SQInteger item, SQInteger value)
 Add a single item to the list. More...
 
void RemoveItem (SQInteger item)
 Remove a single item from the list. More...
 
void Clear ()
 Clear the list, making Count() returning 0 and IsEmpty() returning true.
 
bool HasItem (SQInteger item)
 Check if an item is in the list. More...
 
SQInteger Begin ()
 Go to the beginning of the list and return the item. More...
 
SQInteger Next ()
 Go to the next item in the list and return the item. More...
 
bool IsEmpty ()
 Check if a list is empty. More...
 
bool IsEnd ()
 Check if there is a element left. More...
 
SQInteger Count ()
 Returns the amount of items in the list. More...
 
SQInteger GetValue (SQInteger item)
 Get the value that belongs to this item. More...
 
bool SetValue (SQInteger item, SQInteger value)
 Set a value of an item directly. More...
 
void Sort (SorterType sorter, bool ascending)
 Sort this list by the given sorter and direction. More...
 
void AddList (AIList *list)
 Add one list to another one. More...
 
void SwapList (AIList *list)
 Swap the contents of two lists. More...
 
void RemoveAboveValue (SQInteger value)
 Removes all items with a higher value than 'value'. More...
 
void RemoveBelowValue (SQInteger value)
 Removes all items with a lower value than 'value'. More...
 
void RemoveBetweenValue (SQInteger start, SQInteger end)
 Removes all items with a value above start and below end. More...
 
void RemoveValue (SQInteger value)
 Remove all items with this value. More...
 
void RemoveTop (SQInteger count)
 Remove the first count items. More...
 
void RemoveBottom (SQInteger count)
 Remove the last count items. More...
 
void RemoveList (AIList *list)
 Remove everything that is in the given list from this list (same item index that is). More...
 
void KeepAboveValue (SQInteger value)
 Keep all items with a higher value than 'value'. More...
 
void KeepBelowValue (SQInteger value)
 Keep all items with a lower value than 'value'. More...
 
void KeepBetweenValue (SQInteger start, SQInteger end)
 Keep all items with a value above start and below end. More...
 
void KeepValue (SQInteger value)
 Keep all items with this value. More...
 
void KeepTop (SQInteger count)
 Keep the first count items, i.e. More...
 
void KeepBottom (SQInteger count)
 Keep the last count items, i.e. More...
 
void KeepList (AIList *list)
 Keeps everything that is in the given list from this list (same item index that is). More...
 
void Valuate (void *valuator_function, int params,...)
 Give all items a value defined by the valuator you give. More...
 

Additional Inherited Members

- Static Public Attributes inherited from AIList
static const bool SORT_ASCENDING = true
 Sort ascending.
 
static const bool SORT_DESCENDING = false
 Sort descending.
 

Detailed Description

Creates a list of stations associated with cargo at a station.

This is very generic. Use the subclasses for all practical purposes.

Member Enumeration Documentation

◆ CargoMode

Ways of associating cargo to stations.

Enumerator
CM_WAITING 

Waiting cargo.

CM_PLANNED 

Planned cargo.

◆ CargoSelector

Criteria of selecting and grouping cargo at a station.

Enumerator
CS_BY_FROM 

Group by origin station.

CS_VIA_BY_FROM 

Select by next hop and group by origin station.

CS_BY_VIA 

Group by next hop.

CS_FROM_BY_VIA 

Select by origin station and group by next hop.

Constructor & Destructor Documentation

◆ AIStationList_Cargo()

AIStationList_Cargo::AIStationList_Cargo ( AIStationList_Cargo::CargoMode  mode,
AIStationList_Cargo::CargoSelector  selector,
StationID  station_id,
CargoID  cargo,
StationID  other_station 
)

Creates a list of stations associated with cargo in the specified way, selected and grouped by the chosen criteria.

Parameters
modeMode of association, either waiting cargo or planned cargo.
selectorMode of grouping and selecting to be applied.
station_idStation to be queried.
cargoCargo type to query for.
other_stationOther station to restrict the query with.