MCPcopy Create free account
hub / github.com/bwapi/bwapi / prepareIssueCommand

Method prepareIssueCommand

bwapi/BWAPI/Source/BWAPI/UnitImpl.cpp:49–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47 }
48 }
49 bool UnitImpl::prepareIssueCommand(UnitCommand &command)
50 {
51 command.unit = this;
52
53 // If using train or morph on a hatchery, automatically switch selection to larva
54 // (assuming canIssueCommand ensures that there is a larva)
55 if ( (command.type == UnitCommandTypes::Train ||
56 command.type == UnitCommandTypes::Morph) &&
57 getType().producesLarva() && command.getUnitType().whatBuilds().first == UnitTypes::Zerg_Larva )
58 {
59 Unitset larvae( this->getLarva() );
60 for(Unit larva : larvae)
61 {
62 if ( !larva->isConstructing() && larva->isCompleted() && larva->canCommand() )
63 {
64 command.unit = larva;
65 break;
66 }
67 }
68 if ( command.unit == this )
69 return false;
70 }
71
72 // Set last command and command frames
73 static_cast<UnitImpl*>(command.unit)->lastCommandFrame = BroodwarImpl.getFrameCount();
74 static_cast<UnitImpl*>(command.unit)->lastCommand = command;
75 static_cast<UnitImpl*>(command.unit)->setLastImmediateCommand(command);
76 if (command.type == UnitCommandTypes::Use_Tech_Unit && command.target &&
77 (command.extra == TechTypes::Archon_Warp || command.extra == TechTypes::Dark_Archon_Meld))
78 {
79 static_cast<UnitImpl*>(command.target)->lastCommandFrame = BroodwarImpl.getFrameCount();
80 static_cast<UnitImpl*>(command.target)->lastCommand = command;
81 static_cast<UnitImpl*>(command.target)->setLastImmediateCommand(command);
82 }
83
84 // Add to command optimizer if possible, as well as the latency compensation buffer
85 BroodwarImpl.addToCommandBuffer(Command{ command });
86 return BroodwarImpl.commandOptimizer.add(command);
87 }
88 bool UnitImpl::issueCommand(UnitCommand command)
89 {
90 if ( !canIssueCommand(command) )

Callers 2

issueCommandMethod · 0.95
issueCommandMethod · 0.80

Calls 11

getLarvaMethod · 0.95
producesLarvaMethod · 0.80
whatBuildsMethod · 0.80
getUnitTypeMethod · 0.80
isConstructingMethod · 0.80
isCompletedMethod · 0.80
canCommandMethod · 0.80
addToCommandBufferMethod · 0.80
addMethod · 0.80
getFrameCountMethod · 0.45

Tested by

no test coverage detected