From be10c0893e2e6d1852a027abccc4cd3cdc85a140 Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Sat, 30 Sep 2017 12:00:05 +0200 Subject: Make Player::peer_id server-side only and add getters and setters (#6478) * Make Player::peer_id server-side only and add getters and setters Player::peer_id has no sense client side, move it to server, make it private and add setter and getter Also add some PEER_ID_INEXISTENT instead of harcoded 0 --- src/client.cpp | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'src/client.cpp') diff --git a/src/client.cpp b/src/client.cpp index 13ee8bb76..2538f52aa 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1190,7 +1190,7 @@ void Client::sendReady() void Client::sendPlayerPos() { LocalPlayer *myplayer = m_env.getLocalPlayer(); - if(myplayer == NULL) + if (!myplayer) return; ClientMap &map = m_env.getClientMap(); @@ -1216,16 +1216,6 @@ void Client::sendPlayerPos() myplayer->last_camera_fov = camera_fov; myplayer->last_wanted_range = wanted_range; - //infostream << "Sending Player Position information" << std::endl; - - session_t our_peer_id = m_con->GetPeerID(); - - // Set peer id if not set already - if(myplayer->peer_id == PEER_ID_INEXISTENT) - myplayer->peer_id = our_peer_id; - - assert(myplayer->peer_id == our_peer_id); - NetworkPacket pkt(TOSERVER_PLAYERPOS, 12 + 12 + 4 + 4 + 4 + 1 + 1); writePlayerPos(myplayer, &map, &pkt); @@ -1236,16 +1226,9 @@ void Client::sendPlayerPos() void Client::sendPlayerItem(u16 item) { LocalPlayer *myplayer = m_env.getLocalPlayer(); - if(myplayer == NULL) + if (!myplayer) return; - session_t our_peer_id = m_con->GetPeerID(); - - // Set peer id if not set already - if(myplayer->peer_id == PEER_ID_INEXISTENT) - myplayer->peer_id = our_peer_id; - assert(myplayer->peer_id == our_peer_id); - NetworkPacket pkt(TOSERVER_PLAYERITEM, 2); pkt << item; -- cgit v1.2.3