| 19 | } |
| 20 | |
| 21 | int 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 |
nothing calls this directly
no test coverage detected