NetworkClient: removed static message caching to simplify code and reduce state

This commit is contained in:
vis2k 2018-06-10 10:04:45 +02:00
parent 8957af215c
commit 8e7095262f

View File

@ -37,9 +37,6 @@ public class NetworkClient
EndPoint m_RemoteEndPoint; EndPoint m_RemoteEndPoint;
// static message objects to avoid runtime-allocations
static CRCMessage s_CRCMessage = new CRCMessage();
NetworkMessageHandlers m_MessageHandlers = new NetworkMessageHandlers(); NetworkMessageHandlers m_MessageHandlers = new NetworkMessageHandlers();
protected NetworkConnection m_Connection; protected NetworkConnection m_Connection;
@ -891,8 +888,9 @@ internal void RegisterSystemHandlers(bool localClient)
void OnCRC(NetworkMessage netMsg) void OnCRC(NetworkMessage netMsg)
{ {
netMsg.ReadMessage(s_CRCMessage); CRCMessage msg = new CRCMessage();
NetworkCRC.Validate(s_CRCMessage.scripts, numChannels); netMsg.ReadMessage(msg);
NetworkCRC.Validate(msg.scripts, numChannels);
} }
public void RegisterHandler(short msgType, NetworkMessageDelegate handler) public void RegisterHandler(short msgType, NetworkMessageDelegate handler)