diff --git a/bitmap/float_bm.cpp b/bitmap/float_bm.cpp index 33ab8c1f..f10264ec 100644 --- a/bitmap/float_bm.cpp +++ b/bitmap/float_bm.cpp @@ -311,13 +311,16 @@ FloatBitMap_t *FloatBitMap_t::QuarterSize(void) const FloatBitMap_t *newbm=new FloatBitMap_t(Width/2,Height/2); for(int y=0;yPixel(x,y,c)=((Pixel(x*2,y*2,c)+Pixel(x*2+1,y*2,c)+ Pixel(x*2,y*2+1,c)+Pixel(x*2+1,y*2+1,c))/4); } - return newbm; + } + + return newbm; } FloatBitMap_t *FloatBitMap_t::QuarterSizeBlocky(void) const @@ -326,12 +329,14 @@ FloatBitMap_t *FloatBitMap_t::QuarterSizeBlocky(void) const FloatBitMap_t *newbm=new FloatBitMap_t(Width/2,Height/2); for(int y=0;yPixel(x,y,c)=Pixel(x*2,y*2,c); } - return newbm; + } + return newbm; } Vector FloatBitMap_t::AverageColor(void) @@ -349,12 +354,15 @@ float FloatBitMap_t::BrightestColor(void) { float ret=0.0; for(int y=0;y static inline void SWAP(T & a, T & b) @@ -394,6 +402,7 @@ void FloatBitMap_t::UnLogize(void) void FloatBitMap_t::Clear(float r, float g, float b, float alpha) { for(int y=0;yPixel(x,y,c)=dx1; + for (int i = 0; i < NDELTAS; i++) + { + int x1 = x + dx[i]; + int y1 = y + dy[i]; + x1 = MAX(0, x1); + x1 = MIN(Width - 1, x1); + y1 = MAX(0, y1); + y1 = MIN(Height - 1, y1); + float dx1 = Pixel(x, y, c) - Pixel(x1, y1, c); + deltas[i]->Pixel(x, y, c) = dx1; + } } } - for(int x=1;xPixel(x + xofs, y + yofs, c) = diff; + if (Flags & SPFLAGS_MAXGRADIENT) { - float diff=b.Pixel(x,y,c)-b.Pixel(x+dx[i],y+dy[i],c); - deltas[i]->Pixel(x+xofs,y+yofs,c)=diff; - if (Flags & SPFLAGS_MAXGRADIENT) - { - float dx1=Pixel(x+xofs,y+yofs,c)-Pixel(x+dx[i]+xofs,y+dy[i]+yofs,c); - if (fabs(dx1)>fabs(diff)) - deltas[i]->Pixel(x+xofs,y+yofs,c)=dx1; - } + float dx1 = Pixel(x + xofs, y + yofs, c) - Pixel(x + dx[i] + xofs, y + dy[i] + yofs, c); + if (fabs(dx1) > fabs(diff)) + deltas[i]->Pixel(x + xofs, y + yofs, c) = dx1; } } + } + } + } - // now, calculate modifiability - for(int x=0;xxofs+1) && (x<=xofs+b.Width-2) && - (y>yofs+1) && (y<=yofs+b.Height-2)) - modify=1; - Alpha(x,y)=modify; - } - - // // now, force a fex pixels in center to be constant - // int midx=xofs+b.Width/2; - // int midy=yofs+b.Height/2; - // for(x=midx-10;x xofs + 1) && (x <= xofs + b.Width - 2) && + (y > yofs + 1) && (y <= yofs + b.Height - 2)) + modify = 1; + Alpha(x, y) = modify; + } + } + // // now, force a fex pixels in center to be constant + // int midx=xofs+b.Width/2; + // int midy=yofs+b.Height/2; + // for(x=midx-10;xPixel(x,y,c)=dx1; - gsum+=fabs(dx1); + int x1 = x + dx[i]; + int y1 = y + dy[i]; + x1 = MAX(0, x1); + x1 = MIN(Width - 1, x1); + y1 = MAX(0, y1); + y1 = MIN(Height - 1, y1); + float dx1 = Pixel(x, y, c) - Pixel(x1, y1, c); + deltas[i]->Pixel(x, y, c) = dx1; + gsum += fabs(dx1); + } + } + // now, reduce gradient changes + // float gavg=gsum/(Width*Height); + for (int x = 0; x < Width; x++) + for (int y = 0; y < Height; y++) + for (int c = 0; c < 3; c++) + { + for (int i = 0; i < NDELTAS; i++) + { + float norml = 1.1 *deltas[i]->Pixel(x, y, c); + // if (norml < 0.0) + // norml=-pow(-norml,1.2); + // else + // norml=pow(norml,1.2); + deltas[i]->Pixel(x, y, c) = norml; } } - // now, reduce gradient changes - // float gavg=gsum/(Width*Height); - for(int x=0;xPixel(x,y,c); - // if (norml<0.0) - // norml=-pow(-norml,1.2); - // else - // norml=pow(norml,1.2); - deltas[i]->Pixel(x,y,c)=norml; - } - } - // now, calculate modifiability - for(int x=0;x0) && (x 0) && (x < Width - 1) && + (y) && (y < Height - 1)) + { + modify = 1; + Alpha(x, y) = modify; + } + } - Poisson(deltas,2200,0); + Poisson(deltas, 2200, 0); } @@ -553,7 +572,9 @@ void FloatBitMap_t::MakeTileable(void) // set each pixel=avg-pixel FloatBitMap_t *cursrc=&rslta; for(int x=1;xPixel(x+1,y,c); @@ -596,12 +619,16 @@ void FloatBitMap_t::MakeTileable(void) error+=SQ(desired-cursrc->Pixel(x,y,c)); } SWAP(cursrc,curdst); + } + } } // paste result for(int x=0;xPixel(x,y,c); + } + } } @@ -613,15 +640,18 @@ void FloatBitMap_t::GetAlphaBounds(int &minx, int &miny, int &maxx,int &maxy) for(y=0;y=0;maxx--) { int y; for(y=0;yPoisson(lowdeltas,n_iters*4,flags); // now, propagate results from tmp to us for(int x=0;xWidth;x++) + { for(int y=0;yHeight;y++) + { for(int xi=0;xi<2;xi++) + { for(int yi=0;yi<2;yi++) + { if (Alpha(x*2+xi,y*2+yi)) { for(int c=0;c<3;c++) @@ -683,6 +719,10 @@ void FloatBitMap_t::Poisson(FloatBitMap_t *deltas[4], delete tmp; for(int i=0;iPixel(x,y,c)+cursrc->Pixel(x+dx[i],y+dy[i],c); desired*=(1.0/NDELTAS); - // desired=FLerp(Pixel(x,y,c),desired,Alpha(x,y)); + // desired=FLerp(Pixel(x,y,c),desired,Alpha(x,y)); curdst->Pixel(x,y,c)=FLerp(cursrc->Pixel(x,y,c),desired,0.5); error+=SQ(desired-cursrc->Pixel(x,y,c)); } diff --git a/datacache/mdlcache.cpp b/datacache/mdlcache.cpp index 4719c4d8..57ea4006 100644 --- a/datacache/mdlcache.cpp +++ b/datacache/mdlcache.cpp @@ -1450,9 +1450,6 @@ virtualmodel_t *CMDLCache::GetVirtualModelFast( const studiohdr_t *pStudioHdr, M AllocateVirtualModel( handle ); - // MoeMod : added - pStudioHdr->SetVirtualModel( MDLHandleToVirtual( handle ) ); - // Group has to be zero to ensure refcounting is correct int nGroup = pStudioData->m_pVirtualModel->m_group.AddToTail( ); Assert( nGroup == 0 ); diff --git a/engine/baseclient.cpp b/engine/baseclient.cpp index 9e501e33..ed81068f 100644 --- a/engine/baseclient.cpp +++ b/engine/baseclient.cpp @@ -1098,10 +1098,10 @@ void CBaseClient::EndTrace( bf_write &msg ) } if ( sv_netspike_output.GetInt() & 1 ) - COM_LogString( SERVER_PACKETS_LOG, logData.String() ); + COM_LogString( SERVER_PACKETS_LOG, (const char*)logData.String() ); if ( sv_netspike_output.GetInt() & 2 ) - Log( "%s", logData.String() ); - ETWMark1S( "netspike", logData.String() ); + Log( "%s", (const char*)logData.String() ); + ETWMark1S( "netspike", (const char*)logData.String() ); m_Trace.m_Records.RemoveAll(); m_iTracing = 0; } diff --git a/engine/cmodel_disp.cpp b/engine/cmodel_disp.cpp index 3b71a765..5090600f 100644 --- a/engine/cmodel_disp.cpp +++ b/engine/cmodel_disp.cpp @@ -318,7 +318,7 @@ void CM_CreateDispPhysCollide( dphysdisp_t *pDispLump, int dispLumpSize ) { g_VirtualTerrain.LevelInit(pDispLump, dispLumpSize); g_TerrainList.SetCount( g_DispCollTreeCount ); - for ( int i = 0; i < g_DispCollTreeCount; i++ ) + for ( intp i = 0; i < g_DispCollTreeCount; i++ ) { // Don't create a physics collision model for displacements that have been tagged as such. CDispCollTree *pDispTree = &g_pDispCollTrees[i]; diff --git a/engine/dt_encode.cpp b/engine/dt_encode.cpp index fdd0639a..8bebd113 100644 --- a/engine/dt_encode.cpp +++ b/engine/dt_encode.cpp @@ -39,7 +39,7 @@ void EncodeFloat( const SendProp *pProp, float fVal, bf_write *pOut, int objectI } else // standard clamped-range float { - unsigned long ulVal; + unsigned int ulVal; int nBits = pProp->m_nBits; if ( flags & SPROP_NOSCALE ) { @@ -109,7 +109,7 @@ static float DecodeFloat(SendProp const *pProp, bf_read *pIn) } else // standard clamped-range float { - unsigned long dwInterp = pIn->ReadUBitLong(pProp->m_nBits); + unsigned int dwInterp = pIn->ReadUBitLong(pProp->m_nBits); float fVal = (float)dwInterp / ((1 << pProp->m_nBits) - 1); fVal = pProp->m_fLowValue + (pProp->m_fHighValue - pProp->m_fLowValue) * fVal; return fVal; @@ -281,7 +281,7 @@ void Int_Decode( DecodeInfo *pInfo ) { if ( flags & SPROP_UNSIGNED ) { - pInfo->m_Value.m_Int = (long)pInfo->m_pIn->ReadVarInt32(); + pInfo->m_Value.m_Int = (int)pInfo->m_pIn->ReadVarInt32(); } else { @@ -295,7 +295,7 @@ void Int_Decode( DecodeInfo *pInfo ) if( bits != 32 && (flags & SPROP_UNSIGNED) == 0 ) { - unsigned long highbit = 1ul << (pProp->m_nBits - 1); + unsigned int highbit = 1ul << (pProp->m_nBits - 1); if ( pInfo->m_Value.m_Int & highbit ) { pInfo->m_Value.m_Int -= highbit; // strip high bit... diff --git a/engine/saverestore_filesystem.cpp b/engine/saverestore_filesystem.cpp index 0fde4082..a58bab50 100644 --- a/engine/saverestore_filesystem.cpp +++ b/engine/saverestore_filesystem.cpp @@ -310,12 +310,12 @@ int CSaveRestoreFileSystem::GetFileIndex( const char *filename ) FileHandle_t CSaveRestoreFileSystem::GetFileHandle( const char *filename ) { - int idx = GetFileIndex( filename ); + intp idx = GetFileIndex( filename ); if ( idx == INVALID_INDEX ) { idx = 0; } - return (void*)idx; + return (FileHandle_t)idx; } //----------------------------------------------------------------------------- @@ -339,7 +339,7 @@ bool CSaveRestoreFileSystem::HandleIsValid( FileHandle_t hFile ) //----------------------------------------------------------------------------- void CSaveRestoreFileSystem::RenameFile( char const *pOldPath, char const *pNewPath, const char *pathID ) { - int idx = GetFileIndex( pOldPath ); + intp idx = GetFileIndex( pOldPath ); if ( idx != INVALID_INDEX ) { CUtlSymbol newID = AddString( Q_UnqualifiedFileName( pNewPath ) ); @@ -369,7 +369,7 @@ FileHandle_t CSaveRestoreFileSystem::Open( const char *pFullName, const char *pO { SaveFile_t *pFile = NULL; CUtlSymbol id = AddString( Q_UnqualifiedFileName( pFullName ) ); - int idx = GetDirectory().Find( id ); + intp idx = GetDirectory().Find( id ); if ( idx == INVALID_INDEX ) { // Don't create a read-only file diff --git a/engine/sv_main.cpp b/engine/sv_main.cpp index 66fadb3c..1628c881 100644 --- a/engine/sv_main.cpp +++ b/engine/sv_main.cpp @@ -75,6 +75,7 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" +#include "tier0/memalloc.h" extern CNetworkStringTableContainer *networkStringTableContainerServer; extern CNetworkStringTableContainer *networkStringTableContainerClient; diff --git a/engine/sys_dll2.cpp b/engine/sys_dll2.cpp index 59b66b8c..6bcc2af8 100644 --- a/engine/sys_dll2.cpp +++ b/engine/sys_dll2.cpp @@ -100,6 +100,7 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" +#include "tier0/memalloc.h" //----------------------------------------------------------------------------- // Globals diff --git a/filesystem/QueuedLoader.cpp b/filesystem/QueuedLoader.cpp index 0fe235a6..dce2bd63 100644 --- a/filesystem/QueuedLoader.cpp +++ b/filesystem/QueuedLoader.cpp @@ -306,7 +306,7 @@ CQueuedLoader::CQueuedLoader() : BaseClass( false ) V_memset( m_pLoaders, 0, sizeof( m_pLoaders ) ); // set resource dictionaries sort context - for ( int i = 0; i < RESOURCEPRELOAD_COUNT; i++ ) + for ( intp i = 0; i < RESOURCEPRELOAD_COUNT; i++ ) { m_ResourceNames[i].SetLessContext( (void *)i ); } diff --git a/filesystem/filesystem_async.cpp b/filesystem/filesystem_async.cpp index e8ad047e..adce661c 100644 --- a/filesystem/filesystem_async.cpp +++ b/filesystem/filesystem_async.cpp @@ -126,7 +126,7 @@ public: AUTO_LOCK( m_mutex ); - int iEntry = m_map.Find( szFixedName ); + intp iEntry = m_map.Find( szFixedName ); if ( iEntry == m_map.InvalidIndex() ) { iEntry = m_map.Insert( strdup( szFixedName ), new AsyncOpenedFile_t ); @@ -146,7 +146,7 @@ public: AUTO_LOCK( m_mutex ); - int iEntry = m_map.Find( szFixedName ); + intp iEntry = m_map.Find( szFixedName ); if ( iEntry != m_map.InvalidIndex() ) { m_map[iEntry]->AddRef(); diff --git a/filesystem/linux_support.cpp b/filesystem/linux_support.cpp index c68967c4..81988846 100644 --- a/filesystem/linux_support.cpp +++ b/filesystem/linux_support.cpp @@ -102,7 +102,7 @@ HANDLE FindFirstFile( const char *fileName, FIND_DATA *dat) { char nameStore[PATH_MAX]; char *dir=NULL; - int n,iret=-1; + intp n,iret=-1; Q_strncpy(nameStore,fileName, sizeof( nameStore ) ); diff --git a/game/client/c_particle_smokegrenade.cpp b/game/client/c_particle_smokegrenade.cpp index f2fad7c7..da44878a 100644 --- a/game/client/c_particle_smokegrenade.cpp +++ b/game/client/c_particle_smokegrenade.cpp @@ -968,7 +968,7 @@ void C_ParticleSmokeGrenade::CleanupToolRecordingState( KeyValues *msg ) pLifetime->SetFloat( "maxLifetime", m_FadeEndTime ); KeyValues *pVelocity = pInitializers->FindKey( "DmeAttachmentVelocityInitializer", true ); - pVelocity->SetPtr( "entindex", (void*)entindex() ); + pVelocity->SetPtr( "entindex", (void*)(intp)entindex() ); pVelocity->SetFloat( "minRandomSpeed", 10 ); pVelocity->SetFloat( "maxRandomSpeed", 20 ); diff --git a/game/client/c_smoke_trail.cpp b/game/client/c_smoke_trail.cpp index f3d71adb..7f4b6078 100644 --- a/game/client/c_smoke_trail.cpp +++ b/game/client/c_smoke_trail.cpp @@ -418,7 +418,7 @@ void C_SmokeTrail::CleanupToolRecordingState( KeyValues *msg ) // FIXME: Until we can interpolate ent logs during emission, this can't work KeyValues *pPosition = pInitializers->FindKey( "DmePositionPointToEntityInitializer", true ); - pPosition->SetPtr( "entindex", (void*)pEnt->entindex() ); + pPosition->SetPtr( "entindex", (void*)(intp)pEnt->entindex() ); pPosition->SetInt( "attachmentIndex", m_nAttachment ); pPosition->SetFloat( "randomDist", m_SpawnRadius ); pPosition->SetFloat( "startx", pEnt->GetAbsOrigin().x ); @@ -430,7 +430,7 @@ void C_SmokeTrail::CleanupToolRecordingState( KeyValues *msg ) pLifetime->SetFloat( "maxLifetime", m_ParticleLifetime ); KeyValues *pVelocity = pInitializers->FindKey( "DmeAttachmentVelocityInitializer", true ); - pVelocity->SetPtr( "entindex", (void*)entindex() ); + pVelocity->SetPtr( "entindex", (void*)(intp)entindex() ); pVelocity->SetFloat( "minAttachmentSpeed", m_MinDirectedSpeed ); pVelocity->SetFloat( "maxAttachmentSpeed", m_MaxDirectedSpeed ); pVelocity->SetFloat( "minRandomSpeed", m_MinSpeed ); @@ -1933,7 +1933,7 @@ void C_DustTrail::CleanupToolRecordingState( KeyValues *msg ) // FIXME: Until we can interpolate ent logs during emission, this can't work KeyValues *pPosition = pInitializers->FindKey( "DmePositionPointToEntityInitializer", true ); - pPosition->SetPtr( "entindex", (void*)pEnt->entindex() ); + pPosition->SetPtr( "entindex", (void*)(intp)pEnt->entindex() ); pPosition->SetInt( "attachmentIndex", GetParentAttachment() ); pPosition->SetFloat( "randomDist", m_SpawnRadius ); pPosition->SetFloat( "startx", pEnt->GetAbsOrigin().x ); diff --git a/game/client/c_te_effect_dispatch.cpp b/game/client/c_te_effect_dispatch.cpp index b586df97..9c2557fe 100644 --- a/game/client/c_te_effect_dispatch.cpp +++ b/game/client/c_te_effect_dispatch.cpp @@ -132,7 +132,7 @@ static void RecordEffect( const char *pEffectName, const CEffectData &data ) msg->SetInt( "attachmentindex", data.m_nAttachmentIndex ); // NOTE: Ptrs are our way of indicating it's an entindex - msg->SetPtr( "entindex", (void*)data.entindex() ); + msg->SetPtr( "entindex", (void*)(intp)data.entindex() ); ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg ); msg->deleteThis(); @@ -213,7 +213,7 @@ void TE_DispatchEffect( IRecipientFilter& filter, float delay, KeyValues *pKeyVa // NOTE: Ptrs are our way of indicating it's an entindex ClientEntityHandle_t hWorld = ClientEntityList().EntIndexToHandle( 0 ); - data.m_hEntity = (intp)pKeyValues->GetPtr( "entindex", (void*)hWorld.ToInt() ); + data.m_hEntity = (intp)pKeyValues->GetPtr( "entindex", (void*)(intp)hWorld.ToInt() ); const char *pEffectName = pKeyValues->GetString( "effectname" ); diff --git a/game/client/c_te_playerdecal.cpp b/game/client/c_te_playerdecal.cpp index 9620484f..f8d503b6 100644 --- a/game/client/c_te_playerdecal.cpp +++ b/game/client/c_te_playerdecal.cpp @@ -240,7 +240,7 @@ void TE_PlayerDecal( IRecipientFilter& filter, float delay, color32 rgbaColor = { 255, 255, 255, 255 }; effects->PlayerDecalShoot( logo, - (void *)player, + (void *)(intp)player, entity, ent->GetModel(), ent->GetAbsOrigin(), diff --git a/game/client/fx.cpp b/game/client/fx.cpp index b7f12cbd..3615aa0d 100644 --- a/game/client/fx.cpp +++ b/game/client/fx.cpp @@ -403,7 +403,7 @@ void FX_MuzzleEffectAttached( KeyValues *pInitializers = pEmitter->FindKey( "initializers", true ); KeyValues *pPosition = pInitializers->FindKey( "DmeLinearAttachedPositionInitializer", true ); - pPosition->SetPtr( "entindex", (void*)pEnt->entindex() ); + pPosition->SetPtr( "entindex", (void*)(intp)pEnt->entindex() ); pPosition->SetInt( "attachmentIndex", attachmentIndex ); pPosition->SetFloat( "linearOffsetX", 2.0f * scale ); diff --git a/game/client/hud_lcd.cpp b/game/client/hud_lcd.cpp index 0f0609d6..e2919bbc 100644 --- a/game/client/hud_lcd.cpp +++ b/game/client/hud_lcd.cpp @@ -11,7 +11,7 @@ #include "cbase.h" #ifdef POSIX -#define HICON int +#define HICON intp const int DT_LEFT = 1; const int DT_CENTER = 2; const int DT_RIGHT = 3; diff --git a/game/client/particlemgr.cpp b/game/client/particlemgr.cpp index 792711ed..a82ff1f5 100644 --- a/game/client/particlemgr.cpp +++ b/game/client/particlemgr.cpp @@ -1014,7 +1014,7 @@ bool CParticleEffectBinding::RecalculateBoundingBox() CEffectMaterial* CParticleEffectBinding::GetEffectMaterial( CParticleSubTexture *pSubTexture ) { // Hash the IMaterial pointer. - unsigned int index = (((unsigned int)pSubTexture->m_pGroup) >> 6) % EFFECT_MATERIAL_HASH_SIZE; + unsigned int index = (((intp)pSubTexture->m_pGroup) >> 6) % EFFECT_MATERIAL_HASH_SIZE; for ( CEffectMaterial *pCur=m_EffectMaterialHash[index]; pCur; pCur = pCur->m_pHashedNext ) { if ( pCur->m_pGroup == pSubTexture->m_pGroup ) diff --git a/game/server/ai_behavior_follow.cpp b/game/server/ai_behavior_follow.cpp index 40f66583..0cedd2fa 100644 --- a/game/server/ai_behavior_follow.cpp +++ b/game/server/ai_behavior_follow.cpp @@ -2845,7 +2845,7 @@ AI_FollowGroup_t *CAI_FollowManager::FindFollowerGroup( CBaseEntity *pFollower ) { for ( int i = 0; i < m_groups.Count(); i++ ) { - int h = m_groups[i]->followers.Head(); + intp h = m_groups[i]->followers.Head(); while( h != m_groups[i]->followers.InvalidIndex() ) { AI_Follower_t *p = &m_groups[i]->followers[h]; diff --git a/game/server/ai_hint.cpp b/game/server/ai_hint.cpp index 5d541887..04b8dca8 100644 --- a/game/server/ai_hint.cpp +++ b/game/server/ai_hint.cpp @@ -729,7 +729,7 @@ CAI_Hint *CAI_HintManager::GetFirstHint( AIHintIter_t *pIter ) { if ( !gm_AllHints.Count() ) { - *pIter = (AIHintIter_t)gm_AllHints.InvalidIndex(); + *pIter = (AIHintIter_t)(intp)gm_AllHints.InvalidIndex(); return NULL; } *pIter = (AIHintIter_t)0; @@ -743,10 +743,10 @@ CAI_Hint *CAI_HintManager::GetNextHint( AIHintIter_t *pIter ) { if ( (intp)*pIter != gm_AllHints.InvalidIndex() ) { - int i = ( (intp)*pIter ) + 1; + intp i = ( (intp)*pIter ) + 1; if ( gm_AllHints.Count() <= i ) { - *pIter = (AIHintIter_t)gm_AllHints.InvalidIndex(); + *pIter = (AIHintIter_t)(intp)gm_AllHints.InvalidIndex(); return NULL; } *pIter = (AIHintIter_t)i; diff --git a/game/server/ai_memory.cpp b/game/server/ai_memory.cpp index ca4fe573..c0784e4f 100644 --- a/game/server/ai_memory.cpp +++ b/game/server/ai_memory.cpp @@ -176,7 +176,7 @@ CAI_Enemies::~CAI_Enemies() AI_EnemyInfo_t *CAI_Enemies::GetFirst( AIEnemiesIter_t *pIter ) { CMemMap::IndexType_t i = m_Map.FirstInorder(); - *pIter = (AIEnemiesIter_t)(unsigned)i; + *pIter = (AIEnemiesIter_t)(uintp)i; if ( i == m_Map.InvalidIndex() ) return NULL; @@ -197,7 +197,7 @@ AI_EnemyInfo_t *CAI_Enemies::GetNext( AIEnemiesIter_t *pIter ) return NULL; i = m_Map.NextInorder( i ); - *pIter = (AIEnemiesIter_t)(unsigned)i; + *pIter = (AIEnemiesIter_t)(uintp)i; if ( i == m_Map.InvalidIndex() ) return NULL; diff --git a/game/server/ai_navigator.cpp b/game/server/ai_navigator.cpp index 005ecec7..2825744c 100644 --- a/game/server/ai_navigator.cpp +++ b/game/server/ai_navigator.cpp @@ -1224,7 +1224,7 @@ AI_PathNode_t CAI_Navigator::GetNearestNode() #ifdef WIN32 COMPILE_TIME_ASSERT( (int)AIN_NO_NODE == NO_NODE ); #endif - return (AI_PathNode_t)( GetPathfinder()->NearestNodeToNPC() ); + return (AI_PathNode_t)(intp)( GetPathfinder()->NearestNodeToNPC() ); } //----------------------------------------------------------------------------- diff --git a/game/server/ai_senses.cpp b/game/server/ai_senses.cpp index 3c056f0e..9104b195 100644 --- a/game/server/ai_senses.cpp +++ b/game/server/ai_senses.cpp @@ -573,7 +573,7 @@ CSound* CAI_Senses::GetFirstHeardSound( AISoundIter_t *pIter ) return NULL; } - *pIter = (AISoundIter_t)iFirst; + *pIter = (AISoundIter_t)(intp)iFirst; return CSoundEnt::SoundPointerForIndex( iFirst ); } @@ -584,7 +584,7 @@ CSound* CAI_Senses::GetNextHeardSound( AISoundIter_t *pIter ) if ( !*pIter ) return NULL; - int iCurrent = (intp)*pIter; + intp iCurrent = (intp)*pIter; Assert( iCurrent != SOUNDLIST_EMPTY ); if ( iCurrent == SOUNDLIST_EMPTY ) diff --git a/game/server/ai_squad.cpp b/game/server/ai_squad.cpp index 9ad4b6bb..f8bee51a 100644 --- a/game/server/ai_squad.cpp +++ b/game/server/ai_squad.cpp @@ -420,7 +420,7 @@ CAI_BaseNPC *CAI_Squad::GetLeader( void ) //----------------------------------------------------------------------------- CAI_BaseNPC *CAI_Squad::GetFirstMember( AISquadIter_t *pIter, bool bIgnoreSilentMembers ) { - int i = 0; + intp i = 0; if ( bIgnoreSilentMembers ) { for ( ; i < m_SquadMembers.Count(); i++ ) diff --git a/game/server/ai_task.cpp b/game/server/ai_task.cpp index a2cf6be6..7c05f834 100644 --- a/game/server/ai_task.cpp +++ b/game/server/ai_task.cpp @@ -49,7 +49,7 @@ const char *TaskFailureToString( AI_TaskFailureCode_t code ) { const char *pszResult; if ( code < 0 || code >= NUM_FAIL_CODES ) - pszResult = (const char *)code; + pszResult = (const char *)(intp)code; else pszResult = g_ppszTaskFailureText[code]; return pszResult; diff --git a/game/server/hl2/npc_metropolice.cpp b/game/server/hl2/npc_metropolice.cpp index 833318d4..cb58f1fe 100644 --- a/game/server/hl2/npc_metropolice.cpp +++ b/game/server/hl2/npc_metropolice.cpp @@ -2612,7 +2612,7 @@ void CNPC_MetroPolice::IdleSound( void ) if ( m_Sentences.Speak( pQuestion[bIsCriminal][nQuestionType] ) >= 0 ) { - GetSquad()->BroadcastInteraction( g_interactionMetrocopIdleChatter, (void*)(METROPOLICE_CHATTER_RESPONSE + nQuestionType), this ); + GetSquad()->BroadcastInteraction( g_interactionMetrocopIdleChatter, (void*)(intp)(METROPOLICE_CHATTER_RESPONSE + nQuestionType), this ); m_nIdleChatterType = METROPOLICE_CHATTER_WAIT_FOR_RESPONSE; } } @@ -2983,7 +2983,7 @@ bool CNPC_MetroPolice::HandleInteraction(int interactionType, void *data, CBaseC if ( interactionType == g_interactionMetrocopIdleChatter ) { - m_nIdleChatterType = (int)data; + m_nIdleChatterType = (intp)data; return true; } diff --git a/game/server/physics.cpp b/game/server/physics.cpp index bec86f5f..2adc5587 100644 --- a/game/server/physics.cpp +++ b/game/server/physics.cpp @@ -1068,7 +1068,7 @@ void CCollisionEvent::FluidStartTouch( IPhysicsObject *pObject, IPhysicsFluidCon return; pEntity->AddEFlags( EFL_TOUCHING_FLUID ); - pEntity->OnEntityEvent( ENTITY_EVENT_WATER_TOUCH, (void*)pFluid->GetContents() ); + pEntity->OnEntityEvent( ENTITY_EVENT_WATER_TOUCH, (void*)(intp)pFluid->GetContents() ); float timeSinceLastCollision = DeltaTimeSinceLastFluid( pEntity ); if ( timeSinceLastCollision < 0.5f ) @@ -1124,7 +1124,7 @@ void CCollisionEvent::FluidEndTouch( IPhysicsObject *pObject, IPhysicsFluidContr } pEntity->RemoveEFlags( EFL_TOUCHING_FLUID ); - pEntity->OnEntityEvent( ENTITY_EVENT_WATER_UNTOUCH, (void*)pFluid->GetContents() ); + pEntity->OnEntityEvent( ENTITY_EVENT_WATER_UNTOUCH, (void*)(intp)pFluid->GetContents() ); } class CSkipKeys : public IVPhysicsKeyHandler diff --git a/game/shared/choreoevent.cpp b/game/shared/choreoevent.cpp index 50755f04..7e61cbb1 100644 --- a/game/shared/choreoevent.cpp +++ b/game/shared/choreoevent.cpp @@ -2076,7 +2076,7 @@ public: { if ( ARRAYSIZE( g_NameMap ) != CChoreoEvent::NUM_TYPES ) { - Error( "g_NameMap contains %i entries, CChoreoEvent::NUM_TYPES == %i!", + Error( "g_NameMap contains %zd entries, CChoreoEvent::NUM_TYPES == %i!", ARRAYSIZE( g_NameMap ), CChoreoEvent::NUM_TYPES ); } for ( int i = 0; i < CChoreoEvent::NUM_TYPES; ++i ) @@ -2158,7 +2158,7 @@ public: { if ( ARRAYSIZE( g_CCNameMap ) != CChoreoEvent::NUM_CC_TYPES ) { - Error( "g_CCNameMap contains %i entries, CChoreoEvent::NUM_CC_TYPES == %i!", + Error( "g_CCNameMap contains %zd entries, CChoreoEvent::NUM_CC_TYPES == %i!", ARRAYSIZE( g_CCNameMap ), CChoreoEvent::NUM_CC_TYPES ); } for ( int i = 0; i < CChoreoEvent::NUM_CC_TYPES; ++i ) diff --git a/game/shared/sceneimage.cpp b/game/shared/sceneimage.cpp index 55426008..5283eda9 100644 --- a/game/shared/sceneimage.cpp +++ b/game/shared/sceneimage.cpp @@ -368,7 +368,7 @@ bool CSceneImage::CreateSceneImageFile( CUtlBuffer &targetBuffer, char const *pc if ( !bQuiet ) { - Msg( "Scenes: String Table: %d bytes\n", stringOffsets.Count() * sizeof( int ) ); + Msg( "Scenes: String Table: %zd bytes\n", stringOffsets.Count() * sizeof( int ) ); Msg( "Scenes: String Pool: %d bytes\n", stringPool.TellMaxPut() ); } diff --git a/public/XUnzip.cpp b/public/XUnzip.cpp index 650a932a..9d7c4362 100644 --- a/public/XUnzip.cpp +++ b/public/XUnzip.cpp @@ -2778,7 +2778,7 @@ LUFILE *lufopen(void *z,unsigned int len,DWORD flags,ZRESULT *err) #ifdef _WIN32 res = DuplicateHandle(GetCurrentProcess(),hf,GetCurrentProcess(),&h,0,FALSE,DUPLICATE_SAME_ACCESS) == TRUE; #else - h = (void*) dup( (intptr_t)hf ); + h = (void*)(intptr_t) dup( (intptr_t)hf ); res = (intptr_t) dup >= 0; #endif if (!res) @@ -2793,7 +2793,7 @@ LUFILE *lufopen(void *z,unsigned int len,DWORD flags,ZRESULT *err) h = CreateFile((const TCHAR *)z, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); #else - h = (void*) open( (const TCHAR *)z, O_RDONLY ); + h = (void*)(intptr_t) open( (const TCHAR *)z, O_RDONLY ); #endif if (h == INVALID_HANDLE_VALUE) { @@ -4198,7 +4198,7 @@ ZRESULT TUnzip::Unzip(int index,void *dst,unsigned int len,DWORD flags) h = ::CreateFile((const TCHAR*)dst, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, ze.attr, NULL); #else - h = (void*) open( (const TCHAR*)dst, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO ); + h = (void*)(intptr_t)open( (const TCHAR*)dst, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO ); #endif } diff --git a/public/bitmap/float_bm.h b/public/bitmap/float_bm.h index a80722dd..ec538b0c 100644 --- a/public/bitmap/float_bm.h +++ b/public/bitmap/float_bm.h @@ -278,14 +278,18 @@ public: Vector ret(0,0,0); int nfaces=0; for(int f=0;f<6;f++) + { if (face_maps[f].RGBAData) { nfaces++; ret+=face_maps[f].AverageColor(); } - if (nfaces) - ret*=(1.0/nfaces); - return ret; + } + + if (nfaces) + ret*=(1.0/nfaces); + + return ret; } float BrightestColor(void) @@ -293,12 +297,14 @@ public: float ret=0.0; int nfaces=0; for(int f=0;f<6;f++) + { if (face_maps[f].RGBAData) { nfaces++; ret=max(ret,face_maps[f].BrightestColor()); } - return ret; + } + return ret; } diff --git a/public/filesystem_helpers.h b/public/filesystem_helpers.h index 070e779a..cc0b43c9 100644 --- a/public/filesystem_helpers.h +++ b/public/filesystem_helpers.h @@ -23,7 +23,6 @@ const char* ParseFileInternal( const char* pFileBytes, OUT_Z_CAP(nMaxTokenLen) c template const char* ParseFile( const char* pFileBytes, OUT_Z_ARRAY char (&pTokenOut)[count], bool* pWasQuoted, characterset_t *pCharSet = NULL, unsigned int nMaxTokenLen = (unsigned int)-1 ) { - (void*)nMaxTokenLen; // Avoid unreferenced variable warnings. return ParseFileInternal( pFileBytes, pTokenOut, pWasQuoted, pCharSet, count ); } diff --git a/public/tier0/threadtools.inl b/public/tier0/threadtools.inl index 037a64ed..dda4b5f5 100644 --- a/public/tier0/threadtools.inl +++ b/public/tier0/threadtools.inl @@ -75,7 +75,7 @@ INLINE_ON_PS3 const char *CThread::GetName() #elif defined( _PS3 ) snprintf( m_szName, sizeof(m_szName) - 1, "Thread(%p)", this ); #elif defined( POSIX ) - _snprintf( m_szName, sizeof(m_szName) - 1, "Thread(%p/0x%p)", this, m_threadId ); + _snprintf( m_szName, sizeof(m_szName) - 1, "Thread(%p/0x%p)", this, (void*)m_threadId ); #endif m_szName[sizeof(m_szName) - 1] = 0; } diff --git a/public/tier1/utllinkedlist.h b/public/tier1/utllinkedlist.h index d0f4249b..3717aab2 100644 --- a/public/tier1/utllinkedlist.h +++ b/public/tier1/utllinkedlist.h @@ -121,9 +121,6 @@ public: I Alloc( bool multilist = false ); void Free( I elem ); - // Identify the owner of this linked list's memory: - void SetAllocOwner( const char *pszAllocOwner ); - // list modification void LinkBefore( I before, I elem ); void LinkAfter( I after, I elem ); @@ -618,12 +615,6 @@ void CUtlLinkedList::SetGrowSize( int growSize ) ResetDbgInfo(); } -template< class T, class S, bool ML, class I, class M > -void CUtlLinkedList::SetAllocOwner( const char *pszAllocOwner ) -{ - m_Memory.SetAllocOwner( pszAllocOwner ); -} - //----------------------------------------------------------------------------- // Deallocate memory diff --git a/public/togl/linuxwin/glmgr.h b/public/togl/linuxwin/glmgr.h index b9e5d0d8..8cde5a92 100644 --- a/public/togl/linuxwin/glmgr.h +++ b/public/togl/linuxwin/glmgr.h @@ -1934,11 +1934,11 @@ FORCEINLINE void GLMContext::DrawRangeElements( GLenum mode, GLuint start, GLuin if ( pIndexBuf->m_bPseudo ) { // you have to pass actual address, not offset - indicesActual = (void*)( (int)indicesActual + (int)pIndexBuf->m_pPseudoBuf ); + indicesActual = (void*)( (intp)indicesActual + (intp)pIndexBuf->m_pPseudoBuf ); } if (pIndexBuf->m_bUsingPersistentBuffer) { - indicesActual = (void*)( (int)indicesActual + (int)pIndexBuf->m_nPersistentBufferStartOffset ); + indicesActual = (void*)( (intp)indicesActual + (intp)pIndexBuf->m_nPersistentBufferStartOffset ); } //#if GLMDEBUG diff --git a/public/vgui_controls/BuildGroup.h b/public/vgui_controls/BuildGroup.h index a0fcf352..d6b0ea04 100644 --- a/public/vgui_controls/BuildGroup.h +++ b/public/vgui_controls/BuildGroup.h @@ -38,7 +38,7 @@ class BuildGroup public: BuildGroup(Panel *parentPanel, Panel *contextPanel); - ~BuildGroup(); + virtual ~BuildGroup(); // Toggle build mode on/off virtual void SetEnabled(bool state); diff --git a/public/vstdlib/jobthread.h b/public/vstdlib/jobthread.h index 9b34efe9..05798a2c 100644 --- a/public/vstdlib/jobthread.h +++ b/public/vstdlib/jobthread.h @@ -1162,7 +1162,7 @@ inline ThreadHandle_t ThreadExecuteSoloImpl( CFunctor *pFunctor, const char *psz hThread = CreateSimpleThread( FunctorExecuteThread, pFunctor, &threadId ); if ( pszName ) { - ThreadSetDebugName( threadId, pszName ); + ThreadSetDebugName( (ThreadHandle_t)threadId, pszName ); } return hThread; } diff --git a/tier1/utlbuffer.cpp b/tier1/utlbuffer.cpp index ae29160f..604059f1 100644 --- a/tier1/utlbuffer.cpp +++ b/tier1/utlbuffer.cpp @@ -1573,7 +1573,7 @@ void CUtlBuffer::VaPrintf( const char* pFmt, va_list list ) { char temp[8192]; int nLen = V_vsnprintf( temp, sizeof( temp ), pFmt, list ); - ErrorIfNot( nLen < sizeof( temp ), ( "CUtlBuffer::VaPrintf: String overflowed buffer [%d]\n", sizeof( temp ) ) ); + ErrorIfNot( nLen < sizeof( temp ), ( "CUtlBuffer::VaPrintf: String overflowed buffer [%zd]\n", sizeof( temp ) ) ); PutString( temp ); } diff --git a/togl/linuxwin/glmgr.cpp b/togl/linuxwin/glmgr.cpp index a573210c..7e7d0dc4 100644 --- a/togl/linuxwin/glmgr.cpp +++ b/togl/linuxwin/glmgr.cpp @@ -5098,11 +5098,11 @@ void GLMContext::DrawRangeElementsNonInline( GLenum mode, GLuint start, GLuint e if ( pIndexBuf->m_bPseudo ) { // you have to pass actual address, not offset - indicesActual = (void*)( (int)indicesActual + (int)pIndexBuf->m_pPseudoBuf ); + indicesActual = (void*)( (intp)indicesActual + (intp)pIndexBuf->m_pPseudoBuf ); } if (pIndexBuf->m_bUsingPersistentBuffer) { - indicesActual = (void*)( (int)indicesActual + (int)pIndexBuf->m_nPersistentBufferStartOffset ); + indicesActual = (void*)( (intp)indicesActual + (intp)pIndexBuf->m_nPersistentBufferStartOffset ); } #if GL_ENABLE_INDEX_VERIFICATION diff --git a/vgui2/matsys_controls/QCGenerator.cpp b/vgui2/matsys_controls/QCGenerator.cpp index 89f01732..78ad4404 100644 --- a/vgui2/matsys_controls/QCGenerator.cpp +++ b/vgui2/matsys_controls/QCGenerator.cpp @@ -320,13 +320,13 @@ CQCGenerator::CQCGenerator( vgui::Panel *pParent, const char *pszPath, const cha SetParent( pParent ); char szGamePath[1024] = "\0"; - char szSearchPath[1024] = "\0"; + char szSearchPath[2048] = "\0"; // Get the currently set game configuration GetVConfigRegistrySetting( GAMEDIR_TOKEN, szGamePath, sizeof( szGamePath ) ); static const char *pSurfacePropFilename = "\\scripts\\surfaceproperties.txt"; - sprintf( szSearchPath, "%s%s", szGamePath, pSurfacePropFilename ); + snprintf( szSearchPath, sizeof(szSearchPath), "%s%s", szGamePath, pSurfacePropFilename ); FileHandle_t fp = g_pFullFileSystem->Open( szSearchPath, "rb" ); @@ -338,7 +338,7 @@ CQCGenerator::CQCGenerator( vgui::Panel *pParent, const char *pszPath, const cha char *pszEndGamePath = Q_strrchr( szGamePath, '\\' ); pszEndGamePath[0] = 0; V_strcat_safe( szGamePath, "\\hl2" ); - sprintf( szSearchPath, "%s%s", szGamePath, pSurfacePropFilename ); + snprintf( szSearchPath, sizeof(szSearchPath), "%s%s", szGamePath, pSurfacePropFilename ); fp = g_pFullFileSystem->Open( szSearchPath, "rb" ); } @@ -720,4 +720,4 @@ void CQCGenerator::OnNewLODText() m_pLODPanel->LeaveEditMode(); m_pLODPanel->InvalidateLayout(); return; -} \ No newline at end of file +} diff --git a/vguimatsurface/Input.cpp b/vguimatsurface/Input.cpp index 03df13d5..744aafbb 100644 --- a/vguimatsurface/Input.cpp +++ b/vguimatsurface/Input.cpp @@ -509,7 +509,7 @@ bool InputHandleInputEvent( const InputEvent_t &event ) return true; case IE_IMESetWindow: - g_pIInput->SetIMEWindow( (void *)event.m_nData ); + g_pIInput->SetIMEWindow( (void *)(intp)event.m_nData ); return true; case IE_LocateMouseClick: diff --git a/vphysics/main.cpp b/vphysics/main.cpp index cb8424e4..03bdeb63 100644 --- a/vphysics/main.cpp +++ b/vphysics/main.cpp @@ -189,8 +189,8 @@ IPhysicsCollisionSet *CPhysicsInterface::FindOrCreateCollisionSet( unsigned int IPhysicsCollisionSet *pSet = FindCollisionSet( id ); if ( pSet ) return pSet; - int index = m_collisionSets.AddToTail(); - m_pCollisionSetHash->add_elem( (void *)id, (void *)(index+1) ); + intp index = m_collisionSets.AddToTail(); + m_pCollisionSetHash->add_elem( (void *)(intp)id, (void *)(intp)(index+1) ); return &m_collisionSets[index]; } @@ -198,7 +198,7 @@ IPhysicsCollisionSet *CPhysicsInterface::FindCollisionSet( unsigned int id ) { if ( m_pCollisionSetHash ) { - intp index = (intp)m_pCollisionSetHash->find_elem( (void *)id ); + intp index = (intp)m_pCollisionSetHash->find_elem( (void *)(intp)id ); if ( index > 0 ) { Assert( index <= m_collisionSets.Count() ); diff --git a/vphysics/physics_environment.cpp b/vphysics/physics_environment.cpp index a22670f7..9d3a8e34 100644 --- a/vphysics/physics_environment.cpp +++ b/vphysics/physics_environment.cpp @@ -2051,10 +2051,10 @@ public: void *ListIndexToHash( unsigned short listIndex ) { unsigned int hash = (unsigned int)listIndex; - + // set the high bit, so zero means "not there" hash |= 0x80000000; - return (void *)hash; + return (void *)(intp)hash; } // Lookup this object and get a multilist entry