| 1415 | void AIUnit::CheckGetInGetOut() |
| 1416 | { |
| 1417 | Transport* veh = _inVehicle; |
| 1418 | if (veh) |
| 1419 | { |
| 1420 | if (veh->GetGetInTimeout() <= Glob.time || veh->WhoIsGettingIn().Count() <= 0) |
| 1421 | { |
| 1422 | veh->SetGetInTimeout(Time(0)); |
| 1423 | veh->WhoIsGettingIn().Clear(); |
| 1424 | } |
| 1425 | veh->WhoIsGettingOut().Compact(); |
| 1426 | int n = veh->WhoIsGettingOut().Size(); |
| 1427 | if (n > 0 && Glob.time >= veh->GetGetOutTime()) |
| 1428 | { |
| 1429 | AIUnit* unit = nullptr; |
| 1430 | for (int i = 0; i < n; i++) |
| 1431 | { |
| 1432 | AIUnit* u = veh->WhoIsGettingOut()[i]; |
| 1433 | if (u->IsInCargo()) |
| 1434 | { |
| 1435 | unit = u; |
| 1436 | break; |
| 1437 | } |
| 1438 | } |
| 1439 | if (!unit) |
| 1440 | { |
| 1441 | for (int i = 0; i < n; i++) |
| 1442 | { |
| 1443 | AIUnit* u = veh->WhoIsGettingOut()[i]; |
| 1444 | if (u->IsGunner()) |
| 1445 | { |
| 1446 | unit = u; |
| 1447 | break; |
| 1448 | } |
| 1449 | } |
| 1450 | } |
| 1451 | if (!unit) |
| 1452 | { |
| 1453 | for (int i = 0; i < n; i++) |
| 1454 | { |
| 1455 | AIUnit* u = veh->WhoIsGettingOut()[i]; |
| 1456 | if (u->IsCommander()) |
| 1457 | { |
| 1458 | unit = u; |
| 1459 | break; |
| 1460 | } |
| 1461 | } |
| 1462 | } |
| 1463 | if (!unit) |
| 1464 | { |
| 1465 | unit = veh->WhoIsGettingOut()[0]; |
| 1466 | } |
| 1467 | AI_ERROR(unit); |
| 1468 | if (unit) |
| 1469 | { |
| 1470 | veh->SetGetOutTime(Glob.time + 2.0); |
| 1471 | // FIX |
| 1472 | unit->AddRef(); |
| 1473 | unit->CheckIfAliveInTransport(); // unit can be destroyed inside |
| 1474 | unit->ProcessGetOut(false); |
nothing calls this directly
no test coverage detected