diff --git a/storage/storage.cpp b/storage/storage.cpp index 800b0e0a1e..b0b2091ba7 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -1126,7 +1126,8 @@ void Storage::GetLocalRealMaps(TCountriesVec & localMaps) const localMaps.push_back(keyValue.first); } -void Storage::GetDownloadedChildren(TCountryId const & parent, TCountriesVec & localChildren) const +void Storage::GetChildrenInGroups(TCountryId const & parent, + TCountriesVec & downloadedChildren, TCountriesVec & availChildren) const { ASSERT_THREAD_CHECKER(m_threadChecker, ()); @@ -1137,11 +1138,15 @@ void Storage::GetDownloadedChildren(TCountryId const & parent, TCountriesVec & l return; } - localChildren.clear(); + downloadedChildren.clear(); + availChildren.clear(); TCountriesVec localMaps; GetLocalRealMaps(localMaps); if (localMaps.empty()) + { + GetChildren(parent, availChildren); return; + } size_t const childrenCount = parentNode->ChildrenCount(); sort(localMaps.begin(), localMaps.end()); @@ -1152,28 +1157,22 @@ void Storage::GetDownloadedChildren(TCountryId const & parent, TCountriesVec & l TCountryId const & childCountryId = child.Value().Name(); if (HasCountryId(localMaps, childCountryId)) { // CountryId of child is a name of an mwm. - localChildren.push_back(childCountryId); + downloadedChildren.push_back(childCountryId); continue; } // Child is a group of mwms. - size_t localMapsInChild = 0; - TCountryId lastCountryIdInLocalMaps; + bool hasDownloadedDescendant = false; child.ForEachDescendant([&](TCountriesContainer const & descendant) { TCountryId const & countryId = descendant.Value().Name(); if (HasCountryId(localMaps, countryId)) - { - ++localMapsInChild; - lastCountryIdInLocalMaps = countryId; - } + hasDownloadedDescendant = true; }); - if (localMapsInChild == 0) - continue; // No descendant of the child is in localMaps. - if (localMapsInChild == 1) - localChildren.push_back(lastCountryIdInLocalMaps); // One descendant of the child is in localMaps. + if (hasDownloadedDescendant == true) + downloadedChildren.push_back(childCountryId); else - localChildren.push_back(childCountryId); // Two or more descendants of the child is in localMaps. + availChildren.push_back(childCountryId); } } diff --git a/storage/storage.hpp b/storage/storage.hpp index 1f494e4c28..20db221ea1 100644 --- a/storage/storage.hpp +++ b/storage/storage.hpp @@ -246,16 +246,18 @@ public: /// returns in param all countries ids. It's content of map downloader list by default. void GetChildren(TCountryId const & parent, TCountriesVec & childrenId) const; - /// \brief Fills localChildren with children of parent. - /// The result of the method is composed in a special way because of design requirements. - /// If a direct child (of parent) contains two or more downloaded mwms the direct child id will be added to result. - /// If a direct child (of parent) contains one downloaded mwm the mwm id will be added to result. - /// If there's no downloaded mwms contained by a direct child the direct child id will not be added to result. - /// \param parent is a parent acoording to countries.txt. - /// \note. This method puts to localChildren only real maps which have been written in coutries.txt. It means - /// the method does not put to localChildren neither custom maps generated by user + /// \brief Fills |downloadedChildren| and |availChildren| with children of parent. + /// If a direct child of |parent| contains at least one downloaded mwm + /// the mwm id of the child will be added to |downloadedChildren|. + /// If not, the mwm id the child will not be added to |availChildren|. + /// \param parent is a parent acoording to countries.txt or cournties_migrate.txt. + /// \param downloadedChildren children partly or fully downloaded. + /// \param availChildren fully available children. No of its mwms have been downloaded. + /// \note. This method puts to localChildren only real maps which have been written in coutries.txt or cournties_migrate.txt. + /// It means the method does not put to localChildren neither custom maps generated by user /// nor World.mwm and WorldCoasts.mwm. - void GetDownloadedChildren(TCountryId const & parent, TCountriesVec & localChildren) const; + void GetChildrenInGroups(TCountryId const & parent, + TCountriesVec & downloadedChildren, TCountriesVec & availChildren) const; /// \brief Gets list of available countries. /// \param countryList is filled with a list of node id which an end user will see in