From 04313448868a1d5e690de56613103c977e40ee64 Mon Sep 17 00:00:00 2001 From: Benau Date: Tue, 1 Jan 2019 13:12:28 +0800 Subject: [PATCH] Add copyFrom for RemoteKartInfo --- sources.cmake | 2 +- src/network/remote_kart_info.cpp | 40 ++++++++++++++++++++++++++++++++ src/network/remote_kart_info.hpp | 4 +++- 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/network/remote_kart_info.cpp diff --git a/sources.cmake b/sources.cmake index d4f28ae4d..ba4868d71 100644 --- a/sources.cmake +++ b/sources.cmake @@ -1,5 +1,5 @@ # Modify this file to change the last-modified date when you add/remove a file. -# This will then trigger a new cmake run automatically. +# This will then trigger a new cmake run automatically. file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp") file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp") file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*") diff --git a/src/network/remote_kart_info.cpp b/src/network/remote_kart_info.cpp new file mode 100644 index 000000000..54e959b57 --- /dev/null +++ b/src/network/remote_kart_info.cpp @@ -0,0 +1,40 @@ +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2019 SuperTuxKart-Team +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "network/remote_kart_info.hpp" +#include "network/network_player_profile.hpp" + +// ---------------------------------------------------------------------------- +void RemoteKartInfo::makeReserved() +{ + m_user_name = L""; + m_profile.reset(); +} // makeReserved + +// ---------------------------------------------------------------------------- +void RemoteKartInfo::copyFrom(std::shared_ptr p, + unsigned local_id) +{ + m_kart_name = p->getKartName(); + m_user_name = p->getName(); + m_local_player_id = local_id; + m_host_id = p->getHostId(); + m_difficulty = p->getPerPlayerDifficulty(); + m_default_kart_color = p->getPerPlayerDifficulty(); + m_online_id = p->getOnlineId(); + m_profile = p; +} // copyFrom diff --git a/src/network/remote_kart_info.hpp b/src/network/remote_kart_info.hpp index dd5e9d1ba..356302e4d 100644 --- a/src/network/remote_kart_info.hpp +++ b/src/network/remote_kart_info.hpp @@ -109,7 +109,9 @@ public: { return m_profile; } bool disconnected() const { return m_profile.expired(); } bool isReserved() const { return m_user_name.empty(); } - void makeReserved() { m_user_name = L""; } + void makeReserved(); + void copyFrom(std::shared_ptr p, + unsigned local_id); bool operator<(const RemoteKartInfo& other) const { return ((m_host_id