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

Method JoinToSubgroup

engine/Poseidon/AI/AISubgroup.cpp:1419–1464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1417 }
1418}
1419
1420void AISubgroup::JoinToSubgroup(AISubgroup* subgrp)
1421{
1422 AI_ERROR(subgrp);
1423 AI_ERROR(subgrp != this);
1424 if (subgrp == this)
1425 {
1426 Fail("Join with themselves.");
1427 return;
1428 }
1429 AI_ERROR(subgrp->GetGroup() == GetGroup());
1430 if (subgrp->GetGroup() != GetGroup())
1431 {
1432 Fail("Join to another group");
1433 return;
1434 }
1435 AI_ERROR(this != GetGroup()->MainSubgroup());
1436
1437 PoseidonAssert(AssertValid());
1438
1439 ClearAllCommands();
1440
1441 while (_units.Size() > 0)
1442 {
1443 Ref<AIUnit> unit = _units[0];
1444 _units.Delete(0);
1445 if (!unit)
1446 {
1447 Fail("No unit");
1448 continue;
1449 }
1450 if (unit->GetSubgroup() != this)
1451 {
1452 Fail("Bad structure");
1453 }
1454 // remove explicitly - avoid refresh of destroyed subgroup
1455 unit->_subgroup = nullptr;
1456 subgrp->AddUnit(unit);
1457 }
1458 RemoveFromGroup();
1459
1460 subgrp->SelectLeader();
1461 subgrp->RefreshPlan();
1462 subgrp->UpdateFormationPos();
1463
1464 PoseidonAssert(subgrp->AssertValid());
1465}
1466
1467// Mind

Callers 7

ReceivedJoinMethod · 0.80
ThinkMethod · 0.80
FleeFunction · 0.80
JoinSubgroupsFunction · 0.80
CommandSucceedFunction · 0.80
CommandFailedFunction · 0.80
JoinInitFunction · 0.80

Calls 11

GetGroupFunction · 0.85
MainSubgroupMethod · 0.80
RefreshPlanMethod · 0.80
UpdateFormationPosMethod · 0.80
GetGroupMethod · 0.45
SizeMethod · 0.45
DeleteMethod · 0.45
GetSubgroupMethod · 0.45
AddUnitMethod · 0.45
SelectLeaderMethod · 0.45
AssertValidMethod · 0.45

Tested by

no test coverage detected