Skip to content

Commit

Permalink
Remove unused ConnectionCommand::sendToAll function. NetworkPacket::o…
Browse files Browse the repository at this point in the history
…ldForgePacket returns Buffer instead of SharedBuffer and is used in ConnectionCommand instead of Connection::Send

This remove the NetworkPacket buffer => SharedBuffer => Buffer copy. Now NetworkPacket => Buffer
  • Loading branch information
nerzhul committed Mar 22, 2015
1 parent 761b127 commit 61f2d0c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/network/connection.cpp
Expand Up @@ -2924,7 +2924,7 @@ void Connection::Send(u16 peer_id, u8 channelnum,

ConnectionCommand c;

c.send(peer_id, channelnum, pkt->oldForgePacket(), reliable);
c.send(peer_id, channelnum, pkt, reliable);
putCommand(c);
}

Expand Down
11 changes: 2 additions & 9 deletions src/network/connection.h
Expand Up @@ -437,19 +437,12 @@ struct ConnectionCommand
peer_id = peer_id_;
}
void send(u16 peer_id_, u8 channelnum_,
SharedBuffer<u8> data_, bool reliable_)
NetworkPacket* pkt, bool reliable_)
{
type = CONNCMD_SEND;
peer_id = peer_id_;
channelnum = channelnum_;
data = data_;
reliable = reliable_;
}
void sendToAll(u8 channelnum_, SharedBuffer<u8> data_, bool reliable_)
{
type = CONNCMD_SEND_TO_ALL;
channelnum = channelnum_;
data = data_;
data = pkt->oldForgePacket();
reliable = reliable_;
}

Expand Down
2 changes: 1 addition & 1 deletion src/network/networkpacket.cpp
Expand Up @@ -510,7 +510,7 @@ NetworkPacket& NetworkPacket::operator<<(video::SColor src)
return *this;
}

SharedBuffer<u8> NetworkPacket::oldForgePacket()
Buffer<u8> NetworkPacket::oldForgePacket()
{
SharedBuffer<u8> sb(m_datasize + 2);
writeU16(&sb[0], m_command);
Expand Down
2 changes: 1 addition & 1 deletion src/network/networkpacket.h
Expand Up @@ -104,7 +104,7 @@ class NetworkPacket
NetworkPacket& operator<<(video::SColor src);

// Temp, we remove SharedBuffer when migration finished
SharedBuffer<u8> oldForgePacket();
Buffer<u8> oldForgePacket();
private:
template<typename T> void checkDataSize()
{
Expand Down

0 comments on commit 61f2d0c

Please sign in to comment.