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

Method update

bwapi/BWAPI/Source/GameUpdate.cpp:36–217  ·  view source on GitHub ↗

------------------------------------------------- UPDATE -------------------------------------------------

Source from the content-addressed store, hash-verified

34
35//------------------------------------------------- UPDATE -------------------------------------------------
36void GameImpl::update()
37{
38 //this function is called every frame from a hook attached in DllMain.cpp
39 this->inGame = true;
40
41 // Calculate APM, FPS, etc.
42 updateStatistics();
43
44 //the first time update() is called, we also call onGameStart to initialize some things
45 if ( !onStartCalled )
46 this->onGameStart();
47
48 if ( !this->calledMatchEnd && frameCount > 1 )
49 {
50 bool win = false;
51 bool allDone = false;
52 if ( this->BWAPIPlayer )
53 {
54 if ( this->BWAPIPlayer->isVictorious() )
55 {
56 win = true;
57 allDone = true;
58 }
59 if ( this->BWAPIPlayer->isDefeated() )
60 {
61 win = false;
62 allDone = true;
63 }
64 }
65 else
66 {
67 allDone = true;
68 for(PlayerImpl* p : this->players)
69 {
70 if (p->getIndex() >= BW::PLAYABLE_PLAYER_COUNT)
71 continue;
72 if ( !p->isDefeated() && !p->isVictorious() && !p->leftGame() )
73 allDone = false;
74 }
75 }
76 if ( allDone)
77 {
78 if (win)
79 rn_GameResult = "win";
80 this->calledMatchEnd = true;
81 events.push_back(Event::MatchFrame());
82 events.push_back(Event::MatchEnd(win));
83 server.update();
84 this->inGame = false;
85 events.push_back(Event::MenuFrame());
86 server.update();
87 }
88 }
89
90 //don't have any more MatchFrame events after MatchEnd until MatchStart is called.
91 if ( this->calledMatchEnd ) return;
92
93 // Update unit selection

Callers 1

updateStatisticsMethod · 0.45

Calls 15

onGameStartMethod · 0.95
updateUnitsMethod · 0.95
updateBulletsMethod · 0.95
initializeAIModuleMethod · 0.95
isReplayMethod · 0.95
getFrameCountMethod · 0.95
leftGameMethod · 0.80
isObserverMethod · 0.80
c_strMethod · 0.80
dieMethod · 0.80

Tested by

no test coverage detected