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

Method onGameStart

bwapi/BWAPI/Source/BWAPI/GameEvents.cpp:20–286  ·  view source on GitHub ↗

--------------------------------------------- ON GAME START ----------------------------------------------

Source from the content-addressed store, hash-verified

18{
19 //--------------------------------------------- ON GAME START ----------------------------------------------
20 void GameImpl::onGameStart()
21 {
22 // This function is called at the start of every match
23 this->initializeData();
24
25 // Set the speed override
26 this->setLocalSpeedDirect(this->speedOverride);
27
28 // initialize the variables
29 //this->frameCount = 0;
30 this->onStartCalled = true;
31 this->calledMatchEnd = false;
32
33 // pre-calculate the map hash
34 Map::calculateMapHash();
35
36 // Obtain Broodwar Regions
37 if ( BW::BWDATA::SAIPathing )
38 {
39 u32 rgnCount = BW::BWDATA::SAIPathing->regionCount;
40 // Iterate regions and insert into region list
41 for (u32 i = 0; i < rgnCount; ++i)
42 {
43 Region r = new BWAPI::RegionImpl(i);
44 this->regionsList.insert(r);
45 this->regionMap[i] = r;
46 }
47
48 // Iterate regions again and update neighbor lists
49 for ( BWAPI::Region r : this->regionsList )
50 static_cast<RegionImpl*>(r)->UpdateRegionRelations();
51 } // if SAI_Pathing
52
53 // roughly identify which players can possibly participate in this game
54 // iterate triggers for each player
55 for (int i = 0; i < BW::PLAYABLE_PLAYER_COUNT; ++i)
56 {
57 // reset participation and resources
58 if (this->players[i])
59 {
60 this->players[i]->setParticipating(false);
61 this->players[i]->resetResources();
62 }
63
64 // First check if player owns a unit at start
65 for (int u = 0; u < UnitTypes::None; ++u)
66 {
67 if (BW::BWDATA::Game.unitCounts.all[u][i])
68 {
69 if (this->players[i])
70 this->players[i]->setParticipating();
71 break;
72 }
73 }
74 }
75
76 for (int i = 0; i < BW::PLAYABLE_PLAYER_COUNT; ++i)
77 {

Callers 1

updateMethod · 0.95

Calls 15

initializeDataMethod · 0.95
setLocalSpeedDirectMethod · 0.95
_getPlayerMethod · 0.95
getGameTypeMethod · 0.95
isReplayMethod · 0.95
UpdateRegionRelationsMethod · 0.80
setParticipatingMethod · 0.80
resetResourcesMethod · 0.80
conditionsCanBeMetMethod · 0.80
isObserverMethod · 0.80
actionsAllowGameplayMethod · 0.80
getPlayerIDMethod · 0.80

Tested by

no test coverage detected