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

Function main

bwapi/AIModuleLoader/Source/AIModuleLoader.cpp:21–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}
20
21int main(int argc, const char* argv[])
22{
23 std::string dllPath;
24
25 if ( argc >= 2 )
26 {
27 dllPath = argv[1];
28 }
29 else
30 {
31 std::cout << "Enter path name to AI DLL: " << std::endl;
32 std::getline(std::cin, dllPath);
33 }
34
35 std::cout << "Connecting..." << std::endl;
36
37 assert(BWAPIClient.isConnected() == false);
38 reconnect();
39 assert(BroodwarPtr != nullptr);
40
41 while( true )
42 {
43 std::cout << "waiting to enter match" << std::endl;
44 while ( !Broodwar->isInGame() )
45 {
46 //std::cout << "attempting update" << std::endl;
47 BWAPI::BWAPIClient.update();
48 if (!BWAPI::BWAPIClient.isConnected())
49 {
50 std::cout << "Reconnecting..." << std::endl;
51 reconnect();
52 }
53 }
54 std::cout << "entered match" << std::endl;
55
56 AIModule* client = NULL;
57 HMODULE hMod = LoadLibraryA(dllPath.c_str());
58 if (hMod == NULL)
59 {
60 std::cerr << "ERROR: Failed to load the AI Module" << std::endl;
61 client = new AIModule();
62 Broodwar->sendText("Error: Failed to load the AI Module");
63 }
64 else
65 {
66 typedef AIModule* (*PFNCreateA1)();
67 typedef void (*PFNGameInit)(Game *);
68
69 PFNGameInit newGame = (PFNGameInit)GetProcAddress(hMod, "gameInit");
70 PFNCreateA1 newAIModule = (PFNCreateA1)GetProcAddress(hMod, "newAIModule");
71
72 if ( !newGame || !newAIModule )
73 {
74 std::cerr << "ERROR: Failed to find AI Module exports" << std::endl;
75 client = new AIModule();
76 Broodwar->sendText("Error: Failed to find AI Module exports");
77 }
78 else

Callers

nothing calls this directly

Calls 15

c_strMethod · 0.80
sendTextMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
isWinnerMethod · 0.80
getTextMethod · 0.80
reconnectFunction · 0.70
newAIModuleFunction · 0.50
isConnectedMethod · 0.45
isInGameMethod · 0.45
updateMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected