Added some assertions to the network

This commit is contained in:
heinrich5991 2012-07-05 11:35:17 +02:00 committed by oy
parent 16f2899e3f
commit e49e67e2f4
2 changed files with 14 additions and 0 deletions

View file

@ -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)

View file

@ -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)