diff --git a/public/mathlib/ssemath.h b/public/mathlib/ssemath.h index 82d03d6f..b115df9b 100644 --- a/public/mathlib/ssemath.h +++ b/public/mathlib/ssemath.h @@ -218,7 +218,7 @@ extern const int32 ALIGN16 g_SIMD_EveryOtherMask[]; // 0, ~0, 0, ~0 template inline T *AlignPointer(void * ptr) { - unsigned temp = (unsigned)ptr; + uintp temp = (uintp)ptr; temp = ALIGN_VALUE(temp, sizeof(T)); return (T *)temp; } diff --git a/public/tier1/mempool.h b/public/tier1/mempool.h index 5453508c..80d6b967 100644 --- a/public/tier1/mempool.h +++ b/public/tier1/mempool.h @@ -527,7 +527,7 @@ inline void CAlignedMemPool inline int __cdecl CAlignedMemPool::CompareChunk( void * const *ppLeft, void * const *ppRight ) { - return ((unsigned)*ppLeft) - ((unsigned)*ppRight); + return ((uintp)*ppLeft) - ((uintp)*ppRight); } template diff --git a/public/tier1/utlbuffer.h b/public/tier1/utlbuffer.h index 91265a0b..8a1eeffb 100644 --- a/public/tier1/utlbuffer.h +++ b/public/tier1/utlbuffer.h @@ -187,8 +187,9 @@ public: FORCEINLINE void ActivateByteSwappingIfBigEndian( void ) { - if ( IsX360() ) +#if defined( _X360 ) ActivateByteSwapping( true ); +#endif } @@ -671,7 +672,8 @@ inline void CUtlBuffer::GetTypeBin< float >( float &dest ) if ( CheckGet( sizeof( float ) ) ) { uintp pData = (uintp)PeekGet(); - if ( IsX360() && ( pData & 0x03 ) ) +#if defined( _X360 ) + if ( pData & 0x03 ) { // handle unaligned read ((unsigned char*)&dest)[0] = ((unsigned char*)pData)[0]; @@ -684,6 +686,9 @@ inline void CUtlBuffer::GetTypeBin< float >( float &dest ) // aligned read dest = *(float *)pData; } +#else + dest = *(float *)pData; +#endif if ( m_Byteswap.IsSwappingBytes() ) { m_Byteswap.SwapBufferToTargetEndian< float >( &dest, &dest ); @@ -702,7 +707,8 @@ inline void CUtlBuffer::GetTypeBin< double >( double &dest ) if ( CheckGet( sizeof( double ) ) ) { uintp pData = (uintp)PeekGet(); - if ( IsX360() && ( pData & 0x07 ) ) +#if defined( _X360 ) + if ( pData & 0x07 ) { // handle unaligned read ((unsigned char*)&dest)[0] = ((unsigned char*)pData)[0]; @@ -719,6 +725,9 @@ inline void CUtlBuffer::GetTypeBin< double >( double &dest ) // aligned read dest = *(double *)pData; } +#else + dest = *(double *)pData; +#endif if ( m_Byteswap.IsSwappingBytes() ) { m_Byteswap.SwapBufferToTargetEndian< double >( &dest, &dest ); diff --git a/public/tier1/utlfixedmemory.h b/public/tier1/utlfixedmemory.h index c832ac7e..a2399ca8 100644 --- a/public/tier1/utlfixedmemory.h +++ b/public/tier1/utlfixedmemory.h @@ -64,7 +64,7 @@ public: public: Iterator_t( BlockHeader_t *p, int i ) : m_pBlockHeader( p ), m_nIndex( i ) {} BlockHeader_t *m_pBlockHeader; - int m_nIndex; + intp m_nIndex; bool operator==( const Iterator_t it ) const { return m_pBlockHeader == it.m_pBlockHeader && m_nIndex == it.m_nIndex; } bool operator!=( const Iterator_t it ) const { return m_pBlockHeader != it.m_pBlockHeader || m_nIndex != it.m_nIndex; } @@ -82,15 +82,15 @@ public: return pHeader->m_pNext ? Iterator_t( pHeader->m_pNext, 0 ) : InvalidIterator(); } - int GetIndex( const Iterator_t &it ) const + intp GetIndex( const Iterator_t &it ) const { Assert( IsValidIterator( it ) ); if ( !IsValidIterator( it ) ) return InvalidIndex(); - return ( int )( HeaderToBlock( it.m_pBlockHeader ) + it.m_nIndex ); + return ( intp )( HeaderToBlock( it.m_pBlockHeader ) + it.m_nIndex ); } - bool IsIdxAfter( int i, const Iterator_t &it ) const + bool IsIdxAfter( intp i, const Iterator_t &it ) const { Assert( IsValidIterator( it ) ); if ( !IsValidIterator( it ) ) @@ -107,20 +107,20 @@ public: return false; } bool IsValidIterator( const Iterator_t &it ) const { return it.m_pBlockHeader && it.m_nIndex >= 0 && it.m_nIndex < it.m_pBlockHeader->m_nBlockSize; } - Iterator_t InvalidIterator() const { return Iterator_t( NULL, -1 ); } + Iterator_t InvalidIterator() const { return Iterator_t( NULL, INVALID_INDEX ); } // element access - T& operator[]( int i ); - const T& operator[]( int i ) const; - T& Element( int i ); - const T& Element( int i ) const; + T& operator[]( intp i ); + const T& operator[]( intp i ) const; + T& Element( intp i ); + const T& Element( intp i ) const; // Can we use this index? - bool IsIdxValid( int i ) const; + bool IsIdxValid( intp i ) const; // Specify the invalid ('null') index that we'll only return on failure - static const int INVALID_INDEX = 0; // For use with COMPILE_TIME_ASSERT - static int InvalidIndex() { return INVALID_INDEX; } + static const intp INVALID_INDEX = 0; // For use with COMPILE_TIME_ASSERT + static intp InvalidIndex() { return INVALID_INDEX; } // Size int NumAllocated() const; @@ -139,7 +139,7 @@ protected: // Fast swap - WARNING: Swap invalidates all ptr-based indices!!! void Swap( CUtlFixedMemory< T > &mem ); - bool IsInBlock( int i, BlockHeader_t *pBlockHeader ) const + bool IsInBlock( intp i, BlockHeader_t *pBlockHeader ) const { T *p = ( T* )i; const T *p0 = HeaderToBlock( pBlockHeader ); @@ -149,7 +149,7 @@ protected: struct BlockHeader_t { BlockHeader_t *m_pNext; - int m_nBlockSize; + intp m_nBlockSize; }; const T *HeaderToBlock( const BlockHeader_t *pHeader ) const { return ( T* )( pHeader + 1 ); } @@ -207,28 +207,28 @@ void CUtlFixedMemory::Init( int nGrowSize /* = 0 */, int nInitSize /* = 0 */ // element access //----------------------------------------------------------------------------- template< class T > -inline T& CUtlFixedMemory::operator[]( int i ) +inline T& CUtlFixedMemory::operator[]( intp i ) { Assert( IsIdxValid(i) ); return *( T* )i; } template< class T > -inline const T& CUtlFixedMemory::operator[]( int i ) const +inline const T& CUtlFixedMemory::operator[]( intp i ) const { Assert( IsIdxValid(i) ); return *( T* )i; } template< class T > -inline T& CUtlFixedMemory::Element( int i ) +inline T& CUtlFixedMemory::Element( intp i ) { Assert( IsIdxValid(i) ); return *( T* )i; } template< class T > -inline const T& CUtlFixedMemory::Element( int i ) const +inline const T& CUtlFixedMemory::Element( intp i ) const { Assert( IsIdxValid(i) ); return *( T* )i; @@ -249,7 +249,7 @@ inline int CUtlFixedMemory::NumAllocated() const // Is element index valid? //----------------------------------------------------------------------------- template< class T > -inline bool CUtlFixedMemory::IsIdxValid( int i ) const +inline bool CUtlFixedMemory::IsIdxValid( intp i ) const { #ifdef _DEBUG for ( BlockHeader_t *pbh = m_pBlocks; pbh; pbh = pbh->m_pNext ) diff --git a/tier1/KeyValues.cpp b/tier1/KeyValues.cpp index aa698525..4ac50926 100644 --- a/tier1/KeyValues.cpp +++ b/tier1/KeyValues.cpp @@ -2215,7 +2215,7 @@ bool KeyValues::WriteAsBinary( CUtlBuffer &buffer ) } case TYPE_PTR: { - buffer.PutUnsignedInt( (int)dat->m_pValue ); + buffer.PutPtr( dat->m_pValue ); } default: @@ -2310,7 +2310,7 @@ bool KeyValues::ReadAsBinary( CUtlBuffer &buffer ) } case TYPE_PTR: { - dat->m_pValue = (void*)buffer.GetUnsignedInt(); + dat->m_pValue = buffer.GetPtr(); } default: diff --git a/tier1/checksum_crc.cpp b/tier1/checksum_crc.cpp index 3e0f20d4..cb1d34a3 100644 --- a/tier1/checksum_crc.cpp +++ b/tier1/checksum_crc.cpp @@ -101,7 +101,7 @@ CRC32_t CRC32_GetTableEntry( unsigned int slot ) void CRC32_ProcessBuffer(CRC32_t *pulCRC, const void *pBuffer, int nBuffer) { CRC32_t ulCrc = *pulCRC; - unsigned char *pb = (unsigned char *)pBuffer; + uintp pb = (uintp)pBuffer; unsigned int nFront; int nMain; @@ -110,13 +110,13 @@ JustAfew: switch (nBuffer) { case 7: - ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); + ulCrc = pulCRCTable[*(unsigned char *)(pb++) ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); case 6: - ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); + ulCrc = pulCRCTable[*(unsigned char *)(pb++) ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); case 5: - ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); + ulCrc = pulCRCTable[*(unsigned char *)(pb++) ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); case 4: ulCrc ^= LittleLong( *(CRC32_t *)pb ); @@ -128,13 +128,13 @@ JustAfew: return; case 3: - ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); + ulCrc = pulCRCTable[*(unsigned char *)(pb++) ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); case 2: - ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); + ulCrc = pulCRCTable[*(unsigned char *)(pb++) ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); case 1: - ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); + ulCrc = pulCRCTable[*(unsigned char *)(pb++) ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); case 0: *pulCRC = ulCrc; @@ -147,16 +147,16 @@ JustAfew: // The low-order two bits of pb and nBuffer in total control the // upfront work. // - nFront = ((unsigned int)pb) & 3; + nFront = pb & 3; nBuffer -= nFront; switch (nFront) { case 3: - ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); + ulCrc = pulCRCTable[*(unsigned char *)(pb++) ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); case 2: - ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); + ulCrc = pulCRCTable[*(unsigned char *)(pb++) ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); case 1: - ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); + ulCrc = pulCRCTable[*(unsigned char *)(pb++) ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); } nMain = nBuffer >> 3;