Change: Use bitmap for free unit ID generation. (#12165)

This improves performance of finding the next free unit number for a vehicle.

Based loosely on pool's used slot bitmap.
This commit is contained in:
Peter Nelson
2024-02-25 12:36:13 +00:00
committed by GitHub
parent 8afef45d4e
commit 56cf89d189
7 changed files with 68 additions and 56 deletions

View File

@@ -194,6 +194,8 @@ std::tuple<CommandCost, VehicleID, uint, uint16_t, CargoArray> CmdBuildVehicle(D
GroupStatistics::CountVehicle(v, 1);
if (!(subflags & DC_AUTOREPLACE)) OrderBackup::Restore(v, client_id);
}
Company::Get(v->owner)->freeunits[v->type].UseID(v->unitnumber);
}