MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / SendIsDown

Method SendIsDown

engine/Poseidon/AI/AIGroupImplHealth.cpp:527–604  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

525}
526
527void 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)

Callers 1

Calls 8

GetLifeStateMethod · 0.80
IsPlayerMethod · 0.80
IsRemotePlayerMethod · 0.80
GetPersonMethod · 0.80
GetVehicleMethod · 0.45
IsLocalMethod · 0.45
GetSubgroupMethod · 0.45
ReceiveAnswerMethod · 0.45

Tested by

no test coverage detected