diff --git a/src/config/user_config.hpp b/src/config/user_config.hpp index dc7367f07..fec7c5daf 100644 --- a/src/config/user_config.hpp +++ b/src/config/user_config.hpp @@ -806,7 +806,7 @@ namespace UserConfigParams PARAM_PREFIX StringToUIntUserConfigParam m_server_bookmarks PARAM_DEFAULT(StringToUIntUserConfigParam("server-bookmarks", "Wan server bookmarks", - {{ "server-bookmarks", "server-name", "owner" }}, {})); + {{ "server-bookmarks", "server-name", "last-online" }}, {})); PARAM_PREFIX StringToUIntUserConfigParam m_address_history PARAM_DEFAULT(StringToUIntUserConfigParam("address-history", diff --git a/src/states_screens/dialogs/server_info_dialog.cpp b/src/states_screens/dialogs/server_info_dialog.cpp index afc8017e9..4ced8fce2 100644 --- a/src/states_screens/dialogs/server_info_dialog.cpp +++ b/src/states_screens/dialogs/server_info_dialog.cpp @@ -261,7 +261,7 @@ void ServerInfoDialog::updateBookmarkStatus(bool change_bookmark) { if (change_bookmark) { - bookmarks[key] = m_server->getServerOwner(); + bookmarks[key] = StkTime::getTimeSinceEpoch(); m_bookmark_widget->setLabel(_("Remove from bookmarks")); m_bookmark_widget->setImage(m_remove_icon); } diff --git a/src/states_screens/online/server_selection.cpp b/src/states_screens/online/server_selection.cpp index 5a5d9cd30..5b2afe725 100644 --- a/src/states_screens/online/server_selection.cpp +++ b/src/states_screens/online/server_selection.cpp @@ -69,6 +69,8 @@ void ServerSelection::tearDown() m_servers.clear(); m_server_list_widget->clear(); m_server_list = nullptr; + if (!UserConfigParams::m_server_bookmarks.empty()) + user_config->saveConfig(); } // tearDown // ---------------------------------------------------------------------------- @@ -422,7 +424,7 @@ void ServerSelection::onUpdate(float dt) std::set all_possible_keys; if (NetworkConfig::get()->isWAN()) { - // Remove offline server from bookmarks + // Remove offline server from bookmarks if inactive for 3 days for (auto& server : m_server_list->m_servers) all_possible_keys.insert(server->getBookmarkKey()); std::map& bookmarks = @@ -430,11 +432,21 @@ void ServerSelection::onUpdate(float dt) auto it = bookmarks.begin(); while (it != bookmarks.end()) { + uint64_t three_days = 60 * 60 * 24 * 3; + uint64_t limit = StkTime::getTimeSinceEpoch() - three_days; if (all_possible_keys.find(it->first) == all_possible_keys.end()) - it = bookmarks.erase(it); + { + if (it->second < limit) + it = bookmarks.erase(it); + else + it++; + } else + { + it->second = StkTime::getTimeSinceEpoch(); it++; + } } } int selection = m_server_list_widget->getSelectionID();