From 0d0da15a6237e60cb314e85097aada85bafbbca8 Mon Sep 17 00:00:00 2001 From: Benau Date: Fri, 3 Apr 2020 14:10:52 +0800 Subject: [PATCH] Use std::vector for ai profiles so the order is preserved --- src/network/protocols/server_lobby.cpp | 2 +- src/network/protocols/server_lobby.hpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/network/protocols/server_lobby.cpp b/src/network/protocols/server_lobby.cpp index bbcc06971..3ad781eae 100644 --- a/src/network/protocols/server_lobby.cpp +++ b/src/network/protocols/server_lobby.cpp @@ -3575,7 +3575,7 @@ void ServerLobby::handleUnencryptedConnection(std::shared_ptr peer, #endif if (i > 0) name += core::stringw(" ") + StringUtils::toWString(i); - m_ai_profiles.insert(std::make_shared + m_ai_profiles.push_back(std::make_shared (peer, name, peer->getHostId(), 0.0f, 0, HANDICAP_NONE, player_count + i, KART_TEAM_NONE, "")); } diff --git a/src/network/protocols/server_lobby.hpp b/src/network/protocols/server_lobby.hpp index ed819dc1b..e76ae687a 100644 --- a/src/network/protocols/server_lobby.hpp +++ b/src/network/protocols/server_lobby.hpp @@ -25,6 +25,7 @@ #include "irrString.h" +#include #include #include #include @@ -134,7 +135,7 @@ private: /** AI profiles for all-in-one graphical client server, this will be a * fixed count thorough the live time of server, which its value is * configured in NetworkConfig. */ - std::set > m_ai_profiles; + std::vector > m_ai_profiles; std::atomic m_server_owner_id; @@ -385,7 +386,10 @@ public: void listBanTable(); void initServerStatsTable(); bool isAIProfile(const std::shared_ptr& npp) const - { return m_ai_profiles.find(npp) != m_ai_profiles.end(); } + { + return std::find(m_ai_profiles.begin(), m_ai_profiles.end(), npp) != + m_ai_profiles.end(); + } uint32_t getServerIdOnline() const { return m_server_id_online; } void setClientServerHostId(uint32_t id) { m_client_server_host_id = id; } }; // class ServerLobby