# cargotype.cpp File Reference

Implementation of cargos. More...

`#include "stdafx.h"`
`#include "cargotype.h"`
`#include "core/bitmath_func.hpp"`
`#include "newgrf_cargo.h"`
`#include "table/sprites.h"`
`#include "table/strings.h"`
`#include "table/cargo_const.h"`

Go to the source code of this file.

## Functions

void | SetupCargoForClimate (LandscapeID l)
| Set up the default cargo types for the given landscape type.
CargoID | GetCargoIDByLabel (CargoLabel cl)
| Get the cargo ID by cargo label.
CargoID | GetCargoIDByBitnum (uint8 bitnum)
| Find the CargoID of a 'bitnum' value.

## Variables

uint32 | _cargo_mask
| Bitmask of cargo types available.

## Detailed Description

Implementation of cargos.

Definition in file cargotype.cpp.

## Function Documentation

CargoID GetCargoIDByBitnum | ( | uint8 | bitnum | ) |

Find the CargoID of a 'bitnum' value.

Parameters:

  | bitnum | 'bitnum' to find.

Returns:
  First CargoID with the given bitnum, or CT_INVALID if not found or if the provided bitnum is invalid.

Definition at line 87 of file cargotype.cpp.

References CargoSpec::bitnum, CT_INVALID, CargoSpec::Index(), and INVALID_CARGO.

CargoID GetCargoIDByLabel | ( | CargoLabel | cl | ) |

Get the cargo ID by cargo label.

Parameters:

  | cl | Cargo type to get.

Returns:
  ID number if the cargo exists, else CT_INVALID

Definition at line 71 of file cargotype.cpp.

References CT_INVALID, CargoSpec::Index(), and CargoSpec::label.

Referenced by CalculateRefitMasks().

void SetupCargoForClimate | ( | LandscapeID | l | ) |

Set up the default cargo types for the given landscape type.

Parameters:

  | l | Landscape

Definition at line 31 of file cargotype.cpp.

References _cargo_mask, _default_cargo, _default_climate_cargo, CargoSpec::bitnum, CargoSpec::Get(), INVALID_CARGO, lengthof, and SetBit().

Referenced by ResetNewGRFData().

## Variable Documentation

uint32 _cargo_mask

Bitmask of cargo types available.

Initialized during a call to SetupCargoForClimate.

Definition at line 26 of file cargotype.cpp.

Referenced by CalculateRefitMasks(), CompanyStationsWindow::OnClick(), RailVehicleChangeInfo(), SetupCargoForClimate(), ShipVehicleChangeInfo(), and ShowRefitOptionsList().