OpenTTD Source: FreeUnitIDGenerator Class Reference

OpenTTD Source 15.0-RC2

Public Member Functions | Private Types | Private Attributes | Static Private Attributes
FreeUnitIDGenerator Class Reference

## Public Member Functions
UnitID | NextID () const
| Find first unused unit number.
UnitID | UseID (UnitID index)
| Use a unit number.
void | ReleaseID (UnitID index)
| Release a unit number.

## Private Types
using | BitmapStorage = size_t

## Private Attributes
std::vector< BitmapStorage > | used_bitmap {}

## Static Private Attributes
static constexpr size_t | BITMAP_SIZE = std::numeric_limits<BitmapStorage>::digits

## Detailed Description

Definition at line 54 of file company_base.h.

## Member Typedef Documentation

## ◆ BitmapStorage

using FreeUnitIDGenerator::BitmapStorage = size_t
| private

Definition at line 61 of file company_base.h.

## Member Function Documentation

## ◆ NextID()

UnitID FreeUnitIDGenerator::NextID | ( |  | ) | const

Find first unused unit number.

This does not mark the unit number as used.

Returns
  First unused unit number.

Definition at line 1829 of file vehicle.cpp.

References FindFirstBit().

Referenced by ChangeOwnershipOfCompanyItems(), and CmdCreateGroup().

## ◆ ReleaseID()

void FreeUnitIDGenerator::ReleaseID | ( | UnitID | index | ) |

Release a unit number.

If the unit number is not valid it is ignored.

Parameters

  index | Unit number to release.

Definition at line 1861 of file vehicle.cpp.

References ClrBit().

Referenced by CmdDeleteGroup().

## ◆ UseID()

UnitID FreeUnitIDGenerator::UseID | ( | UnitID | index | ) |

Use a unit number.

If the unit number is not valid it is ignored.

Parameters

  index | Unit number to use.

Returns
  Unit number used.

Definition at line 1844 of file vehicle.cpp.

References SetBit().

Referenced by AfterLoadGame(), ChangeOwnershipOfCompanyItems(), and CmdCreateGroup().

## Field Documentation

## ◆ BITMAP_SIZE

constexpr size_t FreeUnitIDGenerator::BITMAP_SIZE = std::numeric_limits<BitmapStorage>::digits
| staticconstexprprivate

Definition at line 62 of file company_base.h.

## ◆ used_bitmap

std::vector<BitmapStorage> FreeUnitIDGenerator::used_bitmap {}
| private

Definition at line 64 of file company_base.h.

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

- src/company_base.h
- src/vehicle.cpp