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

Method onMatchStart

bwapi/BWAPIClient/Source/GameImpl.cpp:169–230  ·  view source on GitHub ↗

------------------------------------------------- ON MATCH START -----------------------------------------

Source from the content-addressed store, hash-verified

167 }
168 //------------------------------------------------- ON MATCH START -----------------------------------------
169 void GameImpl::onMatchStart()
170 {
171 clearAll();
172 inGame = true;
173
174 //load forces, players, and initial units from shared memory
175 for(int i = 1; i < data->forceCount; ++i)
176 forces.insert(&forceVector[i]);
177 for(int i = 0; i < data->playerCount; ++i)
178 playerSet.insert(&playerVector[i]);
179 for(int i = 0; i < data->initialUnitCount; ++i)
180 {
181 if (unitVector[i].exists())
182 accessibleUnits.insert(&unitVector[i]);
183 //save the initial state of each initial unit
184 unitVector[i].saveInitialState();
185 }
186
187 //load start locations from shared memory
188 for(int i = 0; i < data->startLocationCount; ++i)
189 startLocations.push_back(BWAPI::TilePosition(data->startLocations[i].x,data->startLocations[i].y));
190
191 for ( int i = 0; i < data->regionCount; ++i )
192 {
193 this->regionArray[i] = new RegionImpl(i);
194 regionsList.insert(this->regionArray[i]);
195 }
196 for ( int i = 0; i < data->regionCount; ++i )
197 this->regionArray[i]->setNeighbors();
198
199 thePlayer = getPlayer(data->self);
200 theEnemy = getPlayer(data->enemy);
201 theNeutral = getPlayer(data->neutral);
202 _allies.clear();
203 _enemies.clear();
204 _observers.clear();
205 // check if the current player exists
206 if ( thePlayer )
207 {
208 // iterate each player
209 for(Player p : playerSet)
210 {
211 // check if the player should not be updated
212 if ( !p || p->leftGame() || p->isDefeated() || p == thePlayer )
213 continue;
214 // add player to allies set
215 if ( thePlayer->isAlly(p) )
216 _allies.insert(p);
217 // add player to enemies set
218 if ( thePlayer->isEnemy(p) )
219 _enemies.insert(p);
220 // add player to observers set
221 if ( p->isObserver() )
222 _observers.insert(p);
223 }
224 }
225 onMatchFrame();
226 staticMinerals = minerals;

Callers 1

updateMethod · 0.45

Calls 9

saveInitialStateMethod · 0.80
setNeighborsMethod · 0.80
leftGameMethod · 0.80
isObserverMethod · 0.80
existsMethod · 0.45
clearMethod · 0.45
isDefeatedMethod · 0.45
isAllyMethod · 0.45
isEnemyMethod · 0.45

Tested by

no test coverage detected