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

Method IssueCommand

engine/Poseidon/AI/AIGroupCmd.cpp:37–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35{
36
37void AIGroup::IssueCommand(Command& cmd, PackedBoolArray list)
38{
39 if (list.IsEmpty())
40 {
41 return;
42 }
43
44 AIUnit* leader = Leader();
45 // if leader is not alive, he should not be able to send commands
46 if (leader && leader->GetLifeState() != AIUnit::LSAlive)
47 {
48 // auto commands may be issued even without leader alive
49 if (cmd._context != Command::CtxAuto && cmd._context != Command::CtxAutoSilent)
50 {
51 LOG_DEBUG(AI, "IssueCommand: No command, leader {} is not alive", (const char*)leader->GetDebugName());
52 return;
53 }
54 }
55
56 if (cmd._message == Command::GetOut)
57 {
58 // Get Out processed by units
59 int i;
60 for (i = 0; i < MAX_UNITS_PER_GROUP; i++)
61 {
62 if (!list[i])
63 {
64 continue;
65 }
66 AIUnit* unit = UnitWithID(i + 1);
67 if (!unit)
68 {
69 continue;
70 }
71
72 if (unit->IsFreeSoldier())
73 {
74 continue;
75 }
76
77 AISubgroup* subgrp = unit->GetSubgroup();
78 AI_ERROR(subgrp);
79 if (subgrp != MainSubgroup() && subgrp->NUnits() == 1)
80 {
81 cmd._joinToSubgroup = nullptr;
82 subgrp->ReceiveCommand(cmd);
83 }
84 else
85 {
86 if (cmd._context == Command::CtxAuto || cmd._context == Command::CtxAutoSilent)
87 {
88 cmd._joinToSubgroup = subgrp;
89 }
90 subgrp = new AISubgroup();
91 AddSubgroup(subgrp);
92 subgrp->AddUnit(unit);
93 subgrp->SelectLeader(unit);
94 if (GWorld->GetMode() == GModeNetware)

Callers 5

TransmittedMethod · 0.45
GetInGetOutFunction · 0.45
VehMoveFunction · 0.45
VehStopFunction · 0.45
VehFollowFunction · 0.45

Calls 15

GetLifeStateMethod · 0.80
IsFreeSoldierMethod · 0.80
ReceiveCommandMethod · 0.80
GetVehicleInMethod · 0.80
IsInCargoMethod · 0.80
IssueGetOutMethod · 0.80
IsUnitMethod · 0.80
GetUnitMethod · 0.80
CommanderBrainMethod · 0.80
DriverBrainMethod · 0.80
GunnerBrainMethod · 0.80
ContainMethod · 0.80

Tested by

no test coverage detected