mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Initialize members net-sessions in the class
With this members of `CNetClientSession` and `CNetServerSession` get initialized within the class instead of the constructor.
This commit is contained in:
parent
0c4bcd9139
commit
789d24aa1c
2 changed files with 12 additions and 14 deletions
|
|
@ -36,9 +36,7 @@ constexpr int NETCLIENT_POLL_TIMEOUT = 50;
|
|||
constexpr int CHANNEL_COUNT = 1;
|
||||
|
||||
CNetClientSession::CNetClientSession(CNetClient& client) :
|
||||
m_Client(client), m_FileTransferer(*this), m_Host(nullptr), m_Server(nullptr),
|
||||
m_Stats(nullptr), m_IncomingMessages(16), m_OutgoingMessages(16),
|
||||
m_LoopRunning(false), m_ShouldShutdown(false), m_MeanRTT(0), m_LastReceivedTime(0)
|
||||
m_Client(client), m_FileTransferer(*this)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -239,7 +237,7 @@ u32 CNetClientSession::GetMeanRTT() const
|
|||
}
|
||||
|
||||
CNetServerSession::CNetServerSession(CNetServerWorker& server, ENetPeer* peer) :
|
||||
m_Server(server), m_FileTransferer(*this), m_Peer(peer), m_HostID(0), m_GUID(), m_UserName()
|
||||
m_Server(server), m_FileTransferer(*this), m_Peer(peer)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,9 +113,9 @@ private:
|
|||
CNetFileTransferer m_FileTransferer;
|
||||
|
||||
// Net messages received and waiting for fetching.
|
||||
boost::lockfree::queue<ENetEvent> m_IncomingMessages;
|
||||
boost::lockfree::queue<ENetEvent> m_IncomingMessages{16};
|
||||
// Net messages to send on the next flush() call.
|
||||
boost::lockfree::queue<ENetPacket*> m_OutgoingMessages;
|
||||
boost::lockfree::queue<ENetPacket*> m_OutgoingMessages{16};
|
||||
|
||||
// Last known state. If false, flushing errors are silenced.
|
||||
bool m_Connected = false;
|
||||
|
|
@ -124,16 +124,16 @@ private:
|
|||
bool m_WasConnected = false;
|
||||
|
||||
// Wrapper around enet stats - those are atomic as the code is lock-free.
|
||||
std::atomic<u32> m_LastReceivedTime;
|
||||
std::atomic<u32> m_MeanRTT;
|
||||
std::atomic<u32> m_LastReceivedTime{0};
|
||||
std::atomic<u32> m_MeanRTT{0};
|
||||
|
||||
// If this is true, calling Connect() or deleting the session is an error.
|
||||
std::atomic<bool> m_LoopRunning;
|
||||
std::atomic<bool> m_ShouldShutdown;
|
||||
std::atomic<bool> m_LoopRunning{false};
|
||||
std::atomic<bool> m_ShouldShutdown{false};
|
||||
|
||||
ENetHost* m_Host;
|
||||
ENetPeer* m_Server;
|
||||
CNetStatsTable* m_Stats;
|
||||
ENetHost* m_Host{nullptr};
|
||||
ENetPeer* m_Server{nullptr};
|
||||
CNetStatsTable* m_Stats{nullptr};
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -206,7 +206,7 @@ private:
|
|||
|
||||
CStr m_GUID;
|
||||
CStrW m_UserName;
|
||||
u32 m_HostID;
|
||||
u32 m_HostID{0};
|
||||
CStr m_Password;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue