| 36 | namespace MasterServer |
| 37 | { |
| 38 | bool fillMasterServerGames(const std::string& odVersion, std::vector<MasterServerGame>& masterServerGames) |
| 39 | { |
| 40 | sf::Http::Request request("/get_csv.php", sf::Http::Request::Get); |
| 41 | sf::Http http(ConfigManager::getSingleton().getMasterServerUrl()); |
| 42 | sf::Http::Response response = http.sendRequest(request); |
| 43 | |
| 44 | if (response.getStatus() != sf::Http::Response::Ok) |
| 45 | return false; |
| 46 | |
| 47 | // Read pending games |
| 48 | std::stringstream ss(response.getBody()); |
| 49 | std::string line; |
| 50 | while(!ss.eof()) |
| 51 | { |
| 52 | if(!Helper::readNextLineNotEmpty(ss, line)) |
| 53 | break; |
| 54 | |
| 55 | std::vector<std::string> elems = Helper::split(line, ';'); |
| 56 | if(elems.size() != 7) |
| 57 | continue; |
| 58 | |
| 59 | // Whatever the OD version is, the first column should be the version. We process only lines |
| 60 | // where the version matches |
| 61 | if(odVersion != formatStringFromMasterServer(elems[0])) |
| 62 | continue; |
| 63 | |
| 64 | int32_t port = Helper::toInt(elems[4]); |
| 65 | masterServerGames.emplace_back( |
| 66 | formatStringFromMasterServer(elems[1]), |
| 67 | formatStringFromMasterServer(elems[2]), |
| 68 | formatStringFromMasterServer(elems[3]), |
| 69 | port, |
| 70 | formatStringFromMasterServer(elems[5]), |
| 71 | formatStringFromMasterServer(elems[6])); |
| 72 | } |
| 73 | return true; |
| 74 | } |
| 75 | |
| 76 | bool registerGame(const std::string& odVersion, const std::string& creator, int32_t port, const std::string& label, const std::string& descr, std::string& uuid) |
| 77 | { |
no test coverage detected