| 525 | } |
| 526 | |
| 527 | void AIGroup::SendIsDown(Transport* vehicle, AIUnit* down) |
| 528 | { |
| 529 | // any unit from the same vehicle should report if possible |
| 530 | // check which units are alive |
| 531 | // consider: better check here, with Report Status verification |
| 532 | AIUnit* reportTransport = nullptr; |
| 533 | AIUnit* report = nullptr; |
| 534 | AIUnit* reportPlayer = nullptr; |
| 535 | for (int i = 0; i < MAX_UNITS_PER_GROUP; i++) |
| 536 | { |
| 537 | AIUnit* unit = _units[i]; |
| 538 | if (!unit) |
| 539 | { |
| 540 | continue; |
| 541 | } |
| 542 | // check when was the unit last seen (or heard) |
| 543 | // ignore units that are alive |
| 544 | if (unit->GetLifeState() == AIUnit::LSAlive) |
| 545 | { |
| 546 | if (!reportTransport && unit->GetVehicle() == vehicle) |
| 547 | { |
| 548 | reportTransport = unit; |
| 549 | } |
| 550 | if (report) |
| 551 | { |
| 552 | continue; |
| 553 | } |
| 554 | if (unit->IsPlayer() || unit->GetPerson()->IsRemotePlayer()) |
| 555 | { |
| 556 | if (!reportPlayer) |
| 557 | { |
| 558 | reportPlayer = unit; |
| 559 | } |
| 560 | continue; |
| 561 | } |
| 562 | report = unit; |
| 563 | continue; |
| 564 | } |
| 565 | } |
| 566 | // lowest ID AI soldier should report casualties |
| 567 | if (reportTransport) |
| 568 | { |
| 569 | report = reportTransport; |
| 570 | } |
| 571 | if (!report) |
| 572 | { |
| 573 | report = reportPlayer; |
| 574 | } |
| 575 | for (int i = 0; i < MAX_UNITS_PER_GROUP; i++) |
| 576 | { |
| 577 | AIUnit* unit = _units[i]; |
| 578 | if (!unit) |
| 579 | { |
| 580 | continue; |
| 581 | } |
| 582 | if (unit->GetLifeState() != AIUnit::LSAlive) |
| 583 | { |
| 584 | if (report) |
no test coverage detected