fix some undefined/unspecified behaviours in multiplayer games( may help with #299 )

This commit is contained in:
nillerusr 2023-10-07 05:04:46 +03:00
parent 2636f1a66d
commit 57f6bf6eea
9 changed files with 17 additions and 16 deletions

View File

@ -199,7 +199,7 @@ bool CNetworkStringTableItem::SetUserData( int tick, int length, const void *use
if ( length > 0 ) if ( length > 0 )
{ {
m_pUserData = new unsigned char[ length ]; m_pUserData = new unsigned char[ALIGN_VALUE( length, 4 )];
Q_memcpy( m_pUserData, userData, length ); Q_memcpy( m_pUserData, userData, length );
} }
else else

View File

@ -921,7 +921,7 @@ void DownloadThread( void *voidPtr )
// Delete rc.data, which was allocated in this thread // Delete rc.data, which was allocated in this thread
if ( rc.data != NULL ) if ( rc.data != NULL )
{ {
delete[] rc.data; free(rc.data);
rc.data = NULL; rc.data = NULL;
} }

View File

@ -226,7 +226,7 @@ bool CPureServerWhitelist::LoadCommandsFromKeyValues( KeyValues *kv )
else else
Warning( "Unknown modifier in whitelist file: %s.\n", mods[i] ); Warning( "Unknown modifier in whitelist file: %s.\n", mods[i] );
} }
mods.PurgeAndDeleteElements(); mods.PurgeAndDeleteElementsArray();
if ( if (
( bFromTrustedSource && ( bAllowFromDisk || bCheckCRC || bAny ) ) ( bFromTrustedSource && ( bAllowFromDisk || bCheckCRC || bAny ) )
|| ( bAny && bCheckCRC ) ) || ( bAny && bCheckCRC ) )

View File

@ -1227,7 +1227,7 @@ void SV_DetermineMulticastRecipients( bool usepas, const Vector& origin, CBitVec
serverGameClients->ClientEarPosition( pClient->edict, &vecEarPosition ); serverGameClients->ClientEarPosition( pClient->edict, &vecEarPosition );
int iBitNumber = CM_LeafCluster( CM_PointLeafnum( vecEarPosition ) ); int iBitNumber = CM_LeafCluster( CM_PointLeafnum( vecEarPosition ) );
if ( !(pMask[iBitNumber>>3] & (1<<(iBitNumber&7)) ) ) if ( iBitNumber < 0 || !(pMask[iBitNumber>>3] & (1<<(iBitNumber&7)) ) )
continue; continue;
playerbits.Set( i ); playerbits.Set( i );

View File

@ -1842,7 +1842,7 @@ void CVEngineServer::PlaybackTempEntity( IRecipientFilter& filter, float delay,
newEvent->bits = buffer.GetNumBitsWritten(); newEvent->bits = buffer.GetNumBitsWritten();
int size = Bits2Bytes( buffer.GetNumBitsWritten() ); int size = Bits2Bytes( buffer.GetNumBitsWritten() );
newEvent->pData = new byte[size]; newEvent->pData = new byte[ALIGN_VALUE(size,4)];
Q_memcpy( newEvent->pData, data, size ); Q_memcpy( newEvent->pData, data, size );
// add to list // add to list

View File

@ -115,7 +115,7 @@ void CTeamMenu::ApplySchemeSettings(IScheme *pScheme)
if ( *m_szMapName ) if ( *m_szMapName )
{ {
LoadMapPage( m_szMapName ); // reload the map description to pick up the color LoadMapPage( NULL ); // reload the map description to pick up the color
} }
} }
@ -185,6 +185,7 @@ void CTeamMenu::Update()
void CTeamMenu::LoadMapPage( const char *mapName ) void CTeamMenu::LoadMapPage( const char *mapName )
{ {
// Save off the map name so we can re-load the page in ApplySchemeSettings(). // Save off the map name so we can re-load the page in ApplySchemeSettings().
if( mapName )
Q_strncpy( m_szMapName, mapName, strlen( mapName ) + 1 ); Q_strncpy( m_szMapName, mapName, strlen( mapName ) + 1 );
char mapRES[ MAX_PATH ]; char mapRES[ MAX_PATH ];
@ -193,14 +194,14 @@ void CTeamMenu::LoadMapPage( const char *mapName )
uilanguage[0] = 0; uilanguage[0] = 0;
engine->GetUILanguage( uilanguage, sizeof( uilanguage ) ); engine->GetUILanguage( uilanguage, sizeof( uilanguage ) );
Q_snprintf( mapRES, sizeof( mapRES ), "resource/maphtml/%s_%s.html", mapName, uilanguage ); Q_snprintf( mapRES, sizeof( mapRES ), "resource/maphtml/%s_%s.html", m_szMapName, uilanguage );
bool bFoundHTML = false; bool bFoundHTML = false;
if ( !g_pFullFileSystem->FileExists( mapRES ) ) if ( !g_pFullFileSystem->FileExists( mapRES ) )
{ {
// try english // try english
Q_snprintf( mapRES, sizeof( mapRES ), "resource/maphtml/%s_english.html", mapName ); Q_snprintf( mapRES, sizeof( mapRES ), "resource/maphtml/%s_english.html", m_szMapName );
} }
else else
{ {
@ -240,7 +241,7 @@ void CTeamMenu::LoadMapPage( const char *mapName )
#endif #endif
} }
Q_snprintf( mapRES, sizeof( mapRES ), "maps/%s.txt", mapName); Q_snprintf( mapRES, sizeof( mapRES ), "maps/%s.txt", m_szMapName);
// if no map specific description exists, load default text // if no map specific description exists, load default text
if( !g_pFullFileSystem->FileExists( mapRES ) ) if( !g_pFullFileSystem->FileExists( mapRES ) )

View File

@ -1787,14 +1787,14 @@ FORCEINLINE fltx4 LoadAlignedSIMD( const VectorAligned & pSIMD )
return SetWToZeroSIMD( LoadAlignedSIMD(pSIMD.Base()) ); return SetWToZeroSIMD( LoadAlignedSIMD(pSIMD.Base()) );
} }
#ifdef __SANITIZE_ADDRESS__ #ifdef USING_ASAN
static __attribute__((no_sanitize("address"))) fltx4 LoadUnalignedSIMD( const void *pSIMD ) static NO_ASAN fltx4 LoadUnalignedSIMD( const void *pSIMD )
{ {
return _mm_loadu_ps( reinterpret_cast<const float *>( pSIMD ) ); return _mm_loadu_ps( reinterpret_cast<const float *>( pSIMD ) );
} }
static __attribute__((no_sanitize("address"))) fltx4 LoadUnaligned3SIMD( const void *pSIMD ) static NO_ASAN fltx4 LoadUnaligned3SIMD( const void *pSIMD )
{ {
return _mm_loadu_ps( reinterpret_cast<const float *>( pSIMD ) ); return _mm_loadu_ps( reinterpret_cast<const float *>( pSIMD ) );
} }

View File

@ -50,7 +50,7 @@ enum
// Don't change this without consulting Kelly or Wedge (sjb). // Don't change this without consulting Kelly or Wedge (sjb).
#define ATTN_GUNFIRE 0.27f #define ATTN_GUNFIRE 0.27f
enum soundlevel_t enum soundlevel_t : int
{ {
SNDLVL_NONE = 0, SNDLVL_NONE = 0,

View File

@ -1010,7 +1010,7 @@ CUtlString D3DToGL::FixGLSLSwizzle( const char *pDestRegisterName, const char *p
{ {
bool bAbsWrapper = false; // Parameter wrapped in an abs() bool bAbsWrapper = false; // Parameter wrapped in an abs()
bool bAbsNegative = false; // -abs() bool bAbsNegative = false; // -abs()
char szSrcRegister[128]; static char szSrcRegister[128];
V_strncpy( szSrcRegister, pSrcRegisterName, sizeof(szSrcRegister) ); V_strncpy( szSrcRegister, pSrcRegisterName, sizeof(szSrcRegister) );
// Check for abs() or -abs() wrapper and strip it off during the fixup // Check for abs() or -abs() wrapper and strip it off during the fixup