From 0499fde7518b24a5806bb02a354bc43ab51d0820 Mon Sep 17 00:00:00 2001 From: hymei Date: Wed, 23 Feb 2022 20:10:25 +0800 Subject: [PATCH] arm64 : intp fixes --- engine/spatialpartition.cpp | 36 ++++++++++++++++----------------- game/client/c_baseanimating.cpp | 6 +++--- public/tier2/riff.h | 10 ++++----- tier1/byteswap.cpp | 4 ++++ tier2/soundutils.cpp | 20 +++++++++--------- 5 files changed, 40 insertions(+), 36 deletions(-) diff --git a/engine/spatialpartition.cpp b/engine/spatialpartition.cpp index 3bcc85f3..0b6b0b0a 100644 --- a/engine/spatialpartition.cpp +++ b/engine/spatialpartition.cpp @@ -95,14 +95,14 @@ struct EntityInfo_t uint8 m_flags; char m_nLevel[NUM_TREES]; // Which level voxel tree is it in? unsigned short m_nVisitBit[NUM_TREES]; - int m_iLeafList[NUM_TREES]; // Index into the leaf pool - leaf list for entity (m_aLeafList). + intp m_iLeafList[NUM_TREES]; // Index into the leaf pool - leaf list for entity (m_aLeafList). }; struct LeafListData_t { UtlHashFastHandle_t m_hVoxel; // Voxel handle the entity is in. - int m_iEntity; // Entity list index for voxel + intp m_iEntity; // Entity list index for voxel }; typedef CUtlFixedLinkedList CLeafList; @@ -206,7 +206,7 @@ private: inline void PackVoxel( int iX, int iY, int iZ, Voxel_t &voxel ); - typedef CUtlHashFixed > CHashTable; + typedef CUtlHashFixed > CHashTable; Vector m_vecVoxelOrigin; // Voxel space (hash) origin. CHashTable m_aVoxelHash; // Voxel tree (hash) - data = entity list head handle (m_aEntityList) @@ -603,7 +603,7 @@ void CVoxelHash::InsertIntoTree( SpatialPartitionHandle_t hPartition, const Vect #endif // Entity list. - int iEntity = m_aEntityList.Alloc( true ); + intp iEntity = m_aEntityList.Alloc( true ); m_aEntityList[iEntity] = hPartition; UtlHashFastHandle_t hHash = m_aVoxelHash.Find( voxel.uiVoxel ); @@ -614,13 +614,13 @@ void CVoxelHash::InsertIntoTree( SpatialPartitionHandle_t hPartition, const Vect } else { - int iHead = m_aVoxelHash.Element( hHash ); + intp iHead = m_aVoxelHash.Element( hHash ); m_aEntityList.LinkBefore( iHead, iEntity ); m_aVoxelHash[hHash] = iEntity; } // Leaf list. - int iLeafList = leafList.Alloc( true ); + intp iLeafList = leafList.Alloc( true ); leafList[iLeafList].m_hVoxel = hHash; leafList[iLeafList].m_iEntity = iEntity; @@ -630,7 +630,7 @@ void CVoxelHash::InsertIntoTree( SpatialPartitionHandle_t hPartition, const Vect } else { - int iHead = info.m_iLeafList[treeId]; + intp iHead = info.m_iLeafList[treeId]; leafList.LinkBefore( iHead, iLeafList ); info.m_iLeafList[treeId] = iLeafList; } @@ -649,8 +649,8 @@ void CVoxelHash::RemoveFromTree( SpatialPartitionHandle_t hPartition ) CLeafList &leafList = m_pTree->LeafList(); int treeId = m_pTree->GetTreeId(); - int iLeaf = data.m_iLeafList[treeId]; - int iNext; + intp iLeaf = data.m_iLeafList[treeId]; + intp iNext; while ( iLeaf != leafList.InvalidIndex() ) { // Get the next voxel - if any. @@ -664,12 +664,12 @@ void CVoxelHash::RemoveFromTree( SpatialPartitionHandle_t hPartition ) } // Get the head of the entity list for the voxel. - int iEntity = leafList[iLeaf].m_iEntity; - int iEntityHead = m_aVoxelHash[hHash]; + intp iEntity = leafList[iLeaf].m_iEntity; + intp iEntityHead = m_aVoxelHash[hHash]; if ( iEntityHead == iEntity ) { - int iEntityNext = m_aEntityList.Next( iEntityHead ); + intp iEntityNext = m_aEntityList.Next( iEntityHead ); if ( iEntityNext == m_aEntityList.InvalidIndex() ) { m_aVoxelHash.Remove( hHash ); @@ -911,7 +911,7 @@ bool CVoxelHash::EnumerateElementsInVoxel( Voxel_t voxel, const T &intersectTest return true; SpatialPartitionHandle_t hPartition; - for ( int i = m_aVoxelHash.Element( hHash ); i != m_aEntityList.InvalidIndex(); i = m_aEntityList.Next(i) ) + for ( intp i = m_aVoxelHash.Element( hHash ); i != m_aEntityList.InvalidIndex(); i = m_aEntityList.Next(i) ) { hPartition = m_aEntityList[i]; if ( hPartition == PARTITION_INVALID_HANDLE ) @@ -952,7 +952,7 @@ bool CVoxelHash::EnumerateElementsInSingleVoxel( Voxel_t voxel, const T &interse { // NOTE: We don't have to do the enum id checking, nor do we have to up the // nesting level, since this only visits 1 voxel. - int iEntityList; + intp iEntityList; UtlHashFastHandle_t hHash = m_aVoxelHash.Find( voxel.uiVoxel ); if ( hHash != m_aVoxelHash.InvalidHandle() ) { @@ -1394,7 +1394,7 @@ bool CVoxelHash::EnumerateElementsAtPoint( SpatialPartitionListMask_t listMask, { // NOTE: We don't have to do the enum id checking, nor do we have to up the // nesting level, since this only visits 1 voxel. - int iEntityList; + intp iEntityList; UtlHashFastHandle_t hHash = m_aVoxelHash.Find( v.uiVoxel ); if ( hHash != m_aVoxelHash.InvalidHandle() ) { @@ -1533,7 +1533,7 @@ void CVoxelHash::RenderObjectsInVoxel( Voxel_t voxel, CPartitionVisitor *pVisito if ( hHash == m_aVoxelHash.InvalidHandle() ) return; - int iEntityList = m_aVoxelHash.Element( hHash ); + intp iEntityList = m_aVoxelHash.Element( hHash ); while ( iEntityList != m_aEntityList.InvalidIndex() ) { SpatialPartitionHandle_t hPartition = m_aEntityList[iEntityList]; @@ -1564,7 +1564,7 @@ int CVoxelHash::EntityCount() while ( hHash != m_aVoxelHash.m_aBuckets[iBucket].InvalidIndex() ) { - int iEntity = m_aVoxelHash.m_aBuckets[iBucket][hHash].m_Data; + intp iEntity = m_aVoxelHash.m_aBuckets[iBucket][hHash].m_Data; while ( iEntity!= m_aEntityList.InvalidIndex() ) { ++nCount; @@ -1645,7 +1645,7 @@ void CVoxelHash::RenderAllObjectsInTree( float flTime ) while ( hHash != m_aVoxelHash.m_aBuckets[iBucket].InvalidIndex() ) { - int iEntity = m_aVoxelHash.m_aBuckets[iBucket][hHash].m_Data; + intp iEntity = m_aVoxelHash.m_aBuckets[iBucket][hHash].m_Data; while ( iEntity!= m_aEntityList.InvalidIndex() ) { SpatialPartitionHandle_t hPartition = m_aEntityList[iEntity]; diff --git a/game/client/c_baseanimating.cpp b/game/client/c_baseanimating.cpp index 5727d7b0..d66339e5 100644 --- a/game/client/c_baseanimating.cpp +++ b/game/client/c_baseanimating.cpp @@ -929,7 +929,7 @@ void C_BaseAnimating::LockStudioHdr() if ( pNewWrapper->GetVirtualModel() ) { - MDLHandle_t hVirtualModel = (MDLHandle_t)(int)(pStudioHdr->virtualModel)&0xffff; + MDLHandle_t hVirtualModel = VoidPtrToMDLHandle( pStudioHdr->VirtualModel() ); mdlcache->LockStudioHdr( hVirtualModel ); } @@ -950,7 +950,7 @@ void C_BaseAnimating::UnlockStudioHdr() // Parallel rendering: don't unlock model data until end of rendering if ( pStudioHdr->GetVirtualModel() ) { - MDLHandle_t hVirtualModel = (MDLHandle_t)(int)pStudioHdr->virtualModel&0xffff; + MDLHandle_t hVirtualModel = VoidPtrToMDLHandle( m_pStudioHdr->GetRenderHdr()->VirtualModel() ); pCallQueue->QueueCall( mdlcache, &IMDLCache::UnlockStudioHdr, hVirtualModel ); } pCallQueue->QueueCall( mdlcache, &IMDLCache::UnlockStudioHdr, m_hStudioHdr ); @@ -961,7 +961,7 @@ void C_BaseAnimating::UnlockStudioHdr() // Immediate-mode rendering, can unlock immediately if ( pStudioHdr->GetVirtualModel() ) { - MDLHandle_t hVirtualModel = (MDLHandle_t)(int)pStudioHdr->virtualModel&0xffff; + MDLHandle_t hVirtualModel = VoidPtrToMDLHandle( m_pStudioHdr->GetRenderHdr()->VirtualModel() ); mdlcache->UnlockStudioHdr( hVirtualModel ); } mdlcache->UnlockStudioHdr( m_hStudioHdr ); diff --git a/public/tier2/riff.h b/public/tier2/riff.h index cc8be167..0eb3cfc0 100644 --- a/public/tier2/riff.h +++ b/public/tier2/riff.h @@ -99,11 +99,11 @@ private: class IFileWriteBinary { public: - virtual int create( const char *pFileName ) = 0; - virtual int write( void *pData, int size, int file ) = 0; - virtual void close( int file ) = 0; - virtual void seek( int file, int pos ) = 0; - virtual unsigned int tell( int file ) = 0; + virtual intp create( const char *pFileName ) = 0; + virtual int write( void *pData, int size, intp file ) = 0; + virtual void close( intp file ) = 0; + virtual void seek( intp file, int pos ) = 0; + virtual unsigned int tell( intp file ) = 0; }; //----------------------------------------------------------------------------- // Purpose: Used to write a RIFF format file diff --git a/tier1/byteswap.cpp b/tier1/byteswap.cpp index 9f66297d..f2798793 100644 --- a/tier1/byteswap.cpp +++ b/tier1/byteswap.cpp @@ -34,6 +34,10 @@ void CByteswap::SwapFieldToTargetEndian( void* pOutputBuffer, void *pData, typed SwapBufferToTargetEndian( (int*)pOutputBuffer, (int*)pData, pField->fieldSize ); break; + case FIELD_INTEGER64: + SwapBufferToTargetEndian( (uint64*)pOutputBuffer, (uint64*)pData, pField->fieldSize ); + break; + case FIELD_VECTOR: SwapBufferToTargetEndian( (uint*)pOutputBuffer, (uint*)pData, pField->fieldSize * 3 ); break; diff --git a/tier2/soundutils.cpp b/tier2/soundutils.cpp index ed3e1196..8fb57a16 100644 --- a/tier2/soundutils.cpp +++ b/tier2/soundutils.cpp @@ -40,11 +40,11 @@ public: class CFSIOWriteBinary : public IFileWriteBinary { public: - virtual int create( const char *pFileName ); - virtual int write( void *pData, int size, int file ); - virtual void close( int file ); - virtual void seek( int file, int pos ); - virtual unsigned int tell( int file ); + virtual intp create( const char *pFileName ); + virtual int write( void *pData, int size, intp file ); + virtual void close( intp file ); + virtual void seek( intp file, int pos ); + virtual unsigned int tell( intp file ); }; @@ -110,28 +110,28 @@ void CFSIOReadBinary::close( intp file ) //----------------------------------------------------------------------------- // RIFF writer that use the file system //----------------------------------------------------------------------------- -int CFSIOWriteBinary::create( const char *pFileName ) +intp CFSIOWriteBinary::create( const char *pFileName ) { g_pFullFileSystem->SetFileWritable( pFileName, true ); return (intp)g_pFullFileSystem->Open( pFileName, "wb" ); } -int CFSIOWriteBinary::write( void *pData, int size, int file ) +int CFSIOWriteBinary::write( void *pData, int size, intp file ) { return g_pFullFileSystem->Write( pData, size, (FileHandle_t)file ); } -void CFSIOWriteBinary::close( int file ) +void CFSIOWriteBinary::close( intp file ) { g_pFullFileSystem->Close( (FileHandle_t)file ); } -void CFSIOWriteBinary::seek( int file, int pos ) +void CFSIOWriteBinary::seek( intp file, int pos ) { g_pFullFileSystem->Seek( (FileHandle_t)file, pos, FILESYSTEM_SEEK_HEAD ); } -unsigned int CFSIOWriteBinary::tell( int file ) +unsigned int CFSIOWriteBinary::tell( intp file ) { return g_pFullFileSystem->Tell( (FileHandle_t)file ); }