| 171 | BWAPI::BroodwarPtr = nullptr; |
| 172 | } |
| 173 | void Client::update() |
| 174 | { |
| 175 | DWORD writtenByteCount; |
| 176 | int code = 1; |
| 177 | WriteFile(pipeObjectHandle, &code, sizeof(code), &writtenByteCount, NULL); |
| 178 | //std::cout << "wrote to pipe" << std::endl; |
| 179 | |
| 180 | while (code != 2) |
| 181 | { |
| 182 | DWORD receivedByteCount; |
| 183 | //std::cout << "reading pipe" << std::endl; |
| 184 | BOOL success = ReadFile(pipeObjectHandle, &code, sizeof(code), &receivedByteCount, NULL); |
| 185 | if ( !success ) |
| 186 | { |
| 187 | std::cout << "failed, disconnecting" << std::endl; |
| 188 | disconnect(); |
| 189 | return; |
| 190 | } |
| 191 | } |
| 192 | //std::cout << "about to enter event loop" << std::endl; |
| 193 | |
| 194 | for(int i = 0; i < data->eventCount; ++i) |
| 195 | { |
| 196 | EventType::Enum type(data->events[i].type); |
| 197 | |
| 198 | if ( type == EventType::MatchStart ) |
| 199 | static_cast<GameImpl*>(BWAPI::BroodwarPtr)->onMatchStart(); |
| 200 | if ( type == EventType::MatchFrame || type == EventType::MenuFrame ) |
| 201 | static_cast<GameImpl*>(BWAPI::BroodwarPtr)->onMatchFrame(); |
| 202 | } |
| 203 | if ( BWAPI::BroodwarPtr != nullptr && static_cast<GameImpl*>(BWAPI::BroodwarPtr)->inGame && !Broodwar->isInGame() ) |
| 204 | static_cast<GameImpl*>(BWAPI::BroodwarPtr)->onMatchEnd(); |
| 205 | } |
| 206 | } |
nothing calls this directly
no test coverage detected