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

Method initializeTournamentModule

bwapi/BWAPI/Source/GameUpdate.cpp:265–321  ·  view source on GitHub ↗

--------------------------------------------- TOURNAMENT MODULE ----------------------------------------------

Source from the content-addressed store, hash-verified

263
264//--------------------------------------------- TOURNAMENT MODULE ----------------------------------------------
265void GameImpl::initializeTournamentModule()
266{
267 // Declare typedefs for function pointers
268 typedef void (*PFNGameInit)(Game *);
269 typedef AIModule* (*PFNCreateA1)();
270 typedef TournamentModule* (*PFNCreateTournament)();
271
272 // Initialize Tournament Variables
273#ifndef _DEBUG
274 // Load tournament string and module if string exists
275 std::string TournamentDllPath = LoadConfigString("ai", "tournament");
276 if ( TournamentDllPath.size() > 0 )
277 hTournamentModule = LoadLibrary(TournamentDllPath.c_str());
278
279 // If tournament module exists
280 if ( hTournamentModule )
281 {
282 // Obtain our tournament functions
283 PFNGameInit newGameInit = (PFNGameInit)GetProcAddress(hTournamentModule, TEXT("gameInit"));
284 PFNCreateA1 newTournamentAI = (PFNCreateA1)GetProcAddress(hTournamentModule, TEXT("newTournamentAI"));
285 PFNCreateTournament newTournamentModule = (PFNCreateTournament)GetProcAddress(hTournamentModule, TEXT("newTournamentModule"));
286
287 // Call the tournament functions if they exist
288 if ( newTournamentAI && newTournamentModule && newGameInit )
289 {
290 newGameInit(this);
291 this->tournamentAI = newTournamentAI();
292 this->tournamentController = newTournamentModule();
293 }
294 else // error when one function is not found
295 {
296 // Free the tournament module
297 FreeLibrary(hTournamentModule);
298 hTournamentModule = NULL;
299
300 // Create our error string
301 std::string missing;
302 if ( !newTournamentAI )
303 missing += "newTournamentAI";
304
305 if ( !newTournamentModule )
306 {
307 if ( !missing.empty() )
308 missing += " and ";
309 missing += "newTournamentModule";
310 }
311 missing += " function";
312
313 // print error message
314 Broodwar << Text::Red << "ERROR: Failed to find the " << missing << " in tournament module." << std::endl;
315 }
316 }
317 this->bTournamentMessageAppeared = false;
318#else
319 this->bTournamentMessageAppeared = true;
320#endif
321}
322

Callers 1

updateMethod · 0.95

Calls 5

LoadConfigStringFunction · 0.85
newTournamentAIFunction · 0.85
newTournamentModuleFunction · 0.85
c_strMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected