Add copyFrom for RemoteKartInfo

This commit is contained in:
Benau 2019-01-01 13:12:28 +08:00
parent 564ed41ed3
commit 0431344886
3 changed files with 44 additions and 2 deletions

View File

@ -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/*")

View File

@ -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<NetworkPlayerProfile> 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

View File

@ -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<NetworkPlayerProfile> p,
unsigned local_id);
bool operator<(const RemoteKartInfo& other) const
{
return ((m_host_id<other.m_host_id) ||