| 414 | } |
| 415 | |
| 416 | void AIGroup::SendBehaviour(CombatMode mode, PackedBoolArray list) |
| 417 | { |
| 418 | AIUnit* leader = Leader(); |
| 419 | for (int i = 0; i < MAX_UNITS_PER_GROUP; i++) |
| 420 | { |
| 421 | if (!list.Get(i)) |
| 422 | { |
| 423 | continue; |
| 424 | } |
| 425 | AIUnit* unit = UnitWithID(i + 1); |
| 426 | if (!unit) |
| 427 | { |
| 428 | list.Set(i, false); |
| 429 | continue; |
| 430 | } |
| 431 | |
| 432 | if (!leader || unit == leader) |
| 433 | { |
| 434 | unit->SetCombatModeMajor(mode); |
| 435 | list.Set(i, false); |
| 436 | continue; |
| 437 | } |
| 438 | |
| 439 | // check radio channel |
| 440 | int index = INT_MAX; |
| 441 | while (true) |
| 442 | { |
| 443 | RadioMessage* msg = GetRadio().FindPrevMessage(RMTBehaviour, index); |
| 444 | if (!msg) |
| 445 | { |
| 446 | break; |
| 447 | } |
| 448 | AI_ERROR(dynamic_cast<RadioMessageBehaviour*>(msg)); |
| 449 | RadioMessageBehaviour* msgSem = static_cast<RadioMessageBehaviour*>(msg); |
| 450 | AI_ERROR(msgSem); |
| 451 | AI_ERROR(msgSem->GetFrom() == this); |
| 452 | if (msgSem->IsTo(unit)) |
| 453 | { |
| 454 | if (msgSem->GetBehaviour() == mode) |
| 455 | { |
| 456 | list.Set(i, false); |
| 457 | goto SendBehaviourForContinue; |
| 458 | } |
| 459 | else |
| 460 | { |
| 461 | msgSem->DeleteTo(unit); |
| 462 | break; |
| 463 | } |
| 464 | } |
| 465 | else if (msgSem->GetBehaviour() == mode) |
| 466 | { |
| 467 | msgSem->AddTo(unit); |
| 468 | list.Set(i, false); |
| 469 | goto SendBehaviourForContinue; |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | { |
no test coverage detected