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

Method onMatchStart

bwapi/BWAPI/Source/BWAPI/Server.cpp:355–471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

353 clearAll();
354 }
355 void Server::onMatchStart()
356 {
357 data->self = getPlayerID(Broodwar->self());
358 data->enemy = getPlayerID(Broodwar->enemy());
359 data->neutral = getPlayerID(Broodwar->neutral());
360 data->isMultiplayer = Broodwar->isMultiplayer();
361 data->isBattleNet = Broodwar->isBattleNet();
362 data->isReplay = Broodwar->isReplay();
363
364 // Locally store the map size
365 TilePosition mapSize( Broodwar->mapWidth(), Broodwar->mapHeight() );
366 WalkPosition mapWalkSize( mapSize );
367
368 // Load walkability
369 for ( int x = 0; x < mapWalkSize.x; ++x )
370 for ( int y = 0; y < mapWalkSize.y; ++y )
371 {
372 data->isWalkable[x][y] = Broodwar->isWalkable(x, y);
373 }
374
375 // Load buildability, ground height, tile region id
376 for ( int x = 0; x < mapSize.x; ++x )
377 for ( int y = 0; y < mapSize.y; ++y )
378 {
379 data->isBuildable[x][y] = Broodwar->isBuildable(x, y);
380 data->getGroundHeight[x][y] = Broodwar->getGroundHeight(x, y);
381 if (BW::BWDATA::SAIPathing )
382 data->mapTileRegionId[x][y] = BW::BWDATA::SAIPathing->mapTileRegionId[y][x];
383 else
384 data->mapTileRegionId[x][y] = 0;
385 }
386
387 // Load pathing info
388 if ( BW::BWDATA::SAIPathing )
389 {
390 data->regionCount = BW::BWDATA::SAIPathing->regionCount;
391 for(int i = 0; i < 5000; ++i)
392 {
393 data->mapSplitTilesMiniTileMask[i] = BW::BWDATA::SAIPathing->splitTiles[i].minitileMask;
394 data->mapSplitTilesRegion1[i] = BW::BWDATA::SAIPathing->splitTiles[i].rgn1;
395 data->mapSplitTilesRegion2[i] = BW::BWDATA::SAIPathing->splitTiles[i].rgn2;
396
397 BWAPI::Region r = Broodwar->getRegion(i);
398 if (r)
399 {
400 data->regions[i] = *static_cast<RegionImpl*>(r)->getData();
401 }
402 else
403 {
404 MemZero(data->regions[i]);
405 }
406 }
407 }
408
409 // Store the map size
410 data->mapWidth = mapSize.x;
411 data->mapHeight = mapSize.y;
412

Callers

nothing calls this directly

Calls 15

MemZeroFunction · 0.50
StrCopyFunction · 0.50
selfMethod · 0.45
enemyMethod · 0.45
neutralMethod · 0.45
isMultiplayerMethod · 0.45
isBattleNetMethod · 0.45
isReplayMethod · 0.45
mapWidthMethod · 0.45
mapHeightMethod · 0.45
isWalkableMethod · 0.45
isBuildableMethod · 0.45

Tested by

no test coverage detected