Use client timeout when loading a map

This commit is contained in:
nsubiron 2019-07-10 17:57:07 +02:00
parent 0ce908dbf2
commit c821fc0e7e
1 changed files with 3 additions and 2 deletions

View File

@ -70,9 +70,10 @@ namespace detail {
EpisodeProxy Simulator::LoadEpisode(std::string map_name) {
const auto id = GetCurrentEpisode().GetId();
_client.LoadEpisode(std::move(map_name));
for (auto i = 0u; i < 10u; ++i) { // 10 attempts (at most 20 seconds).
size_t number_of_attempts = _client.GetTimeout().milliseconds() / 10u;
for (auto i = 0u; i < number_of_attempts; ++i) {
using namespace std::literals::chrono_literals;
_episode->WaitForState(2s); // Ignore time-outs.
_episode->WaitForState(10ms);
auto episode = GetCurrentEpisode();
if (episode.GetId() != id) {
return episode;