engine: client: minor refactoring for cls.demoplayback check

This commit is contained in:
Alibek Omarov 2024-06-15 13:56:15 +03:00
parent 3717e5c2e0
commit 1a5e2b907d
2 changed files with 16 additions and 13 deletions

View File

@ -2378,21 +2378,24 @@ static void CL_ReadNetMessage( void )
// can't be a valid sequenced packet // can't be a valid sequenced packet
if( cls.state < ca_connected ) continue; if( cls.state < ca_connected ) continue;
if( !cls.demoplayback && MSG_GetMaxBytes( &net_message ) < 8 ) if( !cls.demoplayback )
{ {
Con_Printf( S_WARN "CL_ReadPackets: %s:runt packet\n", NET_AdrToString( net_from )); if( MSG_GetMaxBytes( &net_message ) < 8 )
continue; {
} Con_Printf( S_WARN "CL_ReadPackets: %s:runt packet\n", NET_AdrToString( net_from ));
continue;
}
// packet from server // packet from server
if( !cls.demoplayback && !NET_CompareAdr( net_from, cls.netchan.remote_address )) if( !NET_CompareAdr( net_from, cls.netchan.remote_address ))
{ {
Con_DPrintf( S_ERROR "CL_ReadPackets: %s:sequenced packet without connection\n", NET_AdrToString( net_from )); Con_DPrintf( S_ERROR "CL_ReadPackets: %s:sequenced packet without connection\n", NET_AdrToString( net_from ));
continue; continue;
} }
if( !cls.demoplayback && !Netchan_Process( &cls.netchan, &net_message )) if( !Netchan_Process( &cls.netchan, &net_message ))
continue; // wasn't accepted for some reason continue; // wasn't accepted for some reason
}
if( cls.state == ca_active ) if( cls.state == ca_active )
{ {

View File

@ -264,7 +264,7 @@ static void CL_LegacyParseResourceList( sizebuf_t *msg )
Q_strncpy( reslist.resnames[i], MSG_ReadString( msg ), sizeof( reslist.resnames[i] )); Q_strncpy( reslist.resnames[i], MSG_ReadString( msg ), sizeof( reslist.resnames[i] ));
} }
if( CL_IsPlaybackDemo() ) if( cls.demoplayback )
return; return;
if( !cl_allow_download.value ) if( !cl_allow_download.value )