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

Method extractUnitData

bwapi/BWAPI/Source/BWAPI/GameUnits.cpp:217–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215 }
216 }
217 void GameImpl::extractUnitData()
218 {
219 //this function extracts all current unit information from Broodwar memory for all the accessible units
220 //and also generates the NukeDetect event when needed
221 nukeDots.clear();
222 for (Unit ui : aliveUnits)
223 {
224 UnitImpl *u = static_cast<UnitImpl*>(ui);
225 u->connectedUnits.clear();
226 u->loadedUnits.clear();
227
228 if (u->getID() == -1)
229 u->setID(server.getUnitID(u));
230
231 u->updateData();
232
233 if ( u->getOriginalRawData->unitType == UnitTypes::Terran_Ghost)
234 {
235 if (u->getOriginalRawData->orderID == Orders::NukePaint)
236 u->nukePosition = BWAPI::Position(u->getOriginalRawData->orderTarget.pt);
237 if (u->getOriginalRawData->orderID != Orders::NukeTrack)
238 u->nukeDetected = false;
239 else
240 {
241 Position target=u->nukePosition;
242 if (isFlagEnabled(Flag::CompleteMapInformation) || isVisible(target.x / 32, target.y / 32))
243 {
244 nukeDots.push_back(target);
245 }
246 if ( !u->nukeDetected )
247 {
248 u->nukeDetected = true;
249 if (isFlagEnabled(Flag::CompleteMapInformation) || isVisible(target.x/32,target.y/32))
250 events.push_back(Event::NukeDetect(target));
251 else
252 events.push_back(Event::NukeDetect(Positions::Unknown));
253 }
254 }
255 }
256 }
257 }
258 void GameImpl::augmentUnitData()
259 {
260 //this function modifies the extracted unit data for build unit, loaded units, larva, and interceptors

Callers

nothing calls this directly

Calls 6

PositionClass · 0.50
clearMethod · 0.45
getIDMethod · 0.45
setIDMethod · 0.45
getUnitIDMethod · 0.45
updateDataMethod · 0.45

Tested by

no test coverage detected