Default initialize newly created Rides

This commit is contained in:
ζeh Matt 2024-03-03 13:55:47 +02:00 committed by Gymnasiast
parent d969a4f80d
commit e3343f263f
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
1 changed files with 6 additions and 0 deletions

View File

@ -176,6 +176,12 @@ Ride* RideAllocateAtIndex(RideId index)
auto result = &GetGameState().Rides[idx];
assert(result->id == RideId::GetNull());
// Initialize the ride to all the defaults.
*result = Ride{};
// Because it is default initialized to zero rather than the magic constant for Null, fill the array.
std::fill(std::begin(result->vehicles), std::end(result->vehicles), EntityId::GetNull());
result->id = index;
return result;
}