mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-25 08:22:17 +00:00
(svn r14933) -Codechange: check the whether a pool item can be constructed instead of trying to make it and check for NULL.
This commit is contained in:
+4
-8
@@ -242,17 +242,13 @@ byte VehicleRandomBits()
|
||||
|
||||
/* static */ bool Vehicle::AllocateList(Vehicle **vl, int num)
|
||||
{
|
||||
if (!Vehicle::CanAllocateItem(num)) return false;
|
||||
if (vl == NULL) return true;
|
||||
|
||||
uint counter = _Vehicle_pool.first_free_index;
|
||||
|
||||
for (int i = 0; i != num; i++) {
|
||||
Vehicle *v = AllocateRaw(counter);
|
||||
|
||||
if (v == NULL) return false;
|
||||
v = new (v) InvalidVehicle();
|
||||
|
||||
if (vl != NULL) {
|
||||
vl[i] = v;
|
||||
}
|
||||
vl[i] = new (AllocateRaw(counter)) InvalidVehicle();
|
||||
counter++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user