From 9820436fbec00e060cbcd49552aa012a2ebf7b86 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 6 Apr 2016 23:16:30 -0400 Subject: [PATCH] First pass at cleaning out 64-bit issues. Touches a lot of code to remove long constants like "1L", so this patch is large and ugly, but I think it makes all those Clamp() calls look nicer in the long run. Most of the game is 64-bit clean, since we can build without assembly code now. I've marked the things that are obviously still wrong with STUBBED lines. That being said: a 64-bit build can already run the demos mostly correctly, so we're actually almost there! There are a few obvious things that are obviously wrong, to be fixed. --- Sources/Engine/Base/Anim.cpp | 8 ++-- Sources/Engine/Base/Console.cpp | 4 +- Sources/Engine/Base/Lists.cpp | 8 ++-- Sources/Engine/Base/Memory.cpp | 9 ++-- Sources/Engine/Base/Shell.h | 6 +-- Sources/Engine/Base/Stream.h | 4 +- Sources/Engine/Base/Timer.cpp | 1 + Sources/Engine/Base/Types.h | 9 ++-- Sources/Engine/Base/Unzip.cpp | 2 +- Sources/Engine/Brushes/BrushShadows.cpp | 24 +++++----- Sources/Engine/Entities/EntityProperties.h | 2 +- Sources/Engine/Graphics/Color.cpp | 18 +++---- Sources/Engine/Graphics/DepthCheck.cpp | 2 +- Sources/Engine/Graphics/DrawPort.cpp | 15 +++--- .../Engine/Graphics/DrawPort_RenderScene.cpp | 14 +++--- Sources/Engine/Graphics/Fog.cpp | 12 ++--- Sources/Engine/Graphics/Fog_internal.h | 10 ++-- Sources/Engine/Graphics/GfxLibrary.cpp | 40 ++++++++-------- Sources/Engine/Graphics/GfxLibrary.h | 6 +-- Sources/Engine/Graphics/Gfx_OpenGL.cpp | 2 +- Sources/Engine/Graphics/Gfx_wrapper.cpp | 16 +++---- Sources/Engine/Graphics/Graphics.cpp | 2 +- Sources/Engine/Graphics/Shader.cpp | 24 +++++----- Sources/Engine/Graphics/ShadowMap.cpp | 4 +- Sources/Engine/Graphics/Stereo.cpp | 2 +- Sources/Engine/Graphics/Texture.cpp | 14 +++--- Sources/Engine/Graphics/TextureEffects.cpp | 2 +- Sources/Engine/Light/LayerMixer.cpp | 8 ++-- Sources/Engine/Math/FixInt.h | 4 +- Sources/Engine/Math/Float.cpp | 11 +---- Sources/Engine/Math/Object3D_CSG.cpp | 9 ++-- Sources/Engine/Math/ObjectSector.cpp | 9 ++-- Sources/Engine/Models/Model.cpp | 24 +++++----- Sources/Engine/Models/RenderModel_View.cpp | 14 +++--- Sources/Engine/Network/Compression.cpp | 17 ++++--- Sources/Engine/Network/Network.cpp | 15 ++++-- Sources/Engine/Network/PlayerSource.cpp | 2 +- Sources/Engine/Network/Server.cpp | 14 +++--- Sources/Engine/Network/SessionState.cpp | 2 +- Sources/Engine/Rendering/Render.cpp | 4 +- Sources/Engine/Rendering/RenderModels.cpp | 48 +++++++++---------- Sources/Engine/Ska/ModelInstance.cpp | 4 +- Sources/Engine/Ska/ModelInstance.h | 2 +- Sources/Engine/Ska/RMRender.cpp | 4 +- Sources/Engine/Sound/SoundDecoder.cpp | 2 +- Sources/Engine/Sound/SoundLibrary.cpp | 8 ++-- Sources/Engine/Sound/SoundMixer.cpp | 2 +- Sources/Engine/Sound/SoundObject.cpp | 6 ++- Sources/Engine/Sound/Wave.cpp | 6 ++- Sources/Engine/Templates/BSP.cpp | 6 ++- Sources/Engine/Terrain/Terrain.cpp | 12 ++--- Sources/Engine/Terrain/TerrainEditing.cpp | 20 ++++---- Sources/Engine/Terrain/TerrainMisc.cpp | 18 +++---- Sources/EntitiesMP/Common/HUD.cpp | 8 ++-- Sources/EntitiesMP/Common/Particles.cpp | 10 ++-- Sources/EntitiesMP/Player.es | 17 +++++-- Sources/GameMP/Computer.cpp | 12 ++--- Sources/GameMP/Console.cpp | 4 +- Sources/GameMP/Game.cpp | 16 +++---- Sources/GameMP/SessionProperties.cpp | 8 ++-- Sources/SeriousSam/GLSettings.cpp | 2 +- Sources/SeriousSam/Menu.cpp | 16 +++---- Sources/SeriousSam/MenuGadgets.cpp | 18 +++---- Sources/SeriousSam/SeriousSam.cpp | 6 +-- Sources/SeriousSam/VarList.cpp | 2 +- Sources/Shaders/Common.cpp | 12 ++--- Sources/build-linux.sh | 6 +++ 67 files changed, 348 insertions(+), 320 deletions(-) diff --git a/Sources/Engine/Base/Anim.cpp b/Sources/Engine/Base/Anim.cpp index fcc0889..b42ce79 100644 --- a/Sources/Engine/Base/Anim.cpp +++ b/Sources/Engine/Base/Anim.cpp @@ -635,8 +635,8 @@ ENGINE_API void CAnimObject::Synchronize(CAnimObject &aoOther) // copy animations, time and flags INDEX ctAnims = GetAnimsCt(); ao_tmAnimStart = aoOther.ao_tmAnimStart; - ao_iCurrentAnim = ClampUp(aoOther.ao_iCurrentAnim, ctAnims-1L); - ao_iLastAnim = ClampUp(aoOther.ao_iLastAnim, ctAnims-1L); + ao_iCurrentAnim = ClampUp(aoOther.ao_iCurrentAnim, ctAnims-1); + ao_iLastAnim = ClampUp(aoOther.ao_iLastAnim, ctAnims-1); ao_ulFlags = aoOther.ao_ulFlags; } @@ -1102,12 +1102,12 @@ void CAnimObject::GetFrame( INDEX &iFrame0, INDEX &iFrame1, FLOAT &fRatio) const INDEX iAnim = ao_iCurrentAnim; ((CAnimObject*)this)->ao_iCurrentAnim = ao_iLastAnim; float fFrameNow = tmCurrentRelative/pOA0->oa_SecsPerFrame+pOA0->oa_NumberOfFrames; - iFrame0 = pOA0->oa_FrameIndices[ Clamp(SLONG(fFrameNow), 0L, pOA0->oa_NumberOfFrames-1L)]; + iFrame0 = pOA0->oa_FrameIndices[ Clamp(SLONG(fFrameNow), 0, pOA0->oa_NumberOfFrames-1)]; INDEX iFrameNext = SLONG(fFrameNow+1); if (iFrameNext>=pOA0->oa_NumberOfFrames) { iFrame1 = pOA1->oa_FrameIndices[0]; } else { - iFrame1 = pOA0->oa_FrameIndices[ Clamp(iFrameNext, 0L, pOA0->oa_NumberOfFrames-1L)]; + iFrame1 = pOA0->oa_FrameIndices[ Clamp(iFrameNext, 0, pOA0->oa_NumberOfFrames-1)]; } ((CAnimObject*)this)->ao_iCurrentAnim = iAnim; fRatio = fFrameNow - (float)floor(fFrameNow); diff --git a/Sources/Engine/Base/Console.cpp b/Sources/Engine/Base/Console.cpp index dad97c6..208fa49 100644 --- a/Sources/Engine/Base/Console.cpp +++ b/Sources/Engine/Base/Console.cpp @@ -133,7 +133,7 @@ INDEX CConsole::NumberOfLinesAfter(TIME tmLast) return 0; } // clamp console variable - con_iLastLines = Clamp( con_iLastLines, 0L, (INDEX)CONSOLE_MAXLASTLINES); + con_iLastLines = Clamp( con_iLastLines, 0, (INDEX)CONSOLE_MAXLASTLINES); // find number of last console lines to be displayed on screen for(INDEX i=0; i iter(*this); !iter.IsPastEnd(); iter.MoveToNext() ) { - aulPointers[i] = ((ULONG)&*iter)-iNodeOffset; + aulPointers[i] = ((size_t)&*iter)-iNodeOffset; i++; } // sort it - qsort(aulPointers, ctCount, sizeof(SLONG), pCompare); + qsort(aulPointers, ctCount, sizeof(aulPointers[0]), pCompare); // make temporary list CListHead lhTmp; // for each pointer {for(INDEX i=0; i= (sizeof (void*) * 2)); + size_t ulMem = (size_t)AllocMemory(memsize+slAlignPow2*2); + size_t ulMemAligned = ((ulMem+slAlignPow2-1) & ~(slAlignPow2-1)) + slAlignPow2; + ((size_t *)ulMemAligned)[-1] = ulMem; return (void*)ulMemAligned; } void FreeMemoryAligned( void *memory) { - FreeMemory((void*) ( ( (ULONG*)memory )[-1] ) ); + FreeMemory((void*) ( ( (size_t*)memory )[-1] ) ); } void FreeMemory( void *memory ) diff --git a/Sources/Engine/Base/Shell.h b/Sources/Engine/Base/Shell.h index a11571f..759ae83 100644 --- a/Sources/Engine/Base/Shell.h +++ b/Sources/Engine/Base/Shell.h @@ -24,11 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include -#if 0 -#define NEXTARGUMENT(type) ( *((type*&)pArgs)++ ) -#else -#define NEXTARGUMENT(type) ( *((type*)&pArgs) ); pArgs+=sizeof(void*); -#endif +#define NEXTARGUMENT(type) ( *((type*)((char*)&pArgs)) ); pArgs = (void*) (((char*)pArgs) + sizeof(void*)); // Object that takes care of shell functions, variables, macros etc. class ENGINE_API CShell { diff --git a/Sources/Engine/Base/Stream.h b/Sources/Engine/Base/Stream.h index 49e3244..00ca500 100644 --- a/Sources/Engine/Base/Stream.h +++ b/Sources/Engine/Base/Stream.h @@ -157,7 +157,7 @@ public: inline CTStream &operator>>(SLONG &sl) { Read_t(&sl, sizeof(sl)); BYTESWAP(sl); return *this; } // throw char * inline CTStream &operator>>(UWORD &uw) { Read_t(&uw, sizeof(uw)); BYTESWAP(uw); return *this; } // throw char * inline CTStream &operator>>(SWORD &sw) { Read_t(&sw, sizeof(sw)); BYTESWAP(sw); return *this; } // throw char * - inline CTStream &operator>>(BOOL &b) { Read_t( &b, sizeof( b)); BYTESWAP( b); return *this; } // throw char * + //inline CTStream &operator>>(BOOL &b) { Read_t( &b, sizeof( b)); BYTESWAP( b); return *this; } // throw char * inline CTStream &operator>>(__int64 i) { Read_t( &i, sizeof( i)); BYTESWAP( i); return *this; } // throw char * inline CTStream &operator>>(__uint64 i) { Read_t( &i, sizeof( i)); BYTESWAP( i); return *this; } // throw char * /* Write an object into stream. */ @@ -169,7 +169,7 @@ public: inline CTStream &operator<<(SLONG sl) { BYTESWAP(sl); Write_t(&sl, sizeof(sl)); return *this; } // throw char * inline CTStream &operator<<(UWORD uw) { BYTESWAP(uw); Write_t(&uw, sizeof(uw)); return *this; } // throw char * inline CTStream &operator<<(SWORD sw) { BYTESWAP(sw); Write_t(&sw, sizeof(sw)); return *this; } // throw char * - inline CTStream &operator<<(BOOL b) { BYTESWAP( b); Write_t( &b, sizeof( b)); return *this; } // throw char * + //inline CTStream &operator<<(BOOL b) { BYTESWAP( b); Write_t( &b, sizeof( b)); return *this; } // throw char * inline CTStream &operator<<(__int64 i) { BYTESWAP( i); Write_t( &i, sizeof( i)); return *this; } // throw char * inline CTStream &operator<<(__uint64 i) { BYTESWAP( i); Write_t( &i, sizeof( i)); return *this; } // throw char * diff --git a/Sources/Engine/Base/Timer.cpp b/Sources/Engine/Base/Timer.cpp index d1b33df..43be607 100644 --- a/Sources/Engine/Base/Timer.cpp +++ b/Sources/Engine/Base/Timer.cpp @@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include +// !!! FIXME: use SDL timer code instead and rdtsc never? #if (USE_PORTABLE_C) #define USE_GETTIMEOFDAY 1 #endif diff --git a/Sources/Engine/Base/Types.h b/Sources/Engine/Base/Types.h index e2e9773..d0905a9 100644 --- a/Sources/Engine/Base/Types.h +++ b/Sources/Engine/Base/Types.h @@ -26,12 +26,13 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include -typedef signed long int SLONG; +// !!! FIXME: use stdint.h for this (and other things like INDEX, too)? +typedef signed int SLONG; typedef signed short int SWORD; typedef signed char SBYTE; typedef signed int SINT; -typedef unsigned long int ULONG; +typedef unsigned int ULONG; typedef unsigned short int UWORD; typedef unsigned char UBYTE; typedef unsigned int UINT; @@ -282,8 +283,8 @@ typedef unsigned int UINT; #define MAX_UBYTE ((UBYTE)0xFF) typedef int BOOL; // this is for TRUE/FALSE -typedef long int RESULT; // for error codes -typedef long int INDEX; // for indexed values and quantities +typedef int RESULT; // for error codes +typedef int INDEX; // for indexed values and quantities #define FALSE 0 #define TRUE 1 diff --git a/Sources/Engine/Base/Unzip.cpp b/Sources/Engine/Base/Unzip.cpp index dd9dbdb..5b80733 100644 --- a/Sources/Engine/Base/Unzip.cpp +++ b/Sources/Engine/Base/Unzip.cpp @@ -230,7 +230,7 @@ void ReadZIPDirectory_t(CTFileName *pfnmZip) } // start at the end of file, minus expected minimum overhead fseek(f, 0, SEEK_END); - int iPos = ftell(f)-sizeof(long)-sizeof(EndOfDir)+2; + int iPos = ftell(f)-sizeof(SLONG)-sizeof(EndOfDir)+2; // do not search more than 128k (should be around 65k at most) int iMinPos = iPos-128*1024; if (iMinPos<0) { diff --git a/Sources/Engine/Brushes/BrushShadows.cpp b/Sources/Engine/Brushes/BrushShadows.cpp index 74f60c0..4abdd84 100644 --- a/Sources/Engine/Brushes/BrushShadows.cpp +++ b/Sources/Engine/Brushes/BrushShadows.cpp @@ -127,8 +127,8 @@ void CBrushPolygon::InitializeShadowMap(void) PIX pixSizeU = mexSizeU>>iMipLevel; PIX pixSizeV = mexSizeV>>iMipLevel; INDEX iMipAdj = ClampTextureSize( MAX_SHADOWMAP_SIZE, _pGfx->gl_pixMaxTextureDimension, pixSizeU, pixSizeV); - pixSizeU = ClampDn( pixSizeU>>iMipAdj, 1L); - pixSizeV = ClampDn( pixSizeV>>iMipAdj, 1L); + pixSizeU = ClampDn( pixSizeU>>iMipAdj, 1); + pixSizeV = ClampDn( pixSizeV>>iMipAdj, 1); iMipLevel += iMipAdj; // move shadow map offset for the sake of dark corners @@ -489,8 +489,8 @@ void CBrushShadowMap::FindLightRectangle(CLightSource &ls, class CLightRectangle // pixMaxU = PIX(sm_mexWidth >>iMipLevel); // pixMaxV = PIX(sm_mexHeight>>iMipLevel); // rectangle is around entire polygon - pixMaxU = Min( sm_pixPolygonSizeU+16L, sm_mexWidth >>iMipLevel); - pixMaxV = Min( sm_pixPolygonSizeV+16L, sm_mexHeight>>iMipLevel); + pixMaxU = Min( sm_pixPolygonSizeU+16, sm_mexWidth >>iMipLevel); + pixMaxV = Min( sm_pixPolygonSizeV+16, sm_mexHeight>>iMipLevel); } // if the light is point else @@ -533,10 +533,10 @@ void CBrushShadowMap::FindLightRectangle(CLightSource &ls, class CLightRectangle // pixMaxU = Min( Max(pixMaxU, 0L), sm_mexWidth >>iMipLevel); // pixMaxV = Min( Max(pixMaxV, 0L), sm_mexHeight>>iMipLevel); // clamp the rectangle to the size of polygon - pixMinU = Min( Max(pixMinU, 0L), Min(sm_pixPolygonSizeU+16L, sm_mexWidth >>iMipLevel)); - pixMinV = Min( Max(pixMinV, 0L), Min(sm_pixPolygonSizeV+16L, sm_mexHeight>>iMipLevel)); - pixMaxU = Min( Max(pixMaxU, 0L), Min(sm_pixPolygonSizeU+16L, sm_mexWidth >>iMipLevel)); - pixMaxV = Min( Max(pixMaxV, 0L), Min(sm_pixPolygonSizeV+16L, sm_mexHeight>>iMipLevel)); + pixMinU = Min( Max(pixMinU, 0), Min(sm_pixPolygonSizeU+16, sm_mexWidth >>iMipLevel)); + pixMinV = Min( Max(pixMinV, 0), Min(sm_pixPolygonSizeV+16, sm_mexHeight>>iMipLevel)); + pixMaxU = Min( Max(pixMaxU, 0), Min(sm_pixPolygonSizeU+16, sm_mexWidth >>iMipLevel)); + pixMaxV = Min( Max(pixMaxV, 0), Min(sm_pixPolygonSizeV+16, sm_mexHeight>>iMipLevel)); } // all done lr.lr_pixMinU = pixMinU; @@ -599,7 +599,7 @@ BOOL CBrushShadowMap::IsShadowFlat( COLOR &colFlat) // fail if flat shadows are not allowed extern INDEX shd_bAllowFlats; extern INDEX shd_iForceFlats; - shd_iForceFlats = Clamp( shd_iForceFlats, 0L, 2L); + shd_iForceFlats = Clamp( shd_iForceFlats, 0, 2); if( !shd_bAllowFlats && shd_iForceFlats<1) return FALSE; COLOR col; @@ -711,9 +711,9 @@ BOOL CBrushShadowMap::IsShadowFlat( COLOR &colFlat) } } // done - phew, layer is flat - slR = Clamp( slR, 0L, 255L); - slG = Clamp( slG, 0L, 255L); - slB = Clamp( slB, 0L, 255L); + slR = Clamp( slR, 0, 255); + slG = Clamp( slG, 0, 255); + slB = Clamp( slB, 0, 255); colFlat = RGBToColor(slR,slG,slB); return TRUE; } diff --git a/Sources/Engine/Entities/EntityProperties.h b/Sources/Engine/Entities/EntityProperties.h index a47fb29..99e35fe 100644 --- a/Sources/Engine/Entities/EntityProperties.h +++ b/Sources/Engine/Entities/EntityProperties.h @@ -277,7 +277,7 @@ public: inline ENGINE_API void ClearToDefault(FLOAT &f) { f = 0.0f; }; inline ENGINE_API void ClearToDefault(INDEX &i) { i = 0; }; -inline ENGINE_API void ClearToDefault(BOOL &b) { b = FALSE; }; +//inline ENGINE_API void ClearToDefault(BOOL &b) { b = FALSE; }; inline ENGINE_API void ClearToDefault(CEntityPointer &pen) { pen = NULL; }; inline ENGINE_API void ClearToDefault(CTString &str) { str = ""; }; inline ENGINE_API void ClearToDefault(FLOATplane3D &pl) { pl = FLOATplane3D(FLOAT3D(0,1,0), 0); }; diff --git a/Sources/Engine/Graphics/Color.cpp b/Sources/Engine/Graphics/Color.cpp index c117ea8..4e6b8c2 100644 --- a/Sources/Engine/Graphics/Color.cpp +++ b/Sources/Engine/Graphics/Color.cpp @@ -203,9 +203,9 @@ COLOR AdjustGamma( COLOR const col, FLOAT const fGamma) const FLOAT f1o255 = 1.0f / 255.0f; UBYTE ubR,ubG,ubB,ubA; ColorToRGBA( col, ubR,ubG,ubB,ubA); - ubR = ClampUp( NormFloatToByte(pow(ubR*f1o255,f1oGamma)), 255UL); - ubG = ClampUp( NormFloatToByte(pow(ubG*f1o255,f1oGamma)), 255UL); - ubB = ClampUp( NormFloatToByte(pow(ubB*f1o255,f1oGamma)), 255UL); + ubR = ClampUp( NormFloatToByte(pow(ubR*f1o255,f1oGamma)), (ULONG) 255); + ubG = ClampUp( NormFloatToByte(pow(ubG*f1o255,f1oGamma)), (ULONG) 255); + ubB = ClampUp( NormFloatToByte(pow(ubB*f1o255,f1oGamma)), (ULONG) 255); return RGBAToColor( ubR,ubG,ubB,ubA); } @@ -459,15 +459,15 @@ COLOR AddColors( COLOR col1, COLOR col2) COLOR col; UBYTE bytes[4]; } conv2; - #define MIN(a, b) ((a)>(b))?(b):(a) + #define MINVAL(a, b) ((a)>(b))?(b):(a) conv1.col = col1; conv2.col = col2; - conv1.bytes[0] = (UBYTE) MIN((((WORD) conv1.bytes[0]) + ((WORD) conv2.bytes[0])) , 255); - conv1.bytes[1] = (UBYTE) MIN((((WORD) conv1.bytes[1]) + ((WORD) conv2.bytes[1])) , 255); - conv1.bytes[2] = (UBYTE) MIN((((WORD) conv1.bytes[2]) + ((WORD) conv2.bytes[2])) , 255); - conv1.bytes[3] = (UBYTE) MIN((((WORD) conv1.bytes[3]) + ((WORD) conv2.bytes[3])) , 255); - #undef MIN + conv1.bytes[0] = (UBYTE) MINVAL((((WORD) conv1.bytes[0]) + ((WORD) conv2.bytes[0])) , 255); + conv1.bytes[1] = (UBYTE) MINVAL((((WORD) conv1.bytes[1]) + ((WORD) conv2.bytes[1])) , 255); + conv1.bytes[2] = (UBYTE) MINVAL((((WORD) conv1.bytes[2]) + ((WORD) conv2.bytes[2])) , 255); + conv1.bytes[3] = (UBYTE) MINVAL((((WORD) conv1.bytes[3]) + ((WORD) conv2.bytes[3])) , 255); + #undef MINVAL colRet = conv1.col; diff --git a/Sources/Engine/Graphics/DepthCheck.cpp b/Sources/Engine/Graphics/DepthCheck.cpp index 45cabdf..1f1aa5c 100644 --- a/Sources/Engine/Graphics/DepthCheck.cpp +++ b/Sources/Engine/Graphics/DepthCheck.cpp @@ -246,7 +246,7 @@ extern BOOL CheckDepthPoint( const CDrawPort *pdp, PIX pixI, PIX pixJ, FLOAT fOo extern void CheckDelayedDepthPoints( const CDrawPort *pdp, INDEX iMirrorLevel/*=0*/) { // skip if not delayed or mirror level is to high - gap_iOptimizeDepthReads = Clamp( gap_iOptimizeDepthReads, 0L, 2L); + gap_iOptimizeDepthReads = Clamp( gap_iOptimizeDepthReads, 0, 2); if( gap_iOptimizeDepthReads==0 || iMirrorLevel>7) return; ASSERT( pdp!=NULL && iMirrorLevel>=0); diff --git a/Sources/Engine/Graphics/DrawPort.cpp b/Sources/Engine/Graphics/DrawPort.cpp index b53468d..26f714a 100755 --- a/Sources/Engine/Graphics/DrawPort.cpp +++ b/Sources/Engine/Graphics/DrawPort.cpp @@ -221,7 +221,8 @@ ULONG CDrawPort::GetID(void) { ULONG ulCRC; CRC_Start( ulCRC); - CRC_AddLONG( ulCRC, (ULONG)dp_Raster); + STUBBED("64-bit issue"); + CRC_AddLONG( ulCRC, (ULONG)(size_t)dp_Raster); CRC_AddLONG( ulCRC, (ULONG)dp_MinI); CRC_AddLONG( ulCRC, (ULONG)dp_MinJ); CRC_AddLONG( ulCRC, (ULONG)dp_MaxI); @@ -306,8 +307,8 @@ void CDrawPort::RecalculateDimensions(void) void CDrawPort::SetOrtho(void) const { // finish all pending render-operations (if required) - ogl_iFinish = Clamp( ogl_iFinish, 0L, 3L); - d3d_iFinish = Clamp( d3d_iFinish, 0L, 3L); + ogl_iFinish = Clamp( ogl_iFinish, 0, 3); + d3d_iFinish = Clamp( d3d_iFinish, 0, 3); if( (ogl_iFinish==3 && _pGfx->gl_eCurrentAPI==GAT_OGL) #ifdef SE1_D3D || (d3d_iFinish==3 && _pGfx->gl_eCurrentAPI==GAT_D3D) @@ -337,8 +338,8 @@ void CDrawPort::SetOrtho(void) const void CDrawPort::SetProjection(CAnyProjection3D &apr) const { // finish all pending render-operations (if required) - ogl_iFinish = Clamp( ogl_iFinish, 0L, 3L); - d3d_iFinish = Clamp( d3d_iFinish, 0L, 3L); + ogl_iFinish = Clamp( ogl_iFinish, 0, 3); + d3d_iFinish = Clamp( d3d_iFinish, 0, 3); if( (ogl_iFinish==3 && _pGfx->gl_eCurrentAPI==GAT_OGL) #ifdef SE1_D3D || (d3d_iFinish==3 && _pGfx->gl_eCurrentAPI==GAT_D3D) @@ -1275,7 +1276,7 @@ void CDrawPort::PutText( const CTString &strText, PIX pixX0, PIX pixY0, const CO // flash? case 'f': chrCurrent = strText[++iChar]; - if( bParse) iFlash = 1+ 2* Clamp( (INDEX)(chrCurrent-'0'), 0L, 9L); + if( bParse) iFlash = 1+ 2* Clamp( (INDEX)(chrCurrent-'0'), 0, 9); continue; // reset all? case 'r': @@ -1678,7 +1679,7 @@ void CDrawPort::BlendScreen(void) ULONG ulRA = (dp_ulBlendingRA*fix1oA)>>16; ULONG ulGA = (dp_ulBlendingGA*fix1oA)>>16; ULONG ulBA = (dp_ulBlendingBA*fix1oA)>>16; - ULONG ulA = ClampUp( dp_ulBlendingA, 255UL); + ULONG ulA = ClampUp( dp_ulBlendingA, (ULONG) 255); COLOR colBlending = RGBAToColor( ulRA, ulGA, ulBA, ulA); // blend drawport (thru z-buffer because of elimination of pixel artefacts) diff --git a/Sources/Engine/Graphics/DrawPort_RenderScene.cpp b/Sources/Engine/Graphics/DrawPort_RenderScene.cpp index 70b0bc6..7118e74 100644 --- a/Sources/Engine/Graphics/DrawPort_RenderScene.cpp +++ b/Sources/Engine/Graphics/DrawPort_RenderScene.cpp @@ -427,9 +427,9 @@ static void RSBinToGroups( ScenePolygon *pspoFirst) else { UBYTE ubR,ubG,ubB; ColorToRGB( colFlat, ubR,ubG,ubB); - ULONG ulR = ClampUp( ((ULONG)ubR)<<1, 255UL); - ULONG ulG = ClampUp( ((ULONG)ubG)<<1, 255UL); - ULONG ulB = ClampUp( ((ULONG)ubB)<<1, 255UL); + const ULONG ulR = ClampUp( ((ULONG)ubR)<<1, (ULONG) 255); + const ULONG ulG = ClampUp( ((ULONG)ubG)<<1, (ULONG) 255); + const ULONG ulB = ClampUp( ((ULONG)ubB)<<1, (ULONG) 255); colFlat = RGBToColor(ulR,ulG,ulB); } } // mix color in the first texture layer @@ -1568,8 +1568,8 @@ void RSRenderGroup( ScenePolygon *pspoGroup, ULONG ulGroupFlags, ULONG ulTestedF // render one group extern INDEX ogl_iMaxBurstSize; extern INDEX d3d_iMaxBurstSize; - ogl_iMaxBurstSize = Clamp( ogl_iMaxBurstSize, 0L, 9999L); - d3d_iMaxBurstSize = Clamp( d3d_iMaxBurstSize, 0L, 9999L); + ogl_iMaxBurstSize = Clamp( ogl_iMaxBurstSize, 0, 9999); + d3d_iMaxBurstSize = Clamp( d3d_iMaxBurstSize, 0, 9999); const INDEX iMaxBurstSize = (eAPI==GAT_OGL) ? ogl_iMaxBurstSize : d3d_iMaxBurstSize; // if unlimited lock count @@ -1891,7 +1891,7 @@ void RenderScene( CDrawPort *pDP, ScenePolygon *pspoFirst, CAnyProjection3D &prP _bTranslucentPass = bTranslucent; // clamp detail textures LOD biasing - wld_iDetailRemovingBias = Clamp( wld_iDetailRemovingBias, -9L, +9L); + wld_iDetailRemovingBias = Clamp( wld_iDetailRemovingBias, -9, 9); // set perspective projection _pDP->SetProjection(prProjection); @@ -1902,7 +1902,7 @@ void RenderScene( CDrawPort *pDP, ScenePolygon *pspoFirst, CAnyProjection3D &prP extern INDEX ogl_bAlternateClipPlane; INDEX ctMaxUsableTexUnits = _pGfx->gl_ctTextureUnits; if( eAPI==GAT_OGL && ogl_bAlternateClipPlane && GFX_bClipPlane && ctMaxUsableTexUnits>1) ctMaxUsableTexUnits--; - _ctUsableTexUnits = Clamp( gap_iUseTextureUnits, 1L, ctMaxUsableTexUnits); + _ctUsableTexUnits = Clamp( gap_iUseTextureUnits, 1, ctMaxUsableTexUnits); // prepare RSPrepare(); diff --git a/Sources/Engine/Graphics/Fog.cpp b/Sources/Engine/Graphics/Fog.cpp index 503f743..69ee670 100644 --- a/Sources/Engine/Graphics/Fog.cpp +++ b/Sources/Engine/Graphics/Fog.cpp @@ -71,10 +71,10 @@ ULONG PrepareTexture( UBYTE *pubTexture, PIX pixSizeI, PIX pixSizeJ) const PIX pixTextureSize = pixSizeI*pixSizeJ; #if (defined USE_PORTABLE_C) - UBYTE* src = pubTexture; + const UBYTE* src = pubTexture; DWORD* dst = (DWORD*)(pubTexture+pixTextureSize); for (int i=0; i>8)+0), 0L, _fog_pixSizeL-1L); - const PIX pixS2 = Clamp( (PIX)((pixSF>>8)+1), 0L, _fog_pixSizeL-1L); + const PIX pixS1 = Clamp( (PIX)((pixSF>>8)+0), 0, _fog_pixSizeL-1); + const PIX pixS2 = Clamp( (PIX)((pixSF>>8)+1), 0, _fog_pixSizeL-1); const ULONG ulF = pixSF & 255; const ULONG ulA1 = _fog_pubTable[pixT +pixS1]; const ULONG ulA2 = _fog_pubTable[pixT +pixS2]; @@ -100,8 +100,8 @@ __forceinline ULONG GetHazeAlpha( const FLOAT fS) { // linear interpolation of depth const PIX pixSH = FloatToInt( fS*(FLOAT)_haze_pixSize*255.4999f); - const PIX pixS1 = Clamp( (PIX)((pixSH>>8)+0), 0L, _haze_pixSize-1L); - const PIX pixS2 = Clamp( (PIX)((pixSH>>8)+1), 0L, _haze_pixSize-1L); + const PIX pixS1 = Clamp( (PIX)((pixSH>>8)+0), 0, _haze_pixSize-1); + const PIX pixS2 = Clamp( (PIX)((pixSH>>8)+1), 0, _haze_pixSize-1); const ULONG ulH = pixSH & 255; const ULONG ulA1 = _haze_pubTable[pixS1]; const ULONG ulA2 = _haze_pubTable[pixS2]; diff --git a/Sources/Engine/Graphics/GfxLibrary.cpp b/Sources/Engine/Graphics/GfxLibrary.cpp index 8eca746..958077f 100644 --- a/Sources/Engine/Graphics/GfxLibrary.cpp +++ b/Sources/Engine/Graphics/GfxLibrary.cpp @@ -618,7 +618,7 @@ static void GAPInfo(void) CPrintF( "- T-Buffer effect: "); if( _pGfx->go_ctSampleBuffers==0) CPrintF( "disabled\n"); else { - ogl_iTBufferEffect = Clamp( ogl_iTBufferEffect, 0L, 2L); + ogl_iTBufferEffect = Clamp( ogl_iTBufferEffect, 0, 2); CTString strEffect = "Partial anti-aliasing"; if( ogl_iTBufferEffect<1) strEffect = "none"; if( ogl_iTBufferEffect>1) strEffect = "Motion blur"; @@ -808,10 +808,10 @@ extern void UncacheShadows(void) // prepare new saturation factors for shadowmaps gfx_fSaturation = ClampDn( gfx_fSaturation, 0.0f); shd_fSaturation = ClampDn( shd_fSaturation, 0.0f); - gfx_iHueShift = Clamp( gfx_iHueShift, 0L, 359L); - shd_iHueShift = Clamp( shd_iHueShift, 0L, 359L); + gfx_iHueShift = Clamp( gfx_iHueShift, 0, 359); + shd_iHueShift = Clamp( shd_iHueShift, 0, 359); _slShdSaturation = (SLONG)( gfx_fSaturation*shd_fSaturation*256.0f); - _slShdHueShift = Clamp( (gfx_iHueShift+shd_iHueShift)*255L/359L, 0L, 255L); + _slShdHueShift = Clamp( (gfx_iHueShift+shd_iHueShift)*255/359, 0, 255); CListHead &lhOriginal = _pGfx->gl_lhCachedShadows; // while there is some shadow in main list @@ -846,10 +846,10 @@ extern void ReloadTextures(void) // prepare new saturation factors for textures gfx_fSaturation = ClampDn( gfx_fSaturation, 0.0f); tex_fSaturation = ClampDn( tex_fSaturation, 0.0f); - gfx_iHueShift = Clamp( gfx_iHueShift, 0L, 359L); - tex_iHueShift = Clamp( tex_iHueShift, 0L, 359L); + gfx_iHueShift = Clamp( gfx_iHueShift, 0, 359); + tex_iHueShift = Clamp( tex_iHueShift, 0, 359); _slTexSaturation = (SLONG)( gfx_fSaturation*tex_fSaturation*256.0f); - _slTexHueShift = Clamp( (gfx_iHueShift+tex_iHueShift)*255L/359L, 0L, 255L); + _slTexHueShift = Clamp( (gfx_iHueShift+tex_iHueShift)*255/359, 0, 255); // update texture settings UpdateTextureSettings(); @@ -927,7 +927,7 @@ static void ReloadModels(void) static BOOL _bLastModelQuality = -1; static void MdlPostFunc(void *pvVar) { - mdl_bFineQuality = Clamp( mdl_bFineQuality, 0L, 1L); + mdl_bFineQuality = Clamp( mdl_bFineQuality, 0, 1); if( _bLastModelQuality!=mdl_bFineQuality) { _bLastModelQuality = mdl_bFineQuality; ReloadModels(); @@ -943,7 +943,7 @@ static void PrepareTables(void) { INDEX i; // prepare array for fast clamping to 0..255 - for( i=-256*2; i<256*4; i++) aubClipByte[i+256*2] = (UBYTE)Clamp( i, 0L, 255L); + for( i=-256*2; i<256*4; i++) aubClipByte[i+256*2] = (UBYTE)Clamp( i, 0, 255); // prepare fast sqrt tables for( i=0; igl_iMaxTessellationLevel); - ogl_iFinish = Clamp( ogl_iFinish, 0L, 3L); - d3d_iFinish = Clamp( d3d_iFinish, 0L, 3L); + gap_iDithering = Clamp( gap_iDithering, 0, 2); + gap_iSwapInterval = Clamp( gap_iSwapInterval, 0, 4); + gap_iOptimizeClipping = Clamp( gap_iOptimizeClipping, 0, 2); + gap_iTruformLevel = Clamp( gap_iTruformLevel, 0, _pGfx->gl_iMaxTessellationLevel); + ogl_iFinish = Clamp( ogl_iFinish, 0, 3); + d3d_iFinish = Clamp( d3d_iFinish, 0, 3); // OpenGL if( gl_eCurrentAPI==GAT_OGL) @@ -1948,7 +1948,7 @@ void CGfxLibrary::SwapBuffers(CViewPort *pvp) GFX_bViewMatrix = TRUE; // set maximum allowed upload ammount - gfx_iProbeSize = Clamp( gfx_iProbeSize, 1L, 16384L); + gfx_iProbeSize = Clamp( gfx_iProbeSize, 1, 16384); gl_slAllowedUploadBurst = gfx_iProbeSize *1024; _ctProbeTexs = 0; _ctProbeShdU = 0; @@ -1966,7 +1966,7 @@ void CGfxLibrary::SwapBuffers(CViewPort *pvp) gl_ctTotalTriangles = 0; // re-adjust multi-texturing support - gap_iUseTextureUnits = Clamp( gap_iUseTextureUnits, 1L, _pGfx->gl_ctTextureUnits); + gap_iUseTextureUnits = Clamp( gap_iUseTextureUnits, 1, _pGfx->gl_ctTextureUnits); ASSERT( gap_iUseTextureUnits>=1 && gap_iUseTextureUnits<=GFX_MAXTEXUNITS); // re-get usage of compiled vertex arrays @@ -2085,7 +2085,7 @@ static BOOL GenerateGammaTable(void) gfx_fBrightness = Clamp( gfx_fBrightness, -0.8f, 0.8f); gfx_fContrast = Clamp( gfx_fContrast, 0.2f, 4.0f); gfx_fGamma = Clamp( gfx_fGamma, 0.2f, 4.0f); - gfx_iLevels = Clamp( gfx_iLevels, 2L, 256L); + gfx_iLevels = Clamp( gfx_iLevels, 2, 256); gfx_fBiasR = Clamp( gfx_fBiasR, 0.0f, 2.0f); gfx_fBiasG = Clamp( gfx_fBiasG, 0.0f, 2.0f); gfx_fBiasB = Clamp( gfx_fBiasB, 0.0f, 2.0f); @@ -2115,7 +2115,7 @@ static BOOL GenerateGammaTable(void) // adjust brightness INDEX iAdd = (INDEX) (256* 256*gfx_fBrightness); for( i=0; i<256; i++) { - _auwGammaTable[i] = Clamp( _auwGammaTable[i]+iAdd, 0L, 65280L); + _auwGammaTable[i] = Clamp( _auwGammaTable[i]+iAdd, 0, 65280); } // adjust levels (posterize) @@ -2124,7 +2124,7 @@ static BOOL GenerateGammaTable(void) for( i=0; i<256; i++) { INDEX iVal = _auwGammaTable[i]; iVal = (INDEX) (((INDEX)(iVal/fLevels)) *fLevels); - _auwGammaTable[i] = ClampUp( iVal, 0xFF00L); + _auwGammaTable[i] = ClampUp( iVal, 0xFF00); } } diff --git a/Sources/Engine/Graphics/GfxLibrary.h b/Sources/Engine/Graphics/GfxLibrary.h index 82cc847..b3c0c61 100644 --- a/Sources/Engine/Graphics/GfxLibrary.h +++ b/Sources/Engine/Graphics/GfxLibrary.h @@ -44,9 +44,9 @@ extern CStaticStackArray _aiCommonQuads; #define SQRTTABLESIZE 8192 #define SQRTTABLESIZELOG2 13 -#define GFX_MAXTEXUNITS (4L) // maximum number of supported texture units for multitexturing -#define GFX_MINSTREAMS (3L) // minimum number of D3D streams in order to support HW T&L -#define GFX_MAXLAYERS (5L) // suggested maximum number of multi-passes per one polygon +#define GFX_MAXTEXUNITS (4) // maximum number of supported texture units for multitexturing +#define GFX_MINSTREAMS (3) // minimum number of D3D streams in order to support HW T&L +#define GFX_MAXLAYERS (5) // suggested maximum number of multi-passes per one polygon // D3D vertex for simple draw functions struct CTVERTEX { diff --git a/Sources/Engine/Graphics/Gfx_OpenGL.cpp b/Sources/Engine/Graphics/Gfx_OpenGL.cpp index 60e5917..3533b23 100644 --- a/Sources/Engine/Graphics/Gfx_OpenGL.cpp +++ b/Sources/Engine/Graphics/Gfx_OpenGL.cpp @@ -491,7 +491,7 @@ void CGfxLibrary::EndDriver_OGL(void) extern void SetTBufferEffect( BOOL bEnable) { // adjust console vars - ogl_iTBufferEffect = Clamp( ogl_iTBufferEffect, 0L, 2L); + ogl_iTBufferEffect = Clamp( ogl_iTBufferEffect, 0, 2); ogl_iTBufferSamples = (1L) << FastLog2(ogl_iTBufferSamples); if( ogl_iTBufferSamples<2) ogl_iTBufferSamples = 4; // if supported diff --git a/Sources/Engine/Graphics/Gfx_wrapper.cpp b/Sources/Engine/Graphics/Gfx_wrapper.cpp index e5b06bc..28a2dcf 100644 --- a/Sources/Engine/Graphics/Gfx_wrapper.cpp +++ b/Sources/Engine/Graphics/Gfx_wrapper.cpp @@ -247,11 +247,11 @@ void gfxGetTextureFiltering( INDEX &iFilterType, INDEX &iAnisotropyDegree) void gfxSetTextureFiltering( INDEX &iFilterType, INDEX &iAnisotropyDegree) { // clamp vars - INDEX iMagTex = iFilterType /100; iMagTex = Clamp( iMagTex, 0L, 2L); // 0=same as iMinTex, 1=nearest, 2=linear - INDEX iMinTex = iFilterType /10 %10; iMinTex = Clamp( iMinTex, 1L, 2L); // 1=nearest, 2=linear - INDEX iMinMip = iFilterType %10; iMinMip = Clamp( iMinMip, 0L, 2L); // 0=no mipmapping, 1=nearest, 2=linear + INDEX iMagTex = iFilterType /100; iMagTex = Clamp( iMagTex, 0, 2); // 0=same as iMinTex, 1=nearest, 2=linear + INDEX iMinTex = iFilterType /10 %10; iMinTex = Clamp( iMinTex, 1, 2); // 1=nearest, 2=linear + INDEX iMinMip = iFilterType %10; iMinMip = Clamp( iMinMip, 0, 2); // 0=no mipmapping, 1=nearest, 2=linear iFilterType = iMagTex*100 + iMinTex*10 + iMinMip; - iAnisotropyDegree = Clamp( iAnisotropyDegree, 1L, _pGfx->gl_iMaxTextureAnisotropy); + iAnisotropyDegree = Clamp( iAnisotropyDegree, 1, _pGfx->gl_iMaxTextureAnisotropy); // skip if not changed if( _tpGlobal[0].tp_iFilter==iFilterType && _tpGlobal[0].tp_iAnisotropy==iAnisotropyDegree) return; @@ -340,9 +340,9 @@ void gfxSetTexture( ULONG &ulTexObject, CTexParams &tpLocal) // clamp texture filtering if needed static INDEX _iLastTextureFiltering = 0; if( _iLastTextureFiltering != _tpGlobal[0].tp_iFilter) { - INDEX iMagTex = _tpGlobal[0].tp_iFilter /100; iMagTex = Clamp( iMagTex, 0L, 2L); // 0=same as iMinTex, 1=nearest, 2=linear - INDEX iMinTex = _tpGlobal[0].tp_iFilter /10 %10; iMinTex = Clamp( iMinTex, 1L, 2L); // 1=nearest, 2=linear - INDEX iMinMip = _tpGlobal[0].tp_iFilter %10; iMinMip = Clamp( iMinMip, 0L, 2L); // 0=no mipmapping, 1=nearest, 2=linear + INDEX iMagTex = _tpGlobal[0].tp_iFilter /100; iMagTex = Clamp( iMagTex, 0, 2); // 0=same as iMinTex, 1=nearest, 2=linear + INDEX iMinTex = _tpGlobal[0].tp_iFilter /10 %10; iMinTex = Clamp( iMinTex, 1, 2); // 1=nearest, 2=linear + INDEX iMinMip = _tpGlobal[0].tp_iFilter %10; iMinMip = Clamp( iMinMip, 0, 2); // 0=no mipmapping, 1=nearest, 2=linear _tpGlobal[0].tp_iFilter = iMagTex*100 + iMinTex*10 + iMinMip; _iLastTextureFiltering = _tpGlobal[0].tp_iFilter; } @@ -622,7 +622,7 @@ void gfxSetTruform( INDEX iLevel, BOOL bLinearNormals) return; } // skip if same as last time - iLevel = Clamp( iLevel, 0L, _pGfx->gl_iMaxTessellationLevel); + iLevel = Clamp( iLevel, 0, _pGfx->gl_iMaxTessellationLevel); if( truform_iLevel==iLevel && !truform_bLinear==!bLinearNormals) return; // determine API diff --git a/Sources/Engine/Graphics/Graphics.cpp b/Sources/Engine/Graphics/Graphics.cpp index feadd99..0fa995f 100644 --- a/Sources/Engine/Graphics/Graphics.cpp +++ b/Sources/Engine/Graphics/Graphics.cpp @@ -1359,7 +1359,7 @@ void FilterBitmap( INDEX iFilter, ULONG *pulSrc, ULONG *pulDst, PIX pixWidth, PI } // prepare convolution matrix and row modulo - iFilter = Clamp( iFilter, -6L, +6L); + iFilter = Clamp( iFilter, -6, 6); GenerateConvolutionMatrix( iFilter); SLONG slModulo1 = (pixCanvasWidth-pixWidth+1) *BYTES_PER_TEXEL; SLONG slCanvasWidth = pixCanvasWidth *BYTES_PER_TEXEL; diff --git a/Sources/Engine/Graphics/Shader.cpp b/Sources/Engine/Graphics/Shader.cpp index 70b74a6..ea39eb5 100644 --- a/Sources/Engine/Graphics/Shader.cpp +++ b/Sources/Engine/Graphics/Shader.cpp @@ -213,9 +213,9 @@ void shaCalculateLight(void) SLONG slab = colAmbient.ub.b; if(shaOverBrightningEnabled()) { - slar = ClampUp(slar,127L); - slag = ClampUp(slag,127L); - slab = ClampUp(slab,127L); + slar = ClampUp(slar,127); + slag = ClampUp(slag,127); + slab = ClampUp(slab,127); ubColShift = 8; } else { slar*=2; @@ -232,9 +232,9 @@ void shaCalculateLight(void) fDot = Clamp(fDot,0.0f,1.0f); SLONG slDot = NormFloatToByte(fDot); - _acolVtxColors[ivx].ub.r = ClampUp(colModel.ub.r * (slar + ((colLight.ub.r * slDot)>>ubColShift))>>8,255L); - _acolVtxColors[ivx].ub.g = ClampUp(colModel.ub.g * (slag + ((colLight.ub.g * slDot)>>ubColShift))>>8,255L); - _acolVtxColors[ivx].ub.b = ClampUp(colModel.ub.b * (slab + ((colLight.ub.b * slDot)>>ubColShift))>>8,255L); + _acolVtxColors[ivx].ub.r = ClampUp(colModel.ub.r * (slar + ((colLight.ub.r * slDot)>>ubColShift))>>8,255); + _acolVtxColors[ivx].ub.g = ClampUp(colModel.ub.g * (slag + ((colLight.ub.g * slDot)>>ubColShift))>>8,255); + _acolVtxColors[ivx].ub.b = ClampUp(colModel.ub.b * (slab + ((colLight.ub.b * slDot)>>ubColShift))>>8,255); _acolVtxColors[ivx].ub.a = colModel.ub.a;//slDot; } // Set current vertex color array @@ -262,9 +262,9 @@ void shaCalculateLightForSpecular(void) SLONG slab = colAmbient.ub.b; if(shaOverBrightningEnabled()) { - slar = ClampUp(slar,127L); - slag = ClampUp(slag,127L); - slab = ClampUp(slab,127L); + slar = ClampUp(slar,127); + slag = ClampUp(slag,127); + slab = ClampUp(slab,127); ubColShift = 8; } else { slar*=2; @@ -281,9 +281,9 @@ void shaCalculateLightForSpecular(void) fDot = Clamp(fDot,0.0f,1.0f); SLONG slDot = NormFloatToByte(fDot); - _acolVtxColors[ivx].ub.r = ClampUp(colModel.ub.r * (slar + ((colLight.ub.r * slDot)>>ubColShift))>>8,255L); - _acolVtxColors[ivx].ub.g = ClampUp(colModel.ub.g * (slag + ((colLight.ub.g * slDot)>>ubColShift))>>8,255L); - _acolVtxColors[ivx].ub.b = ClampUp(colModel.ub.b * (slab + ((colLight.ub.b * slDot)>>ubColShift))>>8,255L); + _acolVtxColors[ivx].ub.r = ClampUp(colModel.ub.r * (slar + ((colLight.ub.r * slDot)>>ubColShift))>>8,255); + _acolVtxColors[ivx].ub.g = ClampUp(colModel.ub.g * (slag + ((colLight.ub.g * slDot)>>ubColShift))>>8,255); + _acolVtxColors[ivx].ub.b = ClampUp(colModel.ub.b * (slab + ((colLight.ub.b * slDot)>>ubColShift))>>8,255); _acolVtxColors[ivx].ub.a = slDot;//colModel.ub.a;//slDot; } // Set current wertex array diff --git a/Sources/Engine/Graphics/ShadowMap.cpp b/Sources/Engine/Graphics/ShadowMap.cpp index 7191b01..05d168f 100644 --- a/Sources/Engine/Graphics/ShadowMap.cpp +++ b/Sources/Engine/Graphics/ShadowMap.cpp @@ -152,7 +152,7 @@ void CShadowMap::Cache( INDEX iWantedMipLevel) } // let the higher level driver mix its layers - INDEX iLastMipLevelToCache = Min( sm_iLastMipLevel, sm_iFirstCachedMipLevel-1L); + INDEX iLastMipLevelToCache = Min( sm_iLastMipLevel, sm_iFirstCachedMipLevel-1); sm_iFirstCachedMipLevel = iWantedMipLevel; ASSERT( iWantedMipLevel <= iLastMipLevelToCache); @@ -481,7 +481,7 @@ void CShadowMap::Prepare(void) BOOL bUseProbe = ProbeMode(sm_tvLastDrawn); // determine and clamp to max allowed shadow dimension - shd_iStaticSize = Clamp( shd_iStaticSize, 5L, 8L); + shd_iStaticSize = Clamp( shd_iStaticSize, 5, 8); PIX pixClampAreaSize = 1L<<(shd_iStaticSize*2); // determine largest allowed mip level INDEX iFinestMipLevel = sm_iFirstMipLevel + diff --git a/Sources/Engine/Graphics/Stereo.cpp b/Sources/Engine/Graphics/Stereo.cpp index 752a13e..0ed76a1 100644 --- a/Sources/Engine/Graphics/Stereo.cpp +++ b/Sources/Engine/Graphics/Stereo.cpp @@ -57,7 +57,7 @@ void Stereo_AdjustProjection(CProjection3D &pr, INDEX iEye, FLOAT fFactor) // prepare and clamp CPerspectiveProjection3D &ppr = (CPerspectiveProjection3D &)pr; gfx_fStereoSeparation = Clamp( gfx_fStereoSeparation, 0.01f, 1.0f); - gfx_iStereoOffset = Clamp( gfx_iStereoOffset, -100L, +100L); + gfx_iStereoOffset = Clamp( gfx_iStereoOffset, -100, 100); // apply! if (iEye==STEREO_BOTH || gfx_iStereo==0) { NOTHING; diff --git a/Sources/Engine/Graphics/Texture.cpp b/Sources/Engine/Graphics/Texture.cpp index 8b96f78..41046dc 100644 --- a/Sources/Engine/Graphics/Texture.cpp +++ b/Sources/Engine/Graphics/Texture.cpp @@ -101,7 +101,7 @@ extern void UpdateTextureSettings(void) { // OpenGL extern INDEX ogl_iTextureCompressionType; // 0=none, 1=default (ARB), 2=S3TC, 3=FXT1, 4=legacy S3TC INDEX &iTC = ogl_iTextureCompressionType; - iTC = Clamp( iTC, 0L, 4L); + iTC = Clamp( iTC, 0, 4); if( iTC==3 && !(ulGfxFlags&GLF_EXTC_FXT1)) iTC = 2; if( iTC==2 && !(ulGfxFlags&GLF_EXTC_S3TC)) iTC = 3; if((iTC==2 || iTC==3) && !((ulGfxFlags&GLF_EXTC_FXT1) || (ulGfxFlags&GLF_EXTC_S3TC))) iTC = 1; @@ -167,8 +167,8 @@ extern void UpdateTextureSettings(void) tex_iNormalQuality = TS.ts_iNormQualityO*10 + TS.ts_iNormQualityA; tex_iAnimationQuality = TS.ts_iAnimQualityO*10 + TS.ts_iAnimQualityA; // clamp texture size - tex_iNormalSize = Clamp( tex_iNormalSize, 5L, 11L); - tex_iAnimationSize = Clamp( tex_iAnimationSize, 5L, 9L); + tex_iNormalSize = Clamp( tex_iNormalSize, 5, 11); + tex_iAnimationSize = Clamp( tex_iAnimationSize, 5, 9); TS.ts_pixNormSize = 1L<<(tex_iNormalSize *2); TS.ts_pixAnimSize = 1L<<(tex_iAnimationSize*2); @@ -919,7 +919,7 @@ void CTextureData::Read_t( CTStream *inFile) } // generate texture mip-maps for each frame (in version 4 they're no longer kept in file) // and eventually adjust texture saturation, do filtering and/or dithering - tex_iFiltering = Clamp( tex_iFiltering, -6L, +6L); + tex_iFiltering = Clamp( tex_iFiltering, -6, 6); INDEX iTexFilter = tex_iFiltering; if( _bExport || (td_ulFlags&TEX_CONSTANT)) iTexFilter = 0; // don't filter constants and textures for exporting if( iTexFilter) td_ulFlags |= TEX_FILTERED; @@ -978,7 +978,7 @@ void CTextureData::Read_t( CTStream *inFile) // prepare dithering type td_ulInternalFormat = DetermineInternalFormat(this); - tex_iDithering = Clamp( tex_iDithering, 0L, 10L); + tex_iDithering = Clamp( tex_iDithering, 0, 10); INDEX iDitherType = 0; if( !(td_ulFlags&TEX_STATIC) || !(td_ulFlags&TEX_CONSTANT)) { // only non-static-constant textures can be dithered extern INDEX AdjustDitheringType_OGL( GLenum eFormat, INDEX iDitheringType); @@ -1210,7 +1210,7 @@ void CTextureData::SetAsCurrent( INDEX iFrameNo/*=0*/, BOOL bForceUpload/*=FALSE ASSERT( iFrameNo==0); // effect texture must have only one frame // get max allowed effect texture dimension PIX pixClampAreaSize = 1L<<16L; - tex_iEffectSize = Clamp( tex_iEffectSize, 4L, 8L); + tex_iEffectSize = Clamp( tex_iEffectSize, 4, 8); if( !(td_ulFlags&TEX_CONSTANT)) pixClampAreaSize = 1L<<(tex_iEffectSize*2); INDEX iWantedMipLevel = td_iFirstMipLevel + ClampTextureSize( pixClampAreaSize, _pGfx->gl_pixMaxTextureDimension, pixWidth, pixHeight); @@ -1285,7 +1285,7 @@ void CTextureData::SetAsCurrent( INDEX iFrameNo/*=0*/, BOOL bForceUpload/*=FALSE extern INDEX tex_bDynamicMipmaps; extern INDEX tex_iEffectFiltering; if( tex_bDynamicMipmaps) tex_bDynamicMipmaps = 1; - tex_iEffectFiltering = Clamp( tex_iEffectFiltering, -6L, +6L); + tex_iEffectFiltering = Clamp( tex_iEffectFiltering, -6, 6); // determine whether texture has single mipmap if( gap_bAllowSingleMipmap) { diff --git a/Sources/Engine/Graphics/TextureEffects.cpp b/Sources/Engine/Graphics/TextureEffects.cpp index 3055cc5..08f816e 100644 --- a/Sources/Engine/Graphics/TextureEffects.cpp +++ b/Sources/Engine/Graphics/TextureEffects.cpp @@ -181,7 +181,7 @@ inline void PutPixel9SLONG_WATER( PIX pixU, PIX pixV, INDEX iHeightMid) inline void PutPixelUBYTE_FIRE( PIX pixU, PIX pixV, INDEX iHeight) { PIX pixLoc = (pixV*_pixBufferWidth+pixU) & _ulBufferMask; - _pubDrawBuffer[pixLoc] = Clamp( _pubDrawBuffer[pixLoc] +iHeight, 0L, 255L); + _pubDrawBuffer[pixLoc] = Clamp( _pubDrawBuffer[pixLoc] +iHeight, 0, 255); } inline void PutPixel9UBYTE_FIRE( PIX pixU, PIX pixV, INDEX iHeightMid) diff --git a/Sources/Engine/Light/LayerMixer.cpp b/Sources/Engine/Light/LayerMixer.cpp index d8d5ecf..e32982f 100644 --- a/Sources/Engine/Light/LayerMixer.cpp +++ b/Sources/Engine/Light/LayerMixer.cpp @@ -185,8 +185,8 @@ void CLayerMixer::CalculateData( CBrushShadowMap *pbsm, INDEX iMipmap) lm_iMipShift = lm_iMipLevel - lm_iFirstLevel; lm_pixCanvasSizeU = pbsm->sm_mexWidth >>lm_iMipLevel; lm_pixCanvasSizeV = pbsm->sm_mexHeight>>lm_iMipLevel; - lm_pixPolygonSizeU = Min( lm_pixCanvasSizeU, (PIX)(lm_pbsmShadowMap->sm_pixPolygonSizeU >>lm_iMipShift)+1L); - lm_pixPolygonSizeV = Min( lm_pixCanvasSizeV, (PIX)(lm_pbsmShadowMap->sm_pixPolygonSizeV >>lm_iMipShift)+1L); + lm_pixPolygonSizeU = Min( lm_pixCanvasSizeU, (PIX)(lm_pbsmShadowMap->sm_pixPolygonSizeU >>lm_iMipShift)+1); + lm_pixPolygonSizeV = Min( lm_pixCanvasSizeV, (PIX)(lm_pbsmShadowMap->sm_pixPolygonSizeV >>lm_iMipShift)+1); // determine where this mip-map is relative to the allocated shadow map memory PIX pixOffset = pbsm->sm_slMemoryUsed/BYTES_PER_TEXEL @@ -1808,7 +1808,7 @@ void CLayerMixer::AddOneLayerDirectional( CBrushShadowLayer *pbsl, UBYTE *pubMas // clamper helper static INDEX GetDither(void) { - shd_iDithering = Clamp( shd_iDithering, 0L, 5L); + shd_iDithering = Clamp( shd_iDithering, 0, 5); INDEX iDither = shd_iDithering; if( iDither>2) iDither++; return iDither; @@ -1944,7 +1944,7 @@ void CLayerMixer::MixOneMipmap(CBrushShadowMap *pbsm, INDEX iMipmap) if( bHasGradient && gpGradient.gp_bDark) AddOneLayerGradient( gpGradient); // do eventual filtering of shadow layer - shd_iFiltering = Clamp( shd_iFiltering, 0L, +6L); + shd_iFiltering = Clamp( shd_iFiltering, 0, 6); if( shd_iFiltering>0) { FilterBitmap( shd_iFiltering, lm_pulShadowMap, lm_pulShadowMap, lm_pixPolygonSizeU, lm_pixPolygonSizeV, lm_pixCanvasSizeU, lm_pixCanvasSizeV); diff --git a/Sources/Engine/Math/FixInt.h b/Sources/Engine/Math/FixInt.h index fc63100..fff5fe3 100644 --- a/Sources/Engine/Math/FixInt.h +++ b/Sources/Engine/Math/FixInt.h @@ -46,8 +46,8 @@ public: inline FixInt(UWORD uw) : slHolder((SLONG)(uw<(SBYTE sb) : slHolder((SLONG)(sb<(UBYTE ub) : slHolder((SLONG)(ub<(signed int si) : slHolder((SLONG)(si<(unsigned int ui) : slHolder((SLONG)(ui<(signed int si) : slHolder((SLONG)(si<(unsigned int ui) : slHolder((SLONG)(ui<(float f) : slHolder((SLONG)(f*(1L<(double f) : slHolder((SLONG)(f*(1L<oed_Vertex1, - *ope.ope_Edge->oed_Vertex0, (ULONG)ope.ope_Edge); + *ope.ope_Edge->oed_Vertex0, (ULONG)(size_t)ope.ope_Edge); // if it is not reversed } else{ // add bsp edge with normal vertices + STUBBED("64-bit issue"); // we're casting ope.ope_Edge to a 32-bit value. Code really only cares if this is zero or !zero, but one could totally have a non-NULL 64-bit pointer that truncates down to zero! abed[iEdge] = DOUBLEbspedge3D(*ope.ope_Edge->oed_Vertex0, - *ope.ope_Edge->oed_Vertex1, (ULONG)ope.ope_Edge); + *ope.ope_Edge->oed_Vertex1, (ULONG)(size_t)ope.ope_Edge); } } @@ -542,7 +544,8 @@ void CObjectCSG::DoCSGSplitting( oc_popoPortalB1B2 = NULL; // create a bsp polygon from first temporary array - DOUBLEbsppolygon3D bpoA(*itopoA->opo_Plane, abedRemaining, (ULONG)itopoA->opo_Plane); + STUBBED("64-bit issue"); + DOUBLEbsppolygon3D bpoA(*itopoA->opo_Plane, abedRemaining, (ULONG)(size_t)itopoA->opo_Plane); // create a BSP cutter for B's sector BSP and A's polygon DOUBLEbspcutter3D bcCutter(bpoA, *itoscB->osc_BSPTree.bt_pbnRoot); diff --git a/Sources/Engine/Math/ObjectSector.cpp b/Sources/Engine/Math/ObjectSector.cpp index de4fd62..2bb402f 100644 --- a/Sources/Engine/Math/ObjectSector.cpp +++ b/Sources/Engine/Math/ObjectSector.cpp @@ -1844,7 +1844,8 @@ void CObjectSector::CreateBSP(void) // copy the plane (DOUBLEplane3D &)bpo = *opo.opo_Plane; - bpo.bpo_ulPlaneTag = (ULONG)opo.opo_Plane; + STUBBED("64-bit issue"); + bpo.bpo_ulPlaneTag = (ULONG)(size_t)opo.opo_Plane; // get count of edges in this polygon const INDEX ctEdges = opo.opo_PolygonEdges.Count(); @@ -1859,11 +1860,13 @@ void CObjectSector::CreateBSP(void) // if the edge is reversed if(ope.ope_Backward) { // add bsp edge with reversed vertices - pbed[iEdge] = DOUBLEbspedge3D(*oed.oed_Vertex1, *oed.oed_Vertex0, (ULONG)&oed); + STUBBED("64-bit issue"); + pbed[iEdge] = DOUBLEbspedge3D(*oed.oed_Vertex1, *oed.oed_Vertex0, (ULONG)(size_t)&oed); // otherwise } else { // add normal bsp edge - pbed[iEdge] = DOUBLEbspedge3D(*oed.oed_Vertex0, *oed.oed_Vertex1, (ULONG)&oed); + STUBBED("64-bit issue"); + pbed[iEdge] = DOUBLEbspedge3D(*oed.oed_Vertex0, *oed.oed_Vertex1, (ULONG)(size_t)&oed); } } opo.opo_PolygonEdges.Unlock(); diff --git a/Sources/Engine/Models/Model.cpp b/Sources/Engine/Models/Model.cpp index cbc256c..b28a533 100644 --- a/Sources/Engine/Models/Model.cpp +++ b/Sources/Engine/Models/Model.cpp @@ -407,7 +407,7 @@ void CModelData::GetAllFramesBBox( FLOATaabbox3D &MaxBB) FLOAT3D CModelData::GetCollisionBoxMin(INDEX iCollisionBox) { md_acbCollisionBox.Lock(); - INDEX iCollisionBoxClamped = Clamp(iCollisionBox, 0L, md_acbCollisionBox.Count()-1L); + INDEX iCollisionBoxClamped = Clamp(iCollisionBox, 0, md_acbCollisionBox.Count()-1); FLOAT3D vMin = md_acbCollisionBox[ iCollisionBoxClamped].mcb_vCollisionBoxMin; md_acbCollisionBox.Unlock(); return vMin; @@ -416,7 +416,7 @@ FLOAT3D CModelData::GetCollisionBoxMin(INDEX iCollisionBox) FLOAT3D CModelData::GetCollisionBoxMax(INDEX iCollisionBox=0) { md_acbCollisionBox.Lock(); - INDEX iCollisionBoxClamped = Clamp(iCollisionBox, 0L, md_acbCollisionBox.Count()-1L); + INDEX iCollisionBoxClamped = Clamp(iCollisionBox, 0, md_acbCollisionBox.Count()-1); FLOAT3D vMax = md_acbCollisionBox[ iCollisionBoxClamped].mcb_vCollisionBoxMax; md_acbCollisionBox.Unlock(); return vMax; @@ -426,7 +426,7 @@ FLOAT3D CModelData::GetCollisionBoxMax(INDEX iCollisionBox=0) INDEX CModelData::GetCollisionBoxDimensionEquality(INDEX iCollisionBox=0) { md_acbCollisionBox.Lock(); - iCollisionBox = Clamp(iCollisionBox, 0L, md_acbCollisionBox.Count()-1L); + iCollisionBox = Clamp(iCollisionBox, 0, md_acbCollisionBox.Count()-1); INDEX iDimEq = md_acbCollisionBox[ iCollisionBox].mcb_iCollisionBoxDimensionEquality; md_acbCollisionBox.Unlock(); return iDimEq; @@ -481,20 +481,20 @@ ModelTextureVertex::ModelTextureVertex(void) //------------------------------------------ WRITE void ModelPolygonVertex::Write_t( CTStream *pFile) // throw char * { - // !!! FIXME: Not 64-bit clean! - (*pFile) << (INDEX) mpv_ptvTransformedVertex; - (*pFile) << (INDEX) mpv_ptvTextureVertex; + STUBBED("64-bit issue"); + (*pFile) << (INDEX) (size_t) mpv_ptvTransformedVertex; + (*pFile) << (INDEX) (size_t) mpv_ptvTextureVertex; } //------------------------------------------ READ void ModelPolygonVertex::Read_t( CTStream *pFile) // throw char * { INDEX itmp; - // !!! FIXME: Not 64-bit clean! + STUBBED("64-bit issue"); (*pFile) >> itmp; - mpv_ptvTransformedVertex = (struct TransformedVertexData *) itmp; + mpv_ptvTransformedVertex = (struct TransformedVertexData *) (size_t) itmp; (*pFile) >> itmp; - mpv_ptvTextureVertex = (ModelTextureVertex *) itmp; + mpv_ptvTextureVertex = (ModelTextureVertex *) (size_t) itmp; } //-------------------------------------------------------------------------------------------- //------------------------------------------ WRITE @@ -1068,9 +1068,11 @@ void CModelData::IndicesToPtrs() FOREACHINSTATICARRAY(it1.Current().mp_PolygonVertices, ModelPolygonVertex, it2) { struct ModelPolygonVertex * pMPV = &it2.Current(); - j = (INDEX) it2.Current().mpv_ptvTransformedVertex; + STUBBED("64-bit issue"); + j = (INDEX) (size_t) it2.Current().mpv_ptvTransformedVertex; it2.Current().mpv_ptvTransformedVertex = &md_TransformedVertices[ j]; - j = (INDEX) it2.Current().mpv_ptvTextureVertex; + STUBBED("64-bit issue"); + j = (INDEX) (size_t) it2.Current().mpv_ptvTextureVertex; it2.Current().mpv_ptvTextureVertex = &md_MipInfos[ i].mmpi_TextureVertices[ j]; } } diff --git a/Sources/Engine/Models/RenderModel_View.cpp b/Sources/Engine/Models/RenderModel_View.cpp index 91779ff..2b18dda 100644 --- a/Sources/Engine/Models/RenderModel_View.cpp +++ b/Sources/Engine/Models/RenderModel_View.cpp @@ -1700,7 +1700,7 @@ colEnd: // generate colors from shades for( INDEX iMipVx=0; iMipVx<_ctAllMipVx; iMipVx++) { GFXColor &col = pcolMipBase[iMipVx]; - const SLONG slShade = Clamp( (SLONG)pswMipCol[iMipVx], 0L, 255L); + const SLONG slShade = Clamp( (SLONG)pswMipCol[iMipVx], 0, 255); col.ub.r = pubClipByte[_slAR + ((_slLR*slShade)>>8)]; col.ub.g = pubClipByte[_slAG + ((_slLG*slShade)>>8)]; col.ub.b = pubClipByte[_slAB + ((_slLB*slShade)>>8)]; @@ -1816,9 +1816,9 @@ void CModelObject::RenderModel_View( CRenderModel &rm) _slAG = (colA & CT_GMASK)>>(CT_GSHIFT-iBright); _slAB = (colA & CT_BMASK)>>(CT_BSHIFT-iBright); if( bOverbright) { - _slAR = ClampUp( _slAR, 127L); - _slAG = ClampUp( _slAG, 127L); - _slAB = ClampUp( _slAB, 127L); + _slAR = ClampUp( _slAR, 127); + _slAG = ClampUp( _slAG, 127); + _slAB = ClampUp( _slAB, 127); } // set forced translucency and color mask @@ -2648,9 +2648,9 @@ specMipLoop: const COLOR colS = AdjustColor( rm.rm_pmdModelData->md_colSpecular, _slTexHueShift, _slTexSaturation); colMdlSpec.ul.abgr = ByteSwap(colS); colMdlSpec.AttenuateRGB( (rm.rm_colBlend&CT_AMASK)>>CT_ASHIFT); - colMdlSpec.ub.r = ClampUp( (colMdlSpec.ub.r *_slLR)>>8, 255L); - colMdlSpec.ub.g = ClampUp( (colMdlSpec.ub.g *_slLG)>>8, 255L); - colMdlSpec.ub.b = ClampUp( (colMdlSpec.ub.b *_slLB)>>8, 255L); + colMdlSpec.ub.r = ClampUp( (colMdlSpec.ub.r *_slLR)>>8, 255); + colMdlSpec.ub.g = ClampUp( (colMdlSpec.ub.g *_slLG)>>8, 255); + colMdlSpec.ub.b = ClampUp( (colMdlSpec.ub.b *_slLB)>>8, 255); // for each specular surface in current mip model FOREACHINSTATICARRAY( mmi.mmpi_MappingSurfaces, MappingSurface, itms) diff --git a/Sources/Engine/Network/Compression.cpp b/Sources/Engine/Network/Compression.cpp index 5d6cc85..c6650ca 100644 --- a/Sources/Engine/Network/Compression.cpp +++ b/Sources/Engine/Network/Compression.cpp @@ -424,9 +424,11 @@ int ZEXPORT compress (dest, destLen, source, sourceLen) */ CTSingleLock slZip(&zip_csLock, TRUE); - int iResult = compress( - (UBYTE *)pvDst, (ULONG *)&slDstSize, - (const UBYTE *)pvSrc, (ULONG)slSrcSize); + uLongf dstlen = (uLongf) slDstSize; + const int iResult = compress( + (Bytef *)pvDst, &dstlen, + (const Bytef *)pvSrc, (uLong)slSrcSize); + slDstSize = (SLONG) dstlen; if (iResult==Z_OK) { return TRUE; } else { @@ -448,10 +450,11 @@ int ZEXPORT uncompress (dest, destLen, source, sourceLen) */ CTSingleLock slZip(&zip_csLock, TRUE); - int iResult = uncompress( - (UBYTE *)pvDst, (ULONG *)&slDstSize, - (const UBYTE *)pvSrc, (ULONG)slSrcSize); - + uLongf dstlen = (uLongf) slDstSize; + const int iResult = uncompress( + (Bytef *)pvDst, &dstlen, + (const Bytef *)pvSrc, (uLong)slSrcSize); + slDstSize = (SLONG) dstlen; if (iResult==Z_OK) { return TRUE; } else { diff --git a/Sources/Engine/Network/Network.cpp b/Sources/Engine/Network/Network.cpp index 3d9f8a0..d268452 100644 --- a/Sources/Engine/Network/Network.cpp +++ b/Sources/Engine/Network/Network.cpp @@ -1039,7 +1039,8 @@ void CNetworkLibrary::StartPeerToPeer_t(const CTString &strSessionName, throw; } // remember the world pointer - _pShell->SetINDEX("pwoCurrentWorld", (INDEX)&ga_World); + STUBBED("64-bit issue"); + _pShell->SetINDEX("pwoCurrentWorld", (INDEX)(size_t)&ga_World); SetProgressDescription(TRANS("starting server")); CallProgressHook_t(0.0f); @@ -1276,7 +1277,8 @@ void CNetworkLibrary::JoinSession_t(const CNetworkSession &nsSesssion, INDEX ctL } // remember the world pointer - _pShell->SetINDEX("pwoCurrentWorld", (INDEX)&ga_World); + STUBBED("64-bit issue"); + _pShell->SetINDEX("pwoCurrentWorld", (INDEX)(size_t)&ga_World); // eventually cache all shadowmaps in world (memory eater!) if( shd_bCacheAll) ga_World.wo_baBrushes.CacheAllShadowmaps(); @@ -1348,7 +1350,8 @@ void CNetworkLibrary::StartDemoPlay_t(const CTFileName &fnDemo) // throw char * _bNeedPretouch = TRUE; // remember the world pointer - _pShell->SetINDEX("pwoCurrentWorld", (INDEX)&ga_World); + STUBBED("64-bit issue"); + _pShell->SetINDEX("pwoCurrentWorld", (INDEX)(size_t)&ga_World); // demo synchronization starts at the beginning initially ga_fDemoTimer = 0.0f; @@ -1681,7 +1684,8 @@ void CNetworkLibrary::ChangeLevel_internal(void) // remember the world filename ga_fnmWorld = ga_fnmNextLevel; // remember the world pointer - _pShell->SetINDEX("pwoCurrentWorld", (INDEX)&ga_World); + STUBBED("64-bit issue"); + _pShell->SetINDEX("pwoCurrentWorld", (INDEX)(size_t)&ga_World); // if there is remembered level } else { // restore it @@ -2386,7 +2390,8 @@ extern void NET_MakeDefaultState_t( _pNetwork->ga_fnmWorld = fnmWorld; _pNetwork->ga_fnmNextLevel = CTString(""); // remember the world pointer - _pShell->SetINDEX("pwoCurrentWorld", (INDEX)&_pNetwork->ga_World); + STUBBED("64-bit issue"); + _pShell->SetINDEX("pwoCurrentWorld", (INDEX)(size_t)&_pNetwork->ga_World); // reset random number generator _pNetwork->ga_sesSessionState.ResetRND(); diff --git a/Sources/Engine/Network/PlayerSource.cpp b/Sources/Engine/Network/PlayerSource.cpp index f8068b3..1b1c4c6 100644 --- a/Sources/Engine/Network/PlayerSource.cpp +++ b/Sources/Engine/Network/PlayerSource.cpp @@ -208,7 +208,7 @@ void CPlayerSource::WriteActionPacket(CNetworkMessage &nm) // get sendbehind parameters extern INDEX cli_iSendBehind; extern INDEX cli_bPredictIfServer; - cli_iSendBehind = Clamp(cli_iSendBehind, 0L, 3L); + cli_iSendBehind = Clamp(cli_iSendBehind, 0, 3); INDEX iSendBehind = cli_iSendBehind; // disable if server diff --git a/Sources/Engine/Network/Server.cpp b/Sources/Engine/Network/Server.cpp index e02e67e..42206c1 100644 --- a/Sources/Engine/Network/Server.cpp +++ b/Sources/Engine/Network/Server.cpp @@ -381,8 +381,8 @@ void CServer::SendGameStreamBlocks(INDEX iClient) INDEX ctMinBytes = sso.sso_sspParams.ssp_iMinBPS/20; INDEX ctMaxBytes = sso.sso_sspParams.ssp_iMaxBPS/20; // make sure outgoing message doesn't overflow UDP size - ctMinBytes = Clamp(ctMinBytes, 0L, 1000L); - ctMaxBytes = Clamp(ctMaxBytes, 0L, 1000L); + ctMinBytes = Clamp(ctMinBytes, 0, 1000); + ctMaxBytes = Clamp(ctMaxBytes, 0, 1000); // limit the clients BPS by server's local settings extern INDEX ser_iMaxAllowedBPS; ctMinBytes = ClampUp(ctMinBytes, (INDEX) ( ser_iMaxAllowedBPS/20L - MAX_HEADER_SIZE)); @@ -743,7 +743,7 @@ void CServer::ServerLoop(void) if (srv_fServerStep>=1.0f) { // find how many ticks were stepped - INDEX iSpeed = ClampDn(INDEX(srv_fServerStep), 1L); + INDEX iSpeed = ClampDn(INDEX(srv_fServerStep), 1); srv_fServerStep -= iSpeed; // for each tick @@ -911,8 +911,8 @@ void CServer::ConnectRemoteSessionState(INDEX iClient, CNetworkMessage &nm) INDEX ctMaxAllowedVIPPlayers = 0; INDEX ctMaxAllowedVIPClients = 0; if (net_iVIPReserve>0 && net_strVIPPassword!="") { - ctMaxAllowedVIPPlayers = ClampDn(net_iVIPReserve-GetVIPPlayersCount(), 0L); - ctMaxAllowedVIPClients = ClampDn(net_iVIPReserve-GetVIPClientsCount(), 0L); + ctMaxAllowedVIPPlayers = ClampDn(net_iVIPReserve-GetVIPPlayersCount(), 0); + ctMaxAllowedVIPClients = ClampDn(net_iVIPReserve-GetVIPClientsCount(), 0); } INDEX ctMaxAllowedObservers = net_iMaxObservers; @@ -940,8 +940,8 @@ void CServer::ConnectRemoteSessionState(INDEX iClient, CNetworkMessage &nm) // if the user is not authorised as a VIP if (!bAutorizedAsVIP) { // artificially decrease allowed number of players and clients - ctMaxAllowedPlayers = ClampDn(ctMaxAllowedPlayers-ctMaxAllowedVIPPlayers, 0L); - ctMaxAllowedClients = ClampDn(ctMaxAllowedClients-ctMaxAllowedVIPClients, 0L); + ctMaxAllowedPlayers = ClampDn(ctMaxAllowedPlayers-ctMaxAllowedVIPPlayers, 0); + ctMaxAllowedClients = ClampDn(ctMaxAllowedClients-ctMaxAllowedVIPClients, 0); } // if too many clients or players diff --git a/Sources/Engine/Network/SessionState.cpp b/Sources/Engine/Network/SessionState.cpp index b8f0790..4475483 100644 --- a/Sources/Engine/Network/SessionState.cpp +++ b/Sources/Engine/Network/SessionState.cpp @@ -231,7 +231,7 @@ void CSessionState::Start_t(INDEX ctLocalPlayers) // if this computer is server if (_pNetwork->IsServer()) { // initialize local client - _cmiComm.Client_Init_t(0UL); + _cmiComm.Client_Init_t((ULONG) 0); // connect as main session state try { Start_AtServer_t(); diff --git a/Sources/Engine/Rendering/Render.cpp b/Sources/Engine/Rendering/Render.cpp index e547ea5..a29f723 100644 --- a/Sources/Engine/Rendering/Render.cpp +++ b/Sources/Engine/Rendering/Render.cpp @@ -710,8 +710,8 @@ void CRenderer::Render(void) // force finishing of all OpenGL pending operations, if required ChangeStatsMode(CStatForm::STI_SWAPBUFFERS); - extern INDEX ogl_iFinish; ogl_iFinish = Clamp( ogl_iFinish, 0L, 3L); - extern INDEX d3d_iFinish; d3d_iFinish = Clamp( d3d_iFinish, 0L, 3L); + extern INDEX ogl_iFinish; ogl_iFinish = Clamp( ogl_iFinish, 0, 3); + extern INDEX d3d_iFinish; d3d_iFinish = Clamp( d3d_iFinish, 0, 3); if( (ogl_iFinish==1 && _pGfx->gl_eCurrentAPI==GAT_OGL) #ifdef SE1_D3D || (d3d_iFinish==1 && _pGfx->gl_eCurrentAPI==GAT_D3D) diff --git a/Sources/Engine/Rendering/RenderModels.cpp b/Sources/Engine/Rendering/RenderModels.cpp index 76bb276..e0630c8 100644 --- a/Sources/Engine/Rendering/RenderModels.cpp +++ b/Sources/Engine/Rendering/RenderModels.cpp @@ -214,9 +214,9 @@ BOOL CRenderer::FindModelLights( CEntity &en, const CPlacement3D &plModel, } // special case for substract sector ambient light if (plsLight->ls_ulFlags&LSF_SUBSTRACTSECTORAMBIENT) { - ubR = (UBYTE)Clamp( (SLONG)ubR-slSAR, 0L, 255L); - ubG = (UBYTE)Clamp( (SLONG)ubG-slSAG, 0L, 255L); - ubB = (UBYTE)Clamp( (SLONG)ubB-slSAB, 0L, 255L); + ubR = (UBYTE)Clamp( (SLONG)ubR-slSAR, 0, 255); + ubG = (UBYTE)Clamp( (SLONG)ubG-slSAG, 0, 255); + ubB = (UBYTE)Clamp( (SLONG)ubB-slSAB, 0, 255); } // calculate light intensity FLOAT fShade = (ubR+ubG+ubB)*(2.0f/(3.0f*255.0f)); @@ -285,17 +285,17 @@ BOOL CRenderer::FindModelLights( CEntity &en, const CPlacement3D &plModel, } } // clamp ambient component - slSAR = Clamp( slSAR, 0L, 255L); - slSAG = Clamp( slSAG, 0L, 255L); - slSAB = Clamp( slSAB, 0L, 255L); + slSAR = Clamp( slSAR, 0, 255); + slSAG = Clamp( slSAG, 0, 255); + slSAB = Clamp( slSAB, 0, 255); // calculate average light properties - SLONG slAR = Clamp( (SLONG)FloatToInt(fTR-fDR) +slSAR, 0L, 255L); - SLONG slAG = Clamp( (SLONG)FloatToInt(fTG-fDG) +slSAG, 0L, 255L); - SLONG slAB = Clamp( (SLONG)FloatToInt(fTB-fDB) +slSAB, 0L, 255L); - SLONG slLR = Clamp( (SLONG)FloatToInt(fDR), 0L, 255L); - SLONG slLG = Clamp( (SLONG)FloatToInt(fDG), 0L, 255L); - SLONG slLB = Clamp( (SLONG)FloatToInt(fDB), 0L, 255L); + SLONG slAR = Clamp( (SLONG)FloatToInt(fTR-fDR) +slSAR, 0, 255); + SLONG slAG = Clamp( (SLONG)FloatToInt(fTG-fDG) +slSAG, 0, 255); + SLONG slAB = Clamp( (SLONG)FloatToInt(fTB-fDB) +slSAB, 0, 255); + SLONG slLR = Clamp( (SLONG)FloatToInt(fDR), 0, 255); + SLONG slLG = Clamp( (SLONG)FloatToInt(fDG), 0, 255); + SLONG slLB = Clamp( (SLONG)FloatToInt(fDB), 0, 255); colLight = RGBToColor( slLR,slLG,slLB); colAmbient = RGBToColor( slAR,slAG,slAB); @@ -352,7 +352,7 @@ void CRenderer::RenderOneModel( CEntity &en, CModelObject &moModel, const CPlace } // let the entity adjust shading parameters if it wants to - mdl_iShadowQuality = Clamp( mdl_iShadowQuality, 0L, 3L); + mdl_iShadowQuality = Clamp( mdl_iShadowQuality, 0, 3); const BOOL bAllowShadows = en.AdjustShadingParameters( vTotalLightDirection, colLight, colAmbient); bRenderModelShadow = (bRenderModelShadow && bAllowShadows && bRenderShadow && mdl_iShadowQuality>0); @@ -479,7 +479,7 @@ void CRenderer::RenderOneSkaModel( CEntity &en, const CPlacement3D &plModel, } // let the entity adjust shading parameters if it wants to - mdl_iShadowQuality = Clamp( mdl_iShadowQuality, 0L, 3L); + mdl_iShadowQuality = Clamp( mdl_iShadowQuality, 0, 3); const BOOL bAllowShadows = en.AdjustShadingParameters( vTotalLightDirection, colLight, colAmbient); bRenderModelShadow = (bRenderModelShadow && bAllowShadows && bRenderShadow && mdl_iShadowQuality>0); @@ -767,7 +767,7 @@ void CRenderer::RenderLensFlares(void) re_pdpDrawPort->SetOrtho(); // if there are no flares or flares are off, do nothing - gfx_iLensFlareQuality = Clamp( gfx_iLensFlareQuality, 0L, 3L); + gfx_iLensFlareQuality = Clamp( gfx_iLensFlareQuality, 0, 3); if( gfx_iLensFlareQuality==0 || re_alfiLensFlares.Count()==0) return; // get drawport ID @@ -932,19 +932,19 @@ void CRenderer::RenderLensFlares(void) }} // for each flare in the lens flare effect // if screen glare is on - CLensFlareType &lft = *lfi.lfi_plsLightSource->ls_plftLensFlare; - FLOAT fGlearCompression = lft.lft_fGlareCompression; + const CLensFlareType &lft = *lfi.lfi_plsLightSource->ls_plftLensFlare; + const FLOAT fGlearCompression = lft.lft_fGlareCompression; if( gfx_iLensFlareQuality>2 && _wrpWorldRenderPrefs.wrp_lftLensFlares >= CWorldRenderPrefs::LFT_REFLECTIONS_AND_GLARE && lft.lft_fGlareIntensity>0.01f) { // calculate glare factor for current position - FLOAT fIntensity = IntensityAtDistance( lfi.lfi_plsLightSource->ls_rFallOff*lft.lft_fGlareFallOffFactor, + const FLOAT fIntensity = IntensityAtDistance( lfi.lfi_plsLightSource->ls_rFallOff*lft.lft_fGlareFallOffFactor, lfi.lfi_plsLightSource->ls_rHotSpot*lft.lft_fGlareFallOffFactor, lfi.lfi_fDistance); - FLOAT fCenterFactor = (1-fOfCenterFadeFactor); - FLOAT fGlare = lft.lft_fGlareIntensity*fIntensity + const FLOAT fCenterFactor = (1-fOfCenterFadeFactor); + const FLOAT fGlare = lft.lft_fGlareIntensity*fIntensity * (exp(1/(1+fGlearCompression*fCenterFactor*fCenterFactor)) -1) / (exp(1)-1); - ULONG ulGlareA = ClampUp( NormFloatToByte(fGlare), 255UL); + const ULONG ulGlareA = ClampUp( (ULONG) NormFloatToByte(fGlare), (ULONG) 255); // if there is any relevant glare if( ulGlareA>1) { // calculate glare color @@ -956,9 +956,9 @@ void CRenderer::RenderLensFlares(void) fGlareR *= fBrightFactor; fGlareG *= fBrightFactor; fGlareB *= fBrightFactor; - ULONG ulGlareR = ClampUp( FloatToInt(fGlareR), 255L); - ULONG ulGlareG = ClampUp( FloatToInt(fGlareG), 255L); - ULONG ulGlareB = ClampUp( FloatToInt(fGlareB), 255L); + ULONG ulGlareR = ClampUp( FloatToInt(fGlareR), 255); + ULONG ulGlareG = ClampUp( FloatToInt(fGlareG), 255); + ULONG ulGlareB = ClampUp( FloatToInt(fGlareB), 255); // add the glare to screen blending re_pdpDrawPort->dp_ulBlendingRA += ulGlareR*ulGlareA; re_pdpDrawPort->dp_ulBlendingGA += ulGlareG*ulGlareA; diff --git a/Sources/Engine/Ska/ModelInstance.cpp b/Sources/Engine/Ska/ModelInstance.cpp index 2c48732..93b5659 100644 --- a/Sources/Engine/Ska/ModelInstance.cpp +++ b/Sources/Engine/Ska/ModelInstance.cpp @@ -182,14 +182,14 @@ ColisionBox &CModelInstance::GetColisionBox(INDEX icb) FLOAT3D CModelInstance::GetCollisionBoxMin(INDEX iCollisionBox/*=0*/) { - INDEX iCollisionBoxClamped = Clamp(iCollisionBox, 0L, mi_cbAABox.Count()-1L); + INDEX iCollisionBoxClamped = Clamp(iCollisionBox, 0, mi_cbAABox.Count()-1); FLOAT3D vMin = mi_cbAABox[ iCollisionBoxClamped].Min(); return vMin; }; FLOAT3D CModelInstance::GetCollisionBoxMax(INDEX iCollisionBox/*=0*/) { - INDEX iCollisionBoxClamped = Clamp(iCollisionBox, 0L, mi_cbAABox.Count()-1L); + INDEX iCollisionBoxClamped = Clamp(iCollisionBox, 0, mi_cbAABox.Count()-1); FLOAT3D vMax = mi_cbAABox[ iCollisionBoxClamped].Max(); return vMax; }; diff --git a/Sources/Engine/Ska/ModelInstance.h b/Sources/Engine/Ska/ModelInstance.h index 7495c56..316795c 100644 --- a/Sources/Engine/Ska/ModelInstance.h +++ b/Sources/Engine/Ska/ModelInstance.h @@ -188,7 +188,7 @@ public: const INDEX &GetID(); // Add animation to last anim queue - void AddAnimation(INDEX iAnimID, DWORD dwFlags, FLOAT fStrength, INDEX iGroupID, FLOAT fSpeedMul = 1.0f); + void AddAnimation(INDEX iAnimID, ULONG ulFlags, FLOAT fStrength, INDEX iGroupID, FLOAT fSpeedMul = 1.0f); // Remove all animations before last animation that has fully faded in void RemovePassedAnimsFromQueue(void); // Remove animation from anim queue diff --git a/Sources/Engine/Ska/RMRender.cpp b/Sources/Engine/Ska/RMRender.cpp index fdd98eb..827648a 100644 --- a/Sources/Engine/Ska/RMRender.cpp +++ b/Sources/Engine/Ska/RMRender.cpp @@ -1907,8 +1907,8 @@ static void MatchAnims(RenModel &rm) } else { if(f>an.an_iFrames) f = an.an_iFrames-1; iCurentFrame = INDEX(f); - iAnimFrame = ClampUp(iCurentFrame,an.an_iFrames-1L); - iNextAnimFrame = ClampUp(iCurentFrame+1L,an.an_iFrames-1L); + iAnimFrame = ClampUp(iCurentFrame,an.an_iFrames-1); + iNextAnimFrame = ClampUp(iCurentFrame+1,an.an_iFrames-1); } // for each bone envelope diff --git a/Sources/Engine/Sound/SoundDecoder.cpp b/Sources/Engine/Sound/SoundDecoder.cpp index ee61191..003ab85 100644 --- a/Sources/Engine/Sound/SoundDecoder.cpp +++ b/Sources/Engine/Sound/SoundDecoder.cpp @@ -148,7 +148,7 @@ static size_t ogg_read_func (void *ptr, size_t size, size_t nmemb, void *dataso // calculate how much can be read at most SLONG slToRead = size*nmemb; SLONG slCurrentPos = ftell(pogg->ogg_fFile)-pogg->ogg_slOffset; - SLONG slSizeLeft = ClampDn(pogg->ogg_slSize-slCurrentPos, 0L); + SLONG slSizeLeft = ClampDn(pogg->ogg_slSize-slCurrentPos, 0); slToRead = ClampUp(slToRead, slSizeLeft); // rounded down to the block size diff --git a/Sources/Engine/Sound/SoundLibrary.cpp b/Sources/Engine/Sound/SoundLibrary.cpp index ff6133c..e8cd0ec 100644 --- a/Sources/Engine/Sound/SoundLibrary.cpp +++ b/Sources/Engine/Sound/SoundLibrary.cpp @@ -442,8 +442,8 @@ static void SndPostFunc(void *pArgs) // clamp variables snd_tmMixAhead = Clamp( snd_tmMixAhead, 0.1f, 0.9f); snd_iFormat = Clamp( snd_iFormat, (INDEX)CSoundLibrary::SF_NONE, (INDEX)CSoundLibrary::SF_44100_16); - snd_iDevice = Clamp( snd_iDevice, -1L, 15L); - snd_iInterface = Clamp( snd_iInterface, 0L, 2L); + snd_iDevice = Clamp( snd_iDevice, -1, 15); + snd_iInterface = Clamp( snd_iInterface, 0, 2); // if any variable has been changed if( _tmLastMixAhead!=snd_tmMixAhead || _iLastFormat!=snd_iFormat || _iLastDevice!=snd_iDevice || _iLastAPI!=snd_iInterface) { @@ -977,9 +977,9 @@ static void SetFormat_internal( CSoundLibrary &sl, CSoundLibrary::SoundFormat Es // set wave format from library format SetWaveFormat( EsfNew, sl.sl_SwfeFormat); - snd_iDevice = Clamp( snd_iDevice, -1L, (INDEX)(sl.sl_ctWaveDevices-1)); + snd_iDevice = Clamp( snd_iDevice, -1, (INDEX)(sl.sl_ctWaveDevices-1)); snd_tmMixAhead = Clamp( snd_tmMixAhead, 0.1f, 0.9f); - snd_iInterface = Clamp( snd_iInterface, 0L, 2L); + snd_iInterface = Clamp( snd_iInterface, 0, 2); BOOL bSoundOK = FALSE; #ifdef PLATFORM_WIN32 diff --git a/Sources/Engine/Sound/SoundMixer.cpp b/Sources/Engine/Sound/SoundMixer.cpp index 1a81457..6a9175a 100644 --- a/Sources/Engine/Sound/SoundMixer.cpp +++ b/Sources/Engine/Sound/SoundMixer.cpp @@ -304,7 +304,7 @@ void NormalizeMixerBuffer( const FLOAT fNormStrength, const SLONG slBytes, FLOAT FLOAT fCurrentNormValue = fLastNormValue; for( i=0; ifNormValue && fNormAdd>0) fCurrentNormValue = fNormValue; diff --git a/Sources/Engine/Sound/SoundObject.cpp b/Sources/Engine/Sound/SoundObject.cpp index 30f150f..9f20aca 100644 --- a/Sources/Engine/Sound/SoundObject.cpp +++ b/Sources/Engine/Sound/SoundObject.cpp @@ -213,7 +213,8 @@ void CSoundObject::Play(CSoundData *pCsdLink, SLONG slFlags) //CPrintF("PLAY: '%s'", (const char*)pCsdLink->GetName().FileName()); // get prediction tail - CSoundObject *psoTail = GetPredictionTail(EVENT_SOUNDPLAY, (ULONG)pCsdLink); + STUBBED("64-bit issue"); + CSoundObject *psoTail = GetPredictionTail(EVENT_SOUNDPLAY, (ULONG)(size_t)pCsdLink); // if the event is predicted if (psoTail==NULL) { // do nothing; @@ -349,7 +350,8 @@ void CSoundObject::Stop(void) CSoundObject *psoTail = this; // get prediction tail - psoTail = GetPredictionTail(EVENT_SOUNDSTOP, (ULONG)so_pCsdLink); + STUBBED("64-bit issue"); + psoTail = GetPredictionTail(EVENT_SOUNDSTOP, (ULONG)(size_t)so_pCsdLink); // if the event is predicted if (psoTail==NULL) { // do nothing; diff --git a/Sources/Engine/Sound/Wave.cpp b/Sources/Engine/Sound/Wave.cpp index 7cd7cac..0c9feff 100644 --- a/Sources/Engine/Sound/Wave.cpp +++ b/Sources/Engine/Sound/Wave.cpp @@ -197,11 +197,13 @@ WAVEFORMATEX PCMWaveInput::LoadInfo_t(CTStream *pCstrInput) SLONG slFmtLength; (*pCstrInput) >> slFmtLength; + ULONG ul = 0; + // read WAVE format (*pCstrInput) >> pwi_wfeWave.wFormatTag; (*pCstrInput) >> pwi_wfeWave.nChannels; - (*pCstrInput) >> pwi_wfeWave.nSamplesPerSec; - (*pCstrInput) >> pwi_wfeWave.nAvgBytesPerSec; + (*pCstrInput) >> ul; pwi_wfeWave.nSamplesPerSec = (DWORD) ul; + (*pCstrInput) >> ul; pwi_wfeWave.nAvgBytesPerSec = (DWORD) ul; (*pCstrInput) >> pwi_wfeWave.nBlockAlign; (*pCstrInput) >> pwi_wfeWave.wBitsPerSample; pwi_wfeWave.cbSize = 0; // Only for PCM Wave !!! diff --git a/Sources/Engine/Templates/BSP.cpp b/Sources/Engine/Templates/BSP.cpp index 577b940..dffaf1f 100644 --- a/Sources/Engine/Templates/BSP.cpp +++ b/Sources/Engine/Templates/BSP.cpp @@ -1132,7 +1132,8 @@ void BSPTree::MoveSubTreeToArray(BSPNode * bnInArray.bn_bnlLocation = pbnSubtree->bn_bnlLocation; bnInArray.bn_ulPlaneTag = pbnSubtree->bn_ulPlaneTag; // let plane tag hold pointer to node in array - pbnSubtree->bn_ulPlaneTag = (ULONG)&bnInArray; + STUBBED("64-bit issue"); + pbnSubtree->bn_ulPlaneTag = (ULONG)(size_t)&bnInArray; // remap pointers to subnodes if (pbnSubtree->bn_pbnFront==NULL) { @@ -1202,7 +1203,8 @@ void BSPTree::Read_t(CTStream &strm) // throw char * // read count of nodes and create array INDEX ctNodes; strm>>ctNodes; - ASSERT(slSize==(SLONG)(sizeof(INDEX)+ctNodes*sizeof(BSPNode))); + // This assert was less silly when it was basically sizeof (*this), but to serialize this across targets, it looks different now. --ryan. + ASSERT(slSize==(SLONG)(sizeof(INDEX)+ctNodes*((sizeof(Type)*(iDimensions+1))+16))); bt_abnNodes.New(ctNodes); // for each node for(INDEX iNode=0; iNodeGetPixWidth() /iTiling, 1L); - INDEX iSrcMipHeight = ClampDn( ptdSrc->GetPixHeight()/iTiling, 1L); + INDEX iSrcMipWidth = ClampDn( ptdSrc->GetPixWidth() /iTiling, 1); + INDEX iSrcMipHeight = ClampDn( ptdSrc->GetPixHeight()/iTiling, 1); // Get mipmap of source texture INDEX immW = FastLog2( ptdSrc->GetPixWidth() / iSrcMipWidth); @@ -1164,8 +1164,8 @@ COLOR CTerrain::GetShadeColor(CShadingInfo *psi) ASSERT(psi!=NULL); ASSERT(tr_auwShadingMap!=NULL); - PIX pixShadowU = Clamp(psi->si_pixShadowU,0L,GetShadingMapWidth()-2L); - PIX pixShadowV = Clamp(psi->si_pixShadowV,0L,GetShadingMapHeight()-2L); + PIX pixShadowU = Clamp(psi->si_pixShadowU,0,GetShadingMapWidth()-2); + PIX pixShadowV = Clamp(psi->si_pixShadowV,0,GetShadingMapHeight()-2); FLOAT fUDRatio = psi->si_fUDRatio; FLOAT fLRRatio = psi->si_fLRRatio; diff --git a/Sources/Engine/Terrain/TerrainEditing.cpp b/Sources/Engine/Terrain/TerrainEditing.cpp index a604994..e425dcb 100644 --- a/Sources/Engine/Terrain/TerrainEditing.cpp +++ b/Sources/Engine/Terrain/TerrainEditing.cpp @@ -128,10 +128,10 @@ void ShowSelectionInternal(CTerrain *ptrTerrain, Rect &rcExtract, CTextureData * Rect rcSelection; FLOATaabbox3D bboxSelection; // Clamp rect used for extraction - rcSelection.rc_iLeft = Clamp(rcExtract.rc_iLeft , 0L, ptrTerrain->tr_pixHeightMapWidth); - rcSelection.rc_iTop = Clamp(rcExtract.rc_iTop , 0L, ptrTerrain->tr_pixHeightMapHeight); - rcSelection.rc_iRight = Clamp(rcExtract.rc_iRight , 0L, ptrTerrain->tr_pixHeightMapWidth); - rcSelection.rc_iBottom = Clamp(rcExtract.rc_iBottom , 0L, ptrTerrain->tr_pixHeightMapHeight); + rcSelection.rc_iLeft = Clamp(rcExtract.rc_iLeft , 0, ptrTerrain->tr_pixHeightMapWidth); + rcSelection.rc_iTop = Clamp(rcExtract.rc_iTop , 0, ptrTerrain->tr_pixHeightMapHeight); + rcSelection.rc_iRight = Clamp(rcExtract.rc_iRight , 0, ptrTerrain->tr_pixHeightMapWidth); + rcSelection.rc_iBottom = Clamp(rcExtract.rc_iBottom , 0, ptrTerrain->tr_pixHeightMapHeight); // Prepare box for vertex selection bboxSelection = FLOAT3D(rcSelection.rc_iLeft, 0, rcSelection.rc_iTop); @@ -302,10 +302,10 @@ UWORD *GetBufferForEditing(CTerrain *ptrTerrain, Rect &rcExtract, BufferType btB UWORD *puwFirstInHeightMap = &ptrTerrain->tr_auwHeightMap[0]; // for each row for(PIX pixY=pixTop;pixYtr_aubEdgeMap[0]; // for each row for(PIX pixY=pixTop;pixYub.r = ClampUp(pacolData->ub.r + ((colLight.ub.r*slDot)>>8),255L); - pacolData->ub.g = ClampUp(pacolData->ub.g + ((colLight.ub.g*slDot)>>8),255L); - pacolData->ub.b = ClampUp(pacolData->ub.b + ((colLight.ub.b*slDot)>>8),255L); + pacolData->ub.r = ClampUp(pacolData->ub.r + ((colLight.ub.r*slDot)>>8),255); + pacolData->ub.g = ClampUp(pacolData->ub.g + ((colLight.ub.g*slDot)>>8),255); + pacolData->ub.b = ClampUp(pacolData->ub.b + ((colLight.ub.b*slDot)>>8),255); pacolData->ub.a = 255; pacolData++; } @@ -810,9 +810,9 @@ static void CalcDirectionalLight(CPlacement3D &plLight, CLightSource *plsLight, // is overbrightning enabled if(bOverBrightning) { - slar = ClampUp(slar,127L); - slag = ClampUp(slag,127L); - slab = ClampUp(slab,127L); + slar = ClampUp(slar,127); + slag = ClampUp(slag,127); + slab = ClampUp(slab,127); ubColShift = 8; } else { slar*=2; @@ -838,9 +838,9 @@ static void CalcDirectionalLight(CPlacement3D &plLight, CLightSource *plsLight, fDot = Clamp(fDot,0.0f,1.0f); SLONG slDot = NormFloatToByte(fDot); - pacolData->ub.r = ClampUp(pacolData->ub.r + slar + ((colLight.ub.r*slDot)>>ubColShift),255L); - pacolData->ub.g = ClampUp(pacolData->ub.g + slag + ((colLight.ub.g*slDot)>>ubColShift),255L); - pacolData->ub.b = ClampUp(pacolData->ub.b + slab + ((colLight.ub.b*slDot)>>ubColShift),255L); + pacolData->ub.r = ClampUp(pacolData->ub.r + slar + ((colLight.ub.r*slDot)>>ubColShift),255); + pacolData->ub.g = ClampUp(pacolData->ub.g + slag + ((colLight.ub.g*slDot)>>ubColShift),255); + pacolData->ub.b = ClampUp(pacolData->ub.b + slab + ((colLight.ub.b*slDot)>>ubColShift),255); pacolData->ub.a = 255; pacolData++; } diff --git a/Sources/EntitiesMP/Common/HUD.cpp b/Sources/EntitiesMP/Common/HUD.cpp index 5b1aaba..e864c51 100644 --- a/Sources/EntitiesMP/Common/HUD.cpp +++ b/Sources/EntitiesMP/Common/HUD.cpp @@ -1138,7 +1138,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO FLOAT fCharHeight = (_pfdDisplayFont->GetHeight()-2)*fTextScale; // generate and sort by mana list of active players BOOL bMaxScore=TRUE, bMaxMana=TRUE, bMaxFrags=TRUE, bMaxDeaths=TRUE; - hud_iSortPlayers = Clamp( hud_iSortPlayers, -1L, 6L); + hud_iSortPlayers = Clamp( hud_iSortPlayers, -1, 6); SortKeys eKey = (SortKeys)hud_iSortPlayers; if (hud_iSortPlayers==-1) { if (bCooperative) eKey = PSK_HEALTH; @@ -1146,7 +1146,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO else if (bFragMatch) eKey = PSK_FRAGS; else { ASSERT(FALSE); eKey = PSK_NAME; } } - if( bCooperative) eKey = (SortKeys)Clamp( (INDEX)eKey, 0L, 3L); + if( bCooperative) eKey = (SortKeys)Clamp( (INDEX)eKey, 0, 3); if( eKey==PSK_HEALTH && (bScoreMatch || bFragMatch)) { eKey = PSK_NAME; }; // prevent health snooping in deathmatch INDEX iPlayers = SetAllPlayersStats(eKey); // loop thru players @@ -1158,8 +1158,8 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO const INDEX iMana = penPlayer->m_iMana; const INDEX iFrags = penPlayer->m_psGameStats.ps_iKills; const INDEX iDeaths = penPlayer->m_psGameStats.ps_iDeaths; - const INDEX iHealth = ClampDn( (INDEX)ceil( penPlayer->GetHealth()), 0L); - const INDEX iArmor = ClampDn( (INDEX)ceil( penPlayer->m_fArmor), 0L); + const INDEX iHealth = ClampDn( (INDEX)ceil( penPlayer->GetHealth()), 0); + const INDEX iArmor = ClampDn( (INDEX)ceil( penPlayer->m_fArmor), 0); CTString strScore, strMana, strFrags, strDeaths, strHealth, strArmor; strScore.PrintF( "%d", iScore); strMana.PrintF( "%d", iMana); diff --git a/Sources/EntitiesMP/Common/Particles.cpp b/Sources/EntitiesMP/Common/Particles.cpp index f92a763..9084eb3 100644 --- a/Sources/EntitiesMP/Common/Particles.cpp +++ b/Sources/EntitiesMP/Common/Particles.cpp @@ -1045,7 +1045,7 @@ void Particles_BeastProjectileTrail( CEntity *pen, FLOAT fSize, FLOAT fHeight, I vZ*(afStarsPositions[iStar][2]*time*fSize*1.5); FLOAT3D vPos = GET_POS( fT); - COLOR colStar = pTD->GetTexel( ClampUp(FloatToInt(fT*8192),8191L), 0); + COLOR colStar = pTD->GetTexel( ClampUp(FloatToInt(fT*8192),8191), 0); if( fT>BEAST_PROJECTILE_LINE_PARTICLES) { @@ -1107,7 +1107,7 @@ void Particles_BeastBigProjectileTrail( CEntity *pen, FLOAT fSize, FLOAT fZOffse vZ*(afStarsPositions[iStar][2]*time*fSize*1.5); FLOAT3D vPos = GET_POS_BIG( fT); - COLOR colStar = pTD->GetTexel( ClampUp(FloatToInt(fT*8192),8191L), 0); + COLOR colStar = pTD->GetTexel( ClampUp(FloatToInt(fT*8192),8191), 0); if( fT>BIG_BEAST_PROJECTILE_LINE_PARTICLES) { @@ -3493,7 +3493,7 @@ void Particles_LavaFlow( CEntity *pen, FLOAT fStretchAll, FLOAT fSize, FLOAT fHe vY*(fT*fT*-4.0f+(afStarsPositions[iStar][1]*fPowerFactor*0.1)) + vZ*(afStarsPositions[iStar][2]*fPowerFactor*fT*fStretchAll); - COLOR colLava = pTD->GetTexel( ClampUp(FloatToInt(fT*2048),2047L), 0); + COLOR colLava = pTD->GetTexel( ClampUp(FloatToInt(fT*2048),2047), 0); ULONG ulA = FloatToInt( ((colLava&CT_AMASK)>>CT_ASHIFT) * fFade); colLava = (colLava&~CT_AMASK) | (ulA<GetLerpFactor())*_pTimer->TickQuantum; FLOAT fRatio=fT/(CT_AFTERBURNER_SMOKES*_pTimer->TickQuantum); INDEX iIndex=(INDEX) (fRatio*255); - INDEX iRnd=INDEX(pvPos1)%CT_MAX_PARTICLES_TABLE; + INDEX iRnd=(INDEX)(size_t(pvPos1)%CT_MAX_PARTICLES_TABLE); // smoke FLOAT3D vPosS = *pvPos1; @@ -5972,7 +5972,7 @@ void Particles_RunAfterBurner(CEntity *pen, FLOAT tmEnd, FLOAT fStretch, INDEX i FLOAT fT=(iPos+_pTimer->GetLerpFactor())*_pTimer->TickQuantum; FLOAT fRatio=fT/(CT_AFTERBURNER_SMOKES*_pTimer->TickQuantum); INDEX iIndex=(INDEX) (fRatio*255); - INDEX iRnd=INDEX(pvPos1)%CT_MAX_PARTICLES_TABLE; + INDEX iRnd=(INDEX)(size_t(pvPos1)%CT_MAX_PARTICLES_TABLE); // smoke FLOAT3D vPosS = *pvPos1; diff --git a/Sources/EntitiesMP/Player.es b/Sources/EntitiesMP/Player.es index d27068a..ef90ebf 100644 --- a/Sources/EntitiesMP/Player.es +++ b/Sources/EntitiesMP/Player.es @@ -1643,7 +1643,9 @@ functions: CTString GetStatsRealWorldStarted(void) { struct tm *newtime; - newtime = localtime(&m_iStartTime); + STUBBED("this isn't 64-bit clean"); + time_t t = (time_t) m_iStartTime; + newtime = localtime(&t); setlocale(LC_ALL, ""); CTString strTimeline; @@ -2663,7 +2665,7 @@ functions: void RenderGameView(CDrawPort *pdp, void *pvUserData) { - BOOL bShowExtras = (ULONG(pvUserData)&GRV_SHOWEXTRAS); + BOOL bShowExtras = (size_t(pvUserData)&GRV_SHOWEXTRAS) != 0; pdp->Unlock(); // if not yet initialized @@ -5370,7 +5372,10 @@ functions: m_iMayRespawn = 0; m_bEndOfLevel = TRUE; // remember end time - time(&m_iEndTime); + STUBBED("Not 64-bit clean"); + time_t t; + time(&t); + m_iEndTime = (INDEX) t; // add time score TIME tmLevelTime = _pTimer->CurrentTick()-m_tmLevelStarted; m_psLevelStats.ps_tmTime = tmLevelTime; @@ -6552,8 +6557,10 @@ procedures: Main(EVoid evoid) { // remember start time - time(&m_iStartTime); - + STUBBED("Not 64-bit clean"); + time_t t; + time(&t); + m_iStartTime = (INDEX) t; m_ctUnreadMessages = 0; SetFlags(GetFlags()|ENF_CROSSESLEVELS|ENF_NOTIFYLEVELCHANGE); InitAsEditorModel(); diff --git a/Sources/GameMP/Computer.cpp b/Sources/GameMP/Computer.cpp index c437033..3757878 100644 --- a/Sources/GameMP/Computer.cpp +++ b/Sources/GameMP/Computer.cpp @@ -272,11 +272,11 @@ void MessagesUpDn(INDEX ctLines) { INDEX ctMessages = _acmMessages.Count(); _iWantedFirstMessageOnScreen += ctLines; - INDEX iMaxFirst = ClampDn(0L, ctMessages-_ctMessagesOnScreen); - _iWantedFirstMessageOnScreen = Clamp(_iWantedFirstMessageOnScreen, 0L, iMaxFirst); + INDEX iMaxFirst = ClampDn(0, ctMessages-_ctMessagesOnScreen); + _iWantedFirstMessageOnScreen = Clamp(_iWantedFirstMessageOnScreen, 0, iMaxFirst); _iActiveMessage = Clamp(_iActiveMessage, _iWantedFirstMessageOnScreen, - _iWantedFirstMessageOnScreen+_ctMessagesOnScreen-1L); + _iWantedFirstMessageOnScreen+_ctMessagesOnScreen-1); } void SelectMessage(INDEX i) @@ -506,7 +506,7 @@ static void UpdateSize(CDrawPort *pdp) _boxMsgImage= PIXaabbox2D(); } - FLOAT fSlideSpeed = Max(_pixSizeI, _pixSizeJ*2L); + FLOAT fSlideSpeed = Max(_pixSizeI, _pixSizeJ*2); FLOAT fGroup0 = ClampDn((1-fComputerFadeValue)*fSlideSpeed-_pixSizeJ, 0.0f); FLOAT fGroup1 = (1-fComputerFadeValue)*fSlideSpeed; // animate box positions @@ -1193,8 +1193,8 @@ void CGame::ComputerRender(CDrawPort *pdp) _pGfx->GetCurrentDisplayMode(dmCurrent); if (dmCurrent.IsFullScreen() && dmCurrent.IsDualHead()) { // clamp mouse pointer - _vpixMouse(1) = Clamp(_vpixMouse(1), 0L, dpComp.GetWidth()); - _vpixMouse(2) = Clamp(_vpixMouse(2), 0L, dpComp.GetHeight()); + _vpixMouse(1) = Clamp(_vpixMouse(1), 0, dpComp.GetWidth()); + _vpixMouse(2) = Clamp(_vpixMouse(2), 0, dpComp.GetHeight()); // if in window } else { // use same mouse pointer as windows diff --git a/Sources/GameMP/Console.cpp b/Sources/GameMP/Console.cpp index 3b5c6b9..75d1b89 100644 --- a/Sources/GameMP/Console.cpp +++ b/Sources/GameMP/Console.cpp @@ -193,7 +193,7 @@ void CGame::ConsoleRender(CDrawPort *pdp) } // render previous outputs - con_iFirstLine = ClampDn( con_iFirstLine, 1L); + con_iFirstLine = ClampDn( con_iFirstLine, 1); pixYLine -= (PIX)(pixLineSpacing * 1.333f); ctConsoleLinesOnScreen = pixYLine/pixLineSpacing; while( pixYLine >= 0) { @@ -519,7 +519,7 @@ static void Key_PgDn( BOOL bShift) { if( bShift) con_iFirstLine -= ctConsoleLinesOnScreen; else con_iFirstLine--; - con_iFirstLine = ClampDn( con_iFirstLine, 1L); + con_iFirstLine = ClampDn( con_iFirstLine, 1); } diff --git a/Sources/GameMP/Game.cpp b/Sources/GameMP/Game.cpp index 52a328e..008c367 100644 --- a/Sources/GameMP/Game.cpp +++ b/Sources/GameMP/Game.cpp @@ -201,7 +201,7 @@ CEnableUserBreak::~CEnableUserBreak() { static void DumpDemoProfile(void) { CTString strFragment, strAnalyzed; - dem_iProfileRate = Clamp( dem_iProfileRate, 0L, 60L); + dem_iProfileRate = Clamp( dem_iProfileRate, 0, 60); strFragment = _pGame->DemoReportFragmentsProfile( dem_iProfileRate); strAnalyzed = _pGame->DemoReportAnalyzedProfile(); try { @@ -225,7 +225,7 @@ static void DumpDemoProfile(void) static void ReportDemoProfile(void) { CTString strFragment, strAnalyzed; - dem_iProfileRate = Clamp( dem_iProfileRate, 0L, 60L); + dem_iProfileRate = Clamp( dem_iProfileRate, 0, 60); strFragment = _pGame->DemoReportFragmentsProfile( dem_iProfileRate); strAnalyzed = _pGame->DemoReportAnalyzedProfile(); CPrintF( strFragment); @@ -1896,7 +1896,7 @@ static void PrintStats( CDrawPort *pdpDrawPort) } // if stats aren't required - hud_iStats = Clamp( hud_iStats, 0L, 2L); + hud_iStats = Clamp( hud_iStats, 0, 2); if( hud_iStats==0 || (hud_iEnableStats==0 && hud_fEnableFPS==0)) { // display nothing _iCheckNow = 0; @@ -1979,7 +1979,7 @@ static void MakeSplitDrawports(enum CGame::SplitScreenCfg ssc, INDEX iCount, CDr // if observer if (ssc==CGame::SSC_OBSERVER) { // must have at least one screen - iCount = Clamp(iCount, 1L, 4L); + iCount = Clamp(iCount, 1, 4); // starting at first drawport iFirstObserver = 0; } @@ -2185,10 +2185,10 @@ void CGame::GameRedrawView( CDrawPort *pdpDrawPort, ULONG ulFlags) && gm_CurrentSplitScreenCfg!=SSC_DEDICATED ) { - INDEX ctObservers = Clamp(gam_iObserverConfig, 0L, 4L); - INDEX iObserverOffset = ClampDn(gam_iObserverOffset, 0L); + INDEX ctObservers = Clamp(gam_iObserverConfig, 0, 4); + INDEX iObserverOffset = ClampDn(gam_iObserverOffset, 0); if (gm_CurrentSplitScreenCfg==SSC_OBSERVER) { - ctObservers = ClampDn(ctObservers, 1L); + ctObservers = ClampDn(ctObservers, 1); } if (gm_CurrentSplitScreenCfg!=SSC_OBSERVER) { if (!gam_bEnableAdvancedObserving || !GetSP()->sp_bCooperative) { @@ -2294,7 +2294,7 @@ void CGame::GameRedrawView( CDrawPort *pdpDrawPort, ULONG ulFlags) if (!CAM_IsOn()) { _bPlayerViewRendered = TRUE; // render it - apenViewers[i]->RenderGameView(pdp, (void*)ulFlags); + apenViewers[i]->RenderGameView(pdp, (void*)((size_t)ulFlags)); } else { CAM_Render(apenViewers[i], pdp); } diff --git a/Sources/GameMP/SessionProperties.cpp b/Sources/GameMP/SessionProperties.cpp index 7a72abb..9474f0f 100644 --- a/Sources/GameMP/SessionProperties.cpp +++ b/Sources/GameMP/SessionProperties.cpp @@ -53,7 +53,7 @@ extern CTString gam_strGameAgentExtras; static void SetGameModeParameters(CSessionProperties &sp) { - sp.sp_gmGameMode = (CSessionProperties::GameMode) Clamp(INDEX(gam_iStartMode), -1L, 2L); + sp.sp_gmGameMode = (CSessionProperties::GameMode) Clamp(INDEX(gam_iStartMode), -1, 2); switch (sp.sp_gmGameMode) { default: @@ -79,7 +79,7 @@ static void SetDifficultyParameters(CSessionProperties &sp) } else { sp.sp_bMental = FALSE; } - sp.sp_gdGameDifficulty = (CSessionProperties::GameDifficulty) Clamp(INDEX(iDifficulty), -1L, 3L); + sp.sp_gdGameDifficulty = (CSessionProperties::GameDifficulty) Clamp(INDEX(iDifficulty), -1, 3); switch (sp.sp_gdGameDifficulty) { case CSessionProperties::GD_TOURIST: @@ -163,7 +163,7 @@ void CGame::SetSinglePlayerSession(CSessionProperties &sp) sp.sp_fExtraEnemyStrength = 0; sp.sp_fExtraEnemyStrengthPerPlayer = 0; - sp.sp_iBlood = Clamp( gam_iBlood, 0L, 3L); + sp.sp_iBlood = Clamp( gam_iBlood, 0, 3); sp.sp_bGibs = gam_bGibs; } @@ -218,7 +218,7 @@ void CGame::SetMultiPlayerSession(CSessionProperties &sp) sp.sp_fExtraEnemyStrengthPerPlayer = gam_fExtraEnemyStrengthPerPlayer; sp.sp_iInitialMana = gam_iInitialMana; - sp.sp_iBlood = Clamp( gam_iBlood, 0L, 3L); + sp.sp_iBlood = Clamp( gam_iBlood, 0, 3); sp.sp_bGibs = gam_bGibs; sp.sp_tmSpawnInvulnerability = gam_tmSpawnInvulnerability; diff --git a/Sources/SeriousSam/GLSettings.cpp b/Sources/SeriousSam/GLSettings.cpp index 3e28c65..2b17080 100644 --- a/Sources/SeriousSam/GLSettings.cpp +++ b/Sources/SeriousSam/GLSettings.cpp @@ -152,7 +152,7 @@ extern void ApplyGLSettings(BOOL bForce) } // clamp rendering preferences (just to be on the safe side) - sam_iVideoSetup = Clamp( sam_iVideoSetup, 0L, 3L); + sam_iVideoSetup = Clamp( sam_iVideoSetup, 0, 3); CPrintF(TRANSV("Mode: %s\n"), (const char *) RenderingPreferencesDescription(sam_iVideoSetup)); // if not in custom mode if (sam_iVideoSetup<3) { diff --git a/Sources/SeriousSam/Menu.cpp b/Sources/SeriousSam/Menu.cpp index 3977b82..a5d450f 100644 --- a/Sources/SeriousSam/Menu.cpp +++ b/Sources/SeriousSam/Menu.cpp @@ -2050,7 +2050,7 @@ void RefreshSoundFormat( void) } mgAudioAutoTrigger.mg_iSelected = Clamp(sam_bAutoAdjustAudio, 0, 1); - mgAudioAPITrigger.mg_iSelected = Clamp(_pShell->GetINDEX("snd_iInterface"), 0L, 2L); + mgAudioAPITrigger.mg_iSelected = Clamp(_pShell->GetINDEX("snd_iInterface"), 0, 2); mgWaveVolume.mg_iMinPos = 0; mgWaveVolume.mg_iMaxPos = VOLUME_STEPS; @@ -2564,8 +2564,8 @@ BOOL DoMenu( CDrawPort *pdp) _pGfx->GetCurrentDisplayMode(dmCurrent); if (dmCurrent.IsFullScreen()) { // clamp mouse pointer - _pixCursorPosI = Clamp(_pixCursorPosI, 0L, dpMenu.GetWidth()); - _pixCursorPosJ = Clamp(_pixCursorPosJ, 0L, dpMenu.GetHeight()); + _pixCursorPosI = Clamp(_pixCursorPosI, 0, dpMenu.GetWidth()); + _pixCursorPosJ = Clamp(_pixCursorPosJ, 0, dpMenu.GetHeight()); // if in window } else { // use same mouse pointer as windows @@ -3020,7 +3020,7 @@ void CGameMenu::StartMenu(void) // scroll it so that the wanted tem is centered gm_iListOffset = gm_iListWantedItem-gm_ctListVisible/2; // clamp the scrolling - gm_iListOffset = Clamp(gm_iListOffset, 0L, Max(0L, gm_ctListTotal-gm_ctListVisible)); + gm_iListOffset = Clamp(gm_iListOffset, 0, Max(0, gm_ctListTotal-gm_ctListVisible)); // fill the list FillListItems(); @@ -5660,7 +5660,7 @@ void CNetworkStartMenu::StartMenu(void) extern INDEX sam_bMentalActivated; mgNetworkDifficulty.mg_ctTexts = sam_bMentalActivated?6:5; - mgNetworkGameType.mg_iSelected = Clamp(_pShell->GetINDEX("gam_iStartMode"), 0L, ctGameTypeRadioTexts-1L); + mgNetworkGameType.mg_iSelected = Clamp(_pShell->GetINDEX("gam_iStartMode"), 0, ctGameTypeRadioTexts-1); mgNetworkGameType.ApplyCurrentSelection(); mgNetworkDifficulty.mg_iSelected = _pShell->GetINDEX("gam_iStartDifficulty")+1; mgNetworkDifficulty.ApplyCurrentSelection(); @@ -5676,7 +5676,7 @@ void CNetworkStartMenu::StartMenu(void) mgNetworkMaxPlayers.mg_iSelected = ctMaxPlayers-2; mgNetworkMaxPlayers.ApplyCurrentSelection(); - mgNetworkWaitAllPlayers.mg_iSelected = Clamp(_pShell->GetINDEX("gam_bWaitAllPlayers"), 0L, 1L); + mgNetworkWaitAllPlayers.mg_iSelected = Clamp(_pShell->GetINDEX("gam_bWaitAllPlayers"), 0, 1); mgNetworkWaitAllPlayers.ApplyCurrentSelection(); mgNetworkVisible.mg_iSelected = _pShell->GetINDEX("ser_bEnumeration"); @@ -6131,13 +6131,13 @@ void CSplitStartMenu::StartMenu(void) extern INDEX sam_bMentalActivated; mgSplitDifficulty.mg_ctTexts = sam_bMentalActivated?6:5; - mgSplitGameType.mg_iSelected = Clamp(_pShell->GetINDEX("gam_iStartMode"), 0L, ctGameTypeRadioTexts-1L); + mgSplitGameType.mg_iSelected = Clamp(_pShell->GetINDEX("gam_iStartMode"), 0, ctGameTypeRadioTexts-1); mgSplitGameType.ApplyCurrentSelection(); mgSplitDifficulty.mg_iSelected = _pShell->GetINDEX("gam_iStartDifficulty")+1; mgSplitDifficulty.ApplyCurrentSelection(); // clamp maximum number of players to at least 4 - _pShell->SetINDEX("gam_ctMaxPlayers", ClampDn(_pShell->GetINDEX("gam_ctMaxPlayers"), 4L)); + _pShell->SetINDEX("gam_ctMaxPlayers", ClampDn(_pShell->GetINDEX("gam_ctMaxPlayers"), 4)); UpdateSplitLevel(0); CGameMenu::StartMenu(); diff --git a/Sources/SeriousSam/MenuGadgets.cpp b/Sources/SeriousSam/MenuGadgets.cpp index c5d0c96..3834563 100644 --- a/Sources/SeriousSam/MenuGadgets.cpp +++ b/Sources/SeriousSam/MenuGadgets.cpp @@ -267,7 +267,7 @@ void CMGButton::Render( CDrawPort *pdp) if (pdp->dp_FontData->fd_bFixedWidth) { str = str.Undecorated(); INDEX iLen = str.Length(); - INDEX iMaxLen = ClampDn(box.Size()(1)/(pdp->dp_pixTextCharSpacing+pdp->dp_FontData->fd_pixCharWidth), 1L); + INDEX iMaxLen = ClampDn(box.Size()(1)/(pdp->dp_pixTextCharSpacing+pdp->dp_FontData->fd_pixCharWidth), 1); if (iCursor>=iMaxLen) { str.TrimRight(iCursor); str.TrimLeft(iMaxLen); @@ -526,7 +526,7 @@ BOOL CMGEdit::OnChar( MSG msg) // only chars are allowed const INDEX ctFullLen = mg_strText.Length(); const INDEX ctNakedLen = mg_strText.LengthNaked(); - mg_iCursorPos = Clamp( mg_iCursorPos, 0L, ctFullLen); + mg_iCursorPos = Clamp( mg_iCursorPos, 0, ctFullLen); int iVKey = msg.wParam; if( isprint(iVKey) && ctNakedLen<=mg_ctMaxStringLen) { mg_strText.InsertChar( mg_iCursorPos, (char)iVKey); @@ -704,7 +704,7 @@ CMGTrigger::CMGTrigger( void) void CMGTrigger::ApplyCurrentSelection(void) { - mg_iSelected = Clamp(mg_iSelected, 0L, mg_ctTexts-1L); + mg_iSelected = Clamp(mg_iSelected, 0, mg_ctTexts-1); mg_strValue = mg_astrTexts[ mg_iSelected]; } @@ -1302,13 +1302,13 @@ CMGServerList::CMGServerList() void CMGServerList::AdjustFirstOnScreen(void) { INDEX ctSessions = _lhServers.Count(); - mg_iSelected = Clamp(mg_iSelected, 0L, ClampDn(ctSessions-1L, 0L)); - mg_iFirstOnScreen = Clamp(mg_iFirstOnScreen, 0L, ClampDn(ctSessions-mg_ctOnScreen, 0L)); + mg_iSelected = Clamp(mg_iSelected, 0, ClampDn(ctSessions-1, 0)); + mg_iFirstOnScreen = Clamp(mg_iFirstOnScreen, 0, ClampDn(ctSessions-mg_ctOnScreen, 0)); if (mg_iSelected=mg_iFirstOnScreen+mg_ctOnScreen) { - mg_iFirstOnScreen = ClampDn(mg_iSelected-mg_ctOnScreen+1L, 0L); + mg_iFirstOnScreen = ClampDn(mg_iSelected-mg_ctOnScreen+1, 0); } } @@ -1572,8 +1572,8 @@ void CMGServerList::OnMouseOver(PIX pixI, PIX pixJ) INDEX ctSessions = _lhServers.Count(); INDEX iWantedLine = mg_iDragLine+ SliderPixToIndex(pixDelta, mg_ctOnScreen, ctSessions, GetScrollBarFullBox()); - mg_iFirstOnScreen = Clamp(iWantedLine, 0L, ClampDn(ctSessions-mg_ctOnScreen, 0L)); - mg_iSelected = Clamp(mg_iSelected, mg_iFirstOnScreen, mg_iFirstOnScreen+mg_ctOnScreen-1L); + mg_iFirstOnScreen = Clamp(iWantedLine, 0, ClampDn(ctSessions-mg_ctOnScreen, 0)); + mg_iSelected = Clamp(mg_iSelected, mg_iFirstOnScreen, mg_iFirstOnScreen+mg_ctOnScreen-1); // AdjustFirstOnScreen(); return; } diff --git a/Sources/SeriousSam/SeriousSam.cpp b/Sources/SeriousSam/SeriousSam.cpp index 31ec35b..68547c9 100644 --- a/Sources/SeriousSam/SeriousSam.cpp +++ b/Sources/SeriousSam/SeriousSam.cpp @@ -273,12 +273,12 @@ void LimitFrameRate(void) TIME tmCurrentDelta = (tvNow-tvLast).GetSeconds(); // limit maximum frame rate - sam_iMaxFPSActive = ClampDn( (INDEX)sam_iMaxFPSActive, 1L); - sam_iMaxFPSInactive = ClampDn( (INDEX)sam_iMaxFPSInactive, 1L); + sam_iMaxFPSActive = ClampDn( (INDEX)sam_iMaxFPSActive, 1); + sam_iMaxFPSInactive = ClampDn( (INDEX)sam_iMaxFPSInactive, 1); INDEX iMaxFPS = sam_iMaxFPSActive; if( IsIconic(_hwndMain)) iMaxFPS = sam_iMaxFPSInactive; if(_pGame->gm_CurrentSplitScreenCfg==CGame::SSC_DEDICATED) { - iMaxFPS = ClampDn(iMaxFPS, 60L); // never go very slow if dedicated server + iMaxFPS = ClampDn(iMaxFPS, 60); // never go very slow if dedicated server } TIME tmWantedDelta = 1.0f / iMaxFPS; if( tmCurrentDeltaSleep( (tmWantedDelta-tmCurrentDelta)*1000.0f); diff --git a/Sources/SeriousSam/VarList.cpp b/Sources/SeriousSam/VarList.cpp index 409c2f4..012f214 100644 --- a/Sources/SeriousSam/VarList.cpp +++ b/Sources/SeriousSam/VarList.cpp @@ -258,7 +258,7 @@ BOOL CVarSetting::Validate(void) return FALSE; } if (!vs_bCustom) { - vs_iValue = Clamp(vs_iValue, 0L, vs_ctValues-1L); + vs_iValue = Clamp(vs_iValue, 0, vs_ctValues-1); } return TRUE; } diff --git a/Sources/Shaders/Common.cpp b/Sources/Shaders/Common.cpp index d304f67..957c422 100644 --- a/Sources/Shaders/Common.cpp +++ b/Sources/Shaders/Common.cpp @@ -41,9 +41,9 @@ void DoSpecularLayer(INDEX iSpeculaTexture,INDEX iSpecularColor) SLONG slAG = (colAmbient & CT_GMASK)>>(CT_GSHIFT-iBright); SLONG slAB = (colAmbient & CT_BMASK)>>(CT_BSHIFT-iBright); if( bOverbright) { - slAR = ClampUp( slAR, 127L); - slAG = ClampUp( slAG, 127L); - slAB = ClampUp( slAB, 127L); + slAR = ClampUp( slAR, 127); + slAG = ClampUp( slAG, 127); + slAB = ClampUp( slAB, 127); } @@ -70,9 +70,9 @@ void DoSpecularLayer(INDEX iSpeculaTexture,INDEX iSpecularColor) GFXColor colSrfSpec = shaGetColor(iSpecularColor); colSrfSpec.AttenuateRGB( (shaGetModelColor()&CT_AMASK)>>CT_ASHIFT); - colSrfSpec.ub.r = ClampUp( (colSrfSpec.ub.r *slLR)>>8, 255L); - colSrfSpec.ub.g = ClampUp( (colSrfSpec.ub.g *slLG)>>8, 255L); - colSrfSpec.ub.b = ClampUp( (colSrfSpec.ub.b *slLB)>>8, 255L); + colSrfSpec.ub.r = ClampUp( (colSrfSpec.ub.r *slLR)>>8, 255); + colSrfSpec.ub.g = ClampUp( (colSrfSpec.ub.g *slLG)>>8, 255); + colSrfSpec.ub.b = ClampUp( (colSrfSpec.ub.b *slLB)>>8, 255); GFXColor *pcolSpec = shaGetNewColorArray(); GFXColor *pcolBase = shaGetColorArray();; diff --git a/Sources/build-linux.sh b/Sources/build-linux.sh index 0890a0c..467fb9f 100755 --- a/Sources/build-linux.sh +++ b/Sources/build-linux.sh @@ -12,6 +12,12 @@ mkdir $_ cd $_ #cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 .. #ninja + +# This is the eventual path for amd64. +#cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_I386_ASM=FALSE .. + +# Right now we force x86, though... cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 .. + make -j$NCPU