0x004AEFB5
| 304 | |
| 305 | // 0x004AEFB5 |
| 306 | void deleteCar(Vehicles::Car& car) |
| 307 | { |
| 308 | Ui::WindowManager::invalidate(Ui::WindowType::vehicle, enumValue(car.front->head)); |
| 309 | Ui::WindowManager::invalidate(Ui::WindowType::vehicleList); |
| 310 | |
| 311 | // Component before this car |
| 312 | Vehicles::VehicleBase* previous = [&car]() { |
| 313 | // Points to one behind the iterator |
| 314 | Vehicles::VehicleBase* previousIter = nullptr; |
| 315 | for (auto* iter = EntityManager::get<Vehicles::VehicleBase>(car.front->head); |
| 316 | iter != car.front; |
| 317 | iter = iter->nextVehicleComponent()) |
| 318 | { |
| 319 | previousIter = iter; |
| 320 | } |
| 321 | return previousIter; |
| 322 | }(); |
| 323 | |
| 324 | // Component after this car |
| 325 | Vehicles::VehicleBase* next = [&car]() { |
| 326 | auto carIter = car.begin(); |
| 327 | // Points to one behind the iterator |
| 328 | auto previousCarIter = carIter; |
| 329 | while (carIter != car.end()) |
| 330 | { |
| 331 | previousCarIter = carIter; |
| 332 | carIter++; |
| 333 | } |
| 334 | // Last component of a car component is a body |
| 335 | return (*previousCarIter).body->nextVehicleComponent(); |
| 336 | }(); |
| 337 | |
| 338 | // Remove the whole car from the linked list |
| 339 | previous->setNextCar(next->id); |
| 340 | |
| 341 | for (auto* toDeleteComponent = static_cast<Vehicles::VehicleBase*>(car.front); |
| 342 | toDeleteComponent != next;) |
| 343 | { |
| 344 | // Must fetch the next before deleting the current! |
| 345 | auto* nextDeletion = toDeleteComponent->nextVehicleComponent(); |
| 346 | |
| 347 | EntityManager::freeEntity(toDeleteComponent); |
| 348 | toDeleteComponent = nextDeletion; |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | // 0x004AF06E |
| 353 | void deleteTrain(Vehicles::VehicleHead& head) |
no test coverage detected