MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / UseID

Method UseID

src/vehicle.cpp:1844–1855  ·  view source on GitHub ↗

* Use a unit number. If the unit number is not valid it is ignored. * @param index Unit number to use. * @returns Unit number used. */

Source from the content-addressed store, hash-verified

1842 * @returns Unit number used.
1843 */
1844UnitID FreeUnitIDGenerator::UseID(UnitID index)
1845{
1846 if (index == 0 || index == UINT16_MAX) return index;
1847
1848 index--;
1849
1850 size_t slot = index / BITMAP_SIZE;
1851 if (slot >= this->used_bitmap.size()) this->used_bitmap.resize(slot + 1);
1852 SetBit(this->used_bitmap[index / BITMAP_SIZE], index % BITMAP_SIZE);
1853
1854 return index + 1;
1855}
1856
1857/**
1858 * Release a unit number. If the unit number is not valid it is ignored.

Callers 6

NormaliseTrainHeadFunction · 0.80
CmdCreateGroupFunction · 0.80
CmdBuildVehicleFunction · 0.80
AfterLoadGameFunction · 0.80
AfterLoadVehiclesPhase2Function · 0.80

Calls 3

SetBitFunction · 0.85
resizeMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected