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

Method augmentUnitData

bwapi/BWAPI/Source/BWAPI/GameUnits.cpp:258–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256 }
257 }
258 void GameImpl::augmentUnitData()
259 {
260 //this function modifies the extracted unit data for build unit, loaded units, larva, and interceptors
261 for(Unit ui : accessibleUnits)
262 {
263 UnitImpl *u = static_cast<UnitImpl*>(ui);
264 UnitImpl* orderTargetUnit = UnitImpl::BWUnitToBWAPIUnit(u->getOriginalRawData->orderTarget.pUnit);
265 UnitImpl* buildUnit = UnitImpl::BWUnitToBWAPIUnit(u->getOriginalRawData->currentBuildUnit);
266 if ( orderTargetUnit && orderTargetUnit->exists() && u->getOrder() == Orders::ConstructingBuilding )
267 {
268 UnitImpl* j = orderTargetUnit;
269 u->self->buildUnit = server.getUnitID(j);
270 u->self->isConstructing = true;
271 u->self->isIdle = false;
272 u->self->buildType = j->self->type;
273 j->self->buildUnit = server.getUnitID(u);
274 j->self->isConstructing = true;
275 j->self->isIdle = false;
276 j->self->buildType = j->self->type;
277 }
278 else if ( u->getAddon() && !u->getAddon()->isCompleted() )
279 {
280 UnitImpl* j = static_cast<UnitImpl*>(u->getAddon());
281 u->self->buildUnit = server.getUnitID(j);
282 u->self->isConstructing = true;
283 u->self->isIdle = false;
284 u->self->buildType = j->self->type;
285 j->self->buildUnit = server.getUnitID(u);
286 j->self->isConstructing = true;
287 j->self->isIdle = false;
288 j->self->buildType = j->self->type;
289 }
290 else if ( buildUnit && buildUnit->exists() && u->isTraining() )
291 {
292 // Apply buildUnit symmetry
293 UnitImpl* j = buildUnit;
294 j->self->buildUnit = server.getUnitID(u);
295 j->self->isConstructing = true;
296 j->self->isIdle = false;
297 j->self->buildType = j->self->type;
298 }
299 if (u->getTransport())
300 {
301 static_cast<UnitImpl*>(u->getTransport())->loadedUnits.insert(u);
302 }
303
304 if ( u->getHatchery() )
305 {
306 UnitImpl* hatchery = static_cast<UnitImpl*>(u->getHatchery());
307 hatchery->connectedUnits.insert(u);
308 if (hatchery->connectedUnits.size() >= 3)
309 hatchery->self->remainingTrainTime = 0;
310 }
311 if (u->getCarrier())
312 {
313 static_cast<UnitImpl*>(u->getCarrier())->connectedUnits.insert(u);
314 }
315 }

Callers

nothing calls this directly

Calls 10

getAddonMethod · 0.80
isCompletedMethod · 0.80
isTrainingMethod · 0.80
getHatcheryMethod · 0.80
getCarrierMethod · 0.80
existsMethod · 0.45
getOrderMethod · 0.45
getUnitIDMethod · 0.45
getTransportMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected