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

Method update

bwapi/TestAIModule/Source/TransportTest.cpp:91–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91void TransportTest::update()
92{
93 if (running == false) return;
94 if (fail)
95 {
96 running = false;
97 return;
98 }
99 int thisFrame = Broodwar->getFrameCount();
100 BWAssert(thisFrame==nextFrame);
101 nextFrame++;
102 Broodwar->setScreenPosition(transport->getPosition() - Position(320,240));
103 if (state == Start)
104 {
105 state = WaitForFirstUnit;
106 currentUnit = *unloadedUnits.begin();
107 transport->load(currentUnit);
108 BWAssertF(unloadedUnits.size()==4,{fail=true;return;});
109 BWAssertF(loadedUnits.size()==0,{fail=true;return;});
110 state=WaitForFirstUnit;
111 }
112 else if (state == WaitForFirstUnit)
113 {
114 if (currentUnit->isLoaded())
115 {
116 loadedUnits.insert(currentUnit);
117 unloadedUnits.erase(currentUnit);
118 if (verifyLoadedUnits()==false) return;
119 BWAssertF(unloadedUnits.size()==3,{fail=true;return;});
120 BWAssertF(loadedUnits.size()==1,{fail=true;return;});
121 currentUnit = *unloadedUnits.begin();
122 if (!transport->load(currentUnit))
123 Broodwar->printf("%s",Broodwar->getLastError().c_str());
124 state=WaitForSecondUnit;
125 }
126 }
127 else if (state == WaitForSecondUnit)
128 {
129 if (currentUnit->isLoaded())
130 {
131 loadedUnits.insert(currentUnit);
132 unloadedUnits.erase(currentUnit);
133 if (verifyLoadedUnits()==false) return;
134 BWAssertF(unloadedUnits.size()==2,{fail=true;return;});
135 BWAssertF(loadedUnits.size()==2,{fail=true;return;});
136 currentUnit = *unloadedUnits.begin();
137 if (!transport->load(currentUnit))
138 Broodwar->printf("%s",Broodwar->getLastError().c_str());
139 state=WaitForThirdUnit;
140 }
141 }
142 else if (state == WaitForThirdUnit)
143 {
144 if (currentUnit->isLoaded())
145 {
146 loadedUnits.insert(currentUnit);
147 unloadedUnits.erase(currentUnit);
148 if (verifyLoadedUnits()==false) return;

Callers

nothing calls this directly

Calls 15

beginMethod · 0.80
isLoadedMethod · 0.80
printfMethod · 0.80
c_strMethod · 0.80
getLastErrorMethod · 0.80
PositionClass · 0.50
getFrameCountMethod · 0.45
setScreenPositionMethod · 0.45
getPositionMethod · 0.45
loadMethod · 0.45
sizeMethod · 0.45
unloadMethod · 0.45

Tested by

no test coverage detected