From 3c89b03c54da1e8906450ba859c9c5b2d3734155 Mon Sep 17 00:00:00 2001 From: Roel Algaba Brizuela Date: Fri, 16 Jul 2021 15:37:14 +0200 Subject: [PATCH] Updated file transfer system --- LibCarla/source/carla/client/detail/Client.cpp | 7 +++++-- .../source/carla/client/detail/Simulator.cpp | 16 +++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/LibCarla/source/carla/client/detail/Client.cpp b/LibCarla/source/carla/client/detail/Client.cpp index c06954b17..508bbab4e 100644 --- a/LibCarla/source/carla/client/detail/Client.cpp +++ b/LibCarla/source/carla/client/detail/Client.cpp @@ -188,9 +188,12 @@ namespace detail { if (download) { // For each required file, check if it exists and request it otherwise - for(auto requiredFile : requiredFiles) { - if(!FileTransfer::FileExists(requiredFile)) { + for (auto requiredFile : requiredFiles) { + if (!FileTransfer::FileExists(requiredFile)) { RequestFile(requiredFile); + log_info("Could not find the required file in cache, downloading... ", requiredFile); + } else { + log_info("Found the required file in cache! ", requiredFile) } } } diff --git a/LibCarla/source/carla/client/detail/Simulator.cpp b/LibCarla/source/carla/client/detail/Simulator.cpp index 986a56912..30ef714ff 100644 --- a/LibCarla/source/carla/client/detail/Simulator.cpp +++ b/LibCarla/source/carla/client/detail/Simulator.cpp @@ -157,11 +157,10 @@ namespace detail { std::string map_name; std::string map_base_path; bool fill_base_string = false; - for(int i = map_info.name.size() - 1; i >= 0; --i){ - if(fill_base_string == false && map_info.name[i] != '/'){ + for (int i = map_info.name.size() - 1; i >= 0; --i) { + if (fill_base_string == false && map_info.name[i] != '/') { map_name += map_info.name[i]; - } - else { + } else { map_base_path += map_info.name[i]; fill_base_string = true; } @@ -169,12 +168,11 @@ namespace detail { std::reverse(map_name.begin(), map_name.end()); std::reverse(map_base_path.begin(), map_base_path.end()); std::string XODRFolder = map_base_path + "/OpenDrive/" + map_name + ".xodr"; - if(FileTransfer::FileExists(XODRFolder) == false){ - _client.GetRequiredFiles(); - _open_drive_file = _client.GetMapData(); - _cached_map = MakeShared(map_info, _open_drive_file); - } + if (FileTransfer::FileExists(XODRFolder) == false) _client.GetRequiredFiles(); + _open_drive_file = _client.GetMapData(); + _cached_map = MakeShared(map_info, _open_drive_file); } + return _cached_map; }