From e49e67e2f40bede1327cb56e120179c28cda2bf3 Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Thu, 5 Jul 2012 11:35:17 +0200 Subject: [PATCH] Added some assertions to the network --- src/engine/shared/network_client.cpp | 7 +++++++ src/engine/shared/network_server.cpp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/engine/shared/network_client.cpp b/src/engine/shared/network_client.cpp index 21afa74b8..18f5d9b3c 100644 --- a/src/engine/shared/network_client.cpp +++ b/src/engine/shared/network_client.cpp @@ -138,6 +138,13 @@ int CNetClient::Recv(CNetChunk *pChunk, TOKEN *pResponseToken, int *pVersion) int CNetClient::Send(CNetChunk *pChunk, TOKEN Token, int Version) { + if(Version != NET_PACKETVERSION) + { + dbg_assert(m_Flags&NETFLAG_ALLOWOLDSTYLE && m_Flags&NETFLAG_ALLOWSTATELESS, "oldstyle packet sending not enabled"); + dbg_assert(pChunk->m_Flags&NETSENDFLAG_CONNLESS && pChunk->m_ClientID == -1, "only connless packets allowed for oldstyle network"); + dbg_assert(pChunk->m_Flags&NETSENDFLAG_STATELESS && Token == NET_TOKEN_NONE, "tokens can't be used in oldstyle packets"); + } + if(pChunk->m_Flags&NETSENDFLAG_CONNLESS) { if(pChunk->m_DataSize >= NET_MAX_PAYLOAD) diff --git a/src/engine/shared/network_server.cpp b/src/engine/shared/network_server.cpp index 5ef147e96..cf3f852a9 100644 --- a/src/engine/shared/network_server.cpp +++ b/src/engine/shared/network_server.cpp @@ -289,6 +289,13 @@ int CNetServer::Recv(CNetChunk *pChunk, TOKEN *pResponseToken, int *pVersion) int CNetServer::Send(CNetChunk *pChunk, TOKEN Token, int Version) { + if(Version != NET_PACKETVERSION) + { + dbg_assert(m_Flags&NETFLAG_ALLOWOLDSTYLE && m_Flags&NETFLAG_ALLOWSTATELESS, "oldstyle packet sending not enabled"); + dbg_assert(pChunk->m_Flags&NETSENDFLAG_CONNLESS && pChunk->m_ClientID == -1, "only connless packets allowed for oldstyle network"); + dbg_assert(pChunk->m_Flags&NETSENDFLAG_STATELESS && Token == NET_TOKEN_NONE, "tokens can't be used in oldstyle packets"); + } + if(pChunk->m_Flags&NETSENDFLAG_CONNLESS) { if(pChunk->m_DataSize >= NET_MAX_PAYLOAD)