Send(0, data, false);
}
+void Client::sendPlayerItem(u16 item)
+{
+ Player *myplayer = m_env.getLocalPlayer();
+ if(myplayer == NULL)
+ return;
+
+ u16 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;
+ // Check that an existing peer_id is the same as the connection's
+ assert(myplayer->peer_id == our_peer_id);
+
+ SharedBuffer<u8> data(2+2);
+ writeU16(&data[0], TOSERVER_PLAYERITEM);
+ writeU16(&data[2], item);
+
+ // Send as reliable
+ Send(0, data, true);
+}
+
void Client::removeNode(v3s16 p)
{
//JMutexAutoLock envlock(m_env_mutex); //bulk comment-out
assert(player != NULL);
player->wieldItem(item);
+
+ sendPlayerItem(item);
}
// Returns true if the inventory of the local player has been
void sendPlayerPos();
// This sends the player's current name etc to the server
void sendPlayerInfo();
+ // Send the item number 'item' as player item to the server
+ void sendPlayerItem(u16 item);
float m_packetcounter_timer;
float m_connection_reinit_timer;
[30] u8[28] new password
*/
+ TOSERVER_PLAYERITEM=0x37,
+ /*
+ Sent to change selected item.
+
+ [0] u16 TOSERVER_PLAYERITEM
+ [2] u16 item
+ */
+
};
inline SharedBuffer<u8> makePacket_TOCLIENT_TIME_OF_DAY(u16 time)
<<std::endl;
SendChatMessage(peer_id, L"Password change successful");
}
+ else if (command == TOSERVER_PLAYERITEM)
+ {
+ if (datasize < 2+2)
+ return;
+
+ u16 item = readU16(&data[2]);
+ player->wieldItem(item);
+ }
else
{
derr_server<<"WARNING: Server::ProcessData(): Ignoring "