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

Function spiLockGameList

bwapi/SNP_DirectIP/SNP/SNPModule.cpp:174–257  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

172 }
173 //------------------------------------------------------------------------------------------------------------------------------------
174 BOOL __stdcall spiLockGameList(int a1, int a2, game **ppGameList)
175 {
176 critSecExLock = new CriticalSection::Lock(critSec);
177 // Strom locks the game list to access it
178// DropMessage(0, "spiLockGameList");
179
180 // interlink gamelist entries (for storm)
181 AdFile *lastAd = nullptr;
182 for ( auto &it : gameList)
183 {
184 it.gameInfo.pExtra = it.extraBytes;
185 if ( lastAd )
186 lastAd->gameInfo.pNext = &it.gameInfo;
187
188 lastAd = ⁢
189 }
190
191 if(lastAd)
192 lastAd->gameInfo.pNext = nullptr;
193
194 // remove outdated entries
195 //std::list<AdFile>::iterator nextAd = gameList.begin();
196 //std::list<AdFile>::iterator currAd;
197 auto currAd = gameList.begin();
198 while ( currAd != gameList.end() )
199 {
200 if(GetTickCount() > currAd->gameInfo.dwTimer + 2000)
201 {
202 // outdated, remove
203 currAd = gameList.erase(currAd);
204 }
205 else // otherwise continue
206 {
207 ++currAd;
208 }
209 }
210
211 try
212 {
213 // return game list
214 *ppGameList = nullptr;
215 if ( !gameList.empty() )
216 *ppGameList = &gameList.begin()->gameInfo;
217 }
218 catch(GeneralException &e)
219 {
220 DropLastError(__FUNCTION__ " unhandled exception: %s", e.getMessage());
221 return FALSE;
222 }
223 /*
224 if ( !ppGameList )
225 {
226 SetLastError(ERROR_INVALID_PARAMETER);
227 return false;
228 }
229 // ClearGameList func embedded
230 EnterCriticalSection(&gCrit);
231 if ( gpMGameList )

Callers

nothing calls this directly

Calls 4

DropLastErrorFunction · 0.85
beginMethod · 0.80
endMethod · 0.80
getMessageMethod · 0.80

Tested by

no test coverage detected