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.
This commit is contained in:
Ryan C. Gordon 2016-04-06 23:16:30 -04:00
parent 70f3f7fe35
commit 9820436fbe
67 changed files with 348 additions and 320 deletions

View File

@ -635,8 +635,8 @@ ENGINE_API void CAnimObject::Synchronize(CAnimObject &aoOther)
// copy animations, time and flags // copy animations, time and flags
INDEX ctAnims = GetAnimsCt(); INDEX ctAnims = GetAnimsCt();
ao_tmAnimStart = aoOther.ao_tmAnimStart; ao_tmAnimStart = aoOther.ao_tmAnimStart;
ao_iCurrentAnim = ClampUp(aoOther.ao_iCurrentAnim, ctAnims-1L); ao_iCurrentAnim = ClampUp(aoOther.ao_iCurrentAnim, ctAnims-1);
ao_iLastAnim = ClampUp(aoOther.ao_iLastAnim, ctAnims-1L); ao_iLastAnim = ClampUp(aoOther.ao_iLastAnim, ctAnims-1);
ao_ulFlags = aoOther.ao_ulFlags; ao_ulFlags = aoOther.ao_ulFlags;
} }
@ -1102,12 +1102,12 @@ void CAnimObject::GetFrame( INDEX &iFrame0, INDEX &iFrame1, FLOAT &fRatio) const
INDEX iAnim = ao_iCurrentAnim; INDEX iAnim = ao_iCurrentAnim;
((CAnimObject*)this)->ao_iCurrentAnim = ao_iLastAnim; ((CAnimObject*)this)->ao_iCurrentAnim = ao_iLastAnim;
float fFrameNow = tmCurrentRelative/pOA0->oa_SecsPerFrame+pOA0->oa_NumberOfFrames; 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); INDEX iFrameNext = SLONG(fFrameNow+1);
if (iFrameNext>=pOA0->oa_NumberOfFrames) { if (iFrameNext>=pOA0->oa_NumberOfFrames) {
iFrame1 = pOA1->oa_FrameIndices[0]; iFrame1 = pOA1->oa_FrameIndices[0];
} else { } 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; ((CAnimObject*)this)->ao_iCurrentAnim = iAnim;
fRatio = fFrameNow - (float)floor(fFrameNow); fRatio = fFrameNow - (float)floor(fFrameNow);

View File

@ -133,7 +133,7 @@ INDEX CConsole::NumberOfLinesAfter(TIME tmLast)
return 0; return 0;
} }
// clamp console variable // 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 // find number of last console lines to be displayed on screen
for(INDEX i=0; i<con_iLastLines; i++) { for(INDEX i=0; i<con_iLastLines; i++) {
if (con_atmLines[con_ctLines-1-i]<tmLast) { if (con_atmLines[con_ctLines-1-i]<tmLast) {
@ -197,7 +197,7 @@ void CConsole::ScrollBufferUp(INDEX ctLines)
con_atmLines, con_atmLines,
con_atmLines+ctLines, con_atmLines+ctLines,
(con_ctLines-ctLines)*sizeof(TIME)); (con_ctLines-ctLines)*sizeof(TIME));
con_ctLinesPrinted = ClampUp(con_ctLinesPrinted+1L, con_ctLines); con_ctLinesPrinted = ClampUp(con_ctLinesPrinted+1, con_ctLines);
// clear lines at the end // clear lines at the end
for(INDEX iLine=con_ctLines-ctLines; iLine<con_ctLines; iLine++) { for(INDEX iLine=con_ctLines-ctLines; iLine<con_ctLines; iLine++) {
ClearLine(iLine); ClearLine(iLine);

View File

@ -168,22 +168,22 @@ void CListHead::Sort(int (*pCompare)(const void *p0, const void *p1), int iNodeO
} }
// create array of that much integers (the array will hold pointers to the list) // create array of that much integers (the array will hold pointers to the list)
ULONG *aulPointers = new ULONG[ctCount]; size_t *aulPointers = new size_t[ctCount];
// fill it // fill it
INDEX i=0; INDEX i=0;
for ( CListIter<int, 0> iter(*this); !iter.IsPastEnd(); iter.MoveToNext() ) { for ( CListIter<int, 0> iter(*this); !iter.IsPastEnd(); iter.MoveToNext() ) {
aulPointers[i] = ((ULONG)&*iter)-iNodeOffset; aulPointers[i] = ((size_t)&*iter)-iNodeOffset;
i++; i++;
} }
// sort it // sort it
qsort(aulPointers, ctCount, sizeof(SLONG), pCompare); qsort(aulPointers, ctCount, sizeof(aulPointers[0]), pCompare);
// make temporary list // make temporary list
CListHead lhTmp; CListHead lhTmp;
// for each pointer // for each pointer
{for(INDEX i=0; i<ctCount; i++) { {for(INDEX i=0; i<ctCount; i++) {
ULONG ul = aulPointers[i]; const size_t ul = aulPointers[i];
// get the node // get the node
CListNode *pln = (CListNode*)(ul+iNodeOffset); CListNode *pln = (CListNode*)(ul+iNodeOffset);
// remove it from original list // remove it from original list

View File

@ -128,14 +128,15 @@ void *_debug_AllocMemory( SLONG memsize, int iType, const char *strFile, int iLi
void *AllocMemoryAligned( SLONG memsize, SLONG slAlignPow2) void *AllocMemoryAligned( SLONG memsize, SLONG slAlignPow2)
{ {
ULONG ulMem = (ULONG)AllocMemory(memsize+slAlignPow2*2); ASSERT(slAlignPow2 >= (sizeof (void*) * 2));
ULONG ulMemAligned = ((ulMem+slAlignPow2-1) & ~(slAlignPow2-1)) + slAlignPow2; size_t ulMem = (size_t)AllocMemory(memsize+slAlignPow2*2);
((ULONG *)ulMemAligned)[-1] = ulMem; size_t ulMemAligned = ((ulMem+slAlignPow2-1) & ~(slAlignPow2-1)) + slAlignPow2;
((size_t *)ulMemAligned)[-1] = ulMem;
return (void*)ulMemAligned; return (void*)ulMemAligned;
} }
void FreeMemoryAligned( void *memory) void FreeMemoryAligned( void *memory)
{ {
FreeMemory((void*) ( ( (ULONG*)memory )[-1] ) ); FreeMemory((void*) ( ( (size_t*)memory )[-1] ) );
} }
void FreeMemory( void *memory ) void FreeMemory( void *memory )

View File

@ -24,11 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <Engine/Templates/DynamicArray.h> #include <Engine/Templates/DynamicArray.h>
#include <Engine/Base/Shell_internal.h> #include <Engine/Base/Shell_internal.h>
#if 0 #define NEXTARGUMENT(type) ( *((type*)((char*)&pArgs)) ); pArgs = (void*) (((char*)pArgs) + sizeof(void*));
#define NEXTARGUMENT(type) ( *((type*&)pArgs)++ )
#else
#define NEXTARGUMENT(type) ( *((type*)&pArgs) ); pArgs+=sizeof(void*);
#endif
// Object that takes care of shell functions, variables, macros etc. // Object that takes care of shell functions, variables, macros etc.
class ENGINE_API CShell { class ENGINE_API CShell {

View File

@ -157,7 +157,7 @@ public:
inline CTStream &operator>>(SLONG &sl) { Read_t(&sl, sizeof(sl)); BYTESWAP(sl); return *this; } // throw char * 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>>(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>>(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>>(__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 * inline CTStream &operator>>(__uint64 i) { Read_t( &i, sizeof( i)); BYTESWAP( i); return *this; } // throw char *
/* Write an object into stream. */ /* 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<<(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<<(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<<(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<<(__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 * inline CTStream &operator<<(__uint64 i) { BYTESWAP( i); Write_t( &i, sizeof( i)); return *this; } // throw char *

View File

@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <Engine/Base/ListIterator.inl> #include <Engine/Base/ListIterator.inl>
#include <Engine/Base/Priority.inl> #include <Engine/Base/Priority.inl>
// !!! FIXME: use SDL timer code instead and rdtsc never?
#if (USE_PORTABLE_C) #if (USE_PORTABLE_C)
#define USE_GETTIMEOFDAY 1 #define USE_GETTIMEOFDAY 1
#endif #endif

View File

@ -26,12 +26,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <Engine/Base/Base.h> #include <Engine/Base/Base.h>
#include <Engine/Graphics/gl_types.h> #include <Engine/Graphics/gl_types.h>
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 short int SWORD;
typedef signed char SBYTE; typedef signed char SBYTE;
typedef signed int SINT; typedef signed int SINT;
typedef unsigned long int ULONG; typedef unsigned int ULONG;
typedef unsigned short int UWORD; typedef unsigned short int UWORD;
typedef unsigned char UBYTE; typedef unsigned char UBYTE;
typedef unsigned int UINT; typedef unsigned int UINT;
@ -282,8 +283,8 @@ typedef unsigned int UINT;
#define MAX_UBYTE ((UBYTE)0xFF) #define MAX_UBYTE ((UBYTE)0xFF)
typedef int BOOL; // this is for TRUE/FALSE typedef int BOOL; // this is for TRUE/FALSE
typedef long int RESULT; // for error codes typedef int RESULT; // for error codes
typedef long int INDEX; // for indexed values and quantities typedef int INDEX; // for indexed values and quantities
#define FALSE 0 #define FALSE 0
#define TRUE 1 #define TRUE 1

View File

@ -230,7 +230,7 @@ void ReadZIPDirectory_t(CTFileName *pfnmZip)
} }
// start at the end of file, minus expected minimum overhead // start at the end of file, minus expected minimum overhead
fseek(f, 0, SEEK_END); 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) // do not search more than 128k (should be around 65k at most)
int iMinPos = iPos-128*1024; int iMinPos = iPos-128*1024;
if (iMinPos<0) { if (iMinPos<0) {

View File

@ -127,8 +127,8 @@ void CBrushPolygon::InitializeShadowMap(void)
PIX pixSizeU = mexSizeU>>iMipLevel; PIX pixSizeU = mexSizeU>>iMipLevel;
PIX pixSizeV = mexSizeV>>iMipLevel; PIX pixSizeV = mexSizeV>>iMipLevel;
INDEX iMipAdj = ClampTextureSize( MAX_SHADOWMAP_SIZE, _pGfx->gl_pixMaxTextureDimension, pixSizeU, pixSizeV); INDEX iMipAdj = ClampTextureSize( MAX_SHADOWMAP_SIZE, _pGfx->gl_pixMaxTextureDimension, pixSizeU, pixSizeV);
pixSizeU = ClampDn( pixSizeU>>iMipAdj, 1L); pixSizeU = ClampDn( pixSizeU>>iMipAdj, 1);
pixSizeV = ClampDn( pixSizeV>>iMipAdj, 1L); pixSizeV = ClampDn( pixSizeV>>iMipAdj, 1);
iMipLevel += iMipAdj; iMipLevel += iMipAdj;
// move shadow map offset for the sake of dark corners // 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); // pixMaxU = PIX(sm_mexWidth >>iMipLevel);
// pixMaxV = PIX(sm_mexHeight>>iMipLevel); // pixMaxV = PIX(sm_mexHeight>>iMipLevel);
// rectangle is around entire polygon // rectangle is around entire polygon
pixMaxU = Min( sm_pixPolygonSizeU+16L, sm_mexWidth >>iMipLevel); pixMaxU = Min( sm_pixPolygonSizeU+16, sm_mexWidth >>iMipLevel);
pixMaxV = Min( sm_pixPolygonSizeV+16L, sm_mexHeight>>iMipLevel); pixMaxV = Min( sm_pixPolygonSizeV+16, sm_mexHeight>>iMipLevel);
} }
// if the light is point // if the light is point
else else
@ -533,10 +533,10 @@ void CBrushShadowMap::FindLightRectangle(CLightSource &ls, class CLightRectangle
// pixMaxU = Min( Max(pixMaxU, 0L), sm_mexWidth >>iMipLevel); // pixMaxU = Min( Max(pixMaxU, 0L), sm_mexWidth >>iMipLevel);
// pixMaxV = Min( Max(pixMaxV, 0L), sm_mexHeight>>iMipLevel); // pixMaxV = Min( Max(pixMaxV, 0L), sm_mexHeight>>iMipLevel);
// clamp the rectangle to the size of polygon // clamp the rectangle to the size of polygon
pixMinU = Min( Max(pixMinU, 0L), Min(sm_pixPolygonSizeU+16L, sm_mexWidth >>iMipLevel)); pixMinU = Min( Max(pixMinU, 0), Min(sm_pixPolygonSizeU+16, sm_mexWidth >>iMipLevel));
pixMinV = Min( Max(pixMinV, 0L), Min(sm_pixPolygonSizeV+16L, sm_mexHeight>>iMipLevel)); pixMinV = Min( Max(pixMinV, 0), Min(sm_pixPolygonSizeV+16, sm_mexHeight>>iMipLevel));
pixMaxU = Min( Max(pixMaxU, 0L), Min(sm_pixPolygonSizeU+16L, sm_mexWidth >>iMipLevel)); pixMaxU = Min( Max(pixMaxU, 0), Min(sm_pixPolygonSizeU+16, sm_mexWidth >>iMipLevel));
pixMaxV = Min( Max(pixMaxV, 0L), Min(sm_pixPolygonSizeV+16L, sm_mexHeight>>iMipLevel)); pixMaxV = Min( Max(pixMaxV, 0), Min(sm_pixPolygonSizeV+16, sm_mexHeight>>iMipLevel));
} }
// all done // all done
lr.lr_pixMinU = pixMinU; lr.lr_pixMinU = pixMinU;
@ -599,7 +599,7 @@ BOOL CBrushShadowMap::IsShadowFlat( COLOR &colFlat)
// fail if flat shadows are not allowed // fail if flat shadows are not allowed
extern INDEX shd_bAllowFlats; extern INDEX shd_bAllowFlats;
extern INDEX shd_iForceFlats; 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; if( !shd_bAllowFlats && shd_iForceFlats<1) return FALSE;
COLOR col; COLOR col;
@ -711,9 +711,9 @@ BOOL CBrushShadowMap::IsShadowFlat( COLOR &colFlat)
} }
} }
// done - phew, layer is flat // done - phew, layer is flat
slR = Clamp( slR, 0L, 255L); slR = Clamp( slR, 0, 255);
slG = Clamp( slG, 0L, 255L); slG = Clamp( slG, 0, 255);
slB = Clamp( slB, 0L, 255L); slB = Clamp( slB, 0, 255);
colFlat = RGBToColor(slR,slG,slB); colFlat = RGBToColor(slR,slG,slB);
return TRUE; return TRUE;
} }

View File

@ -277,7 +277,7 @@ public:
inline ENGINE_API void ClearToDefault(FLOAT &f) { f = 0.0f; }; inline ENGINE_API void ClearToDefault(FLOAT &f) { f = 0.0f; };
inline ENGINE_API void ClearToDefault(INDEX &i) { i = 0; }; 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(CEntityPointer &pen) { pen = NULL; };
inline ENGINE_API void ClearToDefault(CTString &str) { str = ""; }; inline ENGINE_API void ClearToDefault(CTString &str) { str = ""; };
inline ENGINE_API void ClearToDefault(FLOATplane3D &pl) { pl = FLOATplane3D(FLOAT3D(0,1,0), 0); }; inline ENGINE_API void ClearToDefault(FLOATplane3D &pl) { pl = FLOATplane3D(FLOAT3D(0,1,0), 0); };

View File

@ -203,9 +203,9 @@ COLOR AdjustGamma( COLOR const col, FLOAT const fGamma)
const FLOAT f1o255 = 1.0f / 255.0f; const FLOAT f1o255 = 1.0f / 255.0f;
UBYTE ubR,ubG,ubB,ubA; UBYTE ubR,ubG,ubB,ubA;
ColorToRGBA( col, ubR,ubG,ubB,ubA); ColorToRGBA( col, ubR,ubG,ubB,ubA);
ubR = ClampUp( NormFloatToByte(pow(ubR*f1o255,f1oGamma)), 255UL); ubR = ClampUp( NormFloatToByte(pow(ubR*f1o255,f1oGamma)), (ULONG) 255);
ubG = ClampUp( NormFloatToByte(pow(ubG*f1o255,f1oGamma)), 255UL); ubG = ClampUp( NormFloatToByte(pow(ubG*f1o255,f1oGamma)), (ULONG) 255);
ubB = ClampUp( NormFloatToByte(pow(ubB*f1o255,f1oGamma)), 255UL); ubB = ClampUp( NormFloatToByte(pow(ubB*f1o255,f1oGamma)), (ULONG) 255);
return RGBAToColor( ubR,ubG,ubB,ubA); return RGBAToColor( ubR,ubG,ubB,ubA);
} }
@ -459,15 +459,15 @@ COLOR AddColors( COLOR col1, COLOR col2)
COLOR col; COLOR col;
UBYTE bytes[4]; UBYTE bytes[4];
} conv2; } conv2;
#define MIN(a, b) ((a)>(b))?(b):(a) #define MINVAL(a, b) ((a)>(b))?(b):(a)
conv1.col = col1; conv1.col = col1;
conv2.col = col2; conv2.col = col2;
conv1.bytes[0] = (UBYTE) MIN((((WORD) conv1.bytes[0]) + ((WORD) conv2.bytes[0])) , 255); conv1.bytes[0] = (UBYTE) MINVAL((((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[1] = (UBYTE) MINVAL((((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[2] = (UBYTE) MINVAL((((WORD) conv1.bytes[2]) + ((WORD) conv2.bytes[2])) , 255);
conv1.bytes[3] = (UBYTE) MIN((((WORD) conv1.bytes[3]) + ((WORD) conv2.bytes[3])) , 255); conv1.bytes[3] = (UBYTE) MINVAL((((WORD) conv1.bytes[3]) + ((WORD) conv2.bytes[3])) , 255);
#undef MIN #undef MINVAL
colRet = conv1.col; colRet = conv1.col;

View File

@ -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*/) extern void CheckDelayedDepthPoints( const CDrawPort *pdp, INDEX iMirrorLevel/*=0*/)
{ {
// skip if not delayed or mirror level is to high // 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; if( gap_iOptimizeDepthReads==0 || iMirrorLevel>7) return;
ASSERT( pdp!=NULL && iMirrorLevel>=0); ASSERT( pdp!=NULL && iMirrorLevel>=0);

View File

@ -221,7 +221,8 @@ ULONG CDrawPort::GetID(void)
{ {
ULONG ulCRC; ULONG ulCRC;
CRC_Start( 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_MinI);
CRC_AddLONG( ulCRC, (ULONG)dp_MinJ); CRC_AddLONG( ulCRC, (ULONG)dp_MinJ);
CRC_AddLONG( ulCRC, (ULONG)dp_MaxI); CRC_AddLONG( ulCRC, (ULONG)dp_MaxI);
@ -306,8 +307,8 @@ void CDrawPort::RecalculateDimensions(void)
void CDrawPort::SetOrtho(void) const void CDrawPort::SetOrtho(void) const
{ {
// finish all pending render-operations (if required) // finish all pending render-operations (if required)
ogl_iFinish = Clamp( ogl_iFinish, 0L, 3L); ogl_iFinish = Clamp( ogl_iFinish, 0, 3);
d3d_iFinish = Clamp( d3d_iFinish, 0L, 3L); d3d_iFinish = Clamp( d3d_iFinish, 0, 3);
if( (ogl_iFinish==3 && _pGfx->gl_eCurrentAPI==GAT_OGL) if( (ogl_iFinish==3 && _pGfx->gl_eCurrentAPI==GAT_OGL)
#ifdef SE1_D3D #ifdef SE1_D3D
|| (d3d_iFinish==3 && _pGfx->gl_eCurrentAPI==GAT_D3D) || (d3d_iFinish==3 && _pGfx->gl_eCurrentAPI==GAT_D3D)
@ -337,8 +338,8 @@ void CDrawPort::SetOrtho(void) const
void CDrawPort::SetProjection(CAnyProjection3D &apr) const void CDrawPort::SetProjection(CAnyProjection3D &apr) const
{ {
// finish all pending render-operations (if required) // finish all pending render-operations (if required)
ogl_iFinish = Clamp( ogl_iFinish, 0L, 3L); ogl_iFinish = Clamp( ogl_iFinish, 0, 3);
d3d_iFinish = Clamp( d3d_iFinish, 0L, 3L); d3d_iFinish = Clamp( d3d_iFinish, 0, 3);
if( (ogl_iFinish==3 && _pGfx->gl_eCurrentAPI==GAT_OGL) if( (ogl_iFinish==3 && _pGfx->gl_eCurrentAPI==GAT_OGL)
#ifdef SE1_D3D #ifdef SE1_D3D
|| (d3d_iFinish==3 && _pGfx->gl_eCurrentAPI==GAT_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? // flash?
case 'f': case 'f':
chrCurrent = strText[++iChar]; 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; continue;
// reset all? // reset all?
case 'r': case 'r':
@ -1678,7 +1679,7 @@ void CDrawPort::BlendScreen(void)
ULONG ulRA = (dp_ulBlendingRA*fix1oA)>>16; ULONG ulRA = (dp_ulBlendingRA*fix1oA)>>16;
ULONG ulGA = (dp_ulBlendingGA*fix1oA)>>16; ULONG ulGA = (dp_ulBlendingGA*fix1oA)>>16;
ULONG ulBA = (dp_ulBlendingBA*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); COLOR colBlending = RGBAToColor( ulRA, ulGA, ulBA, ulA);
// blend drawport (thru z-buffer because of elimination of pixel artefacts) // blend drawport (thru z-buffer because of elimination of pixel artefacts)

View File

@ -427,9 +427,9 @@ static void RSBinToGroups( ScenePolygon *pspoFirst)
else { else {
UBYTE ubR,ubG,ubB; UBYTE ubR,ubG,ubB;
ColorToRGB( colFlat, ubR,ubG,ubB); ColorToRGB( colFlat, ubR,ubG,ubB);
ULONG ulR = ClampUp( ((ULONG)ubR)<<1, 255UL); const ULONG ulR = ClampUp( ((ULONG)ubR)<<1, (ULONG) 255);
ULONG ulG = ClampUp( ((ULONG)ubG)<<1, 255UL); const ULONG ulG = ClampUp( ((ULONG)ubG)<<1, (ULONG) 255);
ULONG ulB = ClampUp( ((ULONG)ubB)<<1, 255UL); const ULONG ulB = ClampUp( ((ULONG)ubB)<<1, (ULONG) 255);
colFlat = RGBToColor(ulR,ulG,ulB); colFlat = RGBToColor(ulR,ulG,ulB);
} }
} // mix color in the first texture layer } // mix color in the first texture layer
@ -1568,8 +1568,8 @@ void RSRenderGroup( ScenePolygon *pspoGroup, ULONG ulGroupFlags, ULONG ulTestedF
// render one group // render one group
extern INDEX ogl_iMaxBurstSize; extern INDEX ogl_iMaxBurstSize;
extern INDEX d3d_iMaxBurstSize; extern INDEX d3d_iMaxBurstSize;
ogl_iMaxBurstSize = Clamp( ogl_iMaxBurstSize, 0L, 9999L); ogl_iMaxBurstSize = Clamp( ogl_iMaxBurstSize, 0, 9999);
d3d_iMaxBurstSize = Clamp( d3d_iMaxBurstSize, 0L, 9999L); d3d_iMaxBurstSize = Clamp( d3d_iMaxBurstSize, 0, 9999);
const INDEX iMaxBurstSize = (eAPI==GAT_OGL) ? ogl_iMaxBurstSize : d3d_iMaxBurstSize; const INDEX iMaxBurstSize = (eAPI==GAT_OGL) ? ogl_iMaxBurstSize : d3d_iMaxBurstSize;
// if unlimited lock count // if unlimited lock count
@ -1891,7 +1891,7 @@ void RenderScene( CDrawPort *pDP, ScenePolygon *pspoFirst, CAnyProjection3D &prP
_bTranslucentPass = bTranslucent; _bTranslucentPass = bTranslucent;
// clamp detail textures LOD biasing // clamp detail textures LOD biasing
wld_iDetailRemovingBias = Clamp( wld_iDetailRemovingBias, -9L, +9L); wld_iDetailRemovingBias = Clamp( wld_iDetailRemovingBias, -9, 9);
// set perspective projection // set perspective projection
_pDP->SetProjection(prProjection); _pDP->SetProjection(prProjection);
@ -1902,7 +1902,7 @@ void RenderScene( CDrawPort *pDP, ScenePolygon *pspoFirst, CAnyProjection3D &prP
extern INDEX ogl_bAlternateClipPlane; extern INDEX ogl_bAlternateClipPlane;
INDEX ctMaxUsableTexUnits = _pGfx->gl_ctTextureUnits; INDEX ctMaxUsableTexUnits = _pGfx->gl_ctTextureUnits;
if( eAPI==GAT_OGL && ogl_bAlternateClipPlane && GFX_bClipPlane && ctMaxUsableTexUnits>1) ctMaxUsableTexUnits--; if( eAPI==GAT_OGL && ogl_bAlternateClipPlane && GFX_bClipPlane && ctMaxUsableTexUnits>1) ctMaxUsableTexUnits--;
_ctUsableTexUnits = Clamp( gap_iUseTextureUnits, 1L, ctMaxUsableTexUnits); _ctUsableTexUnits = Clamp( gap_iUseTextureUnits, 1, ctMaxUsableTexUnits);
// prepare // prepare
RSPrepare(); RSPrepare();

View File

@ -71,10 +71,10 @@ ULONG PrepareTexture( UBYTE *pubTexture, PIX pixSizeI, PIX pixSizeJ)
const PIX pixTextureSize = pixSizeI*pixSizeJ; const PIX pixTextureSize = pixSizeI*pixSizeJ;
#if (defined USE_PORTABLE_C) #if (defined USE_PORTABLE_C)
UBYTE* src = pubTexture; const UBYTE* src = pubTexture;
DWORD* dst = (DWORD*)(pubTexture+pixTextureSize); DWORD* dst = (DWORD*)(pubTexture+pixTextureSize);
for (int i=0; i<pixTextureSize; i++) { for (int i=0; i<pixTextureSize; i++) {
DWORD tmp = *src | 0xFFFFFF00; const DWORD tmp = ((DWORD)*src) | 0xFFFFFF00;
*dst = bswap_32(tmp); *dst = bswap_32(tmp);
src++; src++;
dst++; dst++;
@ -152,9 +152,9 @@ void StartFog( CFogParameters &fp, const FLOAT3D &vViewPosAbs, const FLOATmatrix
// calculate fog table size wanted // calculate fog table size wanted
extern INDEX tex_iFogSize; extern INDEX tex_iFogSize;
tex_iFogSize = Clamp( tex_iFogSize, 4L, 8L); tex_iFogSize = Clamp( tex_iFogSize, 4, 8);
PIX pixSizeH = ClampUp( _fog_fp.fp_iSizeH, 1L<<tex_iFogSize); PIX pixSizeH = ClampUp( _fog_fp.fp_iSizeH, 1<<tex_iFogSize);
PIX pixSizeL = ClampUp( _fog_fp.fp_iSizeL, 1L<<tex_iFogSize); PIX pixSizeL = ClampUp( _fog_fp.fp_iSizeL, 1<<tex_iFogSize);
BOOL bNoDiscard = TRUE; BOOL bNoDiscard = TRUE;
// if fog table is not allocated in right size // if fog table is not allocated in right size
@ -270,7 +270,7 @@ void StartFog( CFogParameters &fp, const FLOAT3D &vViewPosAbs, const FLOATmatrix
FLOAT fTStep = 1.0f/pixSizeL *fFar*fDensity*fA *255; FLOAT fTStep = 1.0f/pixSizeL *fFar*fDensity*fA *255;
// fog is just clamped fog parameter in each pixel // fog is just clamped fog parameter in each pixel
for( INDEX pixL=0; pixL<pixSizeL; pixL++) { for( INDEX pixL=0; pixL<pixSizeL; pixL++) {
_fog_pubTable[pixH*pixSizeL+pixL] = Clamp( FloatToInt(fT), 0L, 255L); _fog_pubTable[pixH*pixSizeL+pixL] = Clamp( FloatToInt(fT), 0, 255);
fT += fTStep; fT += fTStep;
} }
} break; } break;

View File

@ -75,11 +75,11 @@ __forceinline ULONG GetFogAlpha( const GFXTexCoord &tex)
{ {
// point sampling of height // point sampling of height
PIX pixT = FloatToInt( tex.st.t * _fog_pixSizeH); PIX pixT = FloatToInt( tex.st.t * _fog_pixSizeH);
pixT = Clamp( pixT, 0L, _fog_pixSizeH-1L) * _fog_pixSizeL; pixT = Clamp( pixT, 0, _fog_pixSizeH-1) * _fog_pixSizeL;
// linear interpolation of depth // linear interpolation of depth
const PIX pixSF = FloatToInt( tex.st.s*(FLOAT)_fog_pixSizeL*255.499f); const PIX pixSF = FloatToInt( tex.st.s*(FLOAT)_fog_pixSizeL*255.499f);
const PIX pixS1 = Clamp( (PIX)((pixSF>>8)+0), 0L, _fog_pixSizeL-1L); const PIX pixS1 = Clamp( (PIX)((pixSF>>8)+0), 0, _fog_pixSizeL-1);
const PIX pixS2 = Clamp( (PIX)((pixSF>>8)+1), 0L, _fog_pixSizeL-1L); const PIX pixS2 = Clamp( (PIX)((pixSF>>8)+1), 0, _fog_pixSizeL-1);
const ULONG ulF = pixSF & 255; const ULONG ulF = pixSF & 255;
const ULONG ulA1 = _fog_pubTable[pixT +pixS1]; const ULONG ulA1 = _fog_pubTable[pixT +pixS1];
const ULONG ulA2 = _fog_pubTable[pixT +pixS2]; const ULONG ulA2 = _fog_pubTable[pixT +pixS2];
@ -100,8 +100,8 @@ __forceinline ULONG GetHazeAlpha( const FLOAT fS)
{ {
// linear interpolation of depth // linear interpolation of depth
const PIX pixSH = FloatToInt( fS*(FLOAT)_haze_pixSize*255.4999f); const PIX pixSH = FloatToInt( fS*(FLOAT)_haze_pixSize*255.4999f);
const PIX pixS1 = Clamp( (PIX)((pixSH>>8)+0), 0L, _haze_pixSize-1L); const PIX pixS1 = Clamp( (PIX)((pixSH>>8)+0), 0, _haze_pixSize-1);
const PIX pixS2 = Clamp( (PIX)((pixSH>>8)+1), 0L, _haze_pixSize-1L); const PIX pixS2 = Clamp( (PIX)((pixSH>>8)+1), 0, _haze_pixSize-1);
const ULONG ulH = pixSH & 255; const ULONG ulH = pixSH & 255;
const ULONG ulA1 = _haze_pubTable[pixS1]; const ULONG ulA1 = _haze_pubTable[pixS1];
const ULONG ulA2 = _haze_pubTable[pixS2]; const ULONG ulA2 = _haze_pubTable[pixS2];

View File

@ -618,7 +618,7 @@ static void GAPInfo(void)
CPrintF( "- T-Buffer effect: "); CPrintF( "- T-Buffer effect: ");
if( _pGfx->go_ctSampleBuffers==0) CPrintF( "disabled\n"); if( _pGfx->go_ctSampleBuffers==0) CPrintF( "disabled\n");
else { else {
ogl_iTBufferEffect = Clamp( ogl_iTBufferEffect, 0L, 2L); ogl_iTBufferEffect = Clamp( ogl_iTBufferEffect, 0, 2);
CTString strEffect = "Partial anti-aliasing"; CTString strEffect = "Partial anti-aliasing";
if( ogl_iTBufferEffect<1) strEffect = "none"; if( ogl_iTBufferEffect<1) strEffect = "none";
if( ogl_iTBufferEffect>1) strEffect = "Motion blur"; if( ogl_iTBufferEffect>1) strEffect = "Motion blur";
@ -808,10 +808,10 @@ extern void UncacheShadows(void)
// prepare new saturation factors for shadowmaps // prepare new saturation factors for shadowmaps
gfx_fSaturation = ClampDn( gfx_fSaturation, 0.0f); gfx_fSaturation = ClampDn( gfx_fSaturation, 0.0f);
shd_fSaturation = ClampDn( shd_fSaturation, 0.0f); shd_fSaturation = ClampDn( shd_fSaturation, 0.0f);
gfx_iHueShift = Clamp( gfx_iHueShift, 0L, 359L); gfx_iHueShift = Clamp( gfx_iHueShift, 0, 359);
shd_iHueShift = Clamp( shd_iHueShift, 0L, 359L); shd_iHueShift = Clamp( shd_iHueShift, 0, 359);
_slShdSaturation = (SLONG)( gfx_fSaturation*shd_fSaturation*256.0f); _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; CListHead &lhOriginal = _pGfx->gl_lhCachedShadows;
// while there is some shadow in main list // while there is some shadow in main list
@ -846,10 +846,10 @@ extern void ReloadTextures(void)
// prepare new saturation factors for textures // prepare new saturation factors for textures
gfx_fSaturation = ClampDn( gfx_fSaturation, 0.0f); gfx_fSaturation = ClampDn( gfx_fSaturation, 0.0f);
tex_fSaturation = ClampDn( tex_fSaturation, 0.0f); tex_fSaturation = ClampDn( tex_fSaturation, 0.0f);
gfx_iHueShift = Clamp( gfx_iHueShift, 0L, 359L); gfx_iHueShift = Clamp( gfx_iHueShift, 0, 359);
tex_iHueShift = Clamp( tex_iHueShift, 0L, 359L); tex_iHueShift = Clamp( tex_iHueShift, 0, 359);
_slTexSaturation = (SLONG)( gfx_fSaturation*tex_fSaturation*256.0f); _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 // update texture settings
UpdateTextureSettings(); UpdateTextureSettings();
@ -927,7 +927,7 @@ static void ReloadModels(void)
static BOOL _bLastModelQuality = -1; static BOOL _bLastModelQuality = -1;
static void MdlPostFunc(void *pvVar) static void MdlPostFunc(void *pvVar)
{ {
mdl_bFineQuality = Clamp( mdl_bFineQuality, 0L, 1L); mdl_bFineQuality = Clamp( mdl_bFineQuality, 0, 1);
if( _bLastModelQuality!=mdl_bFineQuality) { if( _bLastModelQuality!=mdl_bFineQuality) {
_bLastModelQuality = mdl_bFineQuality; _bLastModelQuality = mdl_bFineQuality;
ReloadModels(); ReloadModels();
@ -943,7 +943,7 @@ static void PrepareTables(void)
{ {
INDEX i; INDEX i;
// prepare array for fast clamping to 0..255 // 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 // prepare fast sqrt tables
for( i=0; i<SQRTTABLESIZE; i++) aubSqrt[i] = (UBYTE)(sqrt((FLOAT)(i*65536/SQRTTABLESIZE))); for( i=0; i<SQRTTABLESIZE; i++) aubSqrt[i] = (UBYTE)(sqrt((FLOAT)(i*65536/SQRTTABLESIZE)));
for( i=1; i<SQRTTABLESIZE; i++) auw1oSqrt[i] = (UWORD)(sqrt((FLOAT)(SQRTTABLESIZE-1)/i)*255.0f); for( i=1; i<SQRTTABLESIZE; i++) auw1oSqrt[i] = (UWORD)(sqrt((FLOAT)(SQRTTABLESIZE-1)/i)*255.0f);
@ -1852,12 +1852,12 @@ void CGfxLibrary::SwapBuffers(CViewPort *pvp)
gfxSetTextureBiasing( gap_fTextureLODBias); gfxSetTextureBiasing( gap_fTextureLODBias);
// clamp some cvars // clamp some cvars
gap_iDithering = Clamp( gap_iDithering, 0L, 2L); gap_iDithering = Clamp( gap_iDithering, 0, 2);
gap_iSwapInterval = Clamp( gap_iSwapInterval, 0L, 4L); gap_iSwapInterval = Clamp( gap_iSwapInterval, 0, 4);
gap_iOptimizeClipping = Clamp( gap_iOptimizeClipping, 0L, 2L); gap_iOptimizeClipping = Clamp( gap_iOptimizeClipping, 0, 2);
gap_iTruformLevel = Clamp( gap_iTruformLevel, 0L, _pGfx->gl_iMaxTessellationLevel); gap_iTruformLevel = Clamp( gap_iTruformLevel, 0, _pGfx->gl_iMaxTessellationLevel);
ogl_iFinish = Clamp( ogl_iFinish, 0L, 3L); ogl_iFinish = Clamp( ogl_iFinish, 0, 3);
d3d_iFinish = Clamp( d3d_iFinish, 0L, 3L); d3d_iFinish = Clamp( d3d_iFinish, 0, 3);
// OpenGL // OpenGL
if( gl_eCurrentAPI==GAT_OGL) if( gl_eCurrentAPI==GAT_OGL)
@ -1948,7 +1948,7 @@ void CGfxLibrary::SwapBuffers(CViewPort *pvp)
GFX_bViewMatrix = TRUE; GFX_bViewMatrix = TRUE;
// set maximum allowed upload ammount // set maximum allowed upload ammount
gfx_iProbeSize = Clamp( gfx_iProbeSize, 1L, 16384L); gfx_iProbeSize = Clamp( gfx_iProbeSize, 1, 16384);
gl_slAllowedUploadBurst = gfx_iProbeSize *1024; gl_slAllowedUploadBurst = gfx_iProbeSize *1024;
_ctProbeTexs = 0; _ctProbeTexs = 0;
_ctProbeShdU = 0; _ctProbeShdU = 0;
@ -1966,7 +1966,7 @@ void CGfxLibrary::SwapBuffers(CViewPort *pvp)
gl_ctTotalTriangles = 0; gl_ctTotalTriangles = 0;
// re-adjust multi-texturing support // 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); ASSERT( gap_iUseTextureUnits>=1 && gap_iUseTextureUnits<=GFX_MAXTEXUNITS);
// re-get usage of compiled vertex arrays // 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_fBrightness = Clamp( gfx_fBrightness, -0.8f, 0.8f);
gfx_fContrast = Clamp( gfx_fContrast, 0.2f, 4.0f); gfx_fContrast = Clamp( gfx_fContrast, 0.2f, 4.0f);
gfx_fGamma = Clamp( gfx_fGamma, 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_fBiasR = Clamp( gfx_fBiasR, 0.0f, 2.0f);
gfx_fBiasG = Clamp( gfx_fBiasG, 0.0f, 2.0f); gfx_fBiasG = Clamp( gfx_fBiasG, 0.0f, 2.0f);
gfx_fBiasB = Clamp( gfx_fBiasB, 0.0f, 2.0f); gfx_fBiasB = Clamp( gfx_fBiasB, 0.0f, 2.0f);
@ -2115,7 +2115,7 @@ static BOOL GenerateGammaTable(void)
// adjust brightness // adjust brightness
INDEX iAdd = (INDEX) (256* 256*gfx_fBrightness); INDEX iAdd = (INDEX) (256* 256*gfx_fBrightness);
for( i=0; i<256; i++) { 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) // adjust levels (posterize)
@ -2124,7 +2124,7 @@ static BOOL GenerateGammaTable(void)
for( i=0; i<256; i++) { for( i=0; i<256; i++) {
INDEX iVal = _auwGammaTable[i]; INDEX iVal = _auwGammaTable[i];
iVal = (INDEX) (((INDEX)(iVal/fLevels)) *fLevels); iVal = (INDEX) (((INDEX)(iVal/fLevels)) *fLevels);
_auwGammaTable[i] = ClampUp( iVal, 0xFF00L); _auwGammaTable[i] = ClampUp( iVal, 0xFF00);
} }
} }

View File

@ -44,9 +44,9 @@ extern CStaticStackArray<INDEX> _aiCommonQuads;
#define SQRTTABLESIZE 8192 #define SQRTTABLESIZE 8192
#define SQRTTABLESIZELOG2 13 #define SQRTTABLESIZELOG2 13
#define GFX_MAXTEXUNITS (4L) // maximum number of supported texture units for multitexturing #define GFX_MAXTEXUNITS (4) // 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_MINSTREAMS (3) // 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_MAXLAYERS (5) // suggested maximum number of multi-passes per one polygon
// D3D vertex for simple draw functions // D3D vertex for simple draw functions
struct CTVERTEX { struct CTVERTEX {

View File

@ -491,7 +491,7 @@ void CGfxLibrary::EndDriver_OGL(void)
extern void SetTBufferEffect( BOOL bEnable) extern void SetTBufferEffect( BOOL bEnable)
{ {
// adjust console vars // adjust console vars
ogl_iTBufferEffect = Clamp( ogl_iTBufferEffect, 0L, 2L); ogl_iTBufferEffect = Clamp( ogl_iTBufferEffect, 0, 2);
ogl_iTBufferSamples = (1L) << FastLog2(ogl_iTBufferSamples); ogl_iTBufferSamples = (1L) << FastLog2(ogl_iTBufferSamples);
if( ogl_iTBufferSamples<2) ogl_iTBufferSamples = 4; if( ogl_iTBufferSamples<2) ogl_iTBufferSamples = 4;
// if supported // if supported

View File

@ -247,11 +247,11 @@ void gfxGetTextureFiltering( INDEX &iFilterType, INDEX &iAnisotropyDegree)
void gfxSetTextureFiltering( INDEX &iFilterType, INDEX &iAnisotropyDegree) void gfxSetTextureFiltering( INDEX &iFilterType, INDEX &iAnisotropyDegree)
{ {
// clamp vars // clamp vars
INDEX iMagTex = iFilterType /100; iMagTex = Clamp( iMagTex, 0L, 2L); // 0=same as iMinTex, 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, 1L, 2L); // 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, 0L, 2L); // 0=no mipmapping, 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; iFilterType = iMagTex*100 + iMinTex*10 + iMinMip;
iAnisotropyDegree = Clamp( iAnisotropyDegree, 1L, _pGfx->gl_iMaxTextureAnisotropy); iAnisotropyDegree = Clamp( iAnisotropyDegree, 1, _pGfx->gl_iMaxTextureAnisotropy);
// skip if not changed // skip if not changed
if( _tpGlobal[0].tp_iFilter==iFilterType && _tpGlobal[0].tp_iAnisotropy==iAnisotropyDegree) return; 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 // clamp texture filtering if needed
static INDEX _iLastTextureFiltering = 0; static INDEX _iLastTextureFiltering = 0;
if( _iLastTextureFiltering != _tpGlobal[0].tp_iFilter) { 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 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, 1L, 2L); // 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, 0L, 2L); // 0=no mipmapping, 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; _tpGlobal[0].tp_iFilter = iMagTex*100 + iMinTex*10 + iMinMip;
_iLastTextureFiltering = _tpGlobal[0].tp_iFilter; _iLastTextureFiltering = _tpGlobal[0].tp_iFilter;
} }
@ -622,7 +622,7 @@ void gfxSetTruform( INDEX iLevel, BOOL bLinearNormals)
return; return;
} }
// skip if same as last time // 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; if( truform_iLevel==iLevel && !truform_bLinear==!bLinearNormals) return;
// determine API // determine API

View File

@ -1359,7 +1359,7 @@ void FilterBitmap( INDEX iFilter, ULONG *pulSrc, ULONG *pulDst, PIX pixWidth, PI
} }
// prepare convolution matrix and row modulo // prepare convolution matrix and row modulo
iFilter = Clamp( iFilter, -6L, +6L); iFilter = Clamp( iFilter, -6, 6);
GenerateConvolutionMatrix( iFilter); GenerateConvolutionMatrix( iFilter);
SLONG slModulo1 = (pixCanvasWidth-pixWidth+1) *BYTES_PER_TEXEL; SLONG slModulo1 = (pixCanvasWidth-pixWidth+1) *BYTES_PER_TEXEL;
SLONG slCanvasWidth = pixCanvasWidth *BYTES_PER_TEXEL; SLONG slCanvasWidth = pixCanvasWidth *BYTES_PER_TEXEL;

View File

@ -213,9 +213,9 @@ void shaCalculateLight(void)
SLONG slab = colAmbient.ub.b; SLONG slab = colAmbient.ub.b;
if(shaOverBrightningEnabled()) { if(shaOverBrightningEnabled()) {
slar = ClampUp(slar,127L); slar = ClampUp(slar,127);
slag = ClampUp(slag,127L); slag = ClampUp(slag,127);
slab = ClampUp(slab,127L); slab = ClampUp(slab,127);
ubColShift = 8; ubColShift = 8;
} else { } else {
slar*=2; slar*=2;
@ -232,9 +232,9 @@ void shaCalculateLight(void)
fDot = Clamp(fDot,0.0f,1.0f); fDot = Clamp(fDot,0.0f,1.0f);
SLONG slDot = NormFloatToByte(fDot); SLONG slDot = NormFloatToByte(fDot);
_acolVtxColors[ivx].ub.r = ClampUp(colModel.ub.r * (slar + ((colLight.ub.r * 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,255L); _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,255L); _acolVtxColors[ivx].ub.b = ClampUp(colModel.ub.b * (slab + ((colLight.ub.b * slDot)>>ubColShift))>>8,255);
_acolVtxColors[ivx].ub.a = colModel.ub.a;//slDot; _acolVtxColors[ivx].ub.a = colModel.ub.a;//slDot;
} }
// Set current vertex color array // Set current vertex color array
@ -262,9 +262,9 @@ void shaCalculateLightForSpecular(void)
SLONG slab = colAmbient.ub.b; SLONG slab = colAmbient.ub.b;
if(shaOverBrightningEnabled()) { if(shaOverBrightningEnabled()) {
slar = ClampUp(slar,127L); slar = ClampUp(slar,127);
slag = ClampUp(slag,127L); slag = ClampUp(slag,127);
slab = ClampUp(slab,127L); slab = ClampUp(slab,127);
ubColShift = 8; ubColShift = 8;
} else { } else {
slar*=2; slar*=2;
@ -281,9 +281,9 @@ void shaCalculateLightForSpecular(void)
fDot = Clamp(fDot,0.0f,1.0f); fDot = Clamp(fDot,0.0f,1.0f);
SLONG slDot = NormFloatToByte(fDot); SLONG slDot = NormFloatToByte(fDot);
_acolVtxColors[ivx].ub.r = ClampUp(colModel.ub.r * (slar + ((colLight.ub.r * 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,255L); _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,255L); _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; _acolVtxColors[ivx].ub.a = slDot;//colModel.ub.a;//slDot;
} }
// Set current wertex array // Set current wertex array

View File

@ -152,7 +152,7 @@ void CShadowMap::Cache( INDEX iWantedMipLevel)
} }
// let the higher level driver mix its layers // 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; sm_iFirstCachedMipLevel = iWantedMipLevel;
ASSERT( iWantedMipLevel <= iLastMipLevelToCache); ASSERT( iWantedMipLevel <= iLastMipLevelToCache);
@ -481,7 +481,7 @@ void CShadowMap::Prepare(void)
BOOL bUseProbe = ProbeMode(sm_tvLastDrawn); BOOL bUseProbe = ProbeMode(sm_tvLastDrawn);
// determine and clamp to max allowed shadow dimension // 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); PIX pixClampAreaSize = 1L<<(shd_iStaticSize*2);
// determine largest allowed mip level // determine largest allowed mip level
INDEX iFinestMipLevel = sm_iFirstMipLevel + INDEX iFinestMipLevel = sm_iFirstMipLevel +

View File

@ -57,7 +57,7 @@ void Stereo_AdjustProjection(CProjection3D &pr, INDEX iEye, FLOAT fFactor)
// prepare and clamp // prepare and clamp
CPerspectiveProjection3D &ppr = (CPerspectiveProjection3D &)pr; CPerspectiveProjection3D &ppr = (CPerspectiveProjection3D &)pr;
gfx_fStereoSeparation = Clamp( gfx_fStereoSeparation, 0.01f, 1.0f); gfx_fStereoSeparation = Clamp( gfx_fStereoSeparation, 0.01f, 1.0f);
gfx_iStereoOffset = Clamp( gfx_iStereoOffset, -100L, +100L); gfx_iStereoOffset = Clamp( gfx_iStereoOffset, -100, 100);
// apply! // apply!
if (iEye==STEREO_BOTH || gfx_iStereo==0) { if (iEye==STEREO_BOTH || gfx_iStereo==0) {
NOTHING; NOTHING;

View File

@ -101,7 +101,7 @@ extern void UpdateTextureSettings(void)
{ // OpenGL { // OpenGL
extern INDEX ogl_iTextureCompressionType; // 0=none, 1=default (ARB), 2=S3TC, 3=FXT1, 4=legacy S3TC extern INDEX ogl_iTextureCompressionType; // 0=none, 1=default (ARB), 2=S3TC, 3=FXT1, 4=legacy S3TC
INDEX &iTC = ogl_iTextureCompressionType; 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==3 && !(ulGfxFlags&GLF_EXTC_FXT1)) iTC = 2;
if( iTC==2 && !(ulGfxFlags&GLF_EXTC_S3TC)) iTC = 3; if( iTC==2 && !(ulGfxFlags&GLF_EXTC_S3TC)) iTC = 3;
if((iTC==2 || iTC==3) && !((ulGfxFlags&GLF_EXTC_FXT1) || (ulGfxFlags&GLF_EXTC_S3TC))) iTC = 1; 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_iNormalQuality = TS.ts_iNormQualityO*10 + TS.ts_iNormQualityA;
tex_iAnimationQuality = TS.ts_iAnimQualityO*10 + TS.ts_iAnimQualityA; tex_iAnimationQuality = TS.ts_iAnimQualityO*10 + TS.ts_iAnimQualityA;
// clamp texture size // clamp texture size
tex_iNormalSize = Clamp( tex_iNormalSize, 5L, 11L); tex_iNormalSize = Clamp( tex_iNormalSize, 5, 11);
tex_iAnimationSize = Clamp( tex_iAnimationSize, 5L, 9L); tex_iAnimationSize = Clamp( tex_iAnimationSize, 5, 9);
TS.ts_pixNormSize = 1L<<(tex_iNormalSize *2); TS.ts_pixNormSize = 1L<<(tex_iNormalSize *2);
TS.ts_pixAnimSize = 1L<<(tex_iAnimationSize*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) // 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 // 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; INDEX iTexFilter = tex_iFiltering;
if( _bExport || (td_ulFlags&TEX_CONSTANT)) iTexFilter = 0; // don't filter constants and textures for exporting if( _bExport || (td_ulFlags&TEX_CONSTANT)) iTexFilter = 0; // don't filter constants and textures for exporting
if( iTexFilter) td_ulFlags |= TEX_FILTERED; if( iTexFilter) td_ulFlags |= TEX_FILTERED;
@ -978,7 +978,7 @@ void CTextureData::Read_t( CTStream *inFile)
// prepare dithering type // prepare dithering type
td_ulInternalFormat = DetermineInternalFormat(this); td_ulInternalFormat = DetermineInternalFormat(this);
tex_iDithering = Clamp( tex_iDithering, 0L, 10L); tex_iDithering = Clamp( tex_iDithering, 0, 10);
INDEX iDitherType = 0; INDEX iDitherType = 0;
if( !(td_ulFlags&TEX_STATIC) || !(td_ulFlags&TEX_CONSTANT)) { // only non-static-constant textures can be dithered 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); 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 ASSERT( iFrameNo==0); // effect texture must have only one frame
// get max allowed effect texture dimension // get max allowed effect texture dimension
PIX pixClampAreaSize = 1L<<16L; 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); if( !(td_ulFlags&TEX_CONSTANT)) pixClampAreaSize = 1L<<(tex_iEffectSize*2);
INDEX iWantedMipLevel = td_iFirstMipLevel INDEX iWantedMipLevel = td_iFirstMipLevel
+ ClampTextureSize( pixClampAreaSize, _pGfx->gl_pixMaxTextureDimension, pixWidth, pixHeight); + 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_bDynamicMipmaps;
extern INDEX tex_iEffectFiltering; extern INDEX tex_iEffectFiltering;
if( tex_bDynamicMipmaps) tex_bDynamicMipmaps = 1; 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 // determine whether texture has single mipmap
if( gap_bAllowSingleMipmap) { if( gap_bAllowSingleMipmap) {

View File

@ -181,7 +181,7 @@ inline void PutPixel9SLONG_WATER( PIX pixU, PIX pixV, INDEX iHeightMid)
inline void PutPixelUBYTE_FIRE( PIX pixU, PIX pixV, INDEX iHeight) inline void PutPixelUBYTE_FIRE( PIX pixU, PIX pixV, INDEX iHeight)
{ {
PIX pixLoc = (pixV*_pixBufferWidth+pixU) & _ulBufferMask; 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) inline void PutPixel9UBYTE_FIRE( PIX pixU, PIX pixV, INDEX iHeightMid)

View File

@ -185,8 +185,8 @@ void CLayerMixer::CalculateData( CBrushShadowMap *pbsm, INDEX iMipmap)
lm_iMipShift = lm_iMipLevel - lm_iFirstLevel; lm_iMipShift = lm_iMipLevel - lm_iFirstLevel;
lm_pixCanvasSizeU = pbsm->sm_mexWidth >>lm_iMipLevel; lm_pixCanvasSizeU = pbsm->sm_mexWidth >>lm_iMipLevel;
lm_pixCanvasSizeV = pbsm->sm_mexHeight>>lm_iMipLevel; lm_pixCanvasSizeV = pbsm->sm_mexHeight>>lm_iMipLevel;
lm_pixPolygonSizeU = Min( lm_pixCanvasSizeU, (PIX)(lm_pbsmShadowMap->sm_pixPolygonSizeU >>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)+1L); 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 // determine where this mip-map is relative to the allocated shadow map memory
PIX pixOffset = pbsm->sm_slMemoryUsed/BYTES_PER_TEXEL PIX pixOffset = pbsm->sm_slMemoryUsed/BYTES_PER_TEXEL
@ -1808,7 +1808,7 @@ void CLayerMixer::AddOneLayerDirectional( CBrushShadowLayer *pbsl, UBYTE *pubMas
// clamper helper // clamper helper
static INDEX GetDither(void) static INDEX GetDither(void)
{ {
shd_iDithering = Clamp( shd_iDithering, 0L, 5L); shd_iDithering = Clamp( shd_iDithering, 0, 5);
INDEX iDither = shd_iDithering; INDEX iDither = shd_iDithering;
if( iDither>2) iDither++; if( iDither>2) iDither++;
return iDither; return iDither;
@ -1944,7 +1944,7 @@ void CLayerMixer::MixOneMipmap(CBrushShadowMap *pbsm, INDEX iMipmap)
if( bHasGradient && gpGradient.gp_bDark) AddOneLayerGradient( gpGradient); if( bHasGradient && gpGradient.gp_bDark) AddOneLayerGradient( gpGradient);
// do eventual filtering of shadow layer // do eventual filtering of shadow layer
shd_iFiltering = Clamp( shd_iFiltering, 0L, +6L); shd_iFiltering = Clamp( shd_iFiltering, 0, 6);
if( shd_iFiltering>0) { if( shd_iFiltering>0) {
FilterBitmap( shd_iFiltering, lm_pulShadowMap, lm_pulShadowMap, FilterBitmap( shd_iFiltering, lm_pulShadowMap, lm_pulShadowMap,
lm_pixPolygonSizeU, lm_pixPolygonSizeV, lm_pixCanvasSizeU, lm_pixCanvasSizeV); lm_pixPolygonSizeU, lm_pixPolygonSizeV, lm_pixCanvasSizeU, lm_pixCanvasSizeV);

View File

@ -46,8 +46,8 @@ public:
inline FixInt<iInt, iFrac>(UWORD uw) : slHolder((SLONG)(uw<<iFrac)) {}; inline FixInt<iInt, iFrac>(UWORD uw) : slHolder((SLONG)(uw<<iFrac)) {};
inline FixInt<iInt, iFrac>(SBYTE sb) : slHolder((SLONG)(sb<<iFrac)) {}; inline FixInt<iInt, iFrac>(SBYTE sb) : slHolder((SLONG)(sb<<iFrac)) {};
inline FixInt<iInt, iFrac>(UBYTE ub) : slHolder((SLONG)(ub<<iFrac)) {}; inline FixInt<iInt, iFrac>(UBYTE ub) : slHolder((SLONG)(ub<<iFrac)) {};
inline FixInt<iInt, iFrac>(signed int si) : slHolder((SLONG)(si<<iFrac)) {}; //inline FixInt<iInt, iFrac>(signed int si) : slHolder((SLONG)(si<<iFrac)) {};
inline FixInt<iInt, iFrac>(unsigned int ui) : slHolder((SLONG)(ui<<iFrac)) {}; //inline FixInt<iInt, iFrac>(unsigned int ui) : slHolder((SLONG)(ui<<iFrac)) {};
/* Constructor from float. */ /* Constructor from float. */
inline FixInt<iInt, iFrac>(float f) : slHolder((SLONG)(f*(1L<<iFrac))) {}; inline FixInt<iInt, iFrac>(float f) : slHolder((SLONG)(f*(1L<<iFrac))) {};
inline FixInt<iInt, iFrac>(double f) : slHolder((SLONG)(f*(1L<<iFrac))) {}; inline FixInt<iInt, iFrac>(double f) : slHolder((SLONG)(f*(1L<<iFrac))) {};

View File

@ -26,15 +26,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
inline ULONG _control87(WORD newcw, WORD mask) inline ULONG _control87(WORD newcw, WORD mask)
{ {
#if __POWERPC__ // !!! FIXME: I'd like to remove any dependency on the FPU control word from the game, asap. --ryan.
static WORD fpw=_PC_64; #if defined(__x86_64__) || defined(__POWERPC__) || defined(__arm__)
if (mask != 0)
{
fpw &= ~mask;
fpw |= (newcw & mask);
}
return(fpw);
#elif defined(__arm__)
static WORD fpw=_PC_64; static WORD fpw=_PC_64;
if (mask != 0) if (mask != 0)
{ {

View File

@ -323,14 +323,16 @@ void CObjectCSG::PolygonEdgesToBSPEdges(
// if it is reversed // if it is reversed
if (ope.ope_Backward) { if (ope.ope_Backward) {
// add bsp edge with reverse vertices // add bsp edge with reverse 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_Vertex1, abed[iEdge] = DOUBLEbspedge3D(*ope.ope_Edge->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 // if it is not reversed
} else{ } else{
// add bsp edge with normal vertices // 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, 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; oc_popoPortalB1B2 = NULL;
// create a bsp polygon from first temporary array // 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 // create a BSP cutter for B's sector BSP and A's polygon
DOUBLEbspcutter3D bcCutter(bpoA, *itoscB->osc_BSPTree.bt_pbnRoot); DOUBLEbspcutter3D bcCutter(bpoA, *itoscB->osc_BSPTree.bt_pbnRoot);

View File

@ -1844,7 +1844,8 @@ void CObjectSector::CreateBSP(void)
// copy the plane // copy the plane
(DOUBLEplane3D &)bpo = *opo.opo_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 // get count of edges in this polygon
const INDEX ctEdges = opo.opo_PolygonEdges.Count(); const INDEX ctEdges = opo.opo_PolygonEdges.Count();
@ -1859,11 +1860,13 @@ void CObjectSector::CreateBSP(void)
// if the edge is reversed // if the edge is reversed
if(ope.ope_Backward) { if(ope.ope_Backward) {
// add bsp edge with reversed vertices // 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 // otherwise
} else { } else {
// add normal bsp edge // 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(); opo.opo_PolygonEdges.Unlock();

View File

@ -407,7 +407,7 @@ void CModelData::GetAllFramesBBox( FLOATaabbox3D &MaxBB)
FLOAT3D CModelData::GetCollisionBoxMin(INDEX iCollisionBox) FLOAT3D CModelData::GetCollisionBoxMin(INDEX iCollisionBox)
{ {
md_acbCollisionBox.Lock(); 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; FLOAT3D vMin = md_acbCollisionBox[ iCollisionBoxClamped].mcb_vCollisionBoxMin;
md_acbCollisionBox.Unlock(); md_acbCollisionBox.Unlock();
return vMin; return vMin;
@ -416,7 +416,7 @@ FLOAT3D CModelData::GetCollisionBoxMin(INDEX iCollisionBox)
FLOAT3D CModelData::GetCollisionBoxMax(INDEX iCollisionBox=0) FLOAT3D CModelData::GetCollisionBoxMax(INDEX iCollisionBox=0)
{ {
md_acbCollisionBox.Lock(); 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; FLOAT3D vMax = md_acbCollisionBox[ iCollisionBoxClamped].mcb_vCollisionBoxMax;
md_acbCollisionBox.Unlock(); md_acbCollisionBox.Unlock();
return vMax; return vMax;
@ -426,7 +426,7 @@ FLOAT3D CModelData::GetCollisionBoxMax(INDEX iCollisionBox=0)
INDEX CModelData::GetCollisionBoxDimensionEquality(INDEX iCollisionBox=0) INDEX CModelData::GetCollisionBoxDimensionEquality(INDEX iCollisionBox=0)
{ {
md_acbCollisionBox.Lock(); 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; INDEX iDimEq = md_acbCollisionBox[ iCollisionBox].mcb_iCollisionBoxDimensionEquality;
md_acbCollisionBox.Unlock(); md_acbCollisionBox.Unlock();
return iDimEq; return iDimEq;
@ -481,20 +481,20 @@ ModelTextureVertex::ModelTextureVertex(void)
//------------------------------------------ WRITE //------------------------------------------ WRITE
void ModelPolygonVertex::Write_t( CTStream *pFile) // throw char * void ModelPolygonVertex::Write_t( CTStream *pFile) // throw char *
{ {
// !!! FIXME: Not 64-bit clean! STUBBED("64-bit issue");
(*pFile) << (INDEX) mpv_ptvTransformedVertex; (*pFile) << (INDEX) (size_t) mpv_ptvTransformedVertex;
(*pFile) << (INDEX) mpv_ptvTextureVertex; (*pFile) << (INDEX) (size_t) mpv_ptvTextureVertex;
} }
//------------------------------------------ READ //------------------------------------------ READ
void ModelPolygonVertex::Read_t( CTStream *pFile) // throw char * void ModelPolygonVertex::Read_t( CTStream *pFile) // throw char *
{ {
INDEX itmp; INDEX itmp;
// !!! FIXME: Not 64-bit clean! STUBBED("64-bit issue");
(*pFile) >> itmp; (*pFile) >> itmp;
mpv_ptvTransformedVertex = (struct TransformedVertexData *) itmp; mpv_ptvTransformedVertex = (struct TransformedVertexData *) (size_t) itmp;
(*pFile) >> itmp; (*pFile) >> itmp;
mpv_ptvTextureVertex = (ModelTextureVertex *) itmp; mpv_ptvTextureVertex = (ModelTextureVertex *) (size_t) itmp;
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
//------------------------------------------ WRITE //------------------------------------------ WRITE
@ -1068,9 +1068,11 @@ void CModelData::IndicesToPtrs()
FOREACHINSTATICARRAY(it1.Current().mp_PolygonVertices, ModelPolygonVertex, it2) FOREACHINSTATICARRAY(it1.Current().mp_PolygonVertices, ModelPolygonVertex, it2)
{ {
struct ModelPolygonVertex * pMPV = &it2.Current(); 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]; 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]; it2.Current().mpv_ptvTextureVertex = &md_MipInfos[ i].mmpi_TextureVertices[ j];
} }
} }

View File

@ -1700,7 +1700,7 @@ colEnd:
// generate colors from shades // generate colors from shades
for( INDEX iMipVx=0; iMipVx<_ctAllMipVx; iMipVx++) { for( INDEX iMipVx=0; iMipVx<_ctAllMipVx; iMipVx++) {
GFXColor &col = pcolMipBase[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.r = pubClipByte[_slAR + ((_slLR*slShade)>>8)];
col.ub.g = pubClipByte[_slAG + ((_slLG*slShade)>>8)]; col.ub.g = pubClipByte[_slAG + ((_slLG*slShade)>>8)];
col.ub.b = pubClipByte[_slAB + ((_slLB*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); _slAG = (colA & CT_GMASK)>>(CT_GSHIFT-iBright);
_slAB = (colA & CT_BMASK)>>(CT_BSHIFT-iBright); _slAB = (colA & CT_BMASK)>>(CT_BSHIFT-iBright);
if( bOverbright) { if( bOverbright) {
_slAR = ClampUp( _slAR, 127L); _slAR = ClampUp( _slAR, 127);
_slAG = ClampUp( _slAG, 127L); _slAG = ClampUp( _slAG, 127);
_slAB = ClampUp( _slAB, 127L); _slAB = ClampUp( _slAB, 127);
} }
// set forced translucency and color mask // set forced translucency and color mask
@ -2648,9 +2648,9 @@ specMipLoop:
const COLOR colS = AdjustColor( rm.rm_pmdModelData->md_colSpecular, _slTexHueShift, _slTexSaturation); const COLOR colS = AdjustColor( rm.rm_pmdModelData->md_colSpecular, _slTexHueShift, _slTexSaturation);
colMdlSpec.ul.abgr = ByteSwap(colS); colMdlSpec.ul.abgr = ByteSwap(colS);
colMdlSpec.AttenuateRGB( (rm.rm_colBlend&CT_AMASK)>>CT_ASHIFT); colMdlSpec.AttenuateRGB( (rm.rm_colBlend&CT_AMASK)>>CT_ASHIFT);
colMdlSpec.ub.r = ClampUp( (colMdlSpec.ub.r *_slLR)>>8, 255L); colMdlSpec.ub.r = ClampUp( (colMdlSpec.ub.r *_slLR)>>8, 255);
colMdlSpec.ub.g = ClampUp( (colMdlSpec.ub.g *_slLG)>>8, 255L); colMdlSpec.ub.g = ClampUp( (colMdlSpec.ub.g *_slLG)>>8, 255);
colMdlSpec.ub.b = ClampUp( (colMdlSpec.ub.b *_slLB)>>8, 255L); colMdlSpec.ub.b = ClampUp( (colMdlSpec.ub.b *_slLB)>>8, 255);
// for each specular surface in current mip model // for each specular surface in current mip model
FOREACHINSTATICARRAY( mmi.mmpi_MappingSurfaces, MappingSurface, itms) FOREACHINSTATICARRAY( mmi.mmpi_MappingSurfaces, MappingSurface, itms)

View File

@ -424,9 +424,11 @@ int ZEXPORT compress (dest, destLen, source, sourceLen)
*/ */
CTSingleLock slZip(&zip_csLock, TRUE); CTSingleLock slZip(&zip_csLock, TRUE);
int iResult = compress( uLongf dstlen = (uLongf) slDstSize;
(UBYTE *)pvDst, (ULONG *)&slDstSize, const int iResult = compress(
(const UBYTE *)pvSrc, (ULONG)slSrcSize); (Bytef *)pvDst, &dstlen,
(const Bytef *)pvSrc, (uLong)slSrcSize);
slDstSize = (SLONG) dstlen;
if (iResult==Z_OK) { if (iResult==Z_OK) {
return TRUE; return TRUE;
} else { } else {
@ -448,10 +450,11 @@ int ZEXPORT uncompress (dest, destLen, source, sourceLen)
*/ */
CTSingleLock slZip(&zip_csLock, TRUE); CTSingleLock slZip(&zip_csLock, TRUE);
int iResult = uncompress( uLongf dstlen = (uLongf) slDstSize;
(UBYTE *)pvDst, (ULONG *)&slDstSize, const int iResult = uncompress(
(const UBYTE *)pvSrc, (ULONG)slSrcSize); (Bytef *)pvDst, &dstlen,
(const Bytef *)pvSrc, (uLong)slSrcSize);
slDstSize = (SLONG) dstlen;
if (iResult==Z_OK) { if (iResult==Z_OK) {
return TRUE; return TRUE;
} else { } else {

View File

@ -1039,7 +1039,8 @@ void CNetworkLibrary::StartPeerToPeer_t(const CTString &strSessionName,
throw; throw;
} }
// remember the world pointer // 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")); SetProgressDescription(TRANS("starting server"));
CallProgressHook_t(0.0f); CallProgressHook_t(0.0f);
@ -1276,7 +1277,8 @@ void CNetworkLibrary::JoinSession_t(const CNetworkSession &nsSesssion, INDEX ctL
} }
// remember the world pointer // 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!) // eventually cache all shadowmaps in world (memory eater!)
if( shd_bCacheAll) ga_World.wo_baBrushes.CacheAllShadowmaps(); if( shd_bCacheAll) ga_World.wo_baBrushes.CacheAllShadowmaps();
@ -1348,7 +1350,8 @@ void CNetworkLibrary::StartDemoPlay_t(const CTFileName &fnDemo) // throw char *
_bNeedPretouch = TRUE; _bNeedPretouch = TRUE;
// remember the world pointer // 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 // demo synchronization starts at the beginning initially
ga_fDemoTimer = 0.0f; ga_fDemoTimer = 0.0f;
@ -1681,7 +1684,8 @@ void CNetworkLibrary::ChangeLevel_internal(void)
// remember the world filename // remember the world filename
ga_fnmWorld = ga_fnmNextLevel; ga_fnmWorld = ga_fnmNextLevel;
// remember the world pointer // 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 // if there is remembered level
} else { } else {
// restore it // restore it
@ -2386,7 +2390,8 @@ extern void NET_MakeDefaultState_t(
_pNetwork->ga_fnmWorld = fnmWorld; _pNetwork->ga_fnmWorld = fnmWorld;
_pNetwork->ga_fnmNextLevel = CTString(""); _pNetwork->ga_fnmNextLevel = CTString("");
// remember the world pointer // 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 // reset random number generator
_pNetwork->ga_sesSessionState.ResetRND(); _pNetwork->ga_sesSessionState.ResetRND();

View File

@ -208,7 +208,7 @@ void CPlayerSource::WriteActionPacket(CNetworkMessage &nm)
// get sendbehind parameters // get sendbehind parameters
extern INDEX cli_iSendBehind; extern INDEX cli_iSendBehind;
extern INDEX cli_bPredictIfServer; extern INDEX cli_bPredictIfServer;
cli_iSendBehind = Clamp(cli_iSendBehind, 0L, 3L); cli_iSendBehind = Clamp(cli_iSendBehind, 0, 3);
INDEX iSendBehind = cli_iSendBehind; INDEX iSendBehind = cli_iSendBehind;
// disable if server // disable if server

View File

@ -381,8 +381,8 @@ void CServer::SendGameStreamBlocks(INDEX iClient)
INDEX ctMinBytes = sso.sso_sspParams.ssp_iMinBPS/20; INDEX ctMinBytes = sso.sso_sspParams.ssp_iMinBPS/20;
INDEX ctMaxBytes = sso.sso_sspParams.ssp_iMaxBPS/20; INDEX ctMaxBytes = sso.sso_sspParams.ssp_iMaxBPS/20;
// make sure outgoing message doesn't overflow UDP size // make sure outgoing message doesn't overflow UDP size
ctMinBytes = Clamp(ctMinBytes, 0L, 1000L); ctMinBytes = Clamp(ctMinBytes, 0, 1000);
ctMaxBytes = Clamp(ctMaxBytes, 0L, 1000L); ctMaxBytes = Clamp(ctMaxBytes, 0, 1000);
// limit the clients BPS by server's local settings // limit the clients BPS by server's local settings
extern INDEX ser_iMaxAllowedBPS; extern INDEX ser_iMaxAllowedBPS;
ctMinBytes = ClampUp(ctMinBytes, (INDEX) ( ser_iMaxAllowedBPS/20L - MAX_HEADER_SIZE)); ctMinBytes = ClampUp(ctMinBytes, (INDEX) ( ser_iMaxAllowedBPS/20L - MAX_HEADER_SIZE));
@ -743,7 +743,7 @@ void CServer::ServerLoop(void)
if (srv_fServerStep>=1.0f) { if (srv_fServerStep>=1.0f) {
// find how many ticks were stepped // find how many ticks were stepped
INDEX iSpeed = ClampDn(INDEX(srv_fServerStep), 1L); INDEX iSpeed = ClampDn(INDEX(srv_fServerStep), 1);
srv_fServerStep -= iSpeed; srv_fServerStep -= iSpeed;
// for each tick // for each tick
@ -911,8 +911,8 @@ void CServer::ConnectRemoteSessionState(INDEX iClient, CNetworkMessage &nm)
INDEX ctMaxAllowedVIPPlayers = 0; INDEX ctMaxAllowedVIPPlayers = 0;
INDEX ctMaxAllowedVIPClients = 0; INDEX ctMaxAllowedVIPClients = 0;
if (net_iVIPReserve>0 && net_strVIPPassword!="") { if (net_iVIPReserve>0 && net_strVIPPassword!="") {
ctMaxAllowedVIPPlayers = ClampDn(net_iVIPReserve-GetVIPPlayersCount(), 0L); ctMaxAllowedVIPPlayers = ClampDn(net_iVIPReserve-GetVIPPlayersCount(), 0);
ctMaxAllowedVIPClients = ClampDn(net_iVIPReserve-GetVIPClientsCount(), 0L); ctMaxAllowedVIPClients = ClampDn(net_iVIPReserve-GetVIPClientsCount(), 0);
} }
INDEX ctMaxAllowedObservers = net_iMaxObservers; 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 the user is not authorised as a VIP
if (!bAutorizedAsVIP) { if (!bAutorizedAsVIP) {
// artificially decrease allowed number of players and clients // artificially decrease allowed number of players and clients
ctMaxAllowedPlayers = ClampDn(ctMaxAllowedPlayers-ctMaxAllowedVIPPlayers, 0L); ctMaxAllowedPlayers = ClampDn(ctMaxAllowedPlayers-ctMaxAllowedVIPPlayers, 0);
ctMaxAllowedClients = ClampDn(ctMaxAllowedClients-ctMaxAllowedVIPClients, 0L); ctMaxAllowedClients = ClampDn(ctMaxAllowedClients-ctMaxAllowedVIPClients, 0);
} }
// if too many clients or players // if too many clients or players

View File

@ -231,7 +231,7 @@ void CSessionState::Start_t(INDEX ctLocalPlayers)
// if this computer is server // if this computer is server
if (_pNetwork->IsServer()) { if (_pNetwork->IsServer()) {
// initialize local client // initialize local client
_cmiComm.Client_Init_t(0UL); _cmiComm.Client_Init_t((ULONG) 0);
// connect as main session state // connect as main session state
try { try {
Start_AtServer_t(); Start_AtServer_t();

View File

@ -710,8 +710,8 @@ void CRenderer::Render(void)
// force finishing of all OpenGL pending operations, if required // force finishing of all OpenGL pending operations, if required
ChangeStatsMode(CStatForm::STI_SWAPBUFFERS); ChangeStatsMode(CStatForm::STI_SWAPBUFFERS);
extern INDEX ogl_iFinish; ogl_iFinish = Clamp( ogl_iFinish, 0L, 3L); extern INDEX ogl_iFinish; ogl_iFinish = Clamp( ogl_iFinish, 0, 3);
extern INDEX d3d_iFinish; d3d_iFinish = Clamp( d3d_iFinish, 0L, 3L); extern INDEX d3d_iFinish; d3d_iFinish = Clamp( d3d_iFinish, 0, 3);
if( (ogl_iFinish==1 && _pGfx->gl_eCurrentAPI==GAT_OGL) if( (ogl_iFinish==1 && _pGfx->gl_eCurrentAPI==GAT_OGL)
#ifdef SE1_D3D #ifdef SE1_D3D
|| (d3d_iFinish==1 && _pGfx->gl_eCurrentAPI==GAT_D3D) || (d3d_iFinish==1 && _pGfx->gl_eCurrentAPI==GAT_D3D)

View File

@ -214,9 +214,9 @@ BOOL CRenderer::FindModelLights( CEntity &en, const CPlacement3D &plModel,
} }
// special case for substract sector ambient light // special case for substract sector ambient light
if (plsLight->ls_ulFlags&LSF_SUBSTRACTSECTORAMBIENT) { if (plsLight->ls_ulFlags&LSF_SUBSTRACTSECTORAMBIENT) {
ubR = (UBYTE)Clamp( (SLONG)ubR-slSAR, 0L, 255L); ubR = (UBYTE)Clamp( (SLONG)ubR-slSAR, 0, 255);
ubG = (UBYTE)Clamp( (SLONG)ubG-slSAG, 0L, 255L); ubG = (UBYTE)Clamp( (SLONG)ubG-slSAG, 0, 255);
ubB = (UBYTE)Clamp( (SLONG)ubB-slSAB, 0L, 255L); ubB = (UBYTE)Clamp( (SLONG)ubB-slSAB, 0, 255);
} }
// calculate light intensity // calculate light intensity
FLOAT fShade = (ubR+ubG+ubB)*(2.0f/(3.0f*255.0f)); 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 // clamp ambient component
slSAR = Clamp( slSAR, 0L, 255L); slSAR = Clamp( slSAR, 0, 255);
slSAG = Clamp( slSAG, 0L, 255L); slSAG = Clamp( slSAG, 0, 255);
slSAB = Clamp( slSAB, 0L, 255L); slSAB = Clamp( slSAB, 0, 255);
// calculate average light properties // calculate average light properties
SLONG slAR = Clamp( (SLONG)FloatToInt(fTR-fDR) +slSAR, 0L, 255L); SLONG slAR = Clamp( (SLONG)FloatToInt(fTR-fDR) +slSAR, 0, 255);
SLONG slAG = Clamp( (SLONG)FloatToInt(fTG-fDG) +slSAG, 0L, 255L); SLONG slAG = Clamp( (SLONG)FloatToInt(fTG-fDG) +slSAG, 0, 255);
SLONG slAB = Clamp( (SLONG)FloatToInt(fTB-fDB) +slSAB, 0L, 255L); SLONG slAB = Clamp( (SLONG)FloatToInt(fTB-fDB) +slSAB, 0, 255);
SLONG slLR = Clamp( (SLONG)FloatToInt(fDR), 0L, 255L); SLONG slLR = Clamp( (SLONG)FloatToInt(fDR), 0, 255);
SLONG slLG = Clamp( (SLONG)FloatToInt(fDG), 0L, 255L); SLONG slLG = Clamp( (SLONG)FloatToInt(fDG), 0, 255);
SLONG slLB = Clamp( (SLONG)FloatToInt(fDB), 0L, 255L); SLONG slLB = Clamp( (SLONG)FloatToInt(fDB), 0, 255);
colLight = RGBToColor( slLR,slLG,slLB); colLight = RGBToColor( slLR,slLG,slLB);
colAmbient = RGBToColor( slAR,slAG,slAB); 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 // 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); const BOOL bAllowShadows = en.AdjustShadingParameters( vTotalLightDirection, colLight, colAmbient);
bRenderModelShadow = (bRenderModelShadow && bAllowShadows && bRenderShadow && mdl_iShadowQuality>0); 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 // 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); const BOOL bAllowShadows = en.AdjustShadingParameters( vTotalLightDirection, colLight, colAmbient);
bRenderModelShadow = (bRenderModelShadow && bAllowShadows && bRenderShadow && mdl_iShadowQuality>0); bRenderModelShadow = (bRenderModelShadow && bAllowShadows && bRenderShadow && mdl_iShadowQuality>0);
@ -767,7 +767,7 @@ void CRenderer::RenderLensFlares(void)
re_pdpDrawPort->SetOrtho(); re_pdpDrawPort->SetOrtho();
// if there are no flares or flares are off, do nothing // 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; if( gfx_iLensFlareQuality==0 || re_alfiLensFlares.Count()==0) return;
// get drawport ID // get drawport ID
@ -932,19 +932,19 @@ void CRenderer::RenderLensFlares(void)
}} // for each flare in the lens flare effect }} // for each flare in the lens flare effect
// if screen glare is on // if screen glare is on
CLensFlareType &lft = *lfi.lfi_plsLightSource->ls_plftLensFlare; const CLensFlareType &lft = *lfi.lfi_plsLightSource->ls_plftLensFlare;
FLOAT fGlearCompression = lft.lft_fGlareCompression; const FLOAT fGlearCompression = lft.lft_fGlareCompression;
if( gfx_iLensFlareQuality>2 if( gfx_iLensFlareQuality>2
&& _wrpWorldRenderPrefs.wrp_lftLensFlares >= CWorldRenderPrefs::LFT_REFLECTIONS_AND_GLARE && _wrpWorldRenderPrefs.wrp_lftLensFlares >= CWorldRenderPrefs::LFT_REFLECTIONS_AND_GLARE
&& lft.lft_fGlareIntensity>0.01f) { && lft.lft_fGlareIntensity>0.01f) {
// calculate glare factor for current position // 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_plsLightSource->ls_rHotSpot*lft.lft_fGlareFallOffFactor,
lfi.lfi_fDistance); lfi.lfi_fDistance);
FLOAT fCenterFactor = (1-fOfCenterFadeFactor); const FLOAT fCenterFactor = (1-fOfCenterFadeFactor);
FLOAT fGlare = lft.lft_fGlareIntensity*fIntensity const FLOAT fGlare = lft.lft_fGlareIntensity*fIntensity
* (exp(1/(1+fGlearCompression*fCenterFactor*fCenterFactor)) -1) / (exp(1)-1); * (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 there is any relevant glare
if( ulGlareA>1) { if( ulGlareA>1) {
// calculate glare color // calculate glare color
@ -956,9 +956,9 @@ void CRenderer::RenderLensFlares(void)
fGlareR *= fBrightFactor; fGlareR *= fBrightFactor;
fGlareG *= fBrightFactor; fGlareG *= fBrightFactor;
fGlareB *= fBrightFactor; fGlareB *= fBrightFactor;
ULONG ulGlareR = ClampUp( FloatToInt(fGlareR), 255L); ULONG ulGlareR = ClampUp( FloatToInt(fGlareR), 255);
ULONG ulGlareG = ClampUp( FloatToInt(fGlareG), 255L); ULONG ulGlareG = ClampUp( FloatToInt(fGlareG), 255);
ULONG ulGlareB = ClampUp( FloatToInt(fGlareB), 255L); ULONG ulGlareB = ClampUp( FloatToInt(fGlareB), 255);
// add the glare to screen blending // add the glare to screen blending
re_pdpDrawPort->dp_ulBlendingRA += ulGlareR*ulGlareA; re_pdpDrawPort->dp_ulBlendingRA += ulGlareR*ulGlareA;
re_pdpDrawPort->dp_ulBlendingGA += ulGlareG*ulGlareA; re_pdpDrawPort->dp_ulBlendingGA += ulGlareG*ulGlareA;

View File

@ -182,14 +182,14 @@ ColisionBox &CModelInstance::GetColisionBox(INDEX icb)
FLOAT3D CModelInstance::GetCollisionBoxMin(INDEX iCollisionBox/*=0*/) 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(); FLOAT3D vMin = mi_cbAABox[ iCollisionBoxClamped].Min();
return vMin; return vMin;
}; };
FLOAT3D CModelInstance::GetCollisionBoxMax(INDEX iCollisionBox/*=0*/) 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(); FLOAT3D vMax = mi_cbAABox[ iCollisionBoxClamped].Max();
return vMax; return vMax;
}; };

View File

@ -188,7 +188,7 @@ public:
const INDEX &GetID(); const INDEX &GetID();
// Add animation to last anim queue // 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 // Remove all animations before last animation that has fully faded in
void RemovePassedAnimsFromQueue(void); void RemovePassedAnimsFromQueue(void);
// Remove animation from anim queue // Remove animation from anim queue

View File

@ -1907,8 +1907,8 @@ static void MatchAnims(RenModel &rm)
} else { } else {
if(f>an.an_iFrames) f = an.an_iFrames-1; if(f>an.an_iFrames) f = an.an_iFrames-1;
iCurentFrame = INDEX(f); iCurentFrame = INDEX(f);
iAnimFrame = ClampUp(iCurentFrame,an.an_iFrames-1L); iAnimFrame = ClampUp(iCurentFrame,an.an_iFrames-1);
iNextAnimFrame = ClampUp(iCurentFrame+1L,an.an_iFrames-1L); iNextAnimFrame = ClampUp(iCurentFrame+1,an.an_iFrames-1);
} }
// for each bone envelope // for each bone envelope

View File

@ -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 // calculate how much can be read at most
SLONG slToRead = size*nmemb; SLONG slToRead = size*nmemb;
SLONG slCurrentPos = ftell(pogg->ogg_fFile)-pogg->ogg_slOffset; 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); slToRead = ClampUp(slToRead, slSizeLeft);
// rounded down to the block size // rounded down to the block size

View File

@ -442,8 +442,8 @@ static void SndPostFunc(void *pArgs)
// clamp variables // clamp variables
snd_tmMixAhead = Clamp( snd_tmMixAhead, 0.1f, 0.9f); snd_tmMixAhead = Clamp( snd_tmMixAhead, 0.1f, 0.9f);
snd_iFormat = Clamp( snd_iFormat, (INDEX)CSoundLibrary::SF_NONE, (INDEX)CSoundLibrary::SF_44100_16); snd_iFormat = Clamp( snd_iFormat, (INDEX)CSoundLibrary::SF_NONE, (INDEX)CSoundLibrary::SF_44100_16);
snd_iDevice = Clamp( snd_iDevice, -1L, 15L); snd_iDevice = Clamp( snd_iDevice, -1, 15);
snd_iInterface = Clamp( snd_iInterface, 0L, 2L); snd_iInterface = Clamp( snd_iInterface, 0, 2);
// if any variable has been changed // if any variable has been changed
if( _tmLastMixAhead!=snd_tmMixAhead || _iLastFormat!=snd_iFormat if( _tmLastMixAhead!=snd_tmMixAhead || _iLastFormat!=snd_iFormat
|| _iLastDevice!=snd_iDevice || _iLastAPI!=snd_iInterface) { || _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 // set wave format from library format
SetWaveFormat( EsfNew, sl.sl_SwfeFormat); 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_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; BOOL bSoundOK = FALSE;
#ifdef PLATFORM_WIN32 #ifdef PLATFORM_WIN32

View File

@ -304,7 +304,7 @@ void NormalizeMixerBuffer( const FLOAT fNormStrength, const SLONG slBytes, FLOAT
FLOAT fCurrentNormValue = fLastNormValue; FLOAT fCurrentNormValue = fLastNormValue;
for( i=0; i<iSamples; i++) { for( i=0; i<iSamples; i++) {
SLONG slSample = FloatToInt(pslSrc[i]*fCurrentNormValue); SLONG slSample = FloatToInt(pslSrc[i]*fCurrentNormValue);
pswDst[i] = (SWORD)Clamp( slSample, -32767L, +32767L); pswDst[i] = (SWORD)Clamp( slSample, -32767, +32767);
fCurrentNormValue = fCurrentNormValue+fNormAdd; // interpolate normalizer fCurrentNormValue = fCurrentNormValue+fNormAdd; // interpolate normalizer
if( fCurrentNormValue<fNormValue && fNormAdd<0) fCurrentNormValue = fNormValue; // clamp interpolated value if( fCurrentNormValue<fNormValue && fNormAdd<0) fCurrentNormValue = fNormValue; // clamp interpolated value
else if( fCurrentNormValue>fNormValue && fNormAdd>0) fCurrentNormValue = fNormValue; else if( fCurrentNormValue>fNormValue && fNormAdd>0) fCurrentNormValue = fNormValue;

View File

@ -213,7 +213,8 @@ void CSoundObject::Play(CSoundData *pCsdLink, SLONG slFlags)
//CPrintF("PLAY: '%s'", (const char*)pCsdLink->GetName().FileName()); //CPrintF("PLAY: '%s'", (const char*)pCsdLink->GetName().FileName());
// get prediction tail // 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 the event is predicted
if (psoTail==NULL) { if (psoTail==NULL) {
// do nothing; // do nothing;
@ -349,7 +350,8 @@ void CSoundObject::Stop(void)
CSoundObject *psoTail = this; CSoundObject *psoTail = this;
// get prediction tail // 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 the event is predicted
if (psoTail==NULL) { if (psoTail==NULL) {
// do nothing; // do nothing;

View File

@ -197,11 +197,13 @@ WAVEFORMATEX PCMWaveInput::LoadInfo_t(CTStream *pCstrInput)
SLONG slFmtLength; SLONG slFmtLength;
(*pCstrInput) >> slFmtLength; (*pCstrInput) >> slFmtLength;
ULONG ul = 0;
// read WAVE format // read WAVE format
(*pCstrInput) >> pwi_wfeWave.wFormatTag; (*pCstrInput) >> pwi_wfeWave.wFormatTag;
(*pCstrInput) >> pwi_wfeWave.nChannels; (*pCstrInput) >> pwi_wfeWave.nChannels;
(*pCstrInput) >> pwi_wfeWave.nSamplesPerSec; (*pCstrInput) >> ul; pwi_wfeWave.nSamplesPerSec = (DWORD) ul;
(*pCstrInput) >> pwi_wfeWave.nAvgBytesPerSec; (*pCstrInput) >> ul; pwi_wfeWave.nAvgBytesPerSec = (DWORD) ul;
(*pCstrInput) >> pwi_wfeWave.nBlockAlign; (*pCstrInput) >> pwi_wfeWave.nBlockAlign;
(*pCstrInput) >> pwi_wfeWave.wBitsPerSample; (*pCstrInput) >> pwi_wfeWave.wBitsPerSample;
pwi_wfeWave.cbSize = 0; // Only for PCM Wave !!! pwi_wfeWave.cbSize = 0; // Only for PCM Wave !!!

View File

@ -1132,7 +1132,8 @@ void BSPTree<Type, iDimensions>::MoveSubTreeToArray(BSPNode<Type, iDimensions> *
bnInArray.bn_bnlLocation = pbnSubtree->bn_bnlLocation; bnInArray.bn_bnlLocation = pbnSubtree->bn_bnlLocation;
bnInArray.bn_ulPlaneTag = pbnSubtree->bn_ulPlaneTag; bnInArray.bn_ulPlaneTag = pbnSubtree->bn_ulPlaneTag;
// let plane tag hold pointer to node in array // 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 // remap pointers to subnodes
if (pbnSubtree->bn_pbnFront==NULL) { if (pbnSubtree->bn_pbnFront==NULL) {
@ -1202,7 +1203,8 @@ void BSPTree<Type, iDimensions>::Read_t(CTStream &strm) // throw char *
// read count of nodes and create array // read count of nodes and create array
INDEX ctNodes; INDEX ctNodes;
strm>>ctNodes; strm>>ctNodes;
ASSERT(slSize==(SLONG)(sizeof(INDEX)+ctNodes*sizeof(BSPNode<Type, iDimensions>))); // 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); bt_abnNodes.New(ctNodes);
// for each node // for each node
for(INDEX iNode=0; iNode<ctNodes; iNode++) { for(INDEX iNode=0; iNode<ctNodes; iNode++) {

View File

@ -340,8 +340,8 @@ static void CropMap(INDEX iNewWidth, INDEX iNewHeight, INDEX iOldWidth, INDEX iO
{ {
INDEX iWidth = Min(iOldWidth,iNewWidth); INDEX iWidth = Min(iOldWidth,iNewWidth);
INDEX iHeight = Min(iOldHeight,iNewHeight); INDEX iHeight = Min(iOldHeight,iNewHeight);
INDEX iNewStepX = ClampDn(iNewWidth-iOldWidth,0L); INDEX iNewStepX = ClampDn(iNewWidth-iOldWidth,0);
INDEX iOldStepX = ClampDn(iOldWidth-iNewWidth,0L); INDEX iOldStepX = ClampDn(iOldWidth-iNewWidth,0);
INDEX iNew = 0; INDEX iNew = 0;
INDEX iOld = 0; INDEX iOld = 0;
@ -1066,8 +1066,8 @@ void CTerrain::UpdateTopMap(INDEX iTileIndex, Rect *prcDest/*=NULL*/)
// get source texture // get source texture
CTextureData *ptdSrc = tl.tl_ptdTexture; CTextureData *ptdSrc = tl.tl_ptdTexture;
INDEX iSrcMipWidth = ClampDn( ptdSrc->GetPixWidth() /iTiling, 1L); INDEX iSrcMipWidth = ClampDn( ptdSrc->GetPixWidth() /iTiling, 1);
INDEX iSrcMipHeight = ClampDn( ptdSrc->GetPixHeight()/iTiling, 1L); INDEX iSrcMipHeight = ClampDn( ptdSrc->GetPixHeight()/iTiling, 1);
// Get mipmap of source texture // Get mipmap of source texture
INDEX immW = FastLog2( ptdSrc->GetPixWidth() / iSrcMipWidth); INDEX immW = FastLog2( ptdSrc->GetPixWidth() / iSrcMipWidth);
@ -1164,8 +1164,8 @@ COLOR CTerrain::GetShadeColor(CShadingInfo *psi)
ASSERT(psi!=NULL); ASSERT(psi!=NULL);
ASSERT(tr_auwShadingMap!=NULL); ASSERT(tr_auwShadingMap!=NULL);
PIX pixShadowU = Clamp(psi->si_pixShadowU,0L,GetShadingMapWidth()-2L); PIX pixShadowU = Clamp(psi->si_pixShadowU,0,GetShadingMapWidth()-2);
PIX pixShadowV = Clamp(psi->si_pixShadowV,0L,GetShadingMapHeight()-2L); PIX pixShadowV = Clamp(psi->si_pixShadowV,0,GetShadingMapHeight()-2);
FLOAT fUDRatio = psi->si_fUDRatio; FLOAT fUDRatio = psi->si_fUDRatio;
FLOAT fLRRatio = psi->si_fLRRatio; FLOAT fLRRatio = psi->si_fLRRatio;

View File

@ -128,10 +128,10 @@ void ShowSelectionInternal(CTerrain *ptrTerrain, Rect &rcExtract, CTextureData *
Rect rcSelection; Rect rcSelection;
FLOATaabbox3D bboxSelection; FLOATaabbox3D bboxSelection;
// Clamp rect used for extraction // Clamp rect used for extraction
rcSelection.rc_iLeft = Clamp(rcExtract.rc_iLeft , 0L, ptrTerrain->tr_pixHeightMapWidth); rcSelection.rc_iLeft = Clamp(rcExtract.rc_iLeft , 0, ptrTerrain->tr_pixHeightMapWidth);
rcSelection.rc_iTop = Clamp(rcExtract.rc_iTop , 0L, ptrTerrain->tr_pixHeightMapHeight); rcSelection.rc_iTop = Clamp(rcExtract.rc_iTop , 0, ptrTerrain->tr_pixHeightMapHeight);
rcSelection.rc_iRight = Clamp(rcExtract.rc_iRight , 0L, ptrTerrain->tr_pixHeightMapWidth); rcSelection.rc_iRight = Clamp(rcExtract.rc_iRight , 0, ptrTerrain->tr_pixHeightMapWidth);
rcSelection.rc_iBottom = Clamp(rcExtract.rc_iBottom , 0L, ptrTerrain->tr_pixHeightMapHeight); rcSelection.rc_iBottom = Clamp(rcExtract.rc_iBottom , 0, ptrTerrain->tr_pixHeightMapHeight);
// Prepare box for vertex selection // Prepare box for vertex selection
bboxSelection = FLOAT3D(rcSelection.rc_iLeft, 0, rcSelection.rc_iTop); 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]; UWORD *puwFirstInHeightMap = &ptrTerrain->tr_auwHeightMap[0];
// for each row // for each row
for(PIX pixY=pixTop;pixY<pixBottom;pixY++) { for(PIX pixY=pixTop;pixY<pixBottom;pixY++) {
PIX pixRealY = Clamp(pixY,0L,pixMaxHeight-1L); PIX pixRealY = Clamp(pixY,0,pixMaxHeight-1);
// for each col // for each col
for(PIX pixX=pixLeft;pixX<pixRight;pixX++) { for(PIX pixX=pixLeft;pixX<pixRight;pixX++) {
PIX pixRealX = Clamp(pixX,0L,pixMaxWidth-1L); PIX pixRealX = Clamp(pixX,0,pixMaxWidth-1);
// Copy current pixel from height map to dest buffer // Copy current pixel from height map to dest buffer
UWORD *puwHeight = &puwFirstInHeightMap[pixRealX + pixRealY*pixMaxWidth]; UWORD *puwHeight = &puwFirstInHeightMap[pixRealX + pixRealY*pixMaxWidth];
*puwBufferData = *puwHeight; *puwBufferData = *puwHeight;
@ -319,10 +319,10 @@ UWORD *GetBufferForEditing(CTerrain *ptrTerrain, Rect &rcExtract, BufferType btB
UBYTE *pubFirstInLayer = &tl.tl_aubColors[0]; UBYTE *pubFirstInLayer = &tl.tl_aubColors[0];
// for each row // for each row
for(PIX pixY=pixTop;pixY<pixBottom;pixY++) { for(PIX pixY=pixTop;pixY<pixBottom;pixY++) {
PIX pixRealY = Clamp(pixY,0L,pixMaxHeight-1L); PIX pixRealY = Clamp(pixY,0,pixMaxHeight-1);
// for each col // for each col
for(PIX pixX=pixLeft;pixX<pixRight;pixX++) { for(PIX pixX=pixLeft;pixX<pixRight;pixX++) {
PIX pixRealX = Clamp(pixX,0L,pixMaxWidth-1L); PIX pixRealX = Clamp(pixX,0,pixMaxWidth-1);
// Copy current pixel from layer mask to dest buffer // Copy current pixel from layer mask to dest buffer
UBYTE *pubMaskValue = &pubFirstInLayer[pixRealX + pixRealY*pixMaxWidth]; UBYTE *pubMaskValue = &pubFirstInLayer[pixRealX + pixRealY*pixMaxWidth];
*puwBufferData = (*pubMaskValue)<<8|(*pubMaskValue); *puwBufferData = (*pubMaskValue)<<8|(*pubMaskValue);
@ -335,10 +335,10 @@ UWORD *GetBufferForEditing(CTerrain *ptrTerrain, Rect &rcExtract, BufferType btB
UBYTE *pubFirstInEdgeMap = &ptrTerrain->tr_aubEdgeMap[0]; UBYTE *pubFirstInEdgeMap = &ptrTerrain->tr_aubEdgeMap[0];
// for each row // for each row
for(PIX pixY=pixTop;pixY<pixBottom;pixY++) { for(PIX pixY=pixTop;pixY<pixBottom;pixY++) {
PIX pixRealY = Clamp(pixY,0L,pixMaxHeight-1L); PIX pixRealY = Clamp(pixY,0,pixMaxHeight-1);
// for each col // for each col
for(PIX pixX=pixLeft;pixX<pixRight;pixX++) { for(PIX pixX=pixLeft;pixX<pixRight;pixX++) {
PIX pixRealX = Clamp(pixX,0L,pixMaxWidth-1L); PIX pixRealX = Clamp(pixX,0,pixMaxWidth-1);
// Copy current pixel from layer mask to dest buffer // Copy current pixel from layer mask to dest buffer
UBYTE *pubEdgeValue = &pubFirstInEdgeMap[pixRealX + pixRealY*pixMaxWidth]; UBYTE *pubEdgeValue = &pubFirstInEdgeMap[pixRealX + pixRealY*pixMaxWidth];
if((*pubEdgeValue)==255) { if((*pubEdgeValue)==255) {

View File

@ -770,9 +770,9 @@ static void CalcPointLight(CPlacement3D &plLight, CLightSource *plsLight, Rect &
fDot = Clamp(fDot,0.0f,1.0f); fDot = Clamp(fDot,0.0f,1.0f);
SLONG slDot = NormFloatToByte(fDot); SLONG slDot = NormFloatToByte(fDot);
pacolData->ub.r = ClampUp(pacolData->ub.r + ((colLight.ub.r*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),255L); 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),255L); pacolData->ub.b = ClampUp(pacolData->ub.b + ((colLight.ub.b*slDot)>>8),255);
pacolData->ub.a = 255; pacolData->ub.a = 255;
pacolData++; pacolData++;
} }
@ -810,9 +810,9 @@ static void CalcDirectionalLight(CPlacement3D &plLight, CLightSource *plsLight,
// is overbrightning enabled // is overbrightning enabled
if(bOverBrightning) { if(bOverBrightning) {
slar = ClampUp(slar,127L); slar = ClampUp(slar,127);
slag = ClampUp(slag,127L); slag = ClampUp(slag,127);
slab = ClampUp(slab,127L); slab = ClampUp(slab,127);
ubColShift = 8; ubColShift = 8;
} else { } else {
slar*=2; slar*=2;
@ -838,9 +838,9 @@ static void CalcDirectionalLight(CPlacement3D &plLight, CLightSource *plsLight,
fDot = Clamp(fDot,0.0f,1.0f); fDot = Clamp(fDot,0.0f,1.0f);
SLONG slDot = NormFloatToByte(fDot); SLONG slDot = NormFloatToByte(fDot);
pacolData->ub.r = ClampUp(pacolData->ub.r + slar + ((colLight.ub.r*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),255L); 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),255L); pacolData->ub.b = ClampUp(pacolData->ub.b + slab + ((colLight.ub.b*slDot)>>ubColShift),255);
pacolData->ub.a = 255; pacolData->ub.a = 255;
pacolData++; pacolData++;
} }

View File

@ -1138,7 +1138,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO
FLOAT fCharHeight = (_pfdDisplayFont->GetHeight()-2)*fTextScale; FLOAT fCharHeight = (_pfdDisplayFont->GetHeight()-2)*fTextScale;
// generate and sort by mana list of active players // generate and sort by mana list of active players
BOOL bMaxScore=TRUE, bMaxMana=TRUE, bMaxFrags=TRUE, bMaxDeaths=TRUE; 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; SortKeys eKey = (SortKeys)hud_iSortPlayers;
if (hud_iSortPlayers==-1) { if (hud_iSortPlayers==-1) {
if (bCooperative) eKey = PSK_HEALTH; 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 if (bFragMatch) eKey = PSK_FRAGS;
else { ASSERT(FALSE); eKey = PSK_NAME; } 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 if( eKey==PSK_HEALTH && (bScoreMatch || bFragMatch)) { eKey = PSK_NAME; }; // prevent health snooping in deathmatch
INDEX iPlayers = SetAllPlayersStats(eKey); INDEX iPlayers = SetAllPlayersStats(eKey);
// loop thru players // loop thru players
@ -1158,8 +1158,8 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO
const INDEX iMana = penPlayer->m_iMana; const INDEX iMana = penPlayer->m_iMana;
const INDEX iFrags = penPlayer->m_psGameStats.ps_iKills; const INDEX iFrags = penPlayer->m_psGameStats.ps_iKills;
const INDEX iDeaths = penPlayer->m_psGameStats.ps_iDeaths; const INDEX iDeaths = penPlayer->m_psGameStats.ps_iDeaths;
const INDEX iHealth = ClampDn( (INDEX)ceil( penPlayer->GetHealth()), 0L); const INDEX iHealth = ClampDn( (INDEX)ceil( penPlayer->GetHealth()), 0);
const INDEX iArmor = ClampDn( (INDEX)ceil( penPlayer->m_fArmor), 0L); const INDEX iArmor = ClampDn( (INDEX)ceil( penPlayer->m_fArmor), 0);
CTString strScore, strMana, strFrags, strDeaths, strHealth, strArmor; CTString strScore, strMana, strFrags, strDeaths, strHealth, strArmor;
strScore.PrintF( "%d", iScore); strScore.PrintF( "%d", iScore);
strMana.PrintF( "%d", iMana); strMana.PrintF( "%d", iMana);

View File

@ -1045,7 +1045,7 @@ void Particles_BeastProjectileTrail( CEntity *pen, FLOAT fSize, FLOAT fHeight, I
vZ*(afStarsPositions[iStar][2]*time*fSize*1.5); vZ*(afStarsPositions[iStar][2]*time*fSize*1.5);
FLOAT3D vPos = GET_POS( fT); 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) 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); vZ*(afStarsPositions[iStar][2]*time*fSize*1.5);
FLOAT3D vPos = GET_POS_BIG( fT); 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) 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)) + vY*(fT*fT*-4.0f+(afStarsPositions[iStar][1]*fPowerFactor*0.1)) +
vZ*(afStarsPositions[iStar][2]*fPowerFactor*fT*fStretchAll); 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); ULONG ulA = FloatToInt( ((colLava&CT_AMASK)>>CT_ASHIFT) * fFade);
colLava = (colLava&~CT_AMASK) | (ulA<<CT_ASHIFT); colLava = (colLava&~CT_AMASK) | (ulA<<CT_ASHIFT);
Particle_RenderSquare( vPos, fSize, 0, colLava); Particle_RenderSquare( vPos, fSize, 0, colLava);
@ -4776,7 +4776,7 @@ void Particles_AfterBurner(CEntity *pen, FLOAT tmSpawn, FLOAT fStretch, INDEX iG
FLOAT fT=(iPos+_pTimer->GetLerpFactor())*_pTimer->TickQuantum; FLOAT fT=(iPos+_pTimer->GetLerpFactor())*_pTimer->TickQuantum;
FLOAT fRatio=fT/(CT_AFTERBURNER_SMOKES*_pTimer->TickQuantum); FLOAT fRatio=fT/(CT_AFTERBURNER_SMOKES*_pTimer->TickQuantum);
INDEX iIndex=(INDEX) (fRatio*255); INDEX iIndex=(INDEX) (fRatio*255);
INDEX iRnd=INDEX(pvPos1)%CT_MAX_PARTICLES_TABLE; INDEX iRnd=(INDEX)(size_t(pvPos1)%CT_MAX_PARTICLES_TABLE);
// smoke // smoke
FLOAT3D vPosS = *pvPos1; 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 fT=(iPos+_pTimer->GetLerpFactor())*_pTimer->TickQuantum;
FLOAT fRatio=fT/(CT_AFTERBURNER_SMOKES*_pTimer->TickQuantum); FLOAT fRatio=fT/(CT_AFTERBURNER_SMOKES*_pTimer->TickQuantum);
INDEX iIndex=(INDEX) (fRatio*255); INDEX iIndex=(INDEX) (fRatio*255);
INDEX iRnd=INDEX(pvPos1)%CT_MAX_PARTICLES_TABLE; INDEX iRnd=(INDEX)(size_t(pvPos1)%CT_MAX_PARTICLES_TABLE);
// smoke // smoke
FLOAT3D vPosS = *pvPos1; FLOAT3D vPosS = *pvPos1;

View File

@ -1643,7 +1643,9 @@ functions:
CTString GetStatsRealWorldStarted(void) CTString GetStatsRealWorldStarted(void)
{ {
struct tm *newtime; 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, ""); setlocale(LC_ALL, "");
CTString strTimeline; CTString strTimeline;
@ -2663,7 +2665,7 @@ functions:
void RenderGameView(CDrawPort *pdp, void *pvUserData) void RenderGameView(CDrawPort *pdp, void *pvUserData)
{ {
BOOL bShowExtras = (ULONG(pvUserData)&GRV_SHOWEXTRAS); BOOL bShowExtras = (size_t(pvUserData)&GRV_SHOWEXTRAS) != 0;
pdp->Unlock(); pdp->Unlock();
// if not yet initialized // if not yet initialized
@ -5370,7 +5372,10 @@ functions:
m_iMayRespawn = 0; m_iMayRespawn = 0;
m_bEndOfLevel = TRUE; m_bEndOfLevel = TRUE;
// remember end time // remember end time
time(&m_iEndTime); STUBBED("Not 64-bit clean");
time_t t;
time(&t);
m_iEndTime = (INDEX) t;
// add time score // add time score
TIME tmLevelTime = _pTimer->CurrentTick()-m_tmLevelStarted; TIME tmLevelTime = _pTimer->CurrentTick()-m_tmLevelStarted;
m_psLevelStats.ps_tmTime = tmLevelTime; m_psLevelStats.ps_tmTime = tmLevelTime;
@ -6552,8 +6557,10 @@ procedures:
Main(EVoid evoid) Main(EVoid evoid)
{ {
// remember start time // remember start time
time(&m_iStartTime); STUBBED("Not 64-bit clean");
time_t t;
time(&t);
m_iStartTime = (INDEX) t;
m_ctUnreadMessages = 0; m_ctUnreadMessages = 0;
SetFlags(GetFlags()|ENF_CROSSESLEVELS|ENF_NOTIFYLEVELCHANGE); SetFlags(GetFlags()|ENF_CROSSESLEVELS|ENF_NOTIFYLEVELCHANGE);
InitAsEditorModel(); InitAsEditorModel();

View File

@ -272,11 +272,11 @@ void MessagesUpDn(INDEX ctLines)
{ {
INDEX ctMessages = _acmMessages.Count(); INDEX ctMessages = _acmMessages.Count();
_iWantedFirstMessageOnScreen += ctLines; _iWantedFirstMessageOnScreen += ctLines;
INDEX iMaxFirst = ClampDn(0L, ctMessages-_ctMessagesOnScreen); INDEX iMaxFirst = ClampDn(0, ctMessages-_ctMessagesOnScreen);
_iWantedFirstMessageOnScreen = Clamp(_iWantedFirstMessageOnScreen, 0L, iMaxFirst); _iWantedFirstMessageOnScreen = Clamp(_iWantedFirstMessageOnScreen, 0, iMaxFirst);
_iActiveMessage = Clamp(_iActiveMessage, _iActiveMessage = Clamp(_iActiveMessage,
_iWantedFirstMessageOnScreen, _iWantedFirstMessageOnScreen,
_iWantedFirstMessageOnScreen+_ctMessagesOnScreen-1L); _iWantedFirstMessageOnScreen+_ctMessagesOnScreen-1);
} }
void SelectMessage(INDEX i) void SelectMessage(INDEX i)
@ -506,7 +506,7 @@ static void UpdateSize(CDrawPort *pdp)
_boxMsgImage= PIXaabbox2D(); _boxMsgImage= PIXaabbox2D();
} }
FLOAT fSlideSpeed = Max(_pixSizeI, _pixSizeJ*2L); FLOAT fSlideSpeed = Max(_pixSizeI, _pixSizeJ*2);
FLOAT fGroup0 = ClampDn((1-fComputerFadeValue)*fSlideSpeed-_pixSizeJ, 0.0f); FLOAT fGroup0 = ClampDn((1-fComputerFadeValue)*fSlideSpeed-_pixSizeJ, 0.0f);
FLOAT fGroup1 = (1-fComputerFadeValue)*fSlideSpeed; FLOAT fGroup1 = (1-fComputerFadeValue)*fSlideSpeed;
// animate box positions // animate box positions
@ -1193,8 +1193,8 @@ void CGame::ComputerRender(CDrawPort *pdp)
_pGfx->GetCurrentDisplayMode(dmCurrent); _pGfx->GetCurrentDisplayMode(dmCurrent);
if (dmCurrent.IsFullScreen() && dmCurrent.IsDualHead()) { if (dmCurrent.IsFullScreen() && dmCurrent.IsDualHead()) {
// clamp mouse pointer // clamp mouse pointer
_vpixMouse(1) = Clamp(_vpixMouse(1), 0L, dpComp.GetWidth()); _vpixMouse(1) = Clamp(_vpixMouse(1), 0, dpComp.GetWidth());
_vpixMouse(2) = Clamp(_vpixMouse(2), 0L, dpComp.GetHeight()); _vpixMouse(2) = Clamp(_vpixMouse(2), 0, dpComp.GetHeight());
// if in window // if in window
} else { } else {
// use same mouse pointer as windows // use same mouse pointer as windows

View File

@ -193,7 +193,7 @@ void CGame::ConsoleRender(CDrawPort *pdp)
} }
// render previous outputs // render previous outputs
con_iFirstLine = ClampDn( con_iFirstLine, 1L); con_iFirstLine = ClampDn( con_iFirstLine, 1);
pixYLine -= (PIX)(pixLineSpacing * 1.333f); pixYLine -= (PIX)(pixLineSpacing * 1.333f);
ctConsoleLinesOnScreen = pixYLine/pixLineSpacing; ctConsoleLinesOnScreen = pixYLine/pixLineSpacing;
while( pixYLine >= 0) { while( pixYLine >= 0) {
@ -519,7 +519,7 @@ static void Key_PgDn( BOOL bShift)
{ {
if( bShift) con_iFirstLine -= ctConsoleLinesOnScreen; if( bShift) con_iFirstLine -= ctConsoleLinesOnScreen;
else con_iFirstLine--; else con_iFirstLine--;
con_iFirstLine = ClampDn( con_iFirstLine, 1L); con_iFirstLine = ClampDn( con_iFirstLine, 1);
} }

View File

@ -201,7 +201,7 @@ CEnableUserBreak::~CEnableUserBreak() {
static void DumpDemoProfile(void) static void DumpDemoProfile(void)
{ {
CTString strFragment, strAnalyzed; CTString strFragment, strAnalyzed;
dem_iProfileRate = Clamp( dem_iProfileRate, 0L, 60L); dem_iProfileRate = Clamp( dem_iProfileRate, 0, 60);
strFragment = _pGame->DemoReportFragmentsProfile( dem_iProfileRate); strFragment = _pGame->DemoReportFragmentsProfile( dem_iProfileRate);
strAnalyzed = _pGame->DemoReportAnalyzedProfile(); strAnalyzed = _pGame->DemoReportAnalyzedProfile();
try { try {
@ -225,7 +225,7 @@ static void DumpDemoProfile(void)
static void ReportDemoProfile(void) static void ReportDemoProfile(void)
{ {
CTString strFragment, strAnalyzed; CTString strFragment, strAnalyzed;
dem_iProfileRate = Clamp( dem_iProfileRate, 0L, 60L); dem_iProfileRate = Clamp( dem_iProfileRate, 0, 60);
strFragment = _pGame->DemoReportFragmentsProfile( dem_iProfileRate); strFragment = _pGame->DemoReportFragmentsProfile( dem_iProfileRate);
strAnalyzed = _pGame->DemoReportAnalyzedProfile(); strAnalyzed = _pGame->DemoReportAnalyzedProfile();
CPrintF( strFragment); CPrintF( strFragment);
@ -1896,7 +1896,7 @@ static void PrintStats( CDrawPort *pdpDrawPort)
} }
// if stats aren't required // 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)) { if( hud_iStats==0 || (hud_iEnableStats==0 && hud_fEnableFPS==0)) {
// display nothing // display nothing
_iCheckNow = 0; _iCheckNow = 0;
@ -1979,7 +1979,7 @@ static void MakeSplitDrawports(enum CGame::SplitScreenCfg ssc, INDEX iCount, CDr
// if observer // if observer
if (ssc==CGame::SSC_OBSERVER) { if (ssc==CGame::SSC_OBSERVER) {
// must have at least one screen // must have at least one screen
iCount = Clamp(iCount, 1L, 4L); iCount = Clamp(iCount, 1, 4);
// starting at first drawport // starting at first drawport
iFirstObserver = 0; iFirstObserver = 0;
} }
@ -2185,10 +2185,10 @@ void CGame::GameRedrawView( CDrawPort *pdpDrawPort, ULONG ulFlags)
&& gm_CurrentSplitScreenCfg!=SSC_DEDICATED ) && gm_CurrentSplitScreenCfg!=SSC_DEDICATED )
{ {
INDEX ctObservers = Clamp(gam_iObserverConfig, 0L, 4L); INDEX ctObservers = Clamp(gam_iObserverConfig, 0, 4);
INDEX iObserverOffset = ClampDn(gam_iObserverOffset, 0L); INDEX iObserverOffset = ClampDn(gam_iObserverOffset, 0);
if (gm_CurrentSplitScreenCfg==SSC_OBSERVER) { if (gm_CurrentSplitScreenCfg==SSC_OBSERVER) {
ctObservers = ClampDn(ctObservers, 1L); ctObservers = ClampDn(ctObservers, 1);
} }
if (gm_CurrentSplitScreenCfg!=SSC_OBSERVER) { if (gm_CurrentSplitScreenCfg!=SSC_OBSERVER) {
if (!gam_bEnableAdvancedObserving || !GetSP()->sp_bCooperative) { if (!gam_bEnableAdvancedObserving || !GetSP()->sp_bCooperative) {
@ -2294,7 +2294,7 @@ void CGame::GameRedrawView( CDrawPort *pdpDrawPort, ULONG ulFlags)
if (!CAM_IsOn()) { if (!CAM_IsOn()) {
_bPlayerViewRendered = TRUE; _bPlayerViewRendered = TRUE;
// render it // render it
apenViewers[i]->RenderGameView(pdp, (void*)ulFlags); apenViewers[i]->RenderGameView(pdp, (void*)((size_t)ulFlags));
} else { } else {
CAM_Render(apenViewers[i], pdp); CAM_Render(apenViewers[i], pdp);
} }

View File

@ -53,7 +53,7 @@ extern CTString gam_strGameAgentExtras;
static void SetGameModeParameters(CSessionProperties &sp) 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) { switch (sp.sp_gmGameMode) {
default: default:
@ -79,7 +79,7 @@ static void SetDifficultyParameters(CSessionProperties &sp)
} else { } else {
sp.sp_bMental = FALSE; 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) { switch (sp.sp_gdGameDifficulty) {
case CSessionProperties::GD_TOURIST: case CSessionProperties::GD_TOURIST:
@ -163,7 +163,7 @@ void CGame::SetSinglePlayerSession(CSessionProperties &sp)
sp.sp_fExtraEnemyStrength = 0; sp.sp_fExtraEnemyStrength = 0;
sp.sp_fExtraEnemyStrengthPerPlayer = 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; sp.sp_bGibs = gam_bGibs;
} }
@ -218,7 +218,7 @@ void CGame::SetMultiPlayerSession(CSessionProperties &sp)
sp.sp_fExtraEnemyStrengthPerPlayer = gam_fExtraEnemyStrengthPerPlayer; sp.sp_fExtraEnemyStrengthPerPlayer = gam_fExtraEnemyStrengthPerPlayer;
sp.sp_iInitialMana = gam_iInitialMana; 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_bGibs = gam_bGibs;
sp.sp_tmSpawnInvulnerability = gam_tmSpawnInvulnerability; sp.sp_tmSpawnInvulnerability = gam_tmSpawnInvulnerability;

View File

@ -152,7 +152,7 @@ extern void ApplyGLSettings(BOOL bForce)
} }
// clamp rendering preferences (just to be on the safe side) // 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)); CPrintF(TRANSV("Mode: %s\n"), (const char *) RenderingPreferencesDescription(sam_iVideoSetup));
// if not in custom mode // if not in custom mode
if (sam_iVideoSetup<3) { if (sam_iVideoSetup<3) {

View File

@ -2050,7 +2050,7 @@ void RefreshSoundFormat( void)
} }
mgAudioAutoTrigger.mg_iSelected = Clamp(sam_bAutoAdjustAudio, 0, 1); 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_iMinPos = 0;
mgWaveVolume.mg_iMaxPos = VOLUME_STEPS; mgWaveVolume.mg_iMaxPos = VOLUME_STEPS;
@ -2564,8 +2564,8 @@ BOOL DoMenu( CDrawPort *pdp)
_pGfx->GetCurrentDisplayMode(dmCurrent); _pGfx->GetCurrentDisplayMode(dmCurrent);
if (dmCurrent.IsFullScreen()) { if (dmCurrent.IsFullScreen()) {
// clamp mouse pointer // clamp mouse pointer
_pixCursorPosI = Clamp(_pixCursorPosI, 0L, dpMenu.GetWidth()); _pixCursorPosI = Clamp(_pixCursorPosI, 0, dpMenu.GetWidth());
_pixCursorPosJ = Clamp(_pixCursorPosJ, 0L, dpMenu.GetHeight()); _pixCursorPosJ = Clamp(_pixCursorPosJ, 0, dpMenu.GetHeight());
// if in window // if in window
} else { } else {
// use same mouse pointer as windows // use same mouse pointer as windows
@ -3020,7 +3020,7 @@ void CGameMenu::StartMenu(void)
// scroll it so that the wanted tem is centered // scroll it so that the wanted tem is centered
gm_iListOffset = gm_iListWantedItem-gm_ctListVisible/2; gm_iListOffset = gm_iListWantedItem-gm_ctListVisible/2;
// clamp the scrolling // 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 // fill the list
FillListItems(); FillListItems();
@ -5660,7 +5660,7 @@ void CNetworkStartMenu::StartMenu(void)
extern INDEX sam_bMentalActivated; extern INDEX sam_bMentalActivated;
mgNetworkDifficulty.mg_ctTexts = sam_bMentalActivated?6:5; 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(); mgNetworkGameType.ApplyCurrentSelection();
mgNetworkDifficulty.mg_iSelected = _pShell->GetINDEX("gam_iStartDifficulty")+1; mgNetworkDifficulty.mg_iSelected = _pShell->GetINDEX("gam_iStartDifficulty")+1;
mgNetworkDifficulty.ApplyCurrentSelection(); mgNetworkDifficulty.ApplyCurrentSelection();
@ -5676,7 +5676,7 @@ void CNetworkStartMenu::StartMenu(void)
mgNetworkMaxPlayers.mg_iSelected = ctMaxPlayers-2; mgNetworkMaxPlayers.mg_iSelected = ctMaxPlayers-2;
mgNetworkMaxPlayers.ApplyCurrentSelection(); mgNetworkMaxPlayers.ApplyCurrentSelection();
mgNetworkWaitAllPlayers.mg_iSelected = Clamp(_pShell->GetINDEX("gam_bWaitAllPlayers"), 0L, 1L); mgNetworkWaitAllPlayers.mg_iSelected = Clamp(_pShell->GetINDEX("gam_bWaitAllPlayers"), 0, 1);
mgNetworkWaitAllPlayers.ApplyCurrentSelection(); mgNetworkWaitAllPlayers.ApplyCurrentSelection();
mgNetworkVisible.mg_iSelected = _pShell->GetINDEX("ser_bEnumeration"); mgNetworkVisible.mg_iSelected = _pShell->GetINDEX("ser_bEnumeration");
@ -6131,13 +6131,13 @@ void CSplitStartMenu::StartMenu(void)
extern INDEX sam_bMentalActivated; extern INDEX sam_bMentalActivated;
mgSplitDifficulty.mg_ctTexts = sam_bMentalActivated?6:5; 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(); mgSplitGameType.ApplyCurrentSelection();
mgSplitDifficulty.mg_iSelected = _pShell->GetINDEX("gam_iStartDifficulty")+1; mgSplitDifficulty.mg_iSelected = _pShell->GetINDEX("gam_iStartDifficulty")+1;
mgSplitDifficulty.ApplyCurrentSelection(); mgSplitDifficulty.ApplyCurrentSelection();
// clamp maximum number of players to at least 4 // 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); UpdateSplitLevel(0);
CGameMenu::StartMenu(); CGameMenu::StartMenu();

View File

@ -267,7 +267,7 @@ void CMGButton::Render( CDrawPort *pdp)
if (pdp->dp_FontData->fd_bFixedWidth) { if (pdp->dp_FontData->fd_bFixedWidth) {
str = str.Undecorated(); str = str.Undecorated();
INDEX iLen = str.Length(); 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) { if (iCursor>=iMaxLen) {
str.TrimRight(iCursor); str.TrimRight(iCursor);
str.TrimLeft(iMaxLen); str.TrimLeft(iMaxLen);
@ -526,7 +526,7 @@ BOOL CMGEdit::OnChar( MSG msg)
// only chars are allowed // only chars are allowed
const INDEX ctFullLen = mg_strText.Length(); const INDEX ctFullLen = mg_strText.Length();
const INDEX ctNakedLen = mg_strText.LengthNaked(); const INDEX ctNakedLen = mg_strText.LengthNaked();
mg_iCursorPos = Clamp( mg_iCursorPos, 0L, ctFullLen); mg_iCursorPos = Clamp( mg_iCursorPos, 0, ctFullLen);
int iVKey = msg.wParam; int iVKey = msg.wParam;
if( isprint(iVKey) && ctNakedLen<=mg_ctMaxStringLen) { if( isprint(iVKey) && ctNakedLen<=mg_ctMaxStringLen) {
mg_strText.InsertChar( mg_iCursorPos, (char)iVKey); mg_strText.InsertChar( mg_iCursorPos, (char)iVKey);
@ -704,7 +704,7 @@ CMGTrigger::CMGTrigger( void)
void CMGTrigger::ApplyCurrentSelection(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]; mg_strValue = mg_astrTexts[ mg_iSelected];
} }
@ -1302,13 +1302,13 @@ CMGServerList::CMGServerList()
void CMGServerList::AdjustFirstOnScreen(void) void CMGServerList::AdjustFirstOnScreen(void)
{ {
INDEX ctSessions = _lhServers.Count(); INDEX ctSessions = _lhServers.Count();
mg_iSelected = Clamp(mg_iSelected, 0L, ClampDn(ctSessions-1L, 0L)); mg_iSelected = Clamp(mg_iSelected, 0, ClampDn(ctSessions-1, 0));
mg_iFirstOnScreen = Clamp(mg_iFirstOnScreen, 0L, ClampDn(ctSessions-mg_ctOnScreen, 0L)); mg_iFirstOnScreen = Clamp(mg_iFirstOnScreen, 0, ClampDn(ctSessions-mg_ctOnScreen, 0));
if (mg_iSelected<mg_iFirstOnScreen) { if (mg_iSelected<mg_iFirstOnScreen) {
mg_iFirstOnScreen = ClampUp(mg_iSelected, ClampDn(ctSessions-mg_ctOnScreen-1L, 0L)); mg_iFirstOnScreen = ClampUp(mg_iSelected, ClampDn(ctSessions-mg_ctOnScreen-1, 0));
} else if (mg_iSelected>=mg_iFirstOnScreen+mg_ctOnScreen) { } else 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 ctSessions = _lhServers.Count();
INDEX iWantedLine = mg_iDragLine+ INDEX iWantedLine = mg_iDragLine+
SliderPixToIndex(pixDelta, mg_ctOnScreen, ctSessions, GetScrollBarFullBox()); SliderPixToIndex(pixDelta, mg_ctOnScreen, ctSessions, GetScrollBarFullBox());
mg_iFirstOnScreen = Clamp(iWantedLine, 0L, ClampDn(ctSessions-mg_ctOnScreen, 0L)); mg_iFirstOnScreen = Clamp(iWantedLine, 0, ClampDn(ctSessions-mg_ctOnScreen, 0));
mg_iSelected = Clamp(mg_iSelected, mg_iFirstOnScreen, mg_iFirstOnScreen+mg_ctOnScreen-1L); mg_iSelected = Clamp(mg_iSelected, mg_iFirstOnScreen, mg_iFirstOnScreen+mg_ctOnScreen-1);
// AdjustFirstOnScreen(); // AdjustFirstOnScreen();
return; return;
} }

View File

@ -273,12 +273,12 @@ void LimitFrameRate(void)
TIME tmCurrentDelta = (tvNow-tvLast).GetSeconds(); TIME tmCurrentDelta = (tvNow-tvLast).GetSeconds();
// limit maximum frame rate // limit maximum frame rate
sam_iMaxFPSActive = ClampDn( (INDEX)sam_iMaxFPSActive, 1L); sam_iMaxFPSActive = ClampDn( (INDEX)sam_iMaxFPSActive, 1);
sam_iMaxFPSInactive = ClampDn( (INDEX)sam_iMaxFPSInactive, 1L); sam_iMaxFPSInactive = ClampDn( (INDEX)sam_iMaxFPSInactive, 1);
INDEX iMaxFPS = sam_iMaxFPSActive; INDEX iMaxFPS = sam_iMaxFPSActive;
if( IsIconic(_hwndMain)) iMaxFPS = sam_iMaxFPSInactive; if( IsIconic(_hwndMain)) iMaxFPS = sam_iMaxFPSInactive;
if(_pGame->gm_CurrentSplitScreenCfg==CGame::SSC_DEDICATED) { 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; TIME tmWantedDelta = 1.0f / iMaxFPS;
if( tmCurrentDelta<tmWantedDelta) _pTimer->Sleep( (tmWantedDelta-tmCurrentDelta)*1000.0f); if( tmCurrentDelta<tmWantedDelta) _pTimer->Sleep( (tmWantedDelta-tmCurrentDelta)*1000.0f);

View File

@ -258,7 +258,7 @@ BOOL CVarSetting::Validate(void)
return FALSE; return FALSE;
} }
if (!vs_bCustom) { if (!vs_bCustom) {
vs_iValue = Clamp(vs_iValue, 0L, vs_ctValues-1L); vs_iValue = Clamp(vs_iValue, 0, vs_ctValues-1);
} }
return TRUE; return TRUE;
} }

View File

@ -41,9 +41,9 @@ void DoSpecularLayer(INDEX iSpeculaTexture,INDEX iSpecularColor)
SLONG slAG = (colAmbient & CT_GMASK)>>(CT_GSHIFT-iBright); SLONG slAG = (colAmbient & CT_GMASK)>>(CT_GSHIFT-iBright);
SLONG slAB = (colAmbient & CT_BMASK)>>(CT_BSHIFT-iBright); SLONG slAB = (colAmbient & CT_BMASK)>>(CT_BSHIFT-iBright);
if( bOverbright) { if( bOverbright) {
slAR = ClampUp( slAR, 127L); slAR = ClampUp( slAR, 127);
slAG = ClampUp( slAG, 127L); slAG = ClampUp( slAG, 127);
slAB = ClampUp( slAB, 127L); slAB = ClampUp( slAB, 127);
} }
@ -70,9 +70,9 @@ void DoSpecularLayer(INDEX iSpeculaTexture,INDEX iSpecularColor)
GFXColor colSrfSpec = shaGetColor(iSpecularColor); GFXColor colSrfSpec = shaGetColor(iSpecularColor);
colSrfSpec.AttenuateRGB( (shaGetModelColor()&CT_AMASK)>>CT_ASHIFT); colSrfSpec.AttenuateRGB( (shaGetModelColor()&CT_AMASK)>>CT_ASHIFT);
colSrfSpec.ub.r = ClampUp( (colSrfSpec.ub.r *slLR)>>8, 255L); colSrfSpec.ub.r = ClampUp( (colSrfSpec.ub.r *slLR)>>8, 255);
colSrfSpec.ub.g = ClampUp( (colSrfSpec.ub.g *slLG)>>8, 255L); colSrfSpec.ub.g = ClampUp( (colSrfSpec.ub.g *slLG)>>8, 255);
colSrfSpec.ub.b = ClampUp( (colSrfSpec.ub.b *slLB)>>8, 255L); colSrfSpec.ub.b = ClampUp( (colSrfSpec.ub.b *slLB)>>8, 255);
GFXColor *pcolSpec = shaGetNewColorArray(); GFXColor *pcolSpec = shaGetNewColorArray();
GFXColor *pcolBase = shaGetColorArray();; GFXColor *pcolBase = shaGetColorArray();;

View File

@ -12,6 +12,12 @@ mkdir $_
cd $_ cd $_
#cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 .. #cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 ..
#ninja #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 .. cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 ..
make -j$NCPU make -j$NCPU