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

Method onMatchFrame

bwapi/BWAPIClient/Source/GameImpl.cpp:237–360  ·  view source on GitHub ↗

------------------------------------------------- ON MATCH FRAME -----------------------------------------

Source from the content-addressed store, hash-verified

235 }
236 //------------------------------------------------- ON MATCH FRAME -----------------------------------------
237 void GameImpl::onMatchFrame()
238 {
239 events.clear();
240 bullets.clear();
241 for(int i = 0; i < 100; ++i)
242 {
243 if (bulletVector[i].exists())
244 bullets.insert(&bulletVector[i]);
245 }
246 nukeDots.clear();
247 for(int i = 0; i < data->nukeDotCount; ++i)
248 nukeDots.push_back(Position(data->nukeDots[i].x,data->nukeDots[i].y));
249
250 for(int e = 0; e < data->eventCount; ++e)
251 {
252 events.push_back(this->makeEvent(data->events[e]));
253 int id = data->events[e].v1;
254 if (data->events[e].type == EventType::UnitDiscover)
255 {
256 Unit u = &unitVector[id];
257 accessibleUnits.insert(u);
258 static_cast<PlayerImpl*>(u->getPlayer())->units.insert(u);
259 if (u->getPlayer()->isNeutral())
260 {
261 neutralUnits.insert(u);
262 if ( u->getType().isMineralField() )
263 minerals.insert(u);
264 else if ( u->getType() == UnitTypes::Resource_Vespene_Geyser )
265 geysers.insert(u);
266 }
267 else
268 {
269 if (u->getPlayer() == this->self() && u->getType() == UnitTypes::Protoss_Pylon)
270 pylons.insert(u);
271 }
272 }
273 else if (data->events[e].type == EventType::UnitEvade)
274 {
275 Unit u = &unitVector[id];
276 accessibleUnits.erase(u);
277 static_cast<PlayerImpl*>(u->getPlayer())->units.erase(u);
278 if (u->getPlayer()->isNeutral())
279 {
280 neutralUnits.erase(u);
281 if ( u->getType().isMineralField() )
282 minerals.erase(u);
283 else if (u->getType()==UnitTypes::Resource_Vespene_Geyser)
284 geysers.erase(u);
285 }
286 else
287 {
288 if (u->getPlayer() == this->self() && u->getType() == UnitTypes::Protoss_Pylon)
289 pylons.erase(u);
290 }
291 }
292 else if (data->events[e].type==EventType::UnitRenegade)
293 {
294 Unit u = &unitVector[id];

Callers 1

updateMethod · 0.80

Calls 15

makeEventMethod · 0.95
selfMethod · 0.95
isMineralFieldMethod · 0.80
isRefineryMethod · 0.80
getHatcheryMethod · 0.80
getCarrierMethod · 0.80
leftGameMethod · 0.80
isObserverMethod · 0.80
PositionClass · 0.50
clearMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected