mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Migrate to STL containers/algorithms.
This commit is contained in:
parent
e204bedf1d
commit
6a1670dbc3
63 changed files with 1330 additions and 1417 deletions
|
@ -29,6 +29,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "util/thread.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
namespace con
|
||||
{
|
||||
|
@ -142,14 +144,14 @@ SharedBuffer<u8> makeOriginalPacket(
|
|||
SharedBuffer<u8> data);
|
||||
|
||||
// Split data in chunks and add TYPE_SPLIT headers to them
|
||||
core::list<SharedBuffer<u8> > makeSplitPacket(
|
||||
std::list<SharedBuffer<u8> > makeSplitPacket(
|
||||
SharedBuffer<u8> data,
|
||||
u32 chunksize_max,
|
||||
u16 seqnum);
|
||||
|
||||
// Depending on size, make a TYPE_ORIGINAL or TYPE_SPLIT packet
|
||||
// Increments split_seqnum if a split packet is made
|
||||
core::list<SharedBuffer<u8> > makeAutoSplitPacket(
|
||||
std::list<SharedBuffer<u8> > makeAutoSplitPacket(
|
||||
SharedBuffer<u8> data,
|
||||
u32 chunksize_max,
|
||||
u16 &split_seqnum);
|
||||
|
@ -167,7 +169,7 @@ struct IncomingSplitPacket
|
|||
reliable = false;
|
||||
}
|
||||
// Key is chunk number, value is data without headers
|
||||
core::map<u16, SharedBuffer<u8> > chunks;
|
||||
std::map<u16, SharedBuffer<u8> > chunks;
|
||||
u32 chunk_count;
|
||||
float time; // Seconds from adding
|
||||
bool reliable; // If true, isn't deleted on timeout
|
||||
|
@ -268,12 +270,12 @@ with a buffer in the receiving and transmitting end.
|
|||
for fast access to the smallest one.
|
||||
*/
|
||||
|
||||
typedef core::list<BufferedPacket>::Iterator RPBSearchResult;
|
||||
typedef std::list<BufferedPacket>::iterator RPBSearchResult;
|
||||
|
||||
class ReliablePacketBuffer
|
||||
{
|
||||
public:
|
||||
|
||||
ReliablePacketBuffer();
|
||||
void print();
|
||||
bool empty();
|
||||
u32 size();
|
||||
|
@ -286,10 +288,11 @@ public:
|
|||
void incrementTimeouts(float dtime);
|
||||
void resetTimedOuts(float timeout);
|
||||
bool anyTotaltimeReached(float timeout);
|
||||
core::list<BufferedPacket> getTimedOuts(float timeout);
|
||||
std::list<BufferedPacket> getTimedOuts(float timeout);
|
||||
|
||||
private:
|
||||
core::list<BufferedPacket> m_list;
|
||||
std::list<BufferedPacket> m_list;
|
||||
u16 m_list_size;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -310,7 +313,7 @@ public:
|
|||
|
||||
private:
|
||||
// Key is seqnum
|
||||
core::map<u16, IncomingSplitPacket*> m_buf;
|
||||
std::map<u16, IncomingSplitPacket*> m_buf;
|
||||
};
|
||||
|
||||
class Connection;
|
||||
|
@ -589,7 +592,7 @@ private:
|
|||
void rawSend(const BufferedPacket &packet);
|
||||
Peer* getPeer(u16 peer_id);
|
||||
Peer* getPeerNoEx(u16 peer_id);
|
||||
core::list<Peer*> getPeers();
|
||||
std::list<Peer*> getPeers();
|
||||
bool getFromBuffers(u16 &peer_id, SharedBuffer<u8> &dst);
|
||||
// Returns next data from a buffer if possible
|
||||
// If found, returns true; if not, false.
|
||||
|
@ -619,7 +622,7 @@ private:
|
|||
UDPSocket m_socket;
|
||||
u16 m_peer_id;
|
||||
|
||||
core::map<u16, Peer*> m_peers;
|
||||
std::map<u16, Peer*> m_peers;
|
||||
JMutex m_peers_mutex;
|
||||
|
||||
// Backwards compatibility
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue