From 65d8d44f0eb238edce9a4c8fc92d9432d4ffd4a5 Mon Sep 17 00:00:00 2001 From: Tan Wang Leng Date: Sat, 23 Apr 2016 22:49:07 +0800 Subject: [PATCH 01/34] Fix mouse wheel for switching weapons This fixes #32. Strictly follows the Win32 version. --- Sources/Engine/Base/SDL/SDLInput.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/Sources/Engine/Base/SDL/SDLInput.cpp b/Sources/Engine/Base/SDL/SDLInput.cpp index d378cc1..6b39711 100755 --- a/Sources/Engine/Base/SDL/SDLInput.cpp +++ b/Sources/Engine/Base/SDL/SDLInput.cpp @@ -251,6 +251,10 @@ static int _iMouseZ = 0; static BOOL _bWheelUp = FALSE; static BOOL _bWheelDn = FALSE; +// emulate Win32: A single mouse wheel rotation +// is +120 (upwards) or -120 (downwards) +#define MOUSE_SCROLL_INTERVAL 120 + CTCriticalSection csInput; // which keys are pressed, as recorded by message interception (by KIDs) @@ -319,10 +323,7 @@ static void sdl_event_handler(const SDL_Event *event) break; case SDL_MOUSEWHEEL: - if (event->wheel.y > 0) - _abKeysPressed[KID_MOUSEWHEELUP] = TRUE; - else if (event->wheel.y < 0) - _abKeysPressed[KID_MOUSEWHEELDOWN] = TRUE; + _iMouseZ += event->wheel.y * MOUSE_SCROLL_INTERVAL; break; case SDL_KEYDOWN: @@ -744,10 +745,6 @@ void CInput::GetInput(BOOL bPreScan) } } - // reset this every frame (since we explicitly ignore the button-up events). - _abKeysPressed[KID_MOUSEWHEELUP] = FALSE; - _abKeysPressed[KID_MOUSEWHEELDOWN] = FALSE; - // read mouse position #ifdef USE_MOUSEWARP int iMx, iMy; @@ -816,17 +813,16 @@ void CInput::GetInput(BOOL bPreScan) } #endif -/* // if not pre-scanning if (!bPreScan) { // detect wheel up/down movement - _bWheelDn = FALSE; + if (_iMouseZ>0) { if (_bWheelUp) { inp_ubButtonsBuffer[KID_MOUSEWHEELUP] = 0x00; } else { inp_ubButtonsBuffer[KID_MOUSEWHEELUP] = 0xFF; - _iMouseZ = ClampDn(_iMouseZ-120, 0); + _iMouseZ = ClampDn(_iMouseZ-MOUSE_SCROLL_INTERVAL, 0); } } _bWheelUp = inp_ubButtonsBuffer[KID_MOUSEWHEELUP]; @@ -835,12 +831,11 @@ void CInput::GetInput(BOOL bPreScan) inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN] = 0x00; } else { inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN] = 0xFF; - _iMouseZ = ClampUp(_iMouseZ+120, 0); + _iMouseZ = ClampUp(_iMouseZ+MOUSE_SCROLL_INTERVAL, 0); } } _bWheelDn = inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN]; } -*/ inp_bLastPrescan = bPreScan; From 056d77f479d492e3c6f86bd791bee6797302de0a Mon Sep 17 00:00:00 2001 From: Joshua Scoggins Date: Sat, 23 Apr 2016 17:04:45 -0700 Subject: [PATCH 02/34] Assume OSX if we have defined __APPLE__ (#46) --- Sources/Engine/Base/Base.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Sources/Engine/Base/Base.h b/Sources/Engine/Base/Base.h index 41fa86e..fd032f3 100644 --- a/Sources/Engine/Base/Base.h +++ b/Sources/Engine/Base/Base.h @@ -61,17 +61,12 @@ with this program; if not, write to the Free Software Foundation, Inc., #define PLATFORM_LINUX 1 #endif #elif (defined __APPLE__) - #include "TargetConditionals.h" - #if TARGET_OS_MAC #define PLATFORM_MACOSX 1 - #else - #error "Unsupported apple platform" - #endif #else #warning "UNKNOWN PLATFORM IDENTIFIED!!!!" #define PLATFORM_UNKNOWN 1 #warning "USING PORTABLE C!!!" - #define USE_PORTABLE_C + #define USE_PORTABLE_C #endif #if PLATFORM_LINUX || PLATFORM_MACOSX From 4b5cc03bf04bf44a5e0e734e9802d1e196b9be0c Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 24 Apr 2016 17:38:22 +0300 Subject: [PATCH 03/34] rename __GNU_INLINE__ to __GNU_INLINE_X86_32__ There is not only x86 in this world. Simple sed job. --- Sources/Engine/Base/Profiling.cpp | 2 +- Sources/Engine/Base/Timer.cpp | 2 +- Sources/Engine/Base/Types.h | 16 +++++------ Sources/Engine/Engine.cpp | 2 +- Sources/Engine/Graphics/Color.cpp | 6 ++-- Sources/Engine/Graphics/Color.h | 10 +++---- .../Engine/Graphics/DrawPort_RenderScene.cpp | 10 +++---- Sources/Engine/Graphics/Fog.cpp | 2 +- .../Engine/Graphics/Gfx_OpenGL_Textures.cpp | 2 +- Sources/Engine/Graphics/Graphics.cpp | 10 +++---- Sources/Engine/Graphics/OpenGL.h | 2 +- Sources/Engine/Graphics/TextureEffects.cpp | 12 ++++---- Sources/Engine/Light/LayerMixer.cpp | 28 +++++++++---------- Sources/Engine/Math/Float.cpp | 2 +- Sources/Engine/Math/Functions.h | 8 +++--- Sources/Engine/Models/RenderModel_View.cpp | 2 +- Sources/Engine/Rendering/RendMisc.cpp | 2 +- Sources/Engine/Sound/SoundMixer.cpp | 16 +++++------ 18 files changed, 67 insertions(+), 67 deletions(-) diff --git a/Sources/Engine/Base/Profiling.cpp b/Sources/Engine/Base/Profiling.cpp index bd23ba2..744c740 100644 --- a/Sources/Engine/Base/Profiling.cpp +++ b/Sources/Engine/Base/Profiling.cpp @@ -47,7 +47,7 @@ static inline __int64 ReadTSC_profile(void) } return mmRet; -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) __int64 mmRet; __asm__ __volatile__ ( "rdtsc \n\t" diff --git a/Sources/Engine/Base/Timer.cpp b/Sources/Engine/Base/Timer.cpp index 0bfd970..5c77caa 100755 --- a/Sources/Engine/Base/Timer.cpp +++ b/Sources/Engine/Base/Timer.cpp @@ -64,7 +64,7 @@ static inline __int64 ReadTSC(void) } return mmRet; -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) __int64 mmRet; __asm__ __volatile__ ( "rdtsc \n\t" diff --git a/Sources/Engine/Base/Types.h b/Sources/Engine/Base/Types.h index 84de328..a1ac874 100644 --- a/Sources/Engine/Base/Types.h +++ b/Sources/Engine/Base/Types.h @@ -134,21 +134,21 @@ MY_STATIC_ASSERT(size_tSize, sizeof(size_t) == sizeof(void*)); #endif #endif - #if ((defined __GNUC__) && (!defined __GNU_INLINE__)) - #define __GNU_INLINE__ + #if ((defined __GNUC__) && (!defined __GNU_INLINE_X86__)) + #define __GNU_INLINE_X86__ #endif #if (defined __INTEL_COMPILER) - #if ((!defined __GNU_INLINE__) && (!defined __MSVC_INLINE__)) - #error Please define __GNU_INLINE__ or __MSVC_INLINE__ with Intel C++. + #if ((!defined __GNU_INLINE_X86__) && (!defined __MSVC_INLINE__)) + #error Please define __GNU_INLINE_X86__ or __MSVC_INLINE__ with Intel C++. #endif - #if ((defined __GNU_INLINE__) && (defined __MSVC_INLINE__)) - #error Define either __GNU_INLINE__ or __MSVC_INLINE__ with Intel C++. + #if ((defined __GNU_INLINE_X86__) && (defined __MSVC_INLINE__)) + #error Define either __GNU_INLINE_X86__ or __MSVC_INLINE__ with Intel C++. #endif #endif - #if defined(__GNU_INLINE__) && defined(__i386__) + #if defined(__GNU_INLINE_X86__) && defined(__i386__) #define FPU_REGS "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)" #define MMX_REGS "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7" #endif @@ -233,7 +233,7 @@ MY_STATIC_ASSERT(size_tSize, sizeof(size_t) == sizeof(void*)); #if (defined USE_PORTABLE_C) // DG: according to http://blog.regehr.org/archives/1063 this is fast return (ul<>(-bits&31)); - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) // This, on the other hand, is wicked fast. :) __asm__ __volatile__ ( "roll %%cl, %%eax \n\t" diff --git a/Sources/Engine/Engine.cpp b/Sources/Engine/Engine.cpp index 15021ca..1ce48b1 100644 --- a/Sources/Engine/Engine.cpp +++ b/Sources/Engine/Engine.cpp @@ -148,7 +148,7 @@ static void DetectCPU(void) mov dword ptr [ulFeatures], edx } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) // test MMX presence and update flag __asm__ __volatile__ ( "pushl %%ebx \n\t" diff --git a/Sources/Engine/Graphics/Color.cpp b/Sources/Engine/Graphics/Color.cpp index 50e1bf6..1d88614 100644 --- a/Sources/Engine/Graphics/Color.cpp +++ b/Sources/Engine/Graphics/Color.cpp @@ -347,7 +347,7 @@ COLOR MulColors( COLOR col1, COLOR col2) } return colRet; -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) COLOR colRet; __asm__ __volatile__ ( "pushl %%ebx \n\t" @@ -535,7 +535,7 @@ COLOR AddColors( COLOR col1, COLOR col2) mov D [colRet],ebx } -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) ULONG tmp; __asm__ __volatile__ ( // if xbx is "r", gcc runs out of regs in -fPIC + -fno-omit-fp :( @@ -679,7 +679,7 @@ colSkip2: colSkip1: } -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) STUBBED("convert to inline asm."); #else diff --git a/Sources/Engine/Graphics/Color.h b/Sources/Engine/Graphics/Color.h index 4a0318b..a7f048a 100644 --- a/Sources/Engine/Graphics/Color.h +++ b/Sources/Engine/Graphics/Color.h @@ -225,7 +225,7 @@ __forceinline ULONG ByteSwap( ULONG ul) } return ulRet; -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) __asm__ __volatile__ ( "bswapl %%eax \n\t" : "=a" (ul) @@ -252,7 +252,7 @@ __forceinline ULONG rgba2argb( ULONG ul) } return ulRet; -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) ULONG ulRet; __asm__ __volatile__ ( "rorl $8, %%eax \n\t" @@ -287,7 +287,7 @@ __forceinline ULONG abgr2argb( COLOR col) } return ulRet; -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) ULONG ulRet; __asm__ __volatile__ ( "bswapl %%eax \n\t" @@ -323,7 +323,7 @@ inline void CopyLongs( ULONG *pulSrc, ULONG *pulDst, INDEX ctLongs) rep movsd } -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) // I haven't benchmarked it, but in many cases, memcpy() becomes an // inline (asm?) macro on GNU platforms, so this might not be a // speed gain at all over the USE_PORTABLE_C version. @@ -359,7 +359,7 @@ inline void StoreLongs( ULONG ulVal, ULONG *pulDst, INDEX ctLongs) rep stosd } -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) __asm__ __volatile__ ( "cld \n\t" "rep \n\t" diff --git a/Sources/Engine/Graphics/DrawPort_RenderScene.cpp b/Sources/Engine/Graphics/DrawPort_RenderScene.cpp index 3412445..b471251 100644 --- a/Sources/Engine/Graphics/DrawPort_RenderScene.cpp +++ b/Sources/Engine/Graphics/DrawPort_RenderScene.cpp @@ -42,7 +42,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define ASMOPT 0 #elif (defined __MSVC_INLINE__) #define ASMOPT 1 -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) #define ASMOPT 1 #else #define ASMOPT 0 @@ -184,7 +184,7 @@ elemRest: mov D [edi],eax elemDone: } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) __asm__ __volatile__ ( "movl %[ctElems], %%ecx \n\t" "movl %[piDst], %%edi \n\t" @@ -505,7 +505,7 @@ static void RSBinToGroups( ScenePolygon *pspoFirst) mov D [_ctGroupsCount],eax } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) __asm__ __volatile__ ( "movl $2, %%eax \n\t" "bsrl (%%esi), %%ecx \n\t" @@ -860,7 +860,7 @@ static void RSSetTextureCoords( ScenePolygon *pspoGroup, INDEX iLayer, INDEX iUn // !!! FIXME: rcg11232001 This inline conversion is broken. Use the // !!! FIXME: rcg11232001 C version for now with GCC. -#if ((ASMOPT == 1) && (!defined __GNU_INLINE__) && (!defined __INTEL_COMPILER)) +#if ((ASMOPT == 1) && (!defined __GNU_INLINE_X86_32__) && (!defined __INTEL_COMPILER)) #if (defined __MSVC_INLINE__) __asm { mov esi,D [pspo] @@ -915,7 +915,7 @@ vtxLoop: /* // !!! FIXME: rcg11232001 This inline conversion is broken. Use the // !!! FIXME: rcg11232001 C version for now on Linux. - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) STUBBED("debug this"); __asm__ __volatile__ ( "0: \n\t" // vtxLoop diff --git a/Sources/Engine/Graphics/Fog.cpp b/Sources/Engine/Graphics/Fog.cpp index 2d4b259..bf5fb30 100644 --- a/Sources/Engine/Graphics/Fog.cpp +++ b/Sources/Engine/Graphics/Fog.cpp @@ -95,7 +95,7 @@ pixLoop: jnz pixLoop } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) __asm__ __volatile__ ( "movl %[pubTexture], %%esi \n\t" "movl %[pixTextureSize], %%ecx \n\t" diff --git a/Sources/Engine/Graphics/Gfx_OpenGL_Textures.cpp b/Sources/Engine/Graphics/Gfx_OpenGL_Textures.cpp index d20f55b..e694f7b 100644 --- a/Sources/Engine/Graphics/Gfx_OpenGL_Textures.cpp +++ b/Sources/Engine/Graphics/Gfx_OpenGL_Textures.cpp @@ -216,7 +216,7 @@ void UploadTexture_OGL( ULONG *pulTexture, PIX pixSizeU, PIX pixSizeV, emms } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) __asm__ __volatile__ ( "pxor %%mm0,%%mm0 \n\t" "movl %[pulSrc],%%esi \n\t" diff --git a/Sources/Engine/Graphics/Graphics.cpp b/Sources/Engine/Graphics/Graphics.cpp index 1373482..4693d8c 100644 --- a/Sources/Engine/Graphics/Graphics.cpp +++ b/Sources/Engine/Graphics/Graphics.cpp @@ -297,7 +297,7 @@ pixLoopN: emms } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) __asm__ __volatile__ ( "pxor %%mm0, %%mm0 \n\t" "movl %[pulSrcMipmap], %%esi \n\t" @@ -428,7 +428,7 @@ halfEnd: fullEnd: } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) ULONG tmp, tmp2; __asm__ __volatile__ ( "xorl %[xbx], %[xbx] \n\t" @@ -852,7 +852,7 @@ nextRowO: emms; } -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) ULONG tmp; __asm__ __volatile__ ( "movl %[pulSrc], %%esi \n\t" @@ -1046,7 +1046,7 @@ allDoneE: emms; } -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) __asm__ __volatile__ ( "pxor %%mm0, %%mm0 \n\t" "movl %[pulDst], %%esi \n\t" @@ -2204,7 +2204,7 @@ lowerLoop: emms } -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) FB_pulSrc = pulSrc; FB_pulDst = pulDst; diff --git a/Sources/Engine/Graphics/OpenGL.h b/Sources/Engine/Graphics/OpenGL.h index e803301..fe3f137 100644 --- a/Sources/Engine/Graphics/OpenGL.h +++ b/Sources/Engine/Graphics/OpenGL.h @@ -102,7 +102,7 @@ inline void glCOLOR( COLOR col) mov dword ptr [col],eax } -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) __asm__ __volatile__ ( "bswapl %%eax \n\t" : "=a" (col) diff --git a/Sources/Engine/Graphics/TextureEffects.cpp b/Sources/Engine/Graphics/TextureEffects.cpp index 994814e..b50a33e 100644 --- a/Sources/Engine/Graphics/TextureEffects.cpp +++ b/Sources/Engine/Graphics/TextureEffects.cpp @@ -36,7 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define ASMOPT 0 #elif (defined __MSVC_INLINE__) #define ASMOPT 1 -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) #define ASMOPT 1 #else #define ASMOPT 0 @@ -1357,7 +1357,7 @@ pixLoop: pop ebx } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) // rcg12152001 needed extra registers. :( _slHeightMapStep_renderWater = slHeightMapStep; _pixBaseWidth_renderWater = pixBaseWidth; @@ -1626,7 +1626,7 @@ pixLoop2: pop ebx } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) __asm__ __volatile__ ( "bsfl %[pixBaseWidth], %%eax \n\t" "movl $32, %%edx \n\t" @@ -2146,7 +2146,7 @@ pixLoop4: pop ebx } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) __asm__ __volatile__ ( "bsfl %[pixBaseWidth], %%eax \n\t" "movl $32, %%edx \n\t" @@ -2976,7 +2976,7 @@ pixDone: pop ebx } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) __asm__ __volatile__ ( "movl %[slColumnModulo], %%edx \n\t" "movl %[slBufferMask], %%ecx \n\t" @@ -3119,7 +3119,7 @@ pixLoopF: jnz rowLoopF pop ebx } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) _pubHeat_RenderPlasmaFire = pubHeat; // ran out of registers. :/ __asm__ __volatile__ ( "movl %[slHeatRowStep], %%eax \n\t" diff --git a/Sources/Engine/Light/LayerMixer.cpp b/Sources/Engine/Light/LayerMixer.cpp index d2aff1d..0f1b8d0 100755 --- a/Sources/Engine/Light/LayerMixer.cpp +++ b/Sources/Engine/Light/LayerMixer.cpp @@ -44,7 +44,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define ASMOPT 0 #elif (defined __MSVC_INLINE__) #define ASMOPT 1 -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) #define ASMOPT 1 #else #define ASMOPT 0 @@ -364,7 +364,7 @@ skipPixel: emms } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) ULONG tmp1, tmp2; __asm__ __volatile__ ( // prepare interpolants @@ -576,7 +576,7 @@ skipPixel: emms } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) ULONG tmp1, tmp2; __asm__ __volatile__ ( // prepare interpolants @@ -796,7 +796,7 @@ skipPixel: emms } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) ULONG tmp1, tmp2; __asm__ __volatile__ ( // prepare interpolants @@ -1008,7 +1008,7 @@ skipPixel: emms } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) ULONG tmp1, tmp2; __asm__ __volatile__ ( // prepare interpolants @@ -1201,7 +1201,7 @@ BOOL CLayerMixer::PrepareOneLayerPoint( CBrushShadowLayer *pbsl, BOOL bNoMask) FLOAT fDL2oDV = fDDL2oDV + 2*(lm_vStepV%v00); //_v00 = v00; -#if ((ASMOPT == 1) && (!defined __GNU_INLINE__)) +#if ((ASMOPT == 1) && (!defined __GNU_INLINE_X86_32__)) #if (defined __MSVC_INLINE__) __asm { fld D [fDDL2oDU] @@ -1230,7 +1230,7 @@ BOOL CLayerMixer::PrepareOneLayerPoint( CBrushShadowLayer *pbsl, BOOL bNoMask) fistp D [_slDDL2oDV] fistp D [_slDDL2oDU] } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) STUBBED("inline asm."); #else #error Please write inline assembly for your platform. @@ -1321,7 +1321,7 @@ void CLayerMixer::AddOneLayerGradient( CGradientParameters &gp) _pulLayer = lm_pulShadowMap; FLOAT fStart = Clamp( fGr00-(fDGroDJ+fDGroDI)*0.5f, 0.0f, 1.0f); -#if ((ASMOPT == 1) && (!defined __GNU_INLINE__)) +#if ((ASMOPT == 1) && (!defined __GNU_INLINE_X86_32__)) #if (defined __MSVC_INLINE__) __int64 mmRowAdv; SLONG fixGRow = (fGr00-(fDGroDJ+fDGroDI)*0.5f)*32767.0f; // 16:15 @@ -1436,7 +1436,7 @@ rowNext: rowDone: emms } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) STUBBED("WRITE ME. Argh."); @@ -1565,7 +1565,7 @@ rowNext: emms } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) ULONG tmp; __asm__ __volatile__ ( // prepare pointers and variables @@ -1665,7 +1665,7 @@ skipLight: emms } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) ULONG tmp; __asm__ __volatile__ ( // prepare pointers and variables @@ -1862,7 +1862,7 @@ void CLayerMixer::MixOneMipmap(CBrushShadowMap *pbsm, INDEX iMipmap) rep stosd } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) ULONG clob1, clob2, clob3; __asm__ __volatile__ ( "cld \n\t" @@ -1967,7 +1967,7 @@ __forceinline void CLayerMixer::CopyShadowLayer(void) mov edi,D [ebx].lm_pulShadowMap rep movsd } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) ULONG clob1, clob2, clob3; __asm__ __volatile__ ( "cld \n\t" @@ -2006,7 +2006,7 @@ __forceinline void CLayerMixer::FillShadowLayer( COLOR col) rep stosd } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) ULONG clob1, clob2, clob3; __asm__ __volatile__ ( "cld \n\t" diff --git a/Sources/Engine/Math/Float.cpp b/Sources/Engine/Math/Float.cpp index 6c62b5f..7c9f0fc 100755 --- a/Sources/Engine/Math/Float.cpp +++ b/Sources/Engine/Math/Float.cpp @@ -37,7 +37,7 @@ inline ULONG _control87(WORD newcw, WORD mask) return(fpw); } -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) inline ULONG _control87(WORD newcw, WORD mask) { diff --git a/Sources/Engine/Math/Functions.h b/Sources/Engine/Math/Functions.h index d164c0c..f0e8d03 100755 --- a/Sources/Engine/Math/Functions.h +++ b/Sources/Engine/Math/Functions.h @@ -325,7 +325,7 @@ inline SLONG FloatToInt( FLOAT f) } return slRet; -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) SLONG slRet; __asm__ __volatile__ ( "flds (%%eax) \n\t" @@ -355,7 +355,7 @@ inline FLOAT Log2( FLOAT f) { } return fRet; -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) FLOAT fRet; __asm__ __volatile__ ( "fld1 \n\t" @@ -402,7 +402,7 @@ inline SLONG FastLog2( SLONG x) } return slRet; -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) SLONG slRet; __asm__ __volatile__ ( "bsrl %%ecx, %%eax \n\t" @@ -435,7 +435,7 @@ printf("CHECK THIS: %s:%d\n", __FILE__, __LINE__); } return slRet; -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) SLONG slRet; __asm__ __volatile__ ( "bsrl %%ecx, %%eax \n\t" diff --git a/Sources/Engine/Models/RenderModel_View.cpp b/Sources/Engine/Models/RenderModel_View.cpp index 2b18dda..6c574fa 100644 --- a/Sources/Engine/Models/RenderModel_View.cpp +++ b/Sources/Engine/Models/RenderModel_View.cpp @@ -42,7 +42,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #if (defined __MSVC_INLINE__) #define ASMOPT 1 -#elif (defined __GNU_INLINE__) +#elif (defined __GNU_INLINE_X86_32__) #define ASMOPT 0 // !!! FIXME: rcg10112001 Write GCC inline asm versions... #else #define ASMOPT 0 diff --git a/Sources/Engine/Rendering/RendMisc.cpp b/Sources/Engine/Rendering/RendMisc.cpp index 91db0e1..3d0e657 100644 --- a/Sources/Engine/Rendering/RendMisc.cpp +++ b/Sources/Engine/Rendering/RendMisc.cpp @@ -123,7 +123,7 @@ static inline PIX PIXCoord(FLOAT f) // (f+0.9999f) or (ceil(f)) } return pixRet; - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) PIX pixRet; SLONG clobber; __asm__ __volatile__ ( diff --git a/Sources/Engine/Sound/SoundMixer.cpp b/Sources/Engine/Sound/SoundMixer.cpp index e24ace2..82a47fa 100644 --- a/Sources/Engine/Sound/SoundMixer.cpp +++ b/Sources/Engine/Sound/SoundMixer.cpp @@ -43,7 +43,7 @@ static CSoundData *psd; // nasm on MacOS X is getting wrong addresses of external globals, so I have // to define them in the .asm file...lame. -#ifdef __GNU_INLINE__ +#ifdef __GNU_INLINE_X86_32__ #ifdef USE_PORTABLE_C #define INASM #else @@ -94,7 +94,7 @@ void ResetMixer( const SLONG *pslBuffer, const SLONG slBufferSize) shl ecx,1 // *2 because of 32-bit src format rep stosd } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) // !!! FIXME : rcg12172001 Is this REALLY any faster than memset()? ULONG clob1, clob2; __asm__ __volatile__ ( @@ -131,7 +131,7 @@ void CopyMixerBuffer_stereo( const SLONG slSrcOffset, void *pDstBuffer, const SL shr ecx,2 // bytes to samples per channel rep movsd } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) // !!! FIXME : rcg12172001 Is this REALLY any faster than memcpy()? ULONG clob1, clob2, clob3; __asm__ __volatile__ ( @@ -184,7 +184,7 @@ copyLoop: jnz copyLoop } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) __asm__ __volatile__ ( "movl %[pvMixerBuffer], %%esi \n\t" "movl %[pDstBuffer], %%edi \n\t" @@ -250,7 +250,7 @@ copyLoop: emms } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) __asm__ __volatile__ ( "movl %[pvMixerBuffer], %%esi \n\t" "movl %[pvMixerBuffer], %%edi \n\t" @@ -323,7 +323,7 @@ void NormalizeMixerBuffer( const FLOAT fNormStrength, const SLONG slBytes, FLOAT } -#ifdef __GNU_INLINE__ +#ifdef __GNU_INLINE_X86_32__ // These are implemented in an external NASM file. extern "C" { void MixStereo_asm(CSoundObject *pso); @@ -548,7 +548,7 @@ loopEnd: emms } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) // This is implemented in an external NASM file. MixMono_asm(pso); @@ -778,7 +778,7 @@ loopEnd: emms } - #elif (defined __GNU_INLINE__) + #elif (defined __GNU_INLINE_X86_32__) // This is implemented in an external NASM file. MixStereo_asm(pso); From 78b26698ac6f401f7c44035572a236a4022e1a65 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 24 Apr 2016 18:04:43 +0300 Subject: [PATCH 04/34] only enable __GNU_INLINE_X86_32__ for x86/IA32 also don't error out if both __MSVC_INLINE__ and __GNU_INLINE_X86_32__ are not set, we have C fallbacks now --- Sources/Engine/Base/Types.h | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/Sources/Engine/Base/Types.h b/Sources/Engine/Base/Types.h index a1ac874..bfa030f 100644 --- a/Sources/Engine/Base/Types.h +++ b/Sources/Engine/Base/Types.h @@ -109,6 +109,24 @@ MY_STATIC_ASSERT(size_tSize, sizeof(size_t) == sizeof(void*)); #define ASMSYM(x) #x #endif +/* should we enable inline asm? */ +#ifndef USE_PORTABLE_C + #if defined(__MSVC_INLINE__) + /* the build system selected __MSVC_INLINE__ */ + #elif defined(__GNU_INLINE_X86_32__) + /* the build system selected __GNU_INLINE_X86_32__ */ + #elif defined(_MSC_VER) && defined(_M_IX86) + #define __MSVC_INLINE__ + #elif defined (__GNUC__) && defined(__i386) + #define __GNU_INLINE_X86_32__ + #endif + + #if defined(__GNU_INLINE_X86_32__) + #define FPU_REGS "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)" + #define MMX_REGS "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7" + #endif +#endif + #ifdef PLATFORM_UNIX /* rcg10042001 */ #include #include @@ -134,25 +152,6 @@ MY_STATIC_ASSERT(size_tSize, sizeof(size_t) == sizeof(void*)); #endif #endif - #if ((defined __GNUC__) && (!defined __GNU_INLINE_X86__)) - #define __GNU_INLINE_X86__ - #endif - - #if (defined __INTEL_COMPILER) - #if ((!defined __GNU_INLINE_X86__) && (!defined __MSVC_INLINE__)) - #error Please define __GNU_INLINE_X86__ or __MSVC_INLINE__ with Intel C++. - #endif - - #if ((defined __GNU_INLINE_X86__) && (defined __MSVC_INLINE__)) - #error Define either __GNU_INLINE_X86__ or __MSVC_INLINE__ with Intel C++. - #endif - #endif - - #if defined(__GNU_INLINE_X86__) && defined(__i386__) - #define FPU_REGS "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)" - #define MMX_REGS "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7" - #endif - #ifndef PAGESIZE #define PAGESIZE 4096 #endif From 1f70d4e242d96cac742e06a048774b70f9b06657 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 24 Apr 2016 20:16:04 +0300 Subject: [PATCH 05/34] rework asm to always fall back to portable C code with this there is no need to worry about x86 asm switch for other platforms. --- Sources/Engine/Base/Base.h | 4 +- Sources/Engine/Base/Profiling.cpp | 26 +- Sources/Engine/Base/Timer.cpp | 2 +- Sources/Engine/Base/Types.h | 8 +- Sources/Engine/Engine.cpp | 19 +- Sources/Engine/Graphics/Color.cpp | 107 ++- Sources/Engine/Graphics/Color.h | 83 +- .../Engine/Graphics/DrawPort_RenderScene.cpp | 43 +- Sources/Engine/Graphics/Fog.cpp | 29 +- .../Engine/Graphics/Gfx_OpenGL_Textures.cpp | 52 +- Sources/Engine/Graphics/Graphics.cpp | 799 +++++++++--------- Sources/Engine/Graphics/OpenGL.h | 14 +- Sources/Engine/Graphics/TextureEffects.cpp | 13 +- Sources/Engine/Light/LayerMixer.cpp | 175 ++-- Sources/Engine/Math/Float.cpp | 31 +- Sources/Engine/Math/Functions.h | 65 +- Sources/Engine/Models/RenderModel_View.cpp | 32 +- Sources/Engine/Rendering/RendMisc.cpp | 8 +- Sources/Engine/Sound/SoundMixer.cpp | 298 +++---- 19 files changed, 790 insertions(+), 1018 deletions(-) diff --git a/Sources/Engine/Base/Base.h b/Sources/Engine/Base/Base.h index fd032f3..12151f1 100644 --- a/Sources/Engine/Base/Base.h +++ b/Sources/Engine/Base/Base.h @@ -65,9 +65,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #else #warning "UNKNOWN PLATFORM IDENTIFIED!!!!" #define PLATFORM_UNKNOWN 1 - #warning "USING PORTABLE C!!!" - #define USE_PORTABLE_C -#endif +#endif #if PLATFORM_LINUX || PLATFORM_MACOSX #ifndef PLATFORM_UNIX diff --git a/Sources/Engine/Base/Profiling.cpp b/Sources/Engine/Base/Profiling.cpp index 744c740..87bd3b7 100644 --- a/Sources/Engine/Base/Profiling.cpp +++ b/Sources/Engine/Base/Profiling.cpp @@ -21,24 +21,13 @@ with this program; if not, write to the Free Software Foundation, Inc., template class CStaticArray; template class CStaticArray; -#if (defined USE_PORTABLE_C) +#if (defined PLATFORM_UNIX) && !defined(__GNU_INLINE_X86_32__) #include #endif static inline __int64 ReadTSC_profile(void) { -#if (defined USE_PORTABLE_C) - #ifdef __arm__ - struct timespec tv; - clock_gettime(CLOCK_MONOTONIC, &tv); - return( (((__int64) tv.tv_sec) * 1000) + (((__int64) tv.tv_nsec) / 1000000) ); - #else - struct timeval tv; - gettimeofday(&tv, NULL); - return( (((__int64) tv.tv_sec) * 1000) + (((__int64) tv.tv_usec) / 1000) ); - #endif - -#elif (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) __int64 mmRet; __asm { rdtsc @@ -60,7 +49,16 @@ static inline __int64 ReadTSC_profile(void) return(mmRet); #else - #error Please implement for your platform/compiler. + #ifdef __arm__ + struct timespec tv; + clock_gettime(CLOCK_MONOTONIC, &tv); + return( (((__int64) tv.tv_sec) * 1000) + (((__int64) tv.tv_nsec) / 1000000) ); + #else + struct timeval tv; + gettimeofday(&tv, NULL); + return( (((__int64) tv.tv_sec) * 1000) + (((__int64) tv.tv_usec) / 1000) ); + #endif + #endif } diff --git a/Sources/Engine/Base/Timer.cpp b/Sources/Engine/Base/Timer.cpp index 5c77caa..8c02846 100755 --- a/Sources/Engine/Base/Timer.cpp +++ b/Sources/Engine/Base/Timer.cpp @@ -29,7 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include // !!! FIXME: use SDL timer code instead and rdtsc never? -#if (USE_PORTABLE_C) +#if (defined PLATFORM_UNIX) && !defined(__GNU_INLINE_X86_32__) #define USE_GETTIMEOFDAY 1 #endif diff --git a/Sources/Engine/Base/Types.h b/Sources/Engine/Base/Types.h index bfa030f..fe1672a 100644 --- a/Sources/Engine/Base/Types.h +++ b/Sources/Engine/Base/Types.h @@ -229,10 +229,7 @@ MY_STATIC_ASSERT(size_tSize, sizeof(size_t) == sizeof(void*)); inline ULONG _rotl(ULONG ul, int bits) { - #if (defined USE_PORTABLE_C) - // DG: according to http://blog.regehr.org/archives/1063 this is fast - return (ul<>(-bits&31)); - #elif (defined __GNU_INLINE_X86_32__) + #if (defined __GNU_INLINE_X86_32__) // This, on the other hand, is wicked fast. :) __asm__ __volatile__ ( "roll %%cl, %%eax \n\t" @@ -254,7 +251,8 @@ MY_STATIC_ASSERT(size_tSize, sizeof(size_t) == sizeof(void*)); return(ul); #else - #error need inline asm for your platform. + // DG: according to http://blog.regehr.org/archives/1063 this is fast + return (ul<>(-bits&31)); #endif } diff --git a/Sources/Engine/Engine.cpp b/Sources/Engine/Engine.cpp index 1ce48b1..4ca653e 100644 --- a/Sources/Engine/Engine.cpp +++ b/Sources/Engine/Engine.cpp @@ -125,14 +125,10 @@ BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReser static void DetectCPU(void) { -#if (defined USE_PORTABLE_C) // rcg10072001 - CPrintF(TRANSV(" (No CPU detection in this binary.)\n")); - -#else - char strVendor[12+1]; + char strVendor[12+1] = { 0 }; strVendor[12] = 0; - ULONG ulTFMS; - ULONG ulFeatures; + ULONG ulTFMS = 0; + ULONG ulFeatures = 0; #if (defined __MSVC_INLINE__) // test MMX presence and update flag @@ -181,10 +177,13 @@ static void DetectCPU(void) : "eax", "ecx", "edx", "memory" ); - #else - #error Please implement for your platform or define USE_PORTABLE_C. #endif + if (ulTFMS == 0) { + CPrintF(TRANSV(" (No CPU detection in this binary.)\n")); + return; + } + INDEX iType = (ulTFMS>>12)&0x3; INDEX iFamily = (ulTFMS>> 8)&0xF; INDEX iModel = (ulTFMS>> 4)&0xF; @@ -215,8 +214,6 @@ static void DetectCPU(void) sys_iCPUMHz = INDEX(_pTimer->tm_llCPUSpeedHZ/1E6); if( !bMMX) FatalError( TRANS("MMX support required but not present!")); - -#endif // defined USE_PORTABLE_C } static void DetectCPUWrapper(void) diff --git a/Sources/Engine/Graphics/Color.cpp b/Sources/Engine/Graphics/Color.cpp index 1d88614..6a6519c 100644 --- a/Sources/Engine/Graphics/Color.cpp +++ b/Sources/Engine/Graphics/Color.cpp @@ -247,30 +247,7 @@ COLOR MulColors( COLOR col1, COLOR col2) if( col2==0xFFFFFFFF) return col1; if( col1==0 || col2==0) return 0; -#if (defined USE_PORTABLE_C) - // !!! FIXME: This...is not fast. - union - { - COLOR col; - UBYTE bytes[4]; - } conv1; - - union - { - COLOR col; - UBYTE bytes[4]; - } conv2; - - conv1.col = col1; - conv2.col = col2; - conv1.bytes[0] = (UBYTE) ((((DWORD) conv1.bytes[0]) * ((DWORD) conv2.bytes[0])) / 255); - conv1.bytes[1] = (UBYTE) ((((DWORD) conv1.bytes[1]) * ((DWORD) conv2.bytes[1])) / 255); - conv1.bytes[2] = (UBYTE) ((((DWORD) conv1.bytes[2]) * ((DWORD) conv2.bytes[2])) / 255); - conv1.bytes[3] = (UBYTE) ((((DWORD) conv1.bytes[3]) * ((DWORD) conv2.bytes[3])) / 255); - - return(conv1.col); - -#elif (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) COLOR colRet; __asm { xor ebx,ebx @@ -433,20 +410,6 @@ COLOR MulColors( COLOR col1, COLOR col2) return colRet; #else - #error please fill in inline assembly for your platform. -#endif -} - - -// fast color additon function - RES = clamp (1ST + 2ND) -COLOR AddColors( COLOR col1, COLOR col2) -{ - if( col1==0) return col2; - if( col2==0) return col1; - if( col1==0xFFFFFFFF || col2==0xFFFFFFFF) return 0xFFFFFFFF; - COLOR colRet; - -#if (defined USE_PORTABLE_C) // !!! FIXME: This...is not fast. union { @@ -459,19 +422,28 @@ COLOR AddColors( COLOR col1, COLOR col2) COLOR col; UBYTE bytes[4]; } conv2; - #define MINVAL(a, b) ((a)>(b))?(b):(a) conv1.col = col1; conv2.col = col2; - conv1.bytes[0] = (UBYTE) MINVAL((((WORD) conv1.bytes[0]) + ((WORD) conv2.bytes[0])) , 255); - conv1.bytes[1] = (UBYTE) MINVAL((((WORD) conv1.bytes[1]) + ((WORD) conv2.bytes[1])) , 255); - conv1.bytes[2] = (UBYTE) MINVAL((((WORD) conv1.bytes[2]) + ((WORD) conv2.bytes[2])) , 255); - conv1.bytes[3] = (UBYTE) MINVAL((((WORD) conv1.bytes[3]) + ((WORD) conv2.bytes[3])) , 255); - #undef MINVAL + conv1.bytes[0] = (UBYTE) ((((DWORD) conv1.bytes[0]) * ((DWORD) conv2.bytes[0])) / 255); + conv1.bytes[1] = (UBYTE) ((((DWORD) conv1.bytes[1]) * ((DWORD) conv2.bytes[1])) / 255); + conv1.bytes[2] = (UBYTE) ((((DWORD) conv1.bytes[2]) * ((DWORD) conv2.bytes[2])) / 255); + conv1.bytes[3] = (UBYTE) ((((DWORD) conv1.bytes[3]) * ((DWORD) conv2.bytes[3])) / 255); - colRet = conv1.col; + return(conv1.col); +#endif +} -#elif (defined __MSVC_INLINE__) + +// fast color additon function - RES = clamp (1ST + 2ND) +COLOR AddColors( COLOR col1, COLOR col2) +{ + if( col1==0) return col2; + if( col2==0) return col1; + if( col1==0xFFFFFFFF || col2==0xFFFFFFFF) return 0xFFFFFFFF; + COLOR colRet; + +#if (defined __MSVC_INLINE__) __asm { xor ebx,ebx mov esi,255 @@ -608,7 +580,29 @@ COLOR AddColors( COLOR col1, COLOR col2) ); #else - #error please fill in inline assembly for your platform. + // !!! FIXME: This...is not fast. + union + { + COLOR col; + UBYTE bytes[4]; + } conv1; + + union + { + COLOR col; + UBYTE bytes[4]; + } conv2; + #define MINVAL(a, b) ((a)>(b))?(b):(a) + + conv1.col = col1; + conv2.col = col2; + conv1.bytes[0] = (UBYTE) MINVAL((((WORD) conv1.bytes[0]) + ((WORD) conv2.bytes[0])) , 255); + conv1.bytes[1] = (UBYTE) MINVAL((((WORD) conv1.bytes[1]) + ((WORD) conv2.bytes[1])) , 255); + conv1.bytes[2] = (UBYTE) MINVAL((((WORD) conv1.bytes[2]) + ((WORD) conv2.bytes[2])) , 255); + conv1.bytes[3] = (UBYTE) MINVAL((((WORD) conv1.bytes[3]) + ((WORD) conv2.bytes[3])) , 255); + #undef MINVAL + + colRet = conv1.col; #endif return colRet; @@ -619,14 +613,7 @@ COLOR AddColors( COLOR col1, COLOR col2) // multiple conversion from OpenGL color to DirectX color extern void abgr2argb( ULONG *pulSrc, ULONG *pulDst, INDEX ct) { -#if (defined USE_PORTABLE_C) - //#error write me. - for (int i=0; i>16) | ((tmp&0x000000ff)<<16); - } - -#elif (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) __asm { mov esi,dword ptr [pulSrc] mov edi,dword ptr [pulDst] @@ -678,12 +665,12 @@ colSkip2: mov dword ptr [edi],eax colSkip1: } - -#elif (defined __GNU_INLINE_X86_32__) - STUBBED("convert to inline asm."); - #else - #error please fill in inline assembly for your platform. + for (int i=0; i>16) | ((tmp&0x000000ff)<<16); + } + #endif } diff --git a/Sources/Engine/Graphics/Color.h b/Sources/Engine/Graphics/Color.h index a7f048a..de0c666 100644 --- a/Sources/Engine/Graphics/Color.h +++ b/Sources/Engine/Graphics/Color.h @@ -204,19 +204,7 @@ ENGINE_API extern COLOR AddColors( COLOR col1, COLOR col2); // fast color addito __forceinline ULONG ByteSwap( ULONG ul) { /* rcg10052001 Platform-wrappers. */ -#if (defined USE_PORTABLE_C) - ul = ( ((ul << 24) ) | - ((ul << 8) & 0x00FF0000) | - ((ul >> 8) & 0x0000FF00) | - ((ul >> 24) ) ); - - #if (defined PLATFORM_BIGENDIAN) - BYTESWAP(ul); // !!! FIXME: May not be right! - #endif - - return(ul); - -#elif (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) ULONG ulRet; __asm { mov eax,dword ptr [ul] @@ -234,16 +222,22 @@ __forceinline ULONG ByteSwap( ULONG ul) return(ul); #else - #error please define for your platform. + ul = ( ((ul << 24) ) | + ((ul << 8) & 0x00FF0000) | + ((ul >> 8) & 0x0000FF00) | + ((ul >> 24) ) ); + + #if (defined PLATFORM_BIGENDIAN) + BYTESWAP(ul); // !!! FIXME: May not be right! + #endif + + return(ul); #endif } __forceinline ULONG rgba2argb( ULONG ul) { -#if (defined USE_PORTABLE_C) - return( (ul << 24) | (ul >> 8) ); - -#elif (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) ULONG ulRet; __asm { mov eax,dword ptr [ul] @@ -263,21 +257,14 @@ __forceinline ULONG rgba2argb( ULONG ul) return ulRet; #else - #error please define for your platform. + return (ul << 24) | (ul >> 8); + #endif } __forceinline ULONG abgr2argb( COLOR col) { -#if (defined USE_PORTABLE_C) - // this could be simplified, this is just a safe conversion from asm code - col = ( ((col << 24) ) | - ((col << 8) & 0x00FF0000) | - ((col >> 8) & 0x0000FF00) | - ((col >> 24) ) ); - return( (col << 24) | (col >> 8) ); - -#elif (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) ULONG ulRet; __asm { mov eax,dword ptr [col] @@ -299,7 +286,13 @@ __forceinline ULONG abgr2argb( COLOR col) return ulRet; #else - #error please define for your platform. + // this could be simplified, this is just a safe conversion from asm code + col = ( ((col << 24) ) | + ((col << 8) & 0x00FF0000) | + ((col >> 8) & 0x0000FF00) | + ((col >> 24) ) ); + return( (col << 24) | (col >> 8) ); + #endif } @@ -311,10 +304,7 @@ extern void abgr2argb( ULONG *pulSrc, ULONG *pulDst, INDEX ct); // fast memory copy of ULONGs inline void CopyLongs( ULONG *pulSrc, ULONG *pulDst, INDEX ctLongs) { -#if ((defined USE_PORTABLE_C) || (PLATFORM_MACOSX)) - memcpy( pulDst, pulSrc, ctLongs*4); - -#elif (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) __asm { cld mov esi,dword ptr [pulSrc] @@ -322,23 +312,8 @@ inline void CopyLongs( ULONG *pulSrc, ULONG *pulDst, INDEX ctLongs) mov ecx,dword ptr [ctLongs] rep movsd } - -#elif (defined __GNU_INLINE_X86_32__) - // I haven't benchmarked it, but in many cases, memcpy() becomes an - // inline (asm?) macro on GNU platforms, so this might not be a - // speed gain at all over the USE_PORTABLE_C version. - // You Have Been Warned. --ryan. - __asm__ __volatile__ ( - "cld \n\t" - "rep \n\t" - "movsd \n\t" - : "=S" (pulSrc), "=D" (pulDst), "=c" (ctLongs) - : "S" (pulSrc), "D" (pulDst), "c" (ctLongs) - : "cc", "memory" - ); - #else -# error Please fill this in for your platform. + memcpy( pulDst, pulSrc, ctLongs*4); #endif } @@ -346,11 +321,7 @@ inline void CopyLongs( ULONG *pulSrc, ULONG *pulDst, INDEX ctLongs) // fast memory set of ULONGs inline void StoreLongs( ULONG ulVal, ULONG *pulDst, INDEX ctLongs) { -#if (defined USE_PORTABLE_C) - for( INDEX i=0; ispo_ctElements; INDEX *piDst = _aiElements.Push(ctElems); -#if (ASMOPT == 1) - #if (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) __asm { mov eax,D [pspo] mov ecx,D [ctElems] @@ -184,7 +173,7 @@ elemRest: mov D [edi],eax elemDone: } - #elif (defined __GNU_INLINE_X86_32__) +#elif (defined __GNU_INLINE_X86_32__) __asm__ __volatile__ ( "movl %[ctElems], %%ecx \n\t" "movl %[piDst], %%edi \n\t" @@ -219,11 +208,6 @@ elemDone: "cc", "memory" ); - #else - #error Please write inline ASM for your platform. - - #endif - #else const INDEX iVtx0Pass = pspo->spo_iVtx0Pass; const INDEX *piSrc = pspo->spo_piElements; @@ -495,9 +479,7 @@ static void RSBinToGroups( ScenePolygon *pspoFirst) // determine maximum used groups ASSERT( _ctGroupsCount); -#if ASMOPT == 1 - - #if (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) __asm { mov eax,2 bsr ecx,D [_ctGroupsCount] @@ -505,7 +487,7 @@ static void RSBinToGroups( ScenePolygon *pspoFirst) mov D [_ctGroupsCount],eax } - #elif (defined __GNU_INLINE_X86_32__) +#elif (defined __GNU_INLINE_X86_32__) __asm__ __volatile__ ( "movl $2, %%eax \n\t" "bsrl (%%esi), %%ecx \n\t" @@ -516,11 +498,6 @@ static void RSBinToGroups( ScenePolygon *pspoFirst) : "eax", "ecx", "cc", "memory" ); - #else - #error Please write inline ASM for your platform. - - #endif - #else // emulate x86's bsr opcode...not fast. :/ register DWORD val = _ctGroupsCount; @@ -858,10 +835,7 @@ static void RSSetTextureCoords( ScenePolygon *pspoGroup, INDEX iLayer, INDEX iUn continue; } -// !!! FIXME: rcg11232001 This inline conversion is broken. Use the -// !!! FIXME: rcg11232001 C version for now with GCC. -#if ((ASMOPT == 1) && (!defined __GNU_INLINE_X86_32__) && (!defined __INTEL_COMPILER)) - #if (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) __asm { mov esi,D [pspo] mov edi,D [iMappingOffset] @@ -915,7 +889,7 @@ vtxLoop: /* // !!! FIXME: rcg11232001 This inline conversion is broken. Use the // !!! FIXME: rcg11232001 C version for now on Linux. - #elif (defined __GNU_INLINE_X86_32__) +#elif (defined __GNU_INLINE_X86_32__) STUBBED("debug this"); __asm__ __volatile__ ( "0: \n\t" // vtxLoop @@ -956,11 +930,6 @@ vtxLoop: ); */ - #else - #error Please write inline ASM for your platform. - - #endif - #else // diffuse mapping diff --git a/Sources/Engine/Graphics/Fog.cpp b/Sources/Engine/Graphics/Fog.cpp index bf5fb30..2945cb4 100644 --- a/Sources/Engine/Graphics/Fog.cpp +++ b/Sources/Engine/Graphics/Fog.cpp @@ -67,18 +67,7 @@ ULONG PrepareTexture( UBYTE *pubTexture, PIX pixSizeI, PIX pixSizeJ) // need to upload from RGBA format const PIX pixTextureSize = pixSizeI*pixSizeJ; - #if (defined USE_PORTABLE_C) - const UBYTE* src = pubTexture; - DWORD* dst = (DWORD*)(pubTexture+pixTextureSize); - for (int i=0; i> 8) & 0x0000ff00 ) | ((tmp >> 24) & 0x000000ff ); - src++; - dst++; - } - - #elif (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) __asm { mov esi,D [pubTexture] mov edi,D [pubTexture] @@ -95,7 +84,7 @@ pixLoop: jnz pixLoop } - #elif (defined __GNU_INLINE_X86_32__) +#elif (defined __GNU_INLINE_X86_32__) __asm__ __volatile__ ( "movl %[pubTexture], %%esi \n\t" "movl %[pixTextureSize], %%ecx \n\t" @@ -115,10 +104,18 @@ pixLoop: : "eax", "ecx", "esi", "edi", "cc", "memory" ); - #else - #error Write inline ASM for your platform. +#else + const UBYTE* src = pubTexture; + DWORD* dst = (DWORD*)(pubTexture+pixTextureSize); + for (int i=0; i> 8) & 0x0000ff00 ) | ((tmp >> 24) & 0x000000ff ); + src++; + dst++; + } - #endif +#endif // determine internal format extern INDEX gap_bAllowGrayTextures; diff --git a/Sources/Engine/Graphics/Gfx_OpenGL_Textures.cpp b/Sources/Engine/Graphics/Gfx_OpenGL_Textures.cpp index e694f7b..4ad76ab 100644 --- a/Sources/Engine/Graphics/Gfx_OpenGL_Textures.cpp +++ b/Sources/Engine/Graphics/Gfx_OpenGL_Textures.cpp @@ -169,32 +169,7 @@ void UploadTexture_OGL( ULONG *pulTexture, PIX pixSizeU, PIX pixSizeV, if( pixSizeV==0) pixSizeV=1; pixSize = pixSizeU*pixSizeV; - #if (defined USE_PORTABLE_C) - // Basically average every other pixel... - UWORD w = 0; - UBYTE *dptr = (UBYTE *) pulDst; - UBYTE *sptr = (UBYTE *) pulSrc; - #if 0 - pixSize *= 4; - for (PIX i = 0; i < pixSize; i++) - { - *dptr = (UBYTE) ( (((UWORD) sptr[0]) + ((UWORD) sptr[1])) >> 1 ); - dptr++; - sptr += 2; - } - #else - for (PIX i = 0; i < pixSize; i++) - { - for (PIX j = 0; j < 4; j++) - { - *dptr = (UBYTE) ( (((UWORD) sptr[0]) + ((UWORD) sptr[4])) >> 1 ); - dptr++; - sptr++; - } - sptr += 4; - } - #endif - #elif (defined __MSVC_INLINE__) + #if (defined __MSVC_INLINE__) __asm { pxor mm0,mm0 mov esi,D [pulSrc] @@ -244,7 +219,30 @@ void UploadTexture_OGL( ULONG *pulTexture, PIX pixSizeU, PIX pixSizeV, ); #else - #error Please write inline ASM for your platform. + // Basically average every other pixel... + UWORD w = 0; + UBYTE *dptr = (UBYTE *) pulDst; + UBYTE *sptr = (UBYTE *) pulSrc; + #if 0 + pixSize *= 4; + for (PIX i = 0; i < pixSize; i++) + { + *dptr = (UBYTE) ( (((UWORD) sptr[0]) + ((UWORD) sptr[1])) >> 1 ); + dptr++; + sptr += 2; + } + #else + for (PIX i = 0; i < pixSize; i++) + { + for (PIX j = 0; j < 4; j++) + { + *dptr = (UBYTE) ( (((UWORD) sptr[0]) + ((UWORD) sptr[4])) >> 1 ); + dptr++; + sptr++; + } + sptr += 4; + } + #endif #endif // upload mipmap diff --git a/Sources/Engine/Graphics/Graphics.cpp b/Sources/Engine/Graphics/Graphics.cpp index 4693d8c..3d4be59 100644 --- a/Sources/Engine/Graphics/Graphics.cpp +++ b/Sources/Engine/Graphics/Graphics.cpp @@ -209,58 +209,7 @@ static void MakeOneMipmap( ULONG *pulSrcMipmap, ULONG *pulDstMipmap, PIX pixWidt if( bBilinear) // type of filtering? { // BILINEAR - #if (defined USE_PORTABLE_C) - UBYTE *src = (UBYTE *) pulSrcMipmap; - UBYTE *dest = (UBYTE *) pulDstMipmap; - for (int i = 0 ; i < pixHeight; i++) - { - for (int j = 0; j < pixWidth; j++) - { - // Grab pixels from image - UWORD upleft[4]; - UWORD upright[4]; - UWORD downleft[4]; - UWORD downright[4]; - upleft[0] = *(src + 0); - upleft[1] = *(src + 1); - upleft[2] = *(src + 2); - upleft[3] = *(src + 3); - upright[0] = *(src + 4); - upright[1] = *(src + 5); - upright[2] = *(src + 6); - upright[3] = *(src + 7); - - downleft[0] = *(src + pixWidth*8 + 0); - downleft[1] = *(src + pixWidth*8 + 1); - downleft[2] = *(src + pixWidth*8 + 2); - downleft[3] = *(src + pixWidth*8 + 3); - downright[0] = *(src + pixWidth*8 + 4); - downright[1] = *(src + pixWidth*8 + 5); - downright[2] = *(src + pixWidth*8 + 6); - downright[3] = *(src + pixWidth*8 + 7); - - UWORD answer[4]; - answer[0] = upleft[0] + upright[0] + downleft[0] + downright[0] + 2; - answer[1] = upleft[1] + upright[1] + downleft[1] + downright[1] + 2; - answer[2] = upleft[2] + upright[2] + downleft[2] + downright[2] + 2; - answer[3] = upleft[3] + upright[3] + downleft[3] + downright[3] + 2; - answer[0] /= 4; - answer[1] /= 4; - answer[2] /= 4; - answer[3] /= 4; - - *(dest + 0) = answer[0]; - *(dest + 1) = answer[1]; - *(dest + 2) = answer[2]; - *(dest + 3) = answer[3]; - - src += 8; - dest += 4; - } - src += 8*pixWidth; - } - - #elif (defined __MSVC_INLINE__) + #if (defined __MSVC_INLINE__) __asm { pxor mm0,mm0 mov ebx,D [pixWidth] @@ -346,43 +295,63 @@ pixLoopN: ); #else - #error Write inline asm for your platform. + UBYTE *src = (UBYTE *) pulSrcMipmap; + UBYTE *dest = (UBYTE *) pulDstMipmap; + for (int i = 0 ; i < pixHeight; i++) + { + for (int j = 0; j < pixWidth; j++) + { + // Grab pixels from image + UWORD upleft[4]; + UWORD upright[4]; + UWORD downleft[4]; + UWORD downright[4]; + upleft[0] = *(src + 0); + upleft[1] = *(src + 1); + upleft[2] = *(src + 2); + upleft[3] = *(src + 3); + upright[0] = *(src + 4); + upright[1] = *(src + 5); + upright[2] = *(src + 6); + upright[3] = *(src + 7); + + downleft[0] = *(src + pixWidth*8 + 0); + downleft[1] = *(src + pixWidth*8 + 1); + downleft[2] = *(src + pixWidth*8 + 2); + downleft[3] = *(src + pixWidth*8 + 3); + downright[0] = *(src + pixWidth*8 + 4); + downright[1] = *(src + pixWidth*8 + 5); + downright[2] = *(src + pixWidth*8 + 6); + downright[3] = *(src + pixWidth*8 + 7); + + UWORD answer[4]; + answer[0] = upleft[0] + upright[0] + downleft[0] + downright[0] + 2; + answer[1] = upleft[1] + upright[1] + downleft[1] + downright[1] + 2; + answer[2] = upleft[2] + upright[2] + downleft[2] + downright[2] + 2; + answer[3] = upleft[3] + upright[3] + downleft[3] + downright[3] + 2; + answer[0] /= 4; + answer[1] /= 4; + answer[2] /= 4; + answer[3] /= 4; + + *(dest + 0) = answer[0]; + *(dest + 1) = answer[1]; + *(dest + 2) = answer[2]; + *(dest + 3) = answer[3]; + + src += 8; + dest += 4; + } + src += 8*pixWidth; + } + #endif } else { // NEAREST-NEIGHBOUR but with border preserving ULONG ulRowModulo = pixWidth*2 *BYTES_PER_TEXEL; - #if (defined USE_PORTABLE_C) - - PIX offset = 0; - ulRowModulo /= 4; - - for (int q = 0; q < 2; q++) - { - for (PIX i = pixHeight / 2; i > 0; i--) - { - for (PIX j = pixWidth / 2; j > 0; j--) - { - *pulDstMipmap = *(pulSrcMipmap + offset); - pulSrcMipmap += 2; - pulDstMipmap++; - } - - for (PIX j = pixWidth / 2; j > 0; j--) - { - *pulDstMipmap = *(pulSrcMipmap + offset + 1); - pulSrcMipmap += 2; - pulDstMipmap++; - } - - pulSrcMipmap += ulRowModulo; - } - - offset = pixWidth * 2; - } - - #elif (defined __MSVC_INLINE__) + #if (defined __MSVC_INLINE__) __asm { xor ebx,ebx mov esi,D [pulSrcMipmap] @@ -493,7 +462,33 @@ fullEnd: ); #else - #error Write inline asm for your platform. + PIX offset = 0; + ulRowModulo /= 4; + + for (int q = 0; q < 2; q++) + { + for (PIX i = pixHeight / 2; i > 0; i--) + { + for (PIX j = pixWidth / 2; j > 0; j--) + { + *pulDstMipmap = *(pulSrcMipmap + offset); + pulSrcMipmap += 2; + pulDstMipmap++; + } + + for (PIX j = pixWidth / 2; j > 0; j--) + { + *pulDstMipmap = *(pulSrcMipmap + offset + 1); + pulSrcMipmap += 2; + pulDstMipmap++; + } + + pulSrcMipmap += ulRowModulo; + } + + offset = pixWidth * 2; + } + #endif } } @@ -649,7 +644,7 @@ __int64 mmShifter = 0; __int64 mmMask = 0; ULONG *pulDitherTable; -#ifdef USE_PORTABLE_C +#if !(defined __MSVC_INLINE__) && !(defined __GNU_INLINE_X86_32__) extern const UBYTE *pubClipByte; // increment a byte without overflowing it static inline void IncrementByteWithClip( UBYTE &ub, SLONG slAdd) @@ -778,35 +773,7 @@ void DitherBitmap( INDEX iDitherType, ULONG *pulSrc, ULONG *pulDst, PIX pixWidth // ------------------------------- ordered matrix dithering routine ditherOrder: -#if (defined USE_PORTABLE_C) - union uConv - { - ULONG val; - DWORD dwords[2]; - UWORD words[4]; - WORD iwords[4]; - UBYTE bytes[8]; - }; - for (int i=0; i>= mmShifter; } - dith.val &= mmMask; - uConv* src = (uConv*)(pulSrc+i*pixWidth); - uConv* dst = (uConv*)(pulDst+i*pixWidth); - for (int j=0; j>= mmShifter; } + dith.val &= mmMask; + uConv* src = (uConv*)(pulSrc+i*pixWidth); + uConv* dst = (uConv*)(pulDst+i*pixWidth); + for (int j=0; j>4; - p5.words[k] = (p1.words[k]*5)>>4; - p7.words[k] = (p1.words[k]*7)>>4; } - for (int k=0; k<4; k++) { p1.words[k] -= (p3.words[k] + p5.words[k] + p7.words[k]);} - for (int k=0; k<4; k++) { - IncrementByteWithClip( src[k + step] , p7.words[k]); - IncrementByteWithClip( src[pixCanvasWidth*4 -step +k], p5.words[k]); - IncrementByteWithClip( src[pixCanvasWidth*4 +0 +k], p3.words[k]); - IncrementByteWithClip( src[pixCanvasWidth*4 +step +k], p1.words[k]); - } - } - } - #endif - -#elif (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) __asm { pxor mm0,mm0 mov esi,D [pulDst] @@ -1157,7 +1123,32 @@ allDoneE: ); #else - #error Write inline asm for your platform. + #if 1 //SEB doesn't works.... + for (int i=0; i>4; + p5.words[k] = (p1.words[k]*5)>>4; + p7.words[k] = (p1.words[k]*7)>>4; } + for (int k=0; k<4; k++) { p1.words[k] -= (p3.words[k] + p5.words[k] + p7.words[k]);} + for (int k=0; k<4; k++) { + IncrementByteWithClip( src[k + step] , p7.words[k]); + IncrementByteWithClip( src[pixCanvasWidth*4 -step +k], p5.words[k]); + IncrementByteWithClip( src[pixCanvasWidth*4 +0 +k], p3.words[k]); + IncrementByteWithClip( src[pixCanvasWidth*4 +step +k], p1.words[k]); + } + } + } + #endif + #endif goto theEnd; @@ -1265,7 +1256,7 @@ extern "C" { } -#ifdef USE_PORTABLE_C +#if !(defined USE_MMX_INTRINSICS) && !(defined __MSVC_INLINE__) && !(defined __GNU_INLINE_X86_32__) typedef SWORD ExtPix[4]; static inline void extpix_fromi64(ExtPix &pix, const __int64 i64) @@ -1632,265 +1623,6 @@ void FilterBitmap( INDEX iFilter, ULONG *pulSrc, ULONG *pulDst, PIX pixWidth, PI _mm_empty(); // we're done, clear out the MMX registers! -#elif (defined USE_PORTABLE_C) - slModulo1 /= BYTES_PER_TEXEL; // C++ handles incrementing by sizeof type - slCanvasWidth /= BYTES_PER_TEXEL; // C++ handles incrementing by sizeof type - - ULONG *src = pulSrc; - ULONG *dst = pulDst; - ULONG *rowptr = aulRows; - - ExtPix rmm1={0}, rmm2={0}, rmm3={0}, rmm4={0}, rmm5={0}, rmm6={0}, rmm7={0}; - #define EXTPIXFROMINT64(x) ExtPix r##x; extpix_fromi64(r##x, x); - EXTPIXFROMINT64(mmCm); - EXTPIXFROMINT64(mmCe); - EXTPIXFROMINT64(mmCc); - EXTPIXFROMINT64(mmEch); - EXTPIXFROMINT64(mmEcl); - EXTPIXFROMINT64(mmEe); - EXTPIXFROMINT64(mmEm); - EXTPIXFROMINT64(mmMm); - EXTPIXFROMINT64(mmMe); - EXTPIXFROMINT64(mmMc); - EXTPIXFROMINT64(mmAdd); - EXTPIXFROMINT64(mmInvDiv); - #undef EXTPIXFROMINT64 - - // ----------------------- process upper left corner - extend_pixel(src[0], rmm1); - extend_pixel(src[1], rmm2); - extend_pixel(src[pixCanvasWidth], rmm3); - extend_pixel(src[pixCanvasWidth+1], rmm4); - - extpix_add(rmm2, rmm3); - extpix_mul(rmm1, rmmCm); - extpix_mul(rmm2, rmmCe); - extpix_mul(rmm4, rmmCc); - extpix_add(rmm1, rmm2); - extpix_add(rmm1, rmm4); - extpix_adds(rmm1, rmmAdd); - extpix_mulhi(rmm1, rmmInvDiv); - *(rowptr++) = unextend_pixel(rmm1); - - src++; - - // ----------------------- process upper edge pixels - for (PIX i = pixWidth - 2; i != 0; i--) - { - extend_pixel(src[-1], rmm1); - extend_pixel(src[0], rmm2); - extend_pixel(src[1], rmm3); - extend_pixel(src[pixCanvasWidth-1], rmm4); - extend_pixel(src[pixCanvasWidth], rmm5); - extend_pixel(src[pixCanvasWidth+1], rmm6); - - extpix_add(rmm1, rmm3); - extpix_add(rmm4, rmm6); - extpix_mul(rmm1, rmmEch); - extpix_mul(rmm2, rmmEm); - extpix_mul(rmm4, rmmEcl); - extpix_mul(rmm5, rmmEe); - extpix_add(rmm1, rmm2); - extpix_add(rmm1, rmm4); - extpix_add(rmm1, rmm5); - extpix_adds(rmm1, rmmAdd); - extpix_mulhi(rmm1, rmmInvDiv); - *(rowptr++) = unextend_pixel(rmm1); - src++; - } - - // ----------------------- process upper right corner - - extend_pixel(src[-1], rmm1); - extend_pixel(src[0], rmm2); - extend_pixel(src[pixCanvasWidth-1], rmm3); - extend_pixel(src[pixCanvasWidth], rmm4); - - extpix_add(rmm1, rmm4); - extpix_mul(rmm1, rmmCe); - extpix_mul(rmm2, rmmCm); - extpix_mul(rmm3, rmmCc); - extpix_add(rmm1, rmm2); - extpix_add(rmm1, rmm3); - extpix_adds(rmm1, rmmAdd); - extpix_mulhi(rmm1, rmmInvDiv); - *rowptr = unextend_pixel(rmm1); - -// ----------------------- process bitmap middle pixels - - dst += slCanvasWidth; - src += slModulo1; - - // for each row - for (size_t i = pixHeight-2; i != 0; i--) // rowLoop - { - rowptr = aulRows; - - // process left edge pixel - extend_pixel(src[-pixCanvasWidth], rmm1); - extend_pixel(src[(-pixCanvasWidth)+1], rmm2); - extend_pixel(src[0], rmm3); - extend_pixel(src[1], rmm4); - extend_pixel(src[pixCanvasWidth], rmm5); - extend_pixel(src[pixCanvasWidth+1], rmm6); - - extpix_add(rmm1, rmm5); - extpix_add(rmm2, rmm6); - extpix_mul(rmm1, rmmEch); - extpix_mul(rmm2, rmmEcl); - extpix_mul(rmm3, rmmEm); - extpix_mul(rmm4, rmmEe); - extpix_add(rmm1, rmm2); - extpix_add(rmm1, rmm3); - extpix_add(rmm1, rmm4); - extpix_adds(rmm1, rmmAdd); - extpix_mulhi(rmm1, rmmInvDiv); - dst[-pixCanvasWidth] = *rowptr; - *(rowptr++) = unextend_pixel(rmm1); - src++; - dst++; - - // for each pixel in current row - for (size_t j = pixWidth-2; j != 0; j--) // pixLoop - { - // prepare upper convolution row - extend_pixel(src[(-pixCanvasWidth)-1], rmm1); - extend_pixel(src[-pixCanvasWidth], rmm2); - extend_pixel(src[(-pixCanvasWidth)+1], rmm3); - - // prepare middle convolution row - extend_pixel(src[-1], rmm4); - extend_pixel(src[0], rmm5); - extend_pixel(src[1], rmm6); - - // free some registers - extpix_add(rmm1, rmm3); - extpix_add(rmm2, rmm4); - extpix_mul(rmm5, rmmMm); - - // prepare lower convolution row - extend_pixel(src[pixCanvasWidth-1], rmm3); - extend_pixel(src[pixCanvasWidth], rmm4); - extend_pixel(src[pixCanvasWidth+1], rmm7); - - // calc weightened value - extpix_add(rmm2, rmm6); - extpix_add(rmm1, rmm3); - extpix_add(rmm2, rmm4); - extpix_add(rmm1, rmm7); - extpix_mul(rmm2, rmmMe); - extpix_mul(rmm1, rmmMc); - extpix_add(rmm2, rmm5); - extpix_add(rmm1, rmm2); - - // calc and store wightened value - extpix_adds(rmm1, rmmAdd); - extpix_mulhi(rmm1, rmmInvDiv); - dst[-pixCanvasWidth] = *rowptr; - *(rowptr++) = unextend_pixel(rmm1); - - // advance to next pixel - src++; - dst++; - } - - // process right edge pixel - extend_pixel(src[(-pixCanvasWidth)-1], rmm1); - extend_pixel(src[-pixCanvasWidth], rmm2); - extend_pixel(src[-1], rmm3); - extend_pixel(src[0], rmm4); - extend_pixel(src[pixCanvasWidth-1], rmm5); - extend_pixel(src[pixCanvasWidth], rmm6); - - extpix_add(rmm1, rmm5); - extpix_add(rmm2, rmm6); - extpix_mul(rmm1, rmmEcl); - extpix_mul(rmm2, rmmEch); - extpix_mul(rmm3, rmmEe); - extpix_mul(rmm4, rmmEm); - extpix_add(rmm1, rmm2); - extpix_add(rmm1, rmm3); - extpix_add(rmm1, rmm4); - extpix_adds(rmm1, rmmAdd); - extpix_mulhi(rmm1, rmmInvDiv); - dst[-pixCanvasWidth] = *rowptr; - *rowptr = unextend_pixel(rmm1); - - // advance to next row - src += slModulo1; - dst += slModulo1; - } - - // ----------------------- process lower left corner - rowptr = aulRows; - extend_pixel(src[-pixCanvasWidth], rmm1); - extend_pixel(src[(-pixCanvasWidth)+1], rmm2); - extend_pixel(src[0], rmm3); - extend_pixel(src[1], rmm4); - - extpix_add(rmm1, rmm4); - extpix_mul(rmm1, rmmCe); - extpix_mul(rmm2, rmmCc); - extpix_mul(rmm3, rmmCm); - extpix_add(rmm1, rmm2); - extpix_add(rmm1, rmm3); - extpix_adds(rmm1, rmmAdd); - extpix_mulhi(rmm1, rmmInvDiv); - dst[-pixCanvasWidth] = *rowptr; - dst[0] = unextend_pixel(rmm1); - - src++; - dst++; - rowptr++; - - // ----------------------- process lower edge pixels - for (size_t i = pixWidth-2; i != 0; i--) // lowerLoop - { - // for each pixel - extend_pixel(src[(-pixCanvasWidth)-1], rmm1); - extend_pixel(src[-pixCanvasWidth], rmm2); - extend_pixel(src[(-pixCanvasWidth)+1], rmm3); - extend_pixel(src[-1], rmm4); - extend_pixel(src[0], rmm5); - extend_pixel(src[1], rmm6); - - extpix_add(rmm1, rmm3); - extpix_add(rmm4, rmm6); - extpix_mul(rmm1, rmmEcl); - extpix_mul(rmm2, rmmEe); - extpix_mul(rmm4, rmmEch); - extpix_mul(rmm5, rmmEm); - extpix_add(rmm1, rmm2); - extpix_add(rmm1, rmm4); - extpix_add(rmm1, rmm5); - extpix_adds(rmm1, rmmAdd); - extpix_mulhi(rmm1, rmmInvDiv); - dst[-pixCanvasWidth] = *rowptr; - dst[0] = unextend_pixel(rmm1); - - // advance to next pixel - src++; - dst++; - rowptr++; - } - - // ----------------------- lower right corners - extend_pixel(src[(-pixCanvasWidth)-1], rmm1); - extend_pixel(src[-pixCanvasWidth], rmm2); - extend_pixel(src[-1], rmm3); - extend_pixel(src[0], rmm4); - - extpix_add(rmm2, rmm3); - extpix_mul(rmm1, rmmCc); - extpix_mul(rmm2, rmmCe); - extpix_mul(rmm4, rmmCm); - extpix_add(rmm1, rmm2); - extpix_add(rmm1, rmm4); - extpix_adds(rmm1, rmmAdd); - extpix_mulhi(rmm1, rmmInvDiv); - dst[-pixCanvasWidth] = *rowptr; - dst[0] = unextend_pixel(rmm1); - #elif (defined __MSVC_INLINE__) __asm { cld @@ -2537,7 +2269,264 @@ lowerLoop: ); #else - #error Write inline asm for your platform. + slModulo1 /= BYTES_PER_TEXEL; // C++ handles incrementing by sizeof type + slCanvasWidth /= BYTES_PER_TEXEL; // C++ handles incrementing by sizeof type + + ULONG *src = pulSrc; + ULONG *dst = pulDst; + ULONG *rowptr = aulRows; + + ExtPix rmm1={0}, rmm2={0}, rmm3={0}, rmm4={0}, rmm5={0}, rmm6={0}, rmm7={0}; + #define EXTPIXFROMINT64(x) ExtPix r##x; extpix_fromi64(r##x, x); + EXTPIXFROMINT64(mmCm); + EXTPIXFROMINT64(mmCe); + EXTPIXFROMINT64(mmCc); + EXTPIXFROMINT64(mmEch); + EXTPIXFROMINT64(mmEcl); + EXTPIXFROMINT64(mmEe); + EXTPIXFROMINT64(mmEm); + EXTPIXFROMINT64(mmMm); + EXTPIXFROMINT64(mmMe); + EXTPIXFROMINT64(mmMc); + EXTPIXFROMINT64(mmAdd); + EXTPIXFROMINT64(mmInvDiv); + #undef EXTPIXFROMINT64 + + // ----------------------- process upper left corner + extend_pixel(src[0], rmm1); + extend_pixel(src[1], rmm2); + extend_pixel(src[pixCanvasWidth], rmm3); + extend_pixel(src[pixCanvasWidth+1], rmm4); + + extpix_add(rmm2, rmm3); + extpix_mul(rmm1, rmmCm); + extpix_mul(rmm2, rmmCe); + extpix_mul(rmm4, rmmCc); + extpix_add(rmm1, rmm2); + extpix_add(rmm1, rmm4); + extpix_adds(rmm1, rmmAdd); + extpix_mulhi(rmm1, rmmInvDiv); + *(rowptr++) = unextend_pixel(rmm1); + + src++; + + // ----------------------- process upper edge pixels + for (PIX i = pixWidth - 2; i != 0; i--) + { + extend_pixel(src[-1], rmm1); + extend_pixel(src[0], rmm2); + extend_pixel(src[1], rmm3); + extend_pixel(src[pixCanvasWidth-1], rmm4); + extend_pixel(src[pixCanvasWidth], rmm5); + extend_pixel(src[pixCanvasWidth+1], rmm6); + + extpix_add(rmm1, rmm3); + extpix_add(rmm4, rmm6); + extpix_mul(rmm1, rmmEch); + extpix_mul(rmm2, rmmEm); + extpix_mul(rmm4, rmmEcl); + extpix_mul(rmm5, rmmEe); + extpix_add(rmm1, rmm2); + extpix_add(rmm1, rmm4); + extpix_add(rmm1, rmm5); + extpix_adds(rmm1, rmmAdd); + extpix_mulhi(rmm1, rmmInvDiv); + *(rowptr++) = unextend_pixel(rmm1); + src++; + } + + // ----------------------- process upper right corner + + extend_pixel(src[-1], rmm1); + extend_pixel(src[0], rmm2); + extend_pixel(src[pixCanvasWidth-1], rmm3); + extend_pixel(src[pixCanvasWidth], rmm4); + + extpix_add(rmm1, rmm4); + extpix_mul(rmm1, rmmCe); + extpix_mul(rmm2, rmmCm); + extpix_mul(rmm3, rmmCc); + extpix_add(rmm1, rmm2); + extpix_add(rmm1, rmm3); + extpix_adds(rmm1, rmmAdd); + extpix_mulhi(rmm1, rmmInvDiv); + *rowptr = unextend_pixel(rmm1); + +// ----------------------- process bitmap middle pixels + + dst += slCanvasWidth; + src += slModulo1; + + // for each row + for (size_t i = pixHeight-2; i != 0; i--) // rowLoop + { + rowptr = aulRows; + + // process left edge pixel + extend_pixel(src[-pixCanvasWidth], rmm1); + extend_pixel(src[(-pixCanvasWidth)+1], rmm2); + extend_pixel(src[0], rmm3); + extend_pixel(src[1], rmm4); + extend_pixel(src[pixCanvasWidth], rmm5); + extend_pixel(src[pixCanvasWidth+1], rmm6); + + extpix_add(rmm1, rmm5); + extpix_add(rmm2, rmm6); + extpix_mul(rmm1, rmmEch); + extpix_mul(rmm2, rmmEcl); + extpix_mul(rmm3, rmmEm); + extpix_mul(rmm4, rmmEe); + extpix_add(rmm1, rmm2); + extpix_add(rmm1, rmm3); + extpix_add(rmm1, rmm4); + extpix_adds(rmm1, rmmAdd); + extpix_mulhi(rmm1, rmmInvDiv); + dst[-pixCanvasWidth] = *rowptr; + *(rowptr++) = unextend_pixel(rmm1); + src++; + dst++; + + // for each pixel in current row + for (size_t j = pixWidth-2; j != 0; j--) // pixLoop + { + // prepare upper convolution row + extend_pixel(src[(-pixCanvasWidth)-1], rmm1); + extend_pixel(src[-pixCanvasWidth], rmm2); + extend_pixel(src[(-pixCanvasWidth)+1], rmm3); + + // prepare middle convolution row + extend_pixel(src[-1], rmm4); + extend_pixel(src[0], rmm5); + extend_pixel(src[1], rmm6); + + // free some registers + extpix_add(rmm1, rmm3); + extpix_add(rmm2, rmm4); + extpix_mul(rmm5, rmmMm); + + // prepare lower convolution row + extend_pixel(src[pixCanvasWidth-1], rmm3); + extend_pixel(src[pixCanvasWidth], rmm4); + extend_pixel(src[pixCanvasWidth+1], rmm7); + + // calc weightened value + extpix_add(rmm2, rmm6); + extpix_add(rmm1, rmm3); + extpix_add(rmm2, rmm4); + extpix_add(rmm1, rmm7); + extpix_mul(rmm2, rmmMe); + extpix_mul(rmm1, rmmMc); + extpix_add(rmm2, rmm5); + extpix_add(rmm1, rmm2); + + // calc and store wightened value + extpix_adds(rmm1, rmmAdd); + extpix_mulhi(rmm1, rmmInvDiv); + dst[-pixCanvasWidth] = *rowptr; + *(rowptr++) = unextend_pixel(rmm1); + + // advance to next pixel + src++; + dst++; + } + + // process right edge pixel + extend_pixel(src[(-pixCanvasWidth)-1], rmm1); + extend_pixel(src[-pixCanvasWidth], rmm2); + extend_pixel(src[-1], rmm3); + extend_pixel(src[0], rmm4); + extend_pixel(src[pixCanvasWidth-1], rmm5); + extend_pixel(src[pixCanvasWidth], rmm6); + + extpix_add(rmm1, rmm5); + extpix_add(rmm2, rmm6); + extpix_mul(rmm1, rmmEcl); + extpix_mul(rmm2, rmmEch); + extpix_mul(rmm3, rmmEe); + extpix_mul(rmm4, rmmEm); + extpix_add(rmm1, rmm2); + extpix_add(rmm1, rmm3); + extpix_add(rmm1, rmm4); + extpix_adds(rmm1, rmmAdd); + extpix_mulhi(rmm1, rmmInvDiv); + dst[-pixCanvasWidth] = *rowptr; + *rowptr = unextend_pixel(rmm1); + + // advance to next row + src += slModulo1; + dst += slModulo1; + } + + // ----------------------- process lower left corner + rowptr = aulRows; + extend_pixel(src[-pixCanvasWidth], rmm1); + extend_pixel(src[(-pixCanvasWidth)+1], rmm2); + extend_pixel(src[0], rmm3); + extend_pixel(src[1], rmm4); + + extpix_add(rmm1, rmm4); + extpix_mul(rmm1, rmmCe); + extpix_mul(rmm2, rmmCc); + extpix_mul(rmm3, rmmCm); + extpix_add(rmm1, rmm2); + extpix_add(rmm1, rmm3); + extpix_adds(rmm1, rmmAdd); + extpix_mulhi(rmm1, rmmInvDiv); + dst[-pixCanvasWidth] = *rowptr; + dst[0] = unextend_pixel(rmm1); + + src++; + dst++; + rowptr++; + + // ----------------------- process lower edge pixels + for (size_t i = pixWidth-2; i != 0; i--) // lowerLoop + { + // for each pixel + extend_pixel(src[(-pixCanvasWidth)-1], rmm1); + extend_pixel(src[-pixCanvasWidth], rmm2); + extend_pixel(src[(-pixCanvasWidth)+1], rmm3); + extend_pixel(src[-1], rmm4); + extend_pixel(src[0], rmm5); + extend_pixel(src[1], rmm6); + + extpix_add(rmm1, rmm3); + extpix_add(rmm4, rmm6); + extpix_mul(rmm1, rmmEcl); + extpix_mul(rmm2, rmmEe); + extpix_mul(rmm4, rmmEch); + extpix_mul(rmm5, rmmEm); + extpix_add(rmm1, rmm2); + extpix_add(rmm1, rmm4); + extpix_add(rmm1, rmm5); + extpix_adds(rmm1, rmmAdd); + extpix_mulhi(rmm1, rmmInvDiv); + dst[-pixCanvasWidth] = *rowptr; + dst[0] = unextend_pixel(rmm1); + + // advance to next pixel + src++; + dst++; + rowptr++; + } + + // ----------------------- lower right corners + extend_pixel(src[(-pixCanvasWidth)-1], rmm1); + extend_pixel(src[-pixCanvasWidth], rmm2); + extend_pixel(src[-1], rmm3); + extend_pixel(src[0], rmm4); + + extpix_add(rmm2, rmm3); + extpix_mul(rmm1, rmmCc); + extpix_mul(rmm2, rmmCe); + extpix_mul(rmm4, rmmCm); + extpix_add(rmm1, rmm2); + extpix_add(rmm1, rmm4); + extpix_adds(rmm1, rmmAdd); + extpix_mulhi(rmm1, rmmInvDiv); + dst[-pixCanvasWidth] = *rowptr; + dst[0] = unextend_pixel(rmm1); + #endif // all done (finally) diff --git a/Sources/Engine/Graphics/OpenGL.h b/Sources/Engine/Graphics/OpenGL.h index fe3f137..37b5038 100644 --- a/Sources/Engine/Graphics/OpenGL.h +++ b/Sources/Engine/Graphics/OpenGL.h @@ -89,13 +89,7 @@ extern void (__stdcall *pglPNTrianglesfATI)( GLenum pname, GLfloat param); inline void glCOLOR( COLOR col) { /* rcg10052001 Platform-wrappers. */ -#if (defined USE_PORTABLE_C) - col = ( ((col << 24) ) | - ((col << 8) & 0x00FF0000) | - ((col >> 8) & 0x0000FF00) | - ((col >> 24) ) ); - -#elif (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) __asm { mov eax,dword ptr [col] bswap eax @@ -110,7 +104,11 @@ inline void glCOLOR( COLOR col) ); #else - #error please define for your platform. + col = ( ((col << 24) ) | + ((col << 8) & 0x00FF0000) | + ((col >> 8) & 0x0000FF00) | + ((col >> 24) ) ); + #endif pglColor4ubv((GLubyte*)&col); diff --git a/Sources/Engine/Graphics/TextureEffects.cpp b/Sources/Engine/Graphics/TextureEffects.cpp index b50a33e..91fc839 100644 --- a/Sources/Engine/Graphics/TextureEffects.cpp +++ b/Sources/Engine/Graphics/TextureEffects.cpp @@ -32,9 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define W word ptr #define B byte ptr -#if (defined USE_PORTABLE_C) -#define ASMOPT 0 -#elif (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) #define ASMOPT 1 #elif (defined __GNU_INLINE_X86_32__) #define ASMOPT 1 @@ -1285,8 +1283,7 @@ static void RenderWater(void) { // SUB-SAMPLING SLONG slHeightMapStep, slHeightRowStep; -#if ASMOPT == 1 - #if (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) __asm { push ebx bsf ecx,D [_pixTexWidth] @@ -1357,7 +1354,7 @@ pixLoop: pop ebx } - #elif (defined __GNU_INLINE_X86_32__) +#elif (defined __GNU_INLINE_X86_32__) // rcg12152001 needed extra registers. :( _slHeightMapStep_renderWater = slHeightMapStep; _pixBaseWidth_renderWater = pixBaseWidth; @@ -1460,10 +1457,6 @@ pixLoop: "cc", "memory" ); - #else - #error fill in for your platform. - #endif - #else PIX pixPos, pixDU, pixDV; diff --git a/Sources/Engine/Light/LayerMixer.cpp b/Sources/Engine/Light/LayerMixer.cpp index 0f1b8d0..26c0e51 100755 --- a/Sources/Engine/Light/LayerMixer.cpp +++ b/Sources/Engine/Light/LayerMixer.cpp @@ -40,16 +40,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #define W word ptr #define B byte ptr -#if (defined USE_PORTABLE_C) - #define ASMOPT 0 -#elif (defined __MSVC_INLINE__) - #define ASMOPT 1 -#elif (defined __GNU_INLINE_X86_32__) - #define ASMOPT 1 -#else - #define ASMOPT 0 -#endif - extern INDEX shd_bFineQuality; extern INDEX shd_iFiltering; extern INDEX shd_iDithering; @@ -290,8 +280,7 @@ void CLayerMixer::AddAmbientPoint(void) _slLightMax<<=7; _slLightStep>>=1; -#if (ASMOPT == 1) - #if (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) __asm { // prepare interpolants movd mm0,D [_slL2Row] @@ -364,7 +353,7 @@ skipPixel: emms } - #elif (defined __GNU_INLINE_X86_32__) +#elif (defined __GNU_INLINE_X86_32__) ULONG tmp1, tmp2; __asm__ __volatile__ ( // prepare interpolants @@ -439,10 +428,6 @@ skipPixel: : FPU_REGS, MMX_REGS, "eax", "ecx", "edi", "cc", "memory" ); - #else - #error Write inline asm for your platform. - #endif - #else // !!! FIXME WARNING: I have not checked this code, and it could be @@ -496,8 +481,7 @@ void CLayerMixer::AddAmbientMaskPoint( UBYTE *pubMask, UBYTE ubMask) _slLightStep>>=1; -#if (ASMOPT == 1) - #if (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) __asm { // prepare interpolants movd mm0,D [_slL2Row] @@ -576,7 +560,7 @@ skipPixel: emms } - #elif (defined __GNU_INLINE_X86_32__) +#elif (defined __GNU_INLINE_X86_32__) ULONG tmp1, tmp2; __asm__ __volatile__ ( // prepare interpolants @@ -660,10 +644,6 @@ skipPixel: "cc", "memory" ); - #else - #error Please write inline assembly for your platform. - #endif - #else // Portable C version... UBYTE* pubLayer = (UBYTE*)_pulLayer; @@ -723,8 +703,7 @@ void CLayerMixer::AddDiffusionPoint(void) _slLightMax<<=7; _slLightStep>>=1; -#if ASMOPT == 1 - #if (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) __asm { // prepare interpolants movd mm0,D [_slL2Row] @@ -796,7 +775,7 @@ skipPixel: emms } - #elif (defined __GNU_INLINE_X86_32__) +#elif (defined __GNU_INLINE_X86_32__) ULONG tmp1, tmp2; __asm__ __volatile__ ( // prepare interpolants @@ -871,10 +850,6 @@ skipPixel: : FPU_REGS, MMX_REGS, "eax", "ecx", "edi", "cc", "memory" ); - #else - #error Write inline assembly for your platform. - #endif - #else // for each pixel in the shadow map UBYTE* pubLayer = (UBYTE*)_pulLayer; @@ -929,8 +904,7 @@ void CLayerMixer::AddDiffusionMaskPoint( UBYTE *pubMask, UBYTE ubMask) _slLightMax<<=7; _slLightStep>>=1; -#if (ASMOPT == 1) - #if (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) __asm { // prepare interpolants movd mm0,D [_slL2Row] @@ -1008,7 +982,7 @@ skipPixel: emms } - #elif (defined __GNU_INLINE_X86_32__) +#elif (defined __GNU_INLINE_X86_32__) ULONG tmp1, tmp2; __asm__ __volatile__ ( // prepare interpolants @@ -1091,11 +1065,6 @@ skipPixel: "cc", "memory" ); - #else - #error Write inline ASM for your platform. - - #endif - #else // for each pixel in the shadow map @@ -1201,8 +1170,7 @@ BOOL CLayerMixer::PrepareOneLayerPoint( CBrushShadowLayer *pbsl, BOOL bNoMask) FLOAT fDL2oDV = fDDL2oDV + 2*(lm_vStepV%v00); //_v00 = v00; -#if ((ASMOPT == 1) && (!defined __GNU_INLINE_X86_32__)) - #if (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) __asm { fld D [fDDL2oDU] fadd D [fDDL2oDU] @@ -1230,12 +1198,6 @@ BOOL CLayerMixer::PrepareOneLayerPoint( CBrushShadowLayer *pbsl, BOOL bNoMask) fistp D [_slDDL2oDV] fistp D [_slDDL2oDU] } - #elif (defined __GNU_INLINE_X86_32__) - STUBBED("inline asm."); - #else - #error Please write inline assembly for your platform. - #endif - #else fDDL2oDU *= 2; fDDL2oDV *= 2; @@ -1321,8 +1283,7 @@ void CLayerMixer::AddOneLayerGradient( CGradientParameters &gp) _pulLayer = lm_pulShadowMap; FLOAT fStart = Clamp( fGr00-(fDGroDJ+fDGroDI)*0.5f, 0.0f, 1.0f); -#if ((ASMOPT == 1) && (!defined __GNU_INLINE_X86_32__)) - #if (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) __int64 mmRowAdv; SLONG fixGRow = (fGr00-(fDGroDJ+fDGroDI)*0.5f)*32767.0f; // 16:15 SLONG slModulo = (lm_pixCanvasSizeU-lm_pixPolygonSizeU) *BYTES_PER_TEXEL; @@ -1436,14 +1397,6 @@ rowNext: rowDone: emms } - #elif (defined __GNU_INLINE_X86_32__) - - STUBBED("WRITE ME. Argh."); - - #else - #error Need inline assembly for your platform. - #endif - #else // well, make gradient ... SLONG slR0=0,slG0=0,slB0=0; @@ -1528,9 +1481,8 @@ rowDone: // apply directional light or ambient to layer void CLayerMixer::AddDirectional(void) { -#if ASMOPT == 1 +#if (defined __MSVC_INLINE__) ULONG ulLight = ByteSwap( lm_colLight); - #if (defined __MSVC_INLINE__) __asm { // prepare pointers and variables mov edi,D [_pulLayer] @@ -1565,7 +1517,8 @@ rowNext: emms } - #elif (defined __GNU_INLINE_X86_32__) +#elif (defined __GNU_INLINE_X86_32__) + ULONG ulLight = ByteSwap( lm_colLight); ULONG tmp; __asm__ __volatile__ ( // prepare pointers and variables @@ -1608,10 +1561,6 @@ rowNext: : FPU_REGS, "mm5", "mm6", "ecx", "edi", "cc", "memory" ); - #else - #error Write inline assembly for your platform. - #endif - #else UBYTE* pubLayer = (UBYTE*)_pulLayer; // for each pixel in the shadow map @@ -1631,9 +1580,8 @@ rowNext: // apply directional light thru mask to layer void CLayerMixer::AddMaskDirectional( UBYTE *pubMask, UBYTE ubMask) { -#if ASMOPT == 1 +#if (defined __MSVC_INLINE__) ULONG ulLight = ByteSwap( lm_colLight); - #if (defined __MSVC_INLINE__) // prepare some local variables __asm { // prepare pointers and variables @@ -1665,7 +1613,8 @@ skipLight: emms } - #elif (defined __GNU_INLINE_X86_32__) +#elif (defined __GNU_INLINE_X86_32__) + ULONG ulLight = ByteSwap( lm_colLight); ULONG tmp; __asm__ __volatile__ ( // prepare pointers and variables @@ -1706,10 +1655,6 @@ skipLight: "cc", "memory" ); - #else - #error Please write inline assembly for your platform. - #endif - #else UBYTE* pubLayer = (UBYTE*)_pulLayer; // for each pixel in the shadow map @@ -1832,7 +1777,33 @@ void CLayerMixer::MixOneMipmap(CBrushShadowMap *pbsm, INDEX iMipmap) } } // set initial color - #if (defined USE_PORTABLE_C) +#if (defined __MSVC_INLINE__) + __asm { + cld + mov ebx,D [this] + mov ecx,D [ebx].lm_pixCanvasSizeU + imul ecx,D [ebx].lm_pixCanvasSizeV + mov edi,D [ebx].lm_pulShadowMap + mov eax,D [colAmbient] + bswap eax + rep stosd + } + +#elif (defined __GNU_INLINE_X86_32__) + ULONG clob1, clob2, clob3; + __asm__ __volatile__ ( + "cld \n\t" + "imull %%esi, %%ecx \n\t" + "bswapl %%eax \n\t" + "rep \n\t" + "stosl \n\t" + : "=a" (clob1), "=c" (clob2), "=D" (clob3) + : "c" (this->lm_pixCanvasSizeU), "S" (this->lm_pixCanvasSizeV), + "a" (colAmbient), "D" (this->lm_pulShadowMap) + : "cc", "memory" + ); + +#else register ULONG count = this->lm_pixCanvasSizeU * this->lm_pixCanvasSizeV; #if PLATFORM_LITTLEENDIAN // Forces C fallback; BYTESWAP itself is a no-op on little endian. @@ -1850,35 +1821,7 @@ void CLayerMixer::MixOneMipmap(CBrushShadowMap *pbsm, INDEX iMipmap) ptr++; } - #elif (defined __MSVC_INLINE__) - __asm { - cld - mov ebx,D [this] - mov ecx,D [ebx].lm_pixCanvasSizeU - imul ecx,D [ebx].lm_pixCanvasSizeV - mov edi,D [ebx].lm_pulShadowMap - mov eax,D [colAmbient] - bswap eax - rep stosd - } - - #elif (defined __GNU_INLINE_X86_32__) - ULONG clob1, clob2, clob3; - __asm__ __volatile__ ( - "cld \n\t" - "imull %%esi, %%ecx \n\t" - "bswapl %%eax \n\t" - "rep \n\t" - "stosl \n\t" - : "=a" (clob1), "=c" (clob2), "=D" (clob3) - : "c" (this->lm_pixCanvasSizeU), "S" (this->lm_pixCanvasSizeV), - "a" (colAmbient), "D" (this->lm_pulShadowMap) - : "cc", "memory" - ); - - #else - #error Please write inline assembly for your platform. - #endif +#endif _pfWorldEditingProfile.StopTimer(CWorldEditingProfile::PTI_AMBIENTFILL); @@ -1955,9 +1898,7 @@ void CLayerMixer::MixOneMipmap(CBrushShadowMap *pbsm, INDEX iMipmap) // copy from static shadow map to dynamic layer __forceinline void CLayerMixer::CopyShadowLayer(void) { - #if (defined USE_PORTABLE_C) - memcpy(lm_pulShadowMap, lm_pulStaticShadowMap, lm_pixCanvasSizeU*lm_pixCanvasSizeV*4); - #elif (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) __asm { cld mov ebx,D [this] @@ -1967,7 +1908,7 @@ __forceinline void CLayerMixer::CopyShadowLayer(void) mov edi,D [ebx].lm_pulShadowMap rep movsd } - #elif (defined __GNU_INLINE_X86_32__) +#elif (defined __GNU_INLINE_X86_32__) ULONG clob1, clob2, clob3; __asm__ __volatile__ ( "cld \n\t" @@ -1980,21 +1921,16 @@ __forceinline void CLayerMixer::CopyShadowLayer(void) : "cc", "memory" ); - #else - #error Please write inline assembly for your platform. - #endif +#else + memcpy(lm_pulShadowMap, lm_pulStaticShadowMap, lm_pixCanvasSizeU*lm_pixCanvasSizeV*4); +#endif } // copy from static shadow map to dynamic layer __forceinline void CLayerMixer::FillShadowLayer( COLOR col) { - #if (defined USE_PORTABLE_C) - DWORD* dst = (DWORD*)lm_pulShadowMap; - int n = lm_pixCanvasSizeU*lm_pixCanvasSizeV; - DWORD color = __builtin_bswap32(col); - while(n--) {*(dst++)=color;} - #elif (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) __asm { cld mov ebx,D [this] @@ -2006,7 +1942,7 @@ __forceinline void CLayerMixer::FillShadowLayer( COLOR col) rep stosd } - #elif (defined __GNU_INLINE_X86_32__) +#elif (defined __GNU_INLINE_X86_32__) ULONG clob1, clob2, clob3; __asm__ __volatile__ ( "cld \n\t" @@ -2020,9 +1956,12 @@ __forceinline void CLayerMixer::FillShadowLayer( COLOR col) : "cc", "memory" ); - #else - #error Please write inline assembly for your platform. - #endif +#else + DWORD* dst = (DWORD*)lm_pulShadowMap; + int n = lm_pixCanvasSizeU*lm_pixCanvasSizeV; + DWORD color = __builtin_bswap32(col); + while(n--) {*(dst++)=color;} +#endif } diff --git a/Sources/Engine/Math/Float.cpp b/Sources/Engine/Math/Float.cpp index 7c9f0fc..9f04e16 100755 --- a/Sources/Engine/Math/Float.cpp +++ b/Sources/Engine/Math/Float.cpp @@ -24,18 +24,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #define _PC_64 0x0300 // !!! FIXME: I'd like to remove any dependency on the FPU control word from the game, asap. --ryan. -#ifdef USE_PORTABLE_C -// Fake control87 for USE_PORTABLE_C version -inline ULONG _control87(WORD newcw, WORD mask) -{ - static WORD fpw=_PC_64; - if (mask != 0) - { - fpw &= ~mask; - fpw |= (newcw & mask); - } - return(fpw); -} +#if (defined _MSC_VER) + +// _control87 is provided by the compiler #elif (defined __GNU_INLINE_X86_32__) @@ -74,8 +65,20 @@ inline ULONG _control87(WORD newcw, WORD mask) return(fpw); } -#elif (!defined _MSC_VER) -#error Implement for your platform, or add a stub conditional here. +#else + +// Fake control87 for USE_PORTABLE_C version +inline ULONG _control87(WORD newcw, WORD mask) +{ + static WORD fpw=_PC_64; + if (mask != 0) + { + fpw &= ~mask; + fpw |= (newcw & mask); + } + return(fpw); +} + #endif /* Get current precision setting of FPU. */ diff --git a/Sources/Engine/Math/Functions.h b/Sources/Engine/Math/Functions.h index f0e8d03..1108e71 100755 --- a/Sources/Engine/Math/Functions.h +++ b/Sources/Engine/Math/Functions.h @@ -312,12 +312,7 @@ inline FLOAT NormByteToFloat( const ULONG ul) // fast float to int conversion inline SLONG FloatToInt( FLOAT f) { -#if defined(__arm__) || defined(USE_PORTABLE_C) - // round to nearest by adding/subtracting 0.5 (depending on f pos/neg) before converting to SLONG - float addToRound = copysignf(0.5f, f); // copy f's signbit to 0.5 => if f<0 then addToRound = -0.5, else 0.5 - return((SLONG) (f + addToRound)); - -#elif (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) SLONG slRet; __asm { fld D [f] @@ -336,16 +331,16 @@ inline SLONG FloatToInt( FLOAT f) ); return(slRet); #else - #error Fill this in for your platform. + // round to nearest by adding/subtracting 0.5 (depending on f pos/neg) before converting to SLONG + float addToRound = copysignf(0.5f, f); // copy f's signbit to 0.5 => if f<0 then addToRound = -0.5, else 0.5 + return((SLONG) (f + addToRound)); + #endif } // log base 2 of any float numero inline FLOAT Log2( FLOAT f) { -#if (defined USE_PORTABLE_C) || defined(__arm__) - return log2f(f); - -#elif (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) FLOAT fRet; _asm { fld1 @@ -368,7 +363,8 @@ inline FLOAT Log2( FLOAT f) { ); return(fRet); #else - #error Fill this in for your platform. + return log2f(f); + #endif } @@ -376,25 +372,7 @@ inline FLOAT Log2( FLOAT f) { // returns accurate values only for integers that are power of 2 inline SLONG FastLog2( SLONG x) { -#if (defined USE_PORTABLE_C) -#ifdef __GNUC__ - if(x == 0) return 0; // __builtin_clz() is undefined for 0 - int numLeadingZeros = __builtin_clz(x); - return 31 - numLeadingZeros; -#else - register SLONG val = x; - register SLONG retval = 31; - while (retval > 0) - { - if (val & (1 << retval)) - return retval; - retval--; - } - - return 0; -#endif - -#elif (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) SLONG slRet; __asm { bsr eax,D [x] @@ -411,8 +389,21 @@ inline SLONG FastLog2( SLONG x) : "memory" ); return(slRet); +#elif (defined __GNUC__) + if(x == 0) return 0; // __builtin_clz() is undefined for 0 + int numLeadingZeros = __builtin_clz(x); + return 31 - numLeadingZeros; #else - #error Fill this in for your platform. + register SLONG val = x; + register SLONG retval = 31; + while (retval > 0) + { + if (val & (1 << retval)) + return retval; + retval--; + } + + return 0; #endif } @@ -420,11 +411,7 @@ inline SLONG FastLog2( SLONG x) // returns log2 of first larger value that is a power of 2 inline SLONG FastMaxLog2( SLONG x) { -#if (defined USE_PORTABLE_C) -printf("CHECK THIS: %s:%d\n", __FILE__, __LINE__); - return((SLONG) log2((double) x)); - -#elif (defined __MSVC_INLINE__) +#if (defined __MSVC_INLINE__) SLONG slRet; __asm { bsr eax,D [x] @@ -448,7 +435,9 @@ printf("CHECK THIS: %s:%d\n", __FILE__, __LINE__); ); return(slRet); #else - #error Fill this in for your platform. +printf("CHECK THIS: %s:%d\n", __FILE__, __LINE__); + return((SLONG) log2((double) x)); + #endif } */ diff --git a/Sources/Engine/Models/RenderModel_View.cpp b/Sources/Engine/Models/RenderModel_View.cpp index 6c574fa..73fb5ef 100644 --- a/Sources/Engine/Models/RenderModel_View.cpp +++ b/Sources/Engine/Models/RenderModel_View.cpp @@ -40,14 +40,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #define W word ptr #define B byte ptr -#if (defined __MSVC_INLINE__) -#define ASMOPT 1 -#elif (defined __GNU_INLINE_X86_32__) -#define ASMOPT 0 // !!! FIXME: rcg10112001 Write GCC inline asm versions... -#else -#define ASMOPT 0 -#endif - extern BOOL CVA_bModels; extern BOOL GFX_bTruform; @@ -663,7 +655,7 @@ static FLOAT _fHazeAdd; // check vertex against fog static void GetFogMapInVertex( GFXVertex3 &vtx, GFXTexCoord &tex) { -#if ASMOPT == 1 +#if (defined __MSVC_INLINE__) __asm { mov esi,D [vtx] mov edi,D [tex] @@ -708,7 +700,7 @@ static void GetFogMapInVertex( GFXVertex3 &vtx, GFXTexCoord &tex) // check vertex against haze static void GetHazeMapInVertex( GFXVertex3 &vtx, FLOAT &tx1) { -#if ASMOPT == 1 +#if (defined __MSVC_INLINE__) __asm { mov esi,D [vtx] mov edi,D [tx1] @@ -1080,7 +1072,7 @@ static void UnpackFrame( CRenderModel &rm, BOOL bKeepNormals) const ModelFrameVertex16 *pFrame1 = rm.rm_pFrame16_1; if( pFrame0==pFrame1) { -#if ASMOPT == 1 +#if (defined __MSVC_INLINE__) // for each vertex in mip const SLONG fixLerpRatio = FloatToInt(fLerpRatio*256.0f); // fix 8:8 SLONG slTmp1, slTmp2, slTmp3; @@ -1196,7 +1188,7 @@ vtxNext16: // if lerping else { -#if ASMOPT == 1 +#if (defined __MSVC_INLINE__) // for each vertex in mip const SLONG fixLerpRatio = FloatToInt(fLerpRatio*256.0f); // fix 8:8 SLONG slTmp1, slTmp2, slTmp3; @@ -1365,7 +1357,7 @@ vtxNext16L: // if no lerping if( pFrame0==pFrame1) { -#if ASMOPT == 1 +#if (defined __MSVC_INLINE__) // for each vertex in mip const SLONG fixLerpRatio = FloatToInt(fLerpRatio*256.0f); // fix 8:8 SLONG slTmp1, slTmp2, slTmp3; @@ -1464,7 +1456,7 @@ vtxNext8: // if lerping else { -#if ASMOPT == 1 +#if (defined __MSVC_INLINE__) const SLONG fixLerpRatio = FloatToInt(fLerpRatio*256.0f); // fix 8:8 SLONG slTmp1, slTmp2, slTmp3; // re-adjust stretching factors because of fixint lerping (divide by 256) @@ -1610,7 +1602,7 @@ vtxNext8L: } // generate colors from shades -#if ASMOPT == 1 +#if (defined __MSVC_INLINE__) __asm { pxor mm0,mm0 // construct 64-bit RGBA light @@ -1974,7 +1966,7 @@ void CModelObject::RenderModel_View( CRenderModel &rm) pvtxSrfBase = &_avtxSrfBase[iSrfVx0]; INDEX iSrfVx; -#if ASMOPT == 1 +#if (defined __MSVC_INLINE__) __asm { push ebx mov ebx,D [puwSrfToMip] @@ -2074,7 +2066,7 @@ srfVtxLoop: const COLOR colD = AdjustColor( ms.ms_colDiffuse, _slTexHueShift, _slTexSaturation); colSrfDiff.MultiplyRGBA( colD, colMdlDiff); -#if ASMOPT == 1 +#if (defined __MSVC_INLINE__) // setup texcoord array __asm { push ebx @@ -2134,7 +2126,7 @@ vtxEnd: for( INDEX iSrfVx=0; iSrfVxsl_SwfeFormat.nSamplesPerSec; // wipe destination mixer buffer - // (Mac OS X uses this path because Apple's memset() is customized for each CPU they support and way faster than this inline asm. --ryan.) - #if ((defined USE_PORTABLE_C) || (PLATFORM_MACOSX)) - memset(pvMixerBuffer, 0, slMixerBufferSize * 8); - - #elif (defined __MSVC_INLINE__) + #if (defined __MSVC_INLINE__) __asm { cld xor eax,eax @@ -94,19 +88,8 @@ void ResetMixer( const SLONG *pslBuffer, const SLONG slBufferSize) shl ecx,1 // *2 because of 32-bit src format rep stosd } - #elif (defined __GNU_INLINE_X86_32__) - // !!! FIXME : rcg12172001 Is this REALLY any faster than memset()? - ULONG clob1, clob2; - __asm__ __volatile__ ( - "cld \n\t" - "rep \n\t" - "stosl \n\t" - : "=D" (clob1), "=c" (clob2) - : "a" (0), "D" (pvMixerBuffer), "c" (slMixerBufferSize*2) - : "cc", "memory" - ); #else - #error please write inline asm for your platform. + memset(pvMixerBuffer, 0, slMixerBufferSize * 8); #endif } @@ -118,10 +101,7 @@ void CopyMixerBuffer_stereo( const SLONG slSrcOffset, void *pDstBuffer, const SL ASSERT( slBytes%4==0); if( slBytes<4) return; - #if ((defined USE_PORTABLE_C) || (PLATFORM_MACOSX)) - // (Mac OS X uses this path because Apple's memset() is customized for each CPU they support and way faster than this inline asm. --ryan.) - memcpy(pDstBuffer, ((const char *)pvMixerBuffer) + slSrcOffset, slBytes); - #elif (defined __MSVC_INLINE__) + #if (defined __MSVC_INLINE__) __asm { cld mov esi,D [slSrcOffset] @@ -131,21 +111,8 @@ void CopyMixerBuffer_stereo( const SLONG slSrcOffset, void *pDstBuffer, const SL shr ecx,2 // bytes to samples per channel rep movsd } - #elif (defined __GNU_INLINE_X86_32__) - // !!! FIXME : rcg12172001 Is this REALLY any faster than memcpy()? - ULONG clob1, clob2, clob3; - __asm__ __volatile__ ( - "cld \n\t" - "rep \n\t" - "movsl \n\t" - : "=S" (clob1), "=D" (clob2), "=c" (clob3) - : "S" (((char *)pvMixerBuffer) + slSrcOffset), - "D" (pDstBuffer), - "c" (slBytes >> 2) - : "cc", "memory" - ); #else - #error please write inline asm for your platform. + memcpy(pDstBuffer, ((const char *)pvMixerBuffer) + slSrcOffset, slBytes); #endif } @@ -157,18 +124,7 @@ void CopyMixerBuffer_mono( const SLONG slSrcOffset, void *pDstBuffer, const SLON ASSERT( slBytes%2==0); if( slBytes<4) return; - #if (defined USE_PORTABLE_C) - // (This is untested, currently. --ryan.) - WORD *dest = (WORD *) pDstBuffer; - WORD *src = (WORD *) ( ((char *) pvMixerBuffer) + slSrcOffset ); - SLONG max = slBytes / 4; - for (SLONG i = 0; i < max; i++) { - *dest = *src; - dest++; // move 16 bits. - src+=2; // move 32 bits. - } - - #elif (defined __MSVC_INLINE__) + #if (defined __MSVC_INLINE__) __asm { mov esi,D [slSrcOffset] add esi,D [pvMixerBuffer] @@ -204,7 +160,15 @@ copyLoop: ); #else - #error please write inline asm for your platform. + // (This is untested, currently. --ryan.) + WORD *dest = (WORD *) pDstBuffer; + WORD *src = (WORD *) ( ((char *) pvMixerBuffer) + slSrcOffset ); + SLONG max = slBytes / 4; + for (SLONG i = 0; i < max; i++) { + *dest = *src; + dest++; // move 16 bits. + src+=2; // move 32 bits. + } #endif } @@ -215,24 +179,7 @@ static void ConvertMixerBuffer( const SLONG slBytes) ASSERT( slBytes%4==0); if( slBytes<4) return; - #if (defined USE_PORTABLE_C) - //STUBBED("ConvertMixerBuffer"); - SWORD *dest = (SWORD *) pvMixerBuffer; - SLONG *src = (SLONG *) pvMixerBuffer; - SLONG max = slBytes / 2; - int tmp; - for (SLONG i = 0; i < max; i++) { - tmp = *src; - if (tmp>32767) tmp=32767; - if (tmp<-32767) tmp=-32767; - *dest=tmp; - dest++; // move 16 bits. - src++; // move 32 bits. - } - - - - #elif (defined __MSVC_INLINE__) + #if (defined __MSVC_INLINE__) __asm { cld mov esi,D [pvMixerBuffer] @@ -271,7 +218,20 @@ copyLoop: ); #else - #error please write inline asm for your platform. + + SWORD *dest = (SWORD *) pvMixerBuffer; + SLONG *src = (SLONG *) pvMixerBuffer; + SLONG max = slBytes / 2; + int tmp; + for (SLONG i = 0; i < max; i++) { + tmp = *src; + if (tmp>32767) tmp=32767; + if (tmp<-32767) tmp=-32767; + *dest=tmp; + dest++; // move 16 bits. + src++; // move 32 bits. + } + #endif } @@ -337,85 +297,7 @@ inline void MixMono( CSoundObject *pso) { _pfSoundProfile.StartTimer(CSoundProfile::PTI_RAWMIXER); - #if (defined USE_PORTABLE_C) - // initialize some local vars - SLONG slLeftSample, slRightSample, slNextSample; - SLONG *pslDstBuffer = (SLONG*)pvMixerBuffer; - fixLeftOfs = (__int64)(fLeftOfs * 65536.0); - fixRightOfs = (__int64)(fRightOfs * 65536.0); - __int64 fixLeftStep = (__int64)(fLeftStep * 65536.0); - __int64 fixRightStep = (__int64)(fRightStep * 65536.0); - __int64 fixSoundBufferSize = ((__int64)slSoundBufferSize)<<16; - mmSurroundFactor = (__int64)(SWORD)mmSurroundFactor; - - SLONG slLeftVolume_ = slLeftVolume >> 16; - SLONG slRightVolume_ = slRightVolume >> 16; - - // loop thru source buffer - INDEX iCt = slMixerBufferSize; - FOREVER - { - // if left channel source sample came to end of sample buffer - if( fixLeftOfs >= fixSoundBufferSize) { - fixLeftOfs -= fixSoundBufferSize; - // if has no loop, end it - bEndOfSound = bNotLoop; - } - // if right channel source sample came to end of sample buffer - if( fixRightOfs >= fixSoundBufferSize) { - fixRightOfs -= fixSoundBufferSize; - // if has no loop, end it - bEndOfSound = bNotLoop; - } - // end of buffer? - if( iCt<=0 || bEndOfSound) break; - - // fetch one lineary interpolated sample on left channel - slLeftSample = pswSrcBuffer[(fixLeftOfs>>16)+0]; - slNextSample = pswSrcBuffer[(fixLeftOfs>>16)+1]; - slLeftSample = (slLeftSample*(65535-(fixLeftOfs&65535)) + slNextSample*(fixLeftOfs&65535)) >>16; - // fetch one lineary interpolated sample on right channel - slRightSample = pswSrcBuffer[(fixRightOfs>>16)+0]; - slNextSample = pswSrcBuffer[(fixRightOfs>>16)+1]; - slRightSample = (slRightSample*(65535-(fixRightOfs&65535)) + slNextSample*(fixRightOfs&65535)) >>16; - - // filter samples - slLastLeftSample += ((slLeftSample -slLastLeftSample) *slLeftFilter) >>15; - slLastRightSample += ((slRightSample-slLastRightSample)*slRightFilter)>>15; - - // apply stereo volume to current sample - slLeftSample = (slLastLeftSample * slLeftVolume_) >>15; - slRightSample = (slLastRightSample * slRightVolume_)>>15; - - slLeftSample ^= (SLONG)((mmSurroundFactor>> 0)&0xFFFFFFFF); - slRightSample ^= (SLONG)((mmSurroundFactor>>32)&0xFFFFFFFF); - - // mix in current sample - slLeftSample += pslDstBuffer[0]; - slRightSample += pslDstBuffer[1]; - // upper clamp - if( slLeftSample > MAX_SWORD) slLeftSample = MAX_SWORD; - if( slRightSample > MAX_SWORD) slRightSample = MAX_SWORD; - // lower clamp - if( slLeftSample < MIN_SWORD) slLeftSample = MIN_SWORD; - if( slRightSample < MIN_SWORD) slRightSample = MIN_SWORD; - - // store samples (both channels) - pslDstBuffer[0] = slLeftSample; - pslDstBuffer[1] = slRightSample; - - // modify volume ` - slLeftVolume += (SWORD)((mmVolumeGain>> 0)&0xFFFF); - slRightVolume += (SWORD)((mmVolumeGain>>16)&0xFFFF); - - // advance to next sample - fixLeftOfs += fixLeftStep; - fixRightOfs += fixRightStep; - pslDstBuffer += 2; - iCt--; - } - - #elif (defined __MSVC_INLINE__) + #if (defined __MSVC_INLINE__) __asm { // convert from floats to fixints 32:16 fld D [fLeftOfs] @@ -553,19 +435,6 @@ loopEnd: MixMono_asm(pso); #else - #error please write inline asm for your platform. - #endif - - _pfSoundProfile.StopTimer(CSoundProfile::PTI_RAWMIXER); -} - - -// mixes one stereo 16-bit signed sound to destination buffer -inline void MixStereo( CSoundObject *pso) -{ - _pfSoundProfile.StartTimer(CSoundProfile::PTI_RAWMIXER); - - #if (defined USE_PORTABLE_C) // initialize some local vars SLONG slLeftSample, slRightSample, slNextSample; SLONG *pslDstBuffer = (SLONG*)pvMixerBuffer; @@ -599,12 +468,12 @@ inline void MixStereo( CSoundObject *pso) if( iCt<=0 || bEndOfSound) break; // fetch one lineary interpolated sample on left channel - slLeftSample = pswSrcBuffer[(fixLeftOfs>>15)+0]; - slNextSample = pswSrcBuffer[(fixLeftOfs>>15)+2]; + slLeftSample = pswSrcBuffer[(fixLeftOfs>>16)+0]; + slNextSample = pswSrcBuffer[(fixLeftOfs>>16)+1]; slLeftSample = (slLeftSample*(65535-(fixLeftOfs&65535)) + slNextSample*(fixLeftOfs&65535)) >>16; // fetch one lineary interpolated sample on right channel - slRightSample = pswSrcBuffer[(fixRightOfs>>15)+0]; - slNextSample = pswSrcBuffer[(fixRightOfs>>15)+2]; + slRightSample = pswSrcBuffer[(fixRightOfs>>16)+0]; + slNextSample = pswSrcBuffer[(fixRightOfs>>16)+1]; slRightSample = (slRightSample*(65535-(fixRightOfs&65535)) + slNextSample*(fixRightOfs&65535)) >>16; // filter samples @@ -643,7 +512,18 @@ inline void MixStereo( CSoundObject *pso) iCt--; } - #elif (defined __MSVC_INLINE__) + #endif + + _pfSoundProfile.StopTimer(CSoundProfile::PTI_RAWMIXER); +} + + +// mixes one stereo 16-bit signed sound to destination buffer +inline void MixStereo( CSoundObject *pso) +{ + _pfSoundProfile.StartTimer(CSoundProfile::PTI_RAWMIXER); + + #if (defined __MSVC_INLINE__) __asm { // convert from floats to fixints 32:16 fld D [fLeftOfs] @@ -783,7 +663,83 @@ loopEnd: MixStereo_asm(pso); #else - #error please write inline asm for your platform. + // initialize some local vars + SLONG slLeftSample, slRightSample, slNextSample; + SLONG *pslDstBuffer = (SLONG*)pvMixerBuffer; + fixLeftOfs = (__int64)(fLeftOfs * 65536.0); + fixRightOfs = (__int64)(fRightOfs * 65536.0); + __int64 fixLeftStep = (__int64)(fLeftStep * 65536.0); + __int64 fixRightStep = (__int64)(fRightStep * 65536.0); + __int64 fixSoundBufferSize = ((__int64)slSoundBufferSize)<<16; + mmSurroundFactor = (__int64)(SWORD)mmSurroundFactor; + + SLONG slLeftVolume_ = slLeftVolume >> 16; + SLONG slRightVolume_ = slRightVolume >> 16; + + // loop thru source buffer + INDEX iCt = slMixerBufferSize; + FOREVER + { + // if left channel source sample came to end of sample buffer + if( fixLeftOfs >= fixSoundBufferSize) { + fixLeftOfs -= fixSoundBufferSize; + // if has no loop, end it + bEndOfSound = bNotLoop; + } + // if right channel source sample came to end of sample buffer + if( fixRightOfs >= fixSoundBufferSize) { + fixRightOfs -= fixSoundBufferSize; + // if has no loop, end it + bEndOfSound = bNotLoop; + } + // end of buffer? + if( iCt<=0 || bEndOfSound) break; + + // fetch one lineary interpolated sample on left channel + slLeftSample = pswSrcBuffer[(fixLeftOfs>>15)+0]; + slNextSample = pswSrcBuffer[(fixLeftOfs>>15)+2]; + slLeftSample = (slLeftSample*(65535-(fixLeftOfs&65535)) + slNextSample*(fixLeftOfs&65535)) >>16; + // fetch one lineary interpolated sample on right channel + slRightSample = pswSrcBuffer[(fixRightOfs>>15)+0]; + slNextSample = pswSrcBuffer[(fixRightOfs>>15)+2]; + slRightSample = (slRightSample*(65535-(fixRightOfs&65535)) + slNextSample*(fixRightOfs&65535)) >>16; + + // filter samples + slLastLeftSample += ((slLeftSample -slLastLeftSample) *slLeftFilter) >>15; + slLastRightSample += ((slRightSample-slLastRightSample)*slRightFilter)>>15; + + // apply stereo volume to current sample + slLeftSample = (slLastLeftSample * slLeftVolume_) >>15; + slRightSample = (slLastRightSample * slRightVolume_)>>15; + + slLeftSample ^= (SLONG)((mmSurroundFactor>> 0)&0xFFFFFFFF); + slRightSample ^= (SLONG)((mmSurroundFactor>>32)&0xFFFFFFFF); + + // mix in current sample + slLeftSample += pslDstBuffer[0]; + slRightSample += pslDstBuffer[1]; + // upper clamp + if( slLeftSample > MAX_SWORD) slLeftSample = MAX_SWORD; + if( slRightSample > MAX_SWORD) slRightSample = MAX_SWORD; + // lower clamp + if( slLeftSample < MIN_SWORD) slLeftSample = MIN_SWORD; + if( slRightSample < MIN_SWORD) slRightSample = MIN_SWORD; + + // store samples (both channels) + pslDstBuffer[0] = slLeftSample; + pslDstBuffer[1] = slRightSample; + + // modify volume ` + slLeftVolume += (SWORD)((mmVolumeGain>> 0)&0xFFFF); + slRightVolume += (SWORD)((mmVolumeGain>>16)&0xFFFF); + + // advance to next sample + fixLeftOfs += fixLeftStep; + fixRightOfs += fixRightStep; + pslDstBuffer += 2; + iCt--; + } + #endif _pfSoundProfile.StopTimer(CSoundProfile::PTI_RAWMIXER); From ff57a29e0f1b5d13d8a006b270442882a9f308b1 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 24 Apr 2016 21:38:59 +0300 Subject: [PATCH 06/34] make separate option for using nasm asm Other asm is now enabled by default again, since asm blocks are now smarter and won't fail to compile on non-i386 platforms. --- Sources/CMakeLists.txt | 22 ++++++++++++++-------- Sources/Engine/Sound/SoundMixer.cpp | 8 ++++---- Sources/build-linux32.sh | 4 ++-- Sources/build-linux64.sh | 2 +- Sources/build-mac.sh | 2 +- Sources/build-mac64.sh | 2 +- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index c43ced8..39ab5f7 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -188,13 +188,20 @@ else() set(DEBUGSUFFIX "") endif() -# This should not be needed anymore, but might be faster on 32bit x86 -option(USE_I386_ASM "Use X86 ASM" FALSE) +option(USE_ASM "Use ASM code" TRUE) +if (USE_ASM) + MESSAGE(STATUS "Using assembler code (when available)") +else() + add_definitions(-DUSE_PORTABLE_C=1) + MESSAGE(STATUS "Using portable C instead of all ASM") +endif() -if (USE_I386_ASM) +option(USE_I386_NASM_ASM "Use i386 nasm ASM code" FALSE) + +if (USE_ASM AND USE_I386_NASM_ASM) # You need the Netwide Assembler (NASM) to build this on Intel systems. # http://nasm.sf.net/ - add_definitions(-DUSE_I386_ASM=1) + add_definitions(-DUSE_I386_NASM_ASM=1) if (MACOSX) set(ASMOBJFMT "macho") list(APPEND ASMFLAGS --prefix _) @@ -203,10 +210,9 @@ if (USE_I386_ASM) else() set(ASMOBJFMT "elf") endif() - MESSAGE(STATUS "Using i386 assembler") + MESSAGE(STATUS "Using i386 nasm ASM") else() - add_definitions(-DUSE_PORTABLE_C=1) - MESSAGE(STATUS "Using portable C instead of ASM") + MESSAGE(STATUS "Not using i386 nasm ASM") endif() option(PANDORA "Compile for Pandora" FALSE) @@ -655,7 +661,7 @@ add_dependencies(${SHADERSLIB} ParseEntities) add_parser_and_scanner("Engine/Base/Parser" "Engine/Base/Scanner") add_parser_and_scanner("Engine/Ska/smcPars" "Engine/Ska/smcScan") -if (USE_I386_ASM) +if (USE_I386_NASM_ASM) add_custom_command( OUTPUT "SoundMixer386.o" MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/Engine/Sound/SoundMixer386.asm" diff --git a/Sources/Engine/Sound/SoundMixer.cpp b/Sources/Engine/Sound/SoundMixer.cpp index adc16a0..df07861 100644 --- a/Sources/Engine/Sound/SoundMixer.cpp +++ b/Sources/Engine/Sound/SoundMixer.cpp @@ -43,7 +43,7 @@ static CSoundData *psd; // nasm on MacOS X is getting wrong addresses of external globals, so I have // to define them in the .asm file...lame. -#if (defined __GNU_INLINE_X86_32__) +#if (defined __GNU_INLINE_X86_32__) && (defined USE_I386_NASM_ASM) #define INASM extern #elif (defined __MSVC_INLINE__) #define INASM static @@ -283,7 +283,7 @@ void NormalizeMixerBuffer( const FLOAT fNormStrength, const SLONG slBytes, FLOAT } -#ifdef __GNU_INLINE_X86_32__ +#if (defined __GNU_INLINE_X86_32__) && (defined USE_I386_NASM_ASM) // These are implemented in an external NASM file. extern "C" { void MixStereo_asm(CSoundObject *pso); @@ -430,7 +430,7 @@ loopEnd: emms } - #elif (defined __GNU_INLINE_X86_32__) + #elif (defined __GNU_INLINE_X86_32__) && (defined USE_I386_NASM_ASM) // This is implemented in an external NASM file. MixMono_asm(pso); @@ -658,7 +658,7 @@ loopEnd: emms } - #elif (defined __GNU_INLINE_X86_32__) + #elif (defined __GNU_INLINE_X86_32__) && (defined USE_I386_NASM_ASM) // This is implemented in an external NASM file. MixStereo_asm(pso); diff --git a/Sources/build-linux32.sh b/Sources/build-linux32.sh index 4f44315..f7bf3fa 100755 --- a/Sources/build-linux32.sh +++ b/Sources/build-linux32.sh @@ -14,10 +14,10 @@ cd $_ #ninja # This is the eventual path for amd64. -#cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_I386_ASM=FALSE .. +#cmake -DCMAKE_BUILD_TYPE=Debug .. # Right now we force x86, though... -cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 -DUSE_I386_ASM=TRUE .. +cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 -DUSE_I386_NASM_ASM=TRUE .. make -j$NCPU diff --git a/Sources/build-linux64.sh b/Sources/build-linux64.sh index d81e4dd..44fe793 100755 --- a/Sources/build-linux64.sh +++ b/Sources/build-linux64.sh @@ -14,7 +14,7 @@ cd $_ #ninja # This is the eventual path for amd64. -cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_I386_ASM=FALSE .. +cmake -DCMAKE_BUILD_TYPE=Debug .. # Right now we force x86, though... #cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 .. diff --git a/Sources/build-mac.sh b/Sources/build-mac.sh index a0311cf..1f01255 100755 --- a/Sources/build-mac.sh +++ b/Sources/build-mac.sh @@ -9,6 +9,6 @@ set -x rm -rf cmake-build mkdir $_ cd $_ -cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_ARCHITECTURES=i386 -DUSE_I386_ASM=TRUE -DUSE_SYSTEM_SDL2=FALSE .. +cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_ARCHITECTURES=i386 -DUSE_I386_NASM_ASM=TRUE -DUSE_SYSTEM_SDL2=FALSE .. make -j$NCPU diff --git a/Sources/build-mac64.sh b/Sources/build-mac64.sh index 52f295b..5265cdc 100755 --- a/Sources/build-mac64.sh +++ b/Sources/build-mac64.sh @@ -9,6 +9,6 @@ set -x rm -rf cmake-build mkdir $_ cd $_ -cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_ARCHITECTURES=x86_64 -DUSE_I386_ASM=FALSE .. +cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_ARCHITECTURES=x86_64 .. make -j$NCPU From ce46bd1e998231b323b2e95e3b530c204dca6976 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 25 Apr 2016 00:00:55 +0300 Subject: [PATCH 07/34] make cpuid work on x86_64 not that it's used for anything, just for the logs --- Sources/Engine/Base/Types.h | 8 +++++- Sources/Engine/Engine.cpp | 51 +++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/Sources/Engine/Base/Types.h b/Sources/Engine/Base/Types.h index fe1672a..555bc81 100644 --- a/Sources/Engine/Base/Types.h +++ b/Sources/Engine/Base/Types.h @@ -119,9 +119,15 @@ MY_STATIC_ASSERT(size_tSize, sizeof(size_t) == sizeof(void*)); #define __MSVC_INLINE__ #elif defined (__GNUC__) && defined(__i386) #define __GNU_INLINE_X86_32__ + #elif defined (__GNUC__) && defined(__x86_64__) + #define __GNU_INLINE_X86_64__ #endif - #if defined(__GNU_INLINE_X86_32__) + #if defined(__GNU_INLINE_X86_32__) || defined(__GNU_INLINE_X86_64__) + #define __GNU_INLINE_X86__ + #endif + + #if defined(__GNU_INLINE_X86__) #define FPU_REGS "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)" #define MMX_REGS "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7" #endif diff --git a/Sources/Engine/Engine.cpp b/Sources/Engine/Engine.cpp index 4ca653e..452d281 100644 --- a/Sources/Engine/Engine.cpp +++ b/Sources/Engine/Engine.cpp @@ -144,38 +144,39 @@ static void DetectCPU(void) mov dword ptr [ulFeatures], edx } - #elif (defined __GNU_INLINE_X86_32__) + #elif (defined __GNU_INLINE_X86__) + ULONG eax, ebx, ecx, edx; // test MMX presence and update flag __asm__ __volatile__ ( - "pushl %%ebx \n\t" - "xorl %%eax,%%eax \n\t" // request for basic id + #if (defined __GNU_INLINE_X86_64__) "cpuid \n\t" - "movl %%ebx, (%%esi) \n\t" - "movl %%edx, 4(%%esi) \n\t" - "movl %%ecx, 8(%%esi) \n\t" - "popl %%ebx \n\t" - : // no specific outputs. - : "S" (strVendor) - : "eax", "ecx", "edx", "memory" + : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) + #else + "movl %%ebx, %%esi \n\t" + "cpuid \n\t" + "xchgl %%ebx, %%esi \n\t" + : "=a" (eax), "=S" (ebx), "=c" (ecx), "=d" (edx) + #endif + : "a" (0) // request for basic id ); - - // need to break this into a separate asm block, since I'm clobbering - // too many registers. There's something to be said for letting MSVC - // figure out where on the stack your locals are resting, but yeah, - // I know, that's x86-specific anyhow... - // !!! FIXME: can probably do this right with modern GCC. + memcpy(strVendor + 0, &ebx, 4); + memcpy(strVendor + 4, &edx, 4); + memcpy(strVendor + 8, &ecx, 4); __asm__ __volatile__ ( - "pushl %%ebx \n\t" - "movl $1, %%eax \n\t" // request for TFMS feature flags - "cpuid \n\t" - "mov %%eax, (%%esi) \n\t" // remember type, family, model and stepping - "mov %%edx, (%%edi) \n\t" - "popl %%ebx \n\t" - : // no specific outputs. - : "S" (&ulTFMS), "D" (&ulFeatures) - : "eax", "ecx", "edx", "memory" + #if (defined __GNU_INLINE_X86_64__) + "cpuid \n\t" + : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) + #else + "movl %%ebx, %%esi \n\t" + "cpuid \n\t" + "xchgl %%ebx, %%esi \n\t" + : "=a" (eax), "=S" (ebx), "=c" (ecx), "=d" (edx) + #endif + : "a" (1) // request for TFMS feature flags ); + ulTFMS = eax; + ulFeatures = edx; #endif From b42612e8fb9c866a15c7427299d29dd72cb39f54 Mon Sep 17 00:00:00 2001 From: Tan Wang Leng Date: Thu, 5 May 2016 13:38:57 +0800 Subject: [PATCH 08/34] Remove ModExt.txt symlink Does not work on Mac and Windows, and git unable to deal with file thrashing with another file of similar name. --- ModExt.txt | 1 - 1 file changed, 1 deletion(-) delete mode 120000 ModExt.txt diff --git a/ModExt.txt b/ModExt.txt deleted file mode 120000 index a5e8d63..0000000 --- a/ModExt.txt +++ /dev/null @@ -1 +0,0 @@ -ModEXT.txt \ No newline at end of file From 577373f91e65b5921fa16d4d76257edb91d32efa Mon Sep 17 00:00:00 2001 From: Tan Wang Leng Date: Thu, 5 May 2016 13:47:02 +0800 Subject: [PATCH 09/34] Fix casing for ModExt.txt Some file systems are case-sensitive, so use proper casing. --- Sources/Engine/Base/Stream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Engine/Base/Stream.cpp b/Sources/Engine/Base/Stream.cpp index d1ead10..ad8399c 100755 --- a/Sources/Engine/Base/Stream.cpp +++ b/Sources/Engine/Base/Stream.cpp @@ -169,7 +169,7 @@ void InitStreams(void) } // find eventual extension for the mod's dlls _strModExt = ""; - LoadStringVar(CTString("ModExt.txt"), _strModExt); + LoadStringVar(CTString("ModEXT.txt"), _strModExt); CPrintF(TRANSV("Loading group files...\n")); From 46353ffc5de145e5cc9dd965a88de5f23d0520c5 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Fri, 22 Apr 2016 19:03:24 +0200 Subject: [PATCH 10/34] make BYTESWAP*_unsigned() macros inline functions, use GCC builtins the builtins are only used when using GCC or clang, of course, otherwise the usual shifting is done. Them being inline functions instead of macros increases type safety and gets rid of problems with signed shifts. Changed two places in the code that swapped bytes in 32bit ints to use BYTESWAP32_unsigned() instead - in case of PrepareTexture() this has probably even fixed issues with signed shifts --- Sources/Engine/Base/Types.h | 36 ++++++++++++++++++++++++++--- Sources/Engine/Graphics/Fog.cpp | 3 +-- Sources/Engine/Light/LayerMixer.cpp | 2 +- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/Sources/Engine/Base/Types.h b/Sources/Engine/Base/Types.h index 555bc81..0a7d543 100644 --- a/Sources/Engine/Base/Types.h +++ b/Sources/Engine/Base/Types.h @@ -679,15 +679,45 @@ inline void Clear(float i) {}; inline void Clear(double i) {}; inline void Clear(void *pv) {}; -// These macros are not safe to use unless data is UNSIGNED! -#define BYTESWAP16_unsigned(x) ((((x)>>8)&0xff)+ (((x)<<8)&0xff00)) -#define BYTESWAP32_unsigned(x) (((x)>>24) + (((x)>>8)&0xff00) + (((x)<<8)&0xff0000) + ((x)<<24)) +// DG: screw macros, use inline functions instead - they're even safe for signed values +inline UWORD BYTESWAP16_unsigned(UWORD x) +{ +#ifdef __GNUC__ // GCC and clang have a builtin that hopefully does the most efficient thing + return __builtin_bswap16(x); +#else + return (((x)>>8)&0xff)+ (((x)<<8)&0xff00); +#endif +} + +inline ULONG BYTESWAP32_unsigned(ULONG x) +{ +#ifdef __GNUC__ // GCC and clang have a builtin that hopefully does the most efficient thing + return __builtin_bswap32(x); +#else + return ((x)>>24) + (((x)>>8)&0xff00) + (((x)<<8)&0xff0000) + ((x)<<24); +#endif +} + +inline __uint64 BYTESWAP64_unsigned(__uint64 x) +{ +#ifdef __GNUC__ // GCC and clang have a builtin that hopefully does the most efficient thing + return __builtin_bswap64(x); +#else + ULONG l = BYTESWAP32_unsigned((ULONG)(val & 0xFFFFFFFF)); + ULONG h = BYTESWAP32_unsigned((ULONG)((val >> 32) & 0xFFFFFFFF)); + return (((__uint64)l) << 32) | ((__uint64)h); +#endif +} // rcg03242004 #if PLATFORM_LITTLEENDIAN #define BYTESWAP(x) #else +// TODO: DG: the following stuff could probably be updated to use the functions above properly, +// which should make lots of cases easier. As I don't have a big endian machine I can't test, +// so I won't touch this for now. + static inline void BYTESWAP(UWORD &val) { #if __POWERPC__ diff --git a/Sources/Engine/Graphics/Fog.cpp b/Sources/Engine/Graphics/Fog.cpp index 2945cb4..33eb1bc 100644 --- a/Sources/Engine/Graphics/Fog.cpp +++ b/Sources/Engine/Graphics/Fog.cpp @@ -109,8 +109,7 @@ pixLoop: DWORD* dst = (DWORD*)(pubTexture+pixTextureSize); for (int i=0; i> 8) & 0x0000ff00 ) | ((tmp >> 24) & 0x000000ff ); + *dst = BYTESWAP32_unsigned((ULONG)tmp); src++; dst++; } diff --git a/Sources/Engine/Light/LayerMixer.cpp b/Sources/Engine/Light/LayerMixer.cpp index 26c0e51..8b9bad9 100755 --- a/Sources/Engine/Light/LayerMixer.cpp +++ b/Sources/Engine/Light/LayerMixer.cpp @@ -1959,7 +1959,7 @@ __forceinline void CLayerMixer::FillShadowLayer( COLOR col) #else DWORD* dst = (DWORD*)lm_pulShadowMap; int n = lm_pixCanvasSizeU*lm_pixCanvasSizeV; - DWORD color = __builtin_bswap32(col); + DWORD color = BYTESWAP32_unsigned(col); while(n--) {*(dst++)=color;} #endif } From c58328d8817949162abf5887acb98a4f5c60a462 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Fri, 22 Apr 2016 19:40:09 +0200 Subject: [PATCH 11/34] RSBinToGroups() use __builtin_clz() instead of manual bsr if available should be faster. --- .../Engine/Graphics/DrawPort_RenderScene.cpp | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/Sources/Engine/Graphics/DrawPort_RenderScene.cpp b/Sources/Engine/Graphics/DrawPort_RenderScene.cpp index d624442..579c53e 100644 --- a/Sources/Engine/Graphics/DrawPort_RenderScene.cpp +++ b/Sources/Engine/Graphics/DrawPort_RenderScene.cpp @@ -499,18 +499,27 @@ static void RSBinToGroups( ScenePolygon *pspoFirst) ); #else - // emulate x86's bsr opcode...not fast. :/ - register DWORD val = _ctGroupsCount; - register INDEX bsr = 31; - if (val != 0) - { - while (bsr > 0) - { - if (val & (1l << bsr)) - break; - bsr--; - } - } + // emulate x86's bsr opcode... + + // GCC and clang have an architecture-independent intrinsic for this + // (it counts leading zeros starting at MSB and is undefined for 0) + #ifdef __GNUC__ + INDEX bsr = 31; + if(_ctGroupsCount != 0) bsr -= __builtin_clz(_ctGroupsCount); + else bsr = 0; + #else // another compiler - doing it manually.. not fast. :/ + register DWORD val = _ctGroupsCount; + register INDEX bsr = 31; + if (val != 0) + { + while (bsr > 0) + { + if (val & (1l << bsr)) + break; + bsr--; + } + } + #endif _ctGroupsCount = 2 << bsr; #endif From bee4102374891c270f08ad4e3a27f69b4c592ea6 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sat, 23 Apr 2016 03:59:18 +0200 Subject: [PATCH 12/34] Fix several warnings, warn if not using depth buffer Fixed -Wreorder warnings (hopefully the last?), also several potentially uninitialized variables. In SetupPixelFormat_OGL() Assert if gap_iDepthBits ends up being 0. Small adjustments to cmake warning settings for gcc/clang --- Sources/CMakeLists.txt | 5 +++-- Sources/Engine/Brushes/BrushSector.cpp | 8 ++++---- Sources/Engine/Graphics/SDL/SDLOpenGL.cpp | 7 +++++-- Sources/Engine/Math/ObjectSector.cpp | 2 +- Sources/Engine/Network/CommunicationInterface.cpp | 5 +++-- Sources/Engine/Network/Network.cpp | 6 +++--- Sources/Engine/Templates/BSP.cpp | 2 +- Sources/Engine/World/World.cpp | 6 +++--- Sources/EntitiesMP/AirElemental.es | 2 +- Sources/EntitiesMP/Elemental.es | 3 +++ Sources/EntitiesMP/Projectile.es | 2 +- Sources/EntitiesMP/Summoner.es | 1 + Sources/GameMP/Map.cpp | 6 ++++++ 13 files changed, 35 insertions(+), 20 deletions(-) diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 39ab5f7..65d1e03 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -112,11 +112,10 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") # TODO fix these warnings add_compile_options(-Wno-sign-compare) add_compile_options(-Wno-switch) + add_compile_options(-Wno-char-subscripts) add_compile_options(-Wno-unknown-pragmas) add_compile_options(-Wno-unused-variable) add_compile_options(-Wno-unused-value) - add_compile_options(-Wno-reorder) - add_compile_options(-Wno-unused-but-set-variable) add_compile_options(-Wno-parentheses) MESSAGE(WARNING, "re-enable some of the warnings some day!") @@ -125,6 +124,8 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") add_compile_options(-Wno-tautological-undefined-compare) add_compile_options(-Wno-c++11-compat-deprecated-writable-strings) add_compile_options(-Wno-logical-op-parentheses) # FIXME: this too should be re-enabled + else() + add_compile_options(-Wno-unused-but-set-variable) # my clang doesn't know this endif() if(MACOSX) diff --git a/Sources/Engine/Brushes/BrushSector.cpp b/Sources/Engine/Brushes/BrushSector.cpp index 3abc42b..09d9f90 100644 --- a/Sources/Engine/Brushes/BrushSector.cpp +++ b/Sources/Engine/Brushes/BrushSector.cpp @@ -53,8 +53,8 @@ CBrushSector::CBrushSector(void) , bsc_ulFlags2(0) , bsc_ulTempFlags(0) , bsc_ulVisFlags(0) -, bsc_strName("") , bsc_bspBSPTree(*new DOUBLEbsptree3D) +, bsc_strName("") { }; @@ -622,9 +622,9 @@ void CBrushSector::TriangularizeMarkedPolygons( void) bpoNew.bpo_abpePolygonEdges[2].bpe_pbedEdge = &abedEdgesNew[iEdge+2]; bpoNew.bpo_abpePolygonEdges[2].bpe_bReverse = FALSE; - CBrushEdge &edg0 = *bpoNew.bpo_abpePolygonEdges[0].bpe_pbedEdge; - CBrushEdge &edg1 = *bpoNew.bpo_abpePolygonEdges[1].bpe_pbedEdge; - CBrushEdge &edg2 = *bpoNew.bpo_abpePolygonEdges[2].bpe_pbedEdge; + //CBrushEdge &edg0 = *bpoNew.bpo_abpePolygonEdges[0].bpe_pbedEdge; + //CBrushEdge &edg1 = *bpoNew.bpo_abpePolygonEdges[1].bpe_pbedEdge; + //CBrushEdge &edg2 = *bpoNew.bpo_abpePolygonEdges[2].bpe_pbedEdge; // set brush vertex ptrs bpoNew.bpo_apbvxTriangleVertices.New(3); diff --git a/Sources/Engine/Graphics/SDL/SDLOpenGL.cpp b/Sources/Engine/Graphics/SDL/SDLOpenGL.cpp index 574bc9e..4bf398f 100644 --- a/Sources/Engine/Graphics/SDL/SDLOpenGL.cpp +++ b/Sources/Engine/Graphics/SDL/SDLOpenGL.cpp @@ -89,13 +89,16 @@ void *CGfxLibrary::OGL_GetProcAddress(const char *procname) // prepares pixel format for OpenGL context BOOL CGfxLibrary::SetupPixelFormat_OGL( HDC hdc, BOOL bReport/*=FALSE*/) { - SDL_Window *window = (SDL_Window *) hdc; + //SDL_Window *window = (SDL_Window *) hdc; const DisplayDepth dd = gl_dmCurrentDisplayMode.dm_ddDepth; // clamp depth/stencil values extern INDEX gap_iDepthBits; extern INDEX gap_iStencilBits; - if( gap_iDepthBits <12) gap_iDepthBits = 0; + if( gap_iDepthBits <12) { + ASSERT(gap_iDepthBits >= 12 && "Using gap_iDepthBits=0, that's probably bad?!"); + gap_iDepthBits = 0; + } else if( gap_iDepthBits <22) gap_iDepthBits = 16; else if( gap_iDepthBits <28) gap_iDepthBits = 24; else gap_iDepthBits = 32; diff --git a/Sources/Engine/Math/ObjectSector.cpp b/Sources/Engine/Math/ObjectSector.cpp index 9b69542..ab678fc 100644 --- a/Sources/Engine/Math/ObjectSector.cpp +++ b/Sources/Engine/Math/ObjectSector.cpp @@ -254,7 +254,7 @@ void CObjectPolygonEdge::GetVertices(CObjectVertex *&povxStart, CObjectVertex *& * Default constructor. */ CObjectSector::CObjectSector(void) : - osc_colAmbient(0), osc_colColor(0), osc_strName("") + osc_colColor(0), osc_colAmbient(0), osc_strName("") { osc_ulFlags[0] = 0; osc_ulFlags[1] = 0; diff --git a/Sources/Engine/Network/CommunicationInterface.cpp b/Sources/Engine/Network/CommunicationInterface.cpp index 6f35a92..a8f7932 100644 --- a/Sources/Engine/Network/CommunicationInterface.cpp +++ b/Sources/Engine/Network/CommunicationInterface.cpp @@ -629,7 +629,7 @@ void CCommunicationInterface::Broadcast_Update_t() { BOOL bIsAlready; BOOL bFoundEmpty; ULONG iClient; - UBYTE ubDummy=65; + //UBYTE ubDummy=65; // while there is a connection request packet in the input buffer @@ -1080,7 +1080,8 @@ void CCommunicationInterface::Client_OpenNet_t(ULONG ulServerAddress) if (cm_ciLocalClient.ci_pbReliableInputBuffer.pb_ulNumOfPackets > 0) { ppaReadPacket = cm_ciLocalClient.ci_pbReliableInputBuffer.GetFirstPacket(); // and it is a connection confirmation - if (ppaReadPacket->pa_ubReliable && UDP_PACKET_CONNECT_RESPONSE) { + // DG: replaced && with & as done everywhere else, hope this doesn't rely on being buggy. + if (ppaReadPacket->pa_ubReliable & UDP_PACKET_CONNECT_RESPONSE) { // the client has succedeed to connect, so read the uwID from the packet cm_ciLocalClient.ci_adrAddress.adr_ulAddress = ulServerAddress; cm_ciLocalClient.ci_adrAddress.adr_uwPort = net_iPort; diff --git a/Sources/Engine/Network/Network.cpp b/Sources/Engine/Network/Network.cpp index 2ec22f0..e6e2b43 100644 --- a/Sources/Engine/Network/Network.cpp +++ b/Sources/Engine/Network/Network.cpp @@ -676,11 +676,11 @@ void CNetworkTimerHandler::HandleTimer(void) */ CNetworkLibrary::CNetworkLibrary(void) : ga_IsServer(FALSE), // is not server + ga_srvServer(*new CServer), + ga_sesSessionState(*new CSessionState), ga_bDemoRec(FALSE), // not recording demo ga_bDemoPlay(FALSE), // not playing demo - ga_bDemoPlayFinished(FALSE), // demo not finished - ga_srvServer(*new CServer), - ga_sesSessionState(*new CSessionState) + ga_bDemoPlayFinished(FALSE) // demo not finished { ga_aplsPlayers.New(NET_MAXLOCALPLAYERS); diff --git a/Sources/Engine/Templates/BSP.cpp b/Sources/Engine/Templates/BSP.cpp index 16a2b86..17f4c60 100644 --- a/Sources/Engine/Templates/BSP.cpp +++ b/Sources/Engine/Templates/BSP.cpp @@ -416,9 +416,9 @@ template BSPNode::BSPNode(const Plane &plSplitPlane, size_t ulPlaneTag, BSPNode &bnFront, BSPNode &bnBack) : Plane(plSplitPlane) + , bn_bnlLocation(BNL_BRANCH) , bn_pbnFront(&bnFront) , bn_pbnBack(&bnBack) - , bn_bnlLocation(BNL_BRANCH) , bn_ulPlaneTag(ulPlaneTag) { } diff --git a/Sources/Engine/World/World.cpp b/Sources/Engine/World/World.cpp index 6acb704..50e35bc 100644 --- a/Sources/Engine/World/World.cpp +++ b/Sources/Engine/World/World.cpp @@ -84,12 +84,12 @@ CTextureBlending::CTextureBlending(void) * Constructor. */ CWorld::CWorld(void) - : wo_colBackground(C_lGRAY) // clear background color - , wo_pecWorldBaseClass(NULL) // worldbase class must be obtained before using the world - , wo_bPortalLinksUpToDate(FALSE) // portal-sector links must be updated + : wo_pecWorldBaseClass(NULL) // worldbase class must be obtained before using the world , wo_baBrushes(*new CBrushArchive) , wo_taTerrains(*new CTerrainArchive) + , wo_colBackground(C_lGRAY) // clear background color , wo_ulSpawnFlags(0) + , wo_bPortalLinksUpToDate(FALSE) // portal-sector links must be updated { wo_baBrushes.ba_pwoWorld = this; wo_taTerrains.ta_pwoWorld = this; diff --git a/Sources/EntitiesMP/AirElemental.es b/Sources/EntitiesMP/AirElemental.es index d3c66e2..7817f02 100755 --- a/Sources/EntitiesMP/AirElemental.es +++ b/Sources/EntitiesMP/AirElemental.es @@ -273,7 +273,7 @@ functions: // triggers if (fHealth<=fOldHealth && fHealth>fNewHealth) { - if (&*penTrigger[i]) { + if (penTrigger[i].ep_pen != NULL) { SendToTarget(&*penTrigger[i], EET_TRIGGER, FixupCausedToPlayer(this, m_penEnemy)); } } diff --git a/Sources/EntitiesMP/Elemental.es b/Sources/EntitiesMP/Elemental.es index 13fc6f7..6083641 100644 --- a/Sources/EntitiesMP/Elemental.es +++ b/Sources/EntitiesMP/Elemental.es @@ -469,6 +469,7 @@ functions: default: iAnim = ELEMENTALLAVA_ANIM_WOUND03; break; } } else { + iAnim=0; // DG: not sure this makes sense, but at least it has a deterministic value /* switch (IRnd()%3) { case 0: iAnim = STONEMAN_ANIM_WOUND01; break; case 1: iAnim = STONEMAN_ANIM_WOUND02; break; @@ -538,6 +539,7 @@ functions: if (m_EetType == ELT_LAVA) { iAnim = ELEMENTALLAVA_ANIM_DEATH03; } else { + iAnim = 0; // DG: set to deterministic value // iAnim = STONEMAN_ANIM_DEATH03; } StartModelAnim(iAnim, 0); @@ -1265,6 +1267,7 @@ procedures: if (m_EetType == ELT_LAVA) { iAnim = ELEMENTALLAVA_ANIM_MELTUP; } else { + iAnim = 0; // DG: initialize to deterministic value // iAnim = STONEMAN_ANIM_MORPHPLANEUP; } StartModelAnim(iAnim, 0); diff --git a/Sources/EntitiesMP/Projectile.es b/Sources/EntitiesMP/Projectile.es index f68ca19..6fb502a 100755 --- a/Sources/EntitiesMP/Projectile.es +++ b/Sources/EntitiesMP/Projectile.es @@ -3531,7 +3531,7 @@ procedures: // ignore twister bHit &= !IsOfClass(epass.penOther, "Twister"); if (epass.penOther!=m_penLauncher) { - bHit = bHit ; + // bHit = bHit ; // FIXME: DG: what was this supposed to achieve? } if (bHit) { ProjectileTouch(epass.penOther); diff --git a/Sources/EntitiesMP/Summoner.es b/Sources/EntitiesMP/Summoner.es index c424631..1c5469c 100755 --- a/Sources/EntitiesMP/Summoner.es +++ b/Sources/EntitiesMP/Summoner.es @@ -619,6 +619,7 @@ functions: iCount = IRnd()%m_iGroup03Count+1; } else { ASSERT("Invalid group!"); + iCount = 0; // DG: this should have a deterministic value in case this happens after all! } ASSERT(iCount>0); diff --git a/Sources/GameMP/Map.cpp b/Sources/GameMP/Map.cpp index 62f45b2..dee6069 100644 --- a/Sources/GameMP/Map.cpp +++ b/Sources/GameMP/Map.cpp @@ -687,6 +687,12 @@ void RenderMap( CDrawPort *pdp, ULONG ulLevelMask, CProgressHookInfo *pphi) colText = 0xc87832ff; } } + else // DG: make sure iPosX/Y is initialized + { + // no idea if 0 makes sense, but at least it's deterministic + iPosX = 0; + iPosY = 0; + } PIX pixhtcx = (PIX) (pixC1S+iPosX*fStretch); PIX pixhtcy = (PIX) (pixR1S+iPosY*fStretch); From 72edf1c7205bab097bf6298232167c82b5f386bf Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sun, 24 Apr 2016 01:01:37 +0200 Subject: [PATCH 13/34] Commented out unused functions and variables many unused functions and variables are now commented out You'll still get tons of warnings, which should mostly fall in one of the following categories: 1. Unnecessary variables or values generated from .es scripts 2. Pointers assigned to from functions with side-effects: DO NOT REMOVE! Like CEntity *penNew = CreateEntity_t(...); - even if penNew isn't used, CreateEntity() must be called there! --- Sources/CMakeLists.txt | 5 +- Sources/Engine/Base/Anim.cpp | 4 +- Sources/Engine/Base/Shell.cpp | 2 +- Sources/Engine/Base/Stream.cpp | 2 +- Sources/Engine/Base/Timer.cpp | 15 +-- Sources/Engine/Brushes/BrushPolygon.cpp | 2 +- Sources/Engine/Brushes/BrushShadows.cpp | 2 +- Sources/Engine/Brushes/BrushTriangularize.cpp | 4 +- Sources/Engine/Engine.cpp | 7 +- Sources/Engine/Entities/Entity.cpp | 6 +- Sources/Engine/Entities/EntityCopying.cpp | 6 +- Sources/Engine/Entities/EntityProperties.cpp | 4 +- Sources/Engine/Graphics/Adapter.cpp | 5 +- Sources/Engine/Graphics/Benchmark.cpp | 2 +- Sources/Engine/Graphics/Fog.cpp | 4 +- Sources/Engine/Graphics/GfxLibrary.cpp | 14 ++- .../Engine/Graphics/Gfx_OpenGL_Textures.cpp | 2 +- Sources/Engine/Graphics/Gfx_wrapper.cpp | 4 +- Sources/Engine/Graphics/Graphics.cpp | 2 +- Sources/Engine/Graphics/ImageInfo.cpp | 4 + Sources/Engine/Graphics/Texture.cpp | 1 + Sources/Engine/Graphics/TextureEffects.cpp | 2 +- Sources/Engine/Light/LayerMaker.cpp | 16 +-- Sources/Engine/Light/LayerMixer.cpp | 18 +-- Sources/Engine/Math/ObjectSector.cpp | 14 ++- Sources/Engine/Math/TextureMapping.cpp | 8 +- Sources/Engine/Models/Model.cpp | 2 +- Sources/Engine/Models/RenderModel_Mask.cpp | 2 +- Sources/Engine/Models/RenderModel_View.cpp | 4 +- Sources/Engine/Models/VertexGetting.cpp | 12 +- Sources/Engine/Network/ActionBuffer.cpp | 2 +- Sources/Engine/Network/ClientInterface.cpp | 4 +- Sources/Engine/Network/Diff.cpp | 12 +- Sources/Engine/Network/Server.cpp | 6 +- Sources/Engine/Rendering/RenCache.cpp | 10 +- Sources/Engine/Rendering/RendASER.cpp | 2 +- Sources/Engine/Rendering/Render.cpp | 14 +-- Sources/Engine/Rendering/RenderBrushes.cpp | 8 +- Sources/Engine/Ska/RMRender.cpp | 8 +- Sources/Engine/Sound/SoundLibrary.cpp | 11 +- Sources/Engine/Sound/SoundObject.cpp | 2 + Sources/Engine/Templates/BSP.cpp | 3 - Sources/Engine/Templates/Stock.cpp | 2 +- Sources/Engine/Terrain/Terrain.cpp | 16 +-- Sources/Engine/Terrain/TerrainEditing.cpp | 8 +- Sources/Engine/Terrain/TerrainMisc.cpp | 17 +-- Sources/Engine/Terrain/TerrainRender.cpp | 6 +- Sources/Engine/Terrain/TerrainTile.cpp | 6 +- Sources/Engine/World/World.cpp | 2 + .../EntitiesMP/Common/EmanatingParticles.cpp | 2 +- Sources/EntitiesMP/Common/HUD.cpp | 11 +- Sources/EntitiesMP/Common/Particles.cpp | 104 +++++++++--------- Sources/GameMP/CompModels.cpp | 2 +- Sources/GameMP/Computer.cpp | 14 +-- Sources/GameMP/Game.cpp | 6 +- Sources/GameMP/Map.cpp | 5 +- Sources/SeriousSam/GLSettings.cpp | 2 +- Sources/SeriousSam/Menu.cpp | 24 ++-- Sources/SeriousSam/MenuGadgets.cpp | 14 +-- Sources/Shaders/ColorShader.cpp | 2 +- Sources/Shaders/Common.cpp | 4 +- 61 files changed, 265 insertions(+), 239 deletions(-) diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 65d1e03..e40679a 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -114,8 +114,9 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") add_compile_options(-Wno-switch) add_compile_options(-Wno-char-subscripts) add_compile_options(-Wno-unknown-pragmas) - add_compile_options(-Wno-unused-variable) - add_compile_options(-Wno-unused-value) + add_compile_options(-Wno-unused-variable) # TODO: maybe only enable this for Entities + add_compile_options(-Wno-unused-value) # same here (the Scripts generate tons of unused variables and values) + add_compile_options(-Wno-missing-braces) add_compile_options(-Wno-parentheses) MESSAGE(WARNING, "re-enable some of the warnings some day!") diff --git a/Sources/Engine/Base/Anim.cpp b/Sources/Engine/Base/Anim.cpp index b42ce79..d686832 100644 --- a/Sources/Engine/Base/Anim.cpp +++ b/Sources/Engine/Base/Anim.cpp @@ -904,14 +904,14 @@ void CAnimObject::PlayAnim(INDEX iNew, ULONG ulFlags) class COneAnim *pCOA = &ao_AnimData->ad_Anims[ao_iCurrentAnim]; TIME tmNow = _pTimer->CurrentTick(); TIME tmLength = GetCurrentAnimLength(); - FLOAT fFrame = ((_pTimer->CurrentTick() - ao_tmAnimStart)/pCOA->oa_SecsPerFrame); + FLOAT fFrame = ((tmNow - ao_tmAnimStart)/pCOA->oa_SecsPerFrame); INDEX iFrame = INDEX(fFrame); FLOAT fFract = fFrame-iFrame; iFrame = ClipFrame(iFrame); TIME tmPassed = (iFrame+fFract)*pCOA->oa_SecsPerFrame; TIME tmLeft = tmLength-tmPassed; // set time ahead to end of the current animation - ao_tmAnimStart = _pTimer->CurrentTick()+tmLeft; + ao_tmAnimStart = tmNow+tmLeft; // remember last animation ao_iLastAnim = ao_iCurrentAnim; // set new animation number diff --git a/Sources/Engine/Base/Shell.cpp b/Sources/Engine/Base/Shell.cpp index bbdcb30..2611528 100644 --- a/Sources/Engine/Base/Shell.cpp +++ b/Sources/Engine/Base/Shell.cpp @@ -110,7 +110,7 @@ CDynamicStackArray _shell_astrTempStrings; CDynamicStackArray _shell_astrExtStrings; CDynamicStackArray _shell_afExtFloats; -static const char *strCommandLine = ""; +//static const char *strCommandLine = ""; FLOAT tmp_af[10] = { 0 }; INDEX tmp_ai[10] = { 0 }; diff --git a/Sources/Engine/Base/Stream.cpp b/Sources/Engine/Base/Stream.cpp index d1ead10..5e79967 100755 --- a/Sources/Engine/Base/Stream.cpp +++ b/Sources/Engine/Base/Stream.cpp @@ -1433,7 +1433,7 @@ static INDEX ExpandFilePath_read(ULONG ulType, const CTFileName &fnmFile, CTFile { // search for the file in zips INDEX iFileInZip = UNZIPGetFileIndex(fnmFile); - const BOOL userdir_not_basedir = (_fnmUserDir != _fnmApplicationPath); + //const BOOL userdir_not_basedir = (_fnmUserDir != _fnmApplicationPath); // if a mod is active if (_fnmMod!="") { diff --git a/Sources/Engine/Base/Timer.cpp b/Sources/Engine/Base/Timer.cpp index 8c02846..b82043b 100755 --- a/Sources/Engine/Base/Timer.cpp +++ b/Sources/Engine/Base/Timer.cpp @@ -161,8 +161,8 @@ void CTimer_TimerFunc_internal(void) CTimerValue tvTimeNow = _pTimer->GetHighPrecisionTimer(); TIME tmTickNow = _pTimer->tm_RealTimeTimer; // calculate how long has passed since we have last been on time - TIME tmTimeDelay = (TIME)(tvTimeNow - _pTimer->tm_tvLastTimeOnTime).GetSeconds(); - TIME tmTickDelay = (tmTickNow - _pTimer->tm_tmLastTickOnTime); + //TIME tmTimeDelay = (TIME)(tvTimeNow - _pTimer->tm_tvLastTimeOnTime).GetSeconds(); + //TIME tmTickDelay = (tmTickNow - _pTimer->tm_tmLastTickOnTime); _sfStats.StartTimer(CStatForm::STI_TIMER); // if we are keeping up to time (more or less) @@ -209,13 +209,14 @@ Uint32 CTimer_TimerFunc_SDL(Uint32 interval, void* param) #pragma inline_depth() + +#ifdef PLATFORM_WIN32 // DG: not used on other platforms #define MAX_MEASURE_TRIES 5 static INDEX _aiTries[MAX_MEASURE_TRIES]; // Get processor speed in Hertz static __int64 GetCPUSpeedHz(void) { -#ifdef PLATFORM_WIN32 // get the frequency of the 'high' precision timer __int64 llTimerFrequency; BOOL bPerformanceCounterPresent = QueryPerformanceFrequency((LARGE_INTEGER*)&llTimerFrequency); @@ -296,14 +297,8 @@ static __int64 GetCPUSpeedHz(void) // use measured value return (__int64)slSpeedRead*1000000; } -#else - - STUBBED("I hope this isn't critical..."); - return(1); - -#endif - } +#endif // PLATFORM_WIN32 #if PLATFORM_MACOSX diff --git a/Sources/Engine/Brushes/BrushPolygon.cpp b/Sources/Engine/Brushes/BrushPolygon.cpp index 42f4a4b..b5a4342 100644 --- a/Sources/Engine/Brushes/BrushPolygon.cpp +++ b/Sources/Engine/Brushes/BrushPolygon.cpp @@ -509,7 +509,7 @@ CBrushPolygon &CBrushPolygon::CopyPolygon(CBrushPolygon &bp) bpo_boxBoundingBox=bp.bpo_boxBoundingBox; bpo_pbscSector=bp.bpo_pbscSector; bpo_rsOtherSideSectors.Clear(); - bpo_lhShadingInfos; + //bpo_lhShadingInfos; // FIXME: DG: was this missing "= bp.bpo_lhShadingInfos" or something like that? bpo_iInWorld=bp.bpo_iInWorld; return *this; } diff --git a/Sources/Engine/Brushes/BrushShadows.cpp b/Sources/Engine/Brushes/BrushShadows.cpp index d2949e0..d0d832f 100644 --- a/Sources/Engine/Brushes/BrushShadows.cpp +++ b/Sources/Engine/Brushes/BrushShadows.cpp @@ -605,7 +605,7 @@ BOOL CBrushShadowMap::IsShadowFlat( COLOR &colFlat) COLOR col; UBYTE ubR,ubG,ubB, ubR1,ubG1,ubB1; SLONG slR=0,slG=0,slB=0; - INDEX ctPointLights=0; + //INDEX ctPointLights=0; CBrushPolygon *pbpo = GetBrushPolygon(); // if the shadowmap is not using the shading mode diff --git a/Sources/Engine/Brushes/BrushTriangularize.cpp b/Sources/Engine/Brushes/BrushTriangularize.cpp index 0e175f9..51d16ad 100644 --- a/Sources/Engine/Brushes/BrushTriangularize.cpp +++ b/Sources/Engine/Brushes/BrushTriangularize.cpp @@ -480,7 +480,7 @@ void CTriangularizer::FindExistingTriangleEdges(void) // for each edge FOREACHINDYNAMICARRAY(tr_abedEdges, CBrushEdge, itbed) { - CBrushEdge *pbed = itbed; + //CBrushEdge *pbed = itbed; // if it is the bottom edge of the triangle if (tr_pbedBottom == itbed) { @@ -517,7 +517,7 @@ BOOL CTriangularizer::CheckTriangleAgainstEdges(void) { // for each edge FOREACHINDYNAMICARRAY(tr_abedEdges, CBrushEdge, itbed) { - CBrushEdge *pbed = itbed; + //CBrushEdge *pbed = itbed; // if it is the bottom edge of the triangle if (tr_pbedBottom == itbed) { diff --git a/Sources/Engine/Engine.cpp b/Sources/Engine/Engine.cpp index 452d281..2ce0f69 100644 --- a/Sources/Engine/Engine.cpp +++ b/Sources/Engine/Engine.cpp @@ -67,7 +67,9 @@ CTCriticalSection zip_csLock; // critical section for access to zlib functions // to keep system gamma table +#ifdef PLATFORM_WIN32 // DG: other platforms don't (currently?) use this static UWORD auwSystemGamma[256*3]; +#endif // OS info @@ -818,7 +820,7 @@ ENGINE_API void SE_UpdateWindowHandle( HWND hwndMain) _bFullScreen = _pGfx!=NULL && (_pGfx->gl_ulFlags&GLF_FULLSCREEN); } - +#ifdef PLATFORM_WIN32 static BOOL TouchBlock(UBYTE *pubMemoryBlock, INDEX ctBlockSize) { #if (defined __MSC_VER) @@ -856,12 +858,13 @@ touchLoop: // !!! More importantly, will this help if the system is paging to disk // !!! like mad anyhow? Leaving this as a no-op for most systems seems safe // !!! to me. --ryan. + // DG: put this into #ifdef PLATFORM_WIN32 because otherwise the function is not called anyway #endif return TRUE; } - +#endif // PLATFORM_WIN32 // pretouch all memory commited by process BOOL _bNeedPretouch = FALSE; diff --git a/Sources/Engine/Entities/Entity.cpp b/Sources/Engine/Entities/Entity.cpp index fb9a337..c88789b 100644 --- a/Sources/Engine/Entities/Entity.cpp +++ b/Sources/Engine/Entities/Entity.cpp @@ -481,7 +481,7 @@ void CEntity::GetCollisionBoxParameters(INDEX iBox, FLOATaabbox3D &box, INDEX &i if(en_RenderType==RT_SKAMODEL || en_RenderType==RT_SKAEDITORMODEL) { box.minvect = GetModelInstance()->GetCollisionBoxMin(iBox); box.maxvect = GetModelInstance()->GetCollisionBoxMax(iBox); - FLOATaabbox3D boxNS = box; + //FLOATaabbox3D boxNS = box; box.StretchByVector(GetModelInstance()->mi_vStretch); iEquality = GetModelInstance()->GetCollisionBoxDimensionEquality(iBox); } else { @@ -1833,7 +1833,7 @@ void CEntity::FindSectorsAroundEntity(void) // for each brush in the world FOREACHINDYNAMICARRAY(en_pwoWorld->wo_baBrushes.ba_abrBrushes, CBrush3D, itbr) { - CBrush3D &br=*itbr; + //CBrush3D &br=*itbr; // if the brush entity is not zoning if (itbr->br_penEntity==NULL || !(itbr->br_penEntity->en_ulFlags&ENF_ZONING)) { // skip it @@ -3146,7 +3146,7 @@ void CEntity::InflictBoxDamage(CEntity *penInflictor, enum DamageType dmtType, if (en.en_pciCollisionInfo==NULL) { continue; } - CCollisionInfo *pci = en.en_pciCollisionInfo; + //CCollisionInfo *pci = en.en_pciCollisionInfo; // if entity is not allowed to execute now if (!en.IsAllowedForPrediction()) { // do nothing diff --git a/Sources/Engine/Entities/EntityCopying.cpp b/Sources/Engine/Entities/EntityCopying.cpp index 071fd3f..1c3734f 100644 --- a/Sources/Engine/Entities/EntityCopying.cpp +++ b/Sources/Engine/Entities/EntityCopying.cpp @@ -452,7 +452,7 @@ void CWorld::CopyEntities(CWorld &woOther, CDynamicContainer &cenToCopy // for each of the created entities {FOREACHINSTATICARRAY(_aprRemaps, CPointerRemapping, itpr) { - CEntity *penOriginal = itpr->pr_penOriginal; + //CEntity *penOriginal = itpr->pr_penOriginal; CEntity *penCopy = itpr->pr_penCopy; if (_bReinitEntitiesWhileCopying) { // init the new copy @@ -469,7 +469,7 @@ void CWorld::CopyEntities(CWorld &woOther, CDynamicContainer &cenToCopy // for each of the created entities {FOREACHINSTATICARRAY(_aprRemaps, CPointerRemapping, itpr) { - CEntity *penOriginal = itpr->pr_penOriginal; + //CEntity *penOriginal = itpr->pr_penOriginal; CEntity *penCopy = itpr->pr_penCopy; // if this is a brush @@ -718,7 +718,7 @@ void CWorld::CopyEntitiesToPredictors(CDynamicContainer &cenToCopy) // for each of the created entities {FOREACHINSTATICARRAY(_aprRemaps, CPointerRemapping, itpr) { - CEntity *penOriginal = itpr->pr_penOriginal; + //CEntity *penOriginal = itpr->pr_penOriginal; CEntity *penCopy = itpr->pr_penCopy; // if this is a brush diff --git a/Sources/Engine/Entities/EntityProperties.cpp b/Sources/Engine/Entities/EntityProperties.cpp index 5fd407b..5f736e9 100644 --- a/Sources/Engine/Entities/EntityProperties.cpp +++ b/Sources/Engine/Entities/EntityProperties.cpp @@ -96,7 +96,7 @@ void CEntity::WriteEntityPointer_t(CTStream *ostrm, CEntityPointer pen) void CEntity::ReadProperties_t(CTStream &istrm) // throw char * { istrm.ExpectID_t("PRPS"); // 'properties' - CDLLEntityClass *pdecDLLClass = en_pecClass->ec_pdecDLLClass; + //CDLLEntityClass *pdecDLLClass = en_pecClass->ec_pdecDLLClass; INDEX ctProperties; // read number of properties (note that this doesn't have to be same as number // of properties in the class (class might have changed)) @@ -104,7 +104,7 @@ void CEntity::ReadProperties_t(CTStream &istrm) // throw char * // for all saved properties for(INDEX iProperty=0; iPropertydec_ctProperties; + //pdecDLLClass->dec_ctProperties; // read packed identifier ULONG ulIDAndType; istrm>>ulIDAndType; diff --git a/Sources/Engine/Graphics/Adapter.cpp b/Sources/Engine/Graphics/Adapter.cpp index 09880ef..32e23d1 100644 --- a/Sources/Engine/Graphics/Adapter.cpp +++ b/Sources/Engine/Graphics/Adapter.cpp @@ -34,6 +34,7 @@ extern const D3DDEVTYPE d3dDevType; // list of all modes avaliable through CDS static CListHead _lhCDSModes; +#ifdef PLATFORM_WIN32 // DG: all this code is (currently?) only used for windows. class CResolution { public: PIX re_pixSizeI; @@ -74,8 +75,6 @@ static CResolution _areResolutions[] = static const INDEX MAX_RESOLUTIONS = sizeof(_areResolutions)/sizeof(_areResolutions[0]); -#ifdef PLATFORM_WIN32 - // initialize CDS support (enumerate modes at startup) void CGfxLibrary::InitAPIs(void) { @@ -240,7 +239,7 @@ void CGfxLibrary::InitAPIs(void) // fill OpenGL adapter info CDisplayAdapter *pda; - INDEX iResolution; + //INDEX iResolution; gl_gaAPI[GAT_OGL].ga_ctAdapters = 1; gl_gaAPI[GAT_OGL].ga_iCurrentAdapter = 0; diff --git a/Sources/Engine/Graphics/Benchmark.cpp b/Sources/Engine/Graphics/Benchmark.cpp index 17ea71b..dd5df5e 100644 --- a/Sources/Engine/Graphics/Benchmark.cpp +++ b/Sources/Engine/Graphics/Benchmark.cpp @@ -33,7 +33,7 @@ static PIX _pixSizeI; static PIX _pixSizeJ; static CTimerValue _tv; static BOOL _bBlend = FALSE; -static BOOL _bVisible = FALSE; +//static BOOL _bVisible = FALSE; static BOOL _bTexture = FALSE; static BOOL _bDepth = FALSE; static BOOL _bMultiTexture = FALSE; diff --git a/Sources/Engine/Graphics/Fog.cpp b/Sources/Engine/Graphics/Fog.cpp index 33eb1bc..531c842 100644 --- a/Sources/Engine/Graphics/Fog.cpp +++ b/Sources/Engine/Graphics/Fog.cpp @@ -274,7 +274,7 @@ void StartFog( CFogParameters &fp, const FLOAT3D &vViewPosAbs, const FLOATmatrix // exp fog case AT_EXP: { // calculate linear step for the fog parameter - FLOAT fT = 0.0f; + //FLOAT fT = 0.0f; FLOAT fTStep = 1.0f/pixSizeL*fFar*fDensity*fA; // fog is exp(-t) function of fog parameter, now calculate // step (actually multiplication) for the fog @@ -287,7 +287,7 @@ void StartFog( CFogParameters &fp, const FLOAT3D &vViewPosAbs, const FLOATmatrix } break; case AT_EXP2: { // calculate linear step for the fog parameter - FLOAT fT = 0.0f; + //FLOAT fT = 0.0f; FLOAT fTStep = 1.0f/pixSizeL*fFar*fDensity*fA; // fog is exp(-t^2) function of fog parameter, now calculate // first and second order step (actually multiplication) for the fog diff --git a/Sources/Engine/Graphics/GfxLibrary.cpp b/Sources/Engine/Graphics/GfxLibrary.cpp index 4d8b657..9c03272 100644 --- a/Sources/Engine/Graphics/GfxLibrary.cpp +++ b/Sources/Engine/Graphics/GfxLibrary.cpp @@ -91,7 +91,9 @@ extern BOOL CVA_bModels; static FLOAT _fLastBrightness, _fLastContrast, _fLastGamma; static FLOAT _fLastBiasR, _fLastBiasG, _fLastBiasB; static INDEX _iLastLevels; +#ifdef PLATFORM_WIN32 // DG: not used on other platforms static UWORD _auwGammaTable[256*3]; +#endif // table for clipping [-512..+1024] to [0..255] static UBYTE aubClipByte[256*2+ 256 +256*3]; @@ -1213,6 +1215,7 @@ void CGfxLibrary::Init(void) // !!! FIXME : rcg11232001 Scripts/CustomOptions/GFX-AdvancedRendering.cfg // !!! FIXME : rcg11232001 references non-existing cvars, so I'm adding // !!! FIXME : rcg11232001 them here for now. + // FXME: DG: so why are they commented out? // _pShell->DeclareSymbol("persistent user INDEX mdl_bRenderBump;", (void *) &mdl_bRenderBump); // _pShell->DeclareSymbol("persistent user FLOAT ogl_fTextureAnisotropy;", (void *) &ogl_fTextureAnisotropy); _pShell->DeclareSymbol("persistent user FLOAT tex_fNormalSize;", (void *) &tex_fNormalSize); @@ -1609,11 +1612,10 @@ void CGfxLibrary::UnlockDrawPort( CDrawPort *pdpToUnlock) /* Create a new window canvas. */ void CGfxLibrary::CreateWindowCanvas(void *hWnd, CViewPort **ppvpNew, CDrawPort **ppdpNew) { - RECT rectWindow; // rectangle for the client area of the window - // get the dimensions from the window // !!! FIXME : rcg11052001 Abstract this. #ifdef PLATFORM_WIN32 + RECT rectWindow; // rectangle for the client area of the window GetClientRect( (HWND)hWnd, &rectWindow); const PIX pixWidth = rectWindow.right - rectWindow.left; const PIX pixHeight = rectWindow.bottom - rectWindow.top; @@ -1627,7 +1629,7 @@ void CGfxLibrary::CreateWindowCanvas(void *hWnd, CViewPort **ppvpNew, CDrawPort *ppvpNew = NULL; *ppdpNew = NULL; // create a new viewport - if (*ppvpNew = new CViewPort( pixWidth, pixHeight, (HWND)hWnd)) { + if((*ppvpNew = new CViewPort( pixWidth, pixHeight, (HWND)hWnd))) { // and it's drawport *ppdpNew = &(*ppvpNew)->vp_Raster.ra_MainDrawPort; } else { @@ -1802,7 +1804,9 @@ INDEX _ctProbeShdU = 0; INDEX _ctProbeShdB = 0; INDEX _ctFullShdU = 0; SLONG _slFullShdUBytes = 0; +#ifdef PLATFORM_WIN32 // only used there static BOOL GenerateGammaTable(void); +#endif @@ -2064,7 +2068,7 @@ void CGfxLibrary::UnlockRaster( CRaster *praToUnlock) } - +#ifdef PLATFORM_WIN32 // DG: only used on windows // generates gamma table and returns true if gamma table has been changed static BOOL GenerateGammaTable(void) { @@ -2140,7 +2144,7 @@ static BOOL GenerateGammaTable(void) // done return TRUE; } - +#endif // PLATFORM_WIN32 #if 0 diff --git a/Sources/Engine/Graphics/Gfx_OpenGL_Textures.cpp b/Sources/Engine/Graphics/Gfx_OpenGL_Textures.cpp index 4ad76ab..20d1f7b 100644 --- a/Sources/Engine/Graphics/Gfx_OpenGL_Textures.cpp +++ b/Sources/Engine/Graphics/Gfx_OpenGL_Textures.cpp @@ -220,7 +220,7 @@ void UploadTexture_OGL( ULONG *pulTexture, PIX pixSizeU, PIX pixSizeV, #else // Basically average every other pixel... - UWORD w = 0; + //UWORD w = 0; UBYTE *dptr = (UBYTE *) pulDst; UBYTE *sptr = (UBYTE *) pulSrc; #if 0 diff --git a/Sources/Engine/Graphics/Gfx_wrapper.cpp b/Sources/Engine/Graphics/Gfx_wrapper.cpp index 28a2dcf..b284d7d 100644 --- a/Sources/Engine/Graphics/Gfx_wrapper.cpp +++ b/Sources/Engine/Graphics/Gfx_wrapper.cpp @@ -72,7 +72,7 @@ FLOAT GFX_fLastF = 0; INDEX GFX_ctVertices = 0; // for D3D: mark need for clipping (when wants to be disable but cannot be because of user clip plane) -static BOOL _bWantsClipping = TRUE; +//static BOOL _bWantsClipping = TRUE; // current color mask (for Get... function) static ULONG _ulCurrentColorMask = (CT_RMASK|CT_GMASK|CT_BMASK|CT_AMASK); // locking state for OGL @@ -81,7 +81,7 @@ static BOOL _bCVAReallyLocked = FALSE; // clip plane and last view matrix for D3D FLOAT D3D_afClipPlane[4] = {0,0,0,0}; FLOAT D3D_afViewMatrix[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}; -static FLOAT _afActiveClipPlane[4] = {0,0,0,0}; +//static FLOAT _afActiveClipPlane[4] = {0,0,0,0}; // Truform/N-Patches INDEX truform_iLevel = -1; diff --git a/Sources/Engine/Graphics/Graphics.cpp b/Sources/Engine/Graphics/Graphics.cpp index 3d4be59..b1d6f13 100644 --- a/Sources/Engine/Graphics/Graphics.cpp +++ b/Sources/Engine/Graphics/Graphics.cpp @@ -2673,7 +2673,7 @@ void DrawTriangle_Mask( UBYTE *pubMaskPlane, SLONG slMaskWidth, SLONG slMaskHeig // find row counter and max delta J SLONG ctJShort1 = pixMdJ - pixUpJ; SLONG ctJShort2 = pixDnJ - pixMdJ; - SLONG ctJLong = pixDnJ - pixUpJ; + //SLONG ctJLong = pixDnJ - pixUpJ; FLOAT currK, curr1oK, currUoK, currVoK; PIX pixJ = pixUpJ; diff --git a/Sources/Engine/Graphics/ImageInfo.cpp b/Sources/Engine/Graphics/ImageInfo.cpp index b15d1c4..84ea7ff 100644 --- a/Sources/Engine/Graphics/ImageInfo.cpp +++ b/Sources/Engine/Graphics/ImageInfo.cpp @@ -78,6 +78,7 @@ static __forceinline CTStream &operator>>(CTStream &strm, PCXHeader &t) { return strm; } +#if 0 // DG: unused. static __forceinline CTStream &operator<<(CTStream &strm, const PCXHeader &t) { strm<>(CTStream &strm, TGAHeader &t) { return(strm); } +#if 0 // DG: unused. static __forceinline CTStream &operator<<(CTStream &strm, const TGAHeader &t) { strm<> ctEffectSources; // add requested number of members to effect source array CTextureEffectSource *pEffectSources = td_ptegEffect->teg_atesEffectSources.New( ctEffectSources); + (void)pEffectSources; // read whole dynamic array of effect sources FOREACHINDYNAMICARRAY( td_ptegEffect->teg_atesEffectSources, CTextureEffectSource, itEffectSource) diff --git a/Sources/Engine/Graphics/TextureEffects.cpp b/Sources/Engine/Graphics/TextureEffects.cpp index 91fc839..8834a3b 100644 --- a/Sources/Engine/Graphics/TextureEffects.cpp +++ b/Sources/Engine/Graphics/TextureEffects.cpp @@ -2915,9 +2915,9 @@ static void AnimateFire( SLONG slDensity) // use only one buffer (otherwise it's not working) UBYTE *pubNew = (UBYTE*)_ptdEffect->td_pubBuffer2; SLONG slBufferMask = _pixBufferWidth*_pixBufferHeight -1; - SLONG slColumnModulo = _pixBufferWidth*(_pixBufferHeight-2) -1; #if ASMOPT == 1 + SLONG slColumnModulo = _pixBufferWidth*(_pixBufferHeight-2) -1; #if (defined __MSVC_INLINE__) __asm { diff --git a/Sources/Engine/Light/LayerMaker.cpp b/Sources/Engine/Light/LayerMaker.cpp index 62b7fcd..42e12b1 100644 --- a/Sources/Engine/Light/LayerMaker.cpp +++ b/Sources/Engine/Light/LayerMaker.cpp @@ -329,8 +329,8 @@ void CLayerMaker::SpreadShadowMaskOutwards(void) PIX pixLayerMinV = lm_pixLayerMinV>>iMipmap; PIX pixLayerSizeU = lm_pixLayerSizeU>>iMipmap; PIX pixLayerSizeV = lm_pixLayerSizeV>>iMipmap; - PIX pixSizeU = lm_pixSizeU>>iMipmap; - PIX pixSizeV = lm_pixSizeV>>iMipmap; + //PIX pixSizeU = lm_pixSizeU>>iMipmap; + //PIX pixSizeV = lm_pixSizeV>>iMipmap; PIX pixSizeULog2 = FastLog2(lm_pixSizeU)-iMipmap; UBYTE *pubLayer = lm_pubLayer+lm_mmtLayer.mmt_aslOffsets[iMipmap]; UBYTE *pubPolygonMask = lm_pubPolygonMask+lm_mmtPolygonMask.mmt_aslOffsets[iMipmap]; @@ -419,8 +419,8 @@ void CLayerMaker::SpreadShadowMaskInwards(void) PIX pixLayerMinV = lm_pixLayerMinV>>iMipmap; PIX pixLayerSizeU = lm_pixLayerSizeU>>iMipmap; PIX pixLayerSizeV = lm_pixLayerSizeV>>iMipmap; - PIX pixSizeU = lm_pixSizeU>>iMipmap; - PIX pixSizeV = lm_pixSizeV>>iMipmap; + //PIX pixSizeU = lm_pixSizeU>>iMipmap; + //PIX pixSizeV = lm_pixSizeV>>iMipmap; PIX pixSizeULog2 = FastLog2(lm_pixSizeU)-iMipmap; UBYTE *pubLayer = lm_pubLayer+lm_mmtLayer.mmt_aslOffsets[iMipmap]; UBYTE *pubPolygonMask = lm_pubPolygonMask+lm_mmtPolygonMask.mmt_aslOffsets[iMipmap]; @@ -526,7 +526,7 @@ void CLayerMaker::MakePolygonMask(void) UBYTE *pub = lm_pubPolygonMask; // for each mip-map for (INDEX iMipmap=0; iMipmap>iMip; - PIX pixLayerMinV = lm_pixLayerMinV>>iMip; + //PIX pixLayerMinU = lm_pixLayerMinU>>iMip; + //PIX pixLayerMinV = lm_pixLayerMinV>>iMip; PIX pixLayerSizeU = lm_pixLayerSizeU>>iMip; PIX pixLayerSizeV = lm_pixLayerSizeV>>iMip; UBYTE *pubLayer = lm_pubLayer+lm_mmtLayer.mmt_aslOffsets[iMip]; @@ -632,7 +632,7 @@ ULONG CLayerMaker::MakeShadowMask(CBrushShadowLayer *pbsl) // allocate shadow mask for the light (+8 is safety wall for fast conversions) lm_pubLayer = (UBYTE *)AllocMemory(lm_mmtLayer.mmt_slTotalSize+8); - const FLOAT fEpsilon = (1<>=1; @@ -476,7 +478,7 @@ void CLayerMixer::AddAmbientMaskPoint( UBYTE *pubMask, UBYTE ubMask) // prepare some local variables mmDDL2oDU_addAmbientMaskPoint = _slDDL2oDU; mmDDL2oDV_addAmbientMaskPoint = _slDDL2oDV; - ULONG ulLightRGB = ByteSwap(lm_colLight); + ULONG ulLightRGB = ByteSwap(lm_colLight); // FIXME: shouldn't this be used in plain C impl too? _slLightMax<<=7; _slLightStep>>=1; @@ -654,7 +656,7 @@ skipPixel: for( PIX pixU=0; pixU<_iPixCt; pixU++) { // if the point is not masked - if( *pubMask & ubMask && (slL2Point>SHIFTX)&(SQRTTABLESIZE-1); // and is just for degenerate cases SLONG slIntensity = _slLightMax; slL = aubSqrt[slL]; @@ -699,7 +701,7 @@ void CLayerMixer::AddDiffusionPoint(void) // prepare some local variables mmDDL2oDU_AddDiffusionPoint = _slDDL2oDU; mmDDL2oDV_AddDiffusionPoint = _slDDL2oDV; - ULONG ulLightRGB = ByteSwap(lm_colLight); + ULONG ulLightRGB = ByteSwap(lm_colLight); // FIXME: shouldn't this be used in plain C impl too? _slLightMax<<=7; _slLightStep>>=1; @@ -900,7 +902,7 @@ void CLayerMixer::AddDiffusionMaskPoint( UBYTE *pubMask, UBYTE ubMask) // prepare some local variables mmDDL2oDU_AddDiffusionMaskPoint = _slDDL2oDU; mmDDL2oDV_AddDiffusionMaskPoint = _slDDL2oDV; - ULONG ulLightRGB = ByteSwap(lm_colLight); + ULONG ulLightRGB = ByteSwap(lm_colLight); // FIXME: shouldn't this be used in plain C impl too? _slLightMax<<=7; _slLightStep>>=1; @@ -1076,7 +1078,7 @@ skipPixel: for( PIX pixU=0; pixU<_iPixCt; pixU++) { // if the point is not masked - if( *pubMask&ubMask && (slL2Point>SHIFTX)&(SQRTTABLESIZE-1); // and is just for degenerate cases sl1oL = auw1oSqrt[sl1oL]; SLONG slIntensity = _slLightMax; @@ -1709,7 +1711,7 @@ void CLayerMixer::AddOneLayerDirectional( CBrushShadowLayer *pbsl, UBYTE *pubMas // get the light source of the layer lm_plsLight = pbsl->bsl_plsLightSource; - const FLOAT3D &vLight = lm_plsLight->ls_penEntity->GetPlacement().pl_PositionVector; + //const FLOAT3D &vLight = lm_plsLight->ls_penEntity->GetPlacement().pl_PositionVector; AnglesToDirectionVector( lm_plsLight->ls_penEntity->GetPlacement().pl_OrientationAngle, lm_vLightDirection); // calculate intensity @@ -1845,7 +1847,7 @@ void CLayerMixer::MixOneMipmap(CBrushShadowMap *pbsm, INDEX iMipmap) ASSERT( &ls!=NULL); if( &ls==NULL) continue; // safety check // skip if should not be applied - if( (bDynamicOnly && !(ls.ls_ulFlags&LSF_NONPERSISTENT)) || ls.ls_ulFlags&LSF_DYNAMIC) continue; + if( (bDynamicOnly && !(ls.ls_ulFlags&LSF_NONPERSISTENT)) || (ls.ls_ulFlags & LSF_DYNAMIC)) continue; // set corresponding shadowmap flag if this is an animating light if( ls.ls_paoLightAnimation!=NULL) lm_pbsmShadowMap->sm_ulFlags |= SMF_ANIMATINGLIGHTS; diff --git a/Sources/Engine/Math/ObjectSector.cpp b/Sources/Engine/Math/ObjectSector.cpp index ab678fc..f02d59b 100644 --- a/Sources/Engine/Math/ObjectSector.cpp +++ b/Sources/Engine/Math/ObjectSector.cpp @@ -90,6 +90,7 @@ static int qsort_CompareVerticesAlongLine(const void *pvVertex0, const void *pvV CObjectVertex &vx1 = **(CObjectVertex **)pvVertex1; return CompareVerticesAlongLine(vx0, vx1); } +#if 0 // DG: unused. /* * Compare two vertices along a line for quick-sort - reversely. */ @@ -99,6 +100,7 @@ static int qsort_CompareVerticesAlongLineReversely(const void *pvVertex0, const CObjectVertex &vx1 = **(CObjectVertex **)pvVertex1; return -CompareVerticesAlongLine(vx0, vx1); } +#endif // 0 (unused) /* @@ -548,6 +550,7 @@ CObjectPolygon *CObjectSector::CreatePolygon(INDEX ctVertices, INDEX aivVertices void CObjectSector::CheckOptimizationAlgorithm(void) { // for vertices +#if 0 // DG: this doesn't really do anything?! FOREACHINDYNAMICARRAY(osc_aovxVertices, CObjectVertex, itvx1) { FOREACHINDYNAMICARRAY(osc_aovxVertices, CObjectVertex, itvx2) { CObjectVertex &vx1 = itvx1.Current(); @@ -555,6 +558,7 @@ void CObjectSector::CheckOptimizationAlgorithm(void) // !!!!why this fails sometimes ?(on spheres) ASSERT( (&vx1 == &vx2) || (CompareVertices(vx1, vx2)!=0) ); } } +#endif // 0 // for planes FOREACHINDYNAMICARRAY(osc_aoplPlanes, CObjectPlane, itpl1) { @@ -600,7 +604,7 @@ void CObjectSector::CheckOptimizationAlgorithm(void) {FOREACHINDYNAMICARRAY(osc_aopoPolygons, CObjectPolygon, itopo) { // for each edge in polygon {FOREACHINDYNAMICARRAY(itopo->opo_PolygonEdges, CObjectPolygonEdge, itope) { - CObjectEdge &oedThis = *itope->ope_Edge; + //CObjectEdge &oedThis = *itope->ope_Edge; CObjectVertex *povxStartThis, *povxEndThis; // get start and end vertices itope->GetVertices(povxStartThis, povxEndThis); @@ -629,7 +633,7 @@ BOOL CObjectSector::ArePolygonsPlanar(void) {FOREACHINDYNAMICARRAY(osc_aopoPolygons, CObjectPolygon, itopo) { // for each edge in polygon {FOREACHINDYNAMICARRAY(itopo->opo_PolygonEdges, CObjectPolygonEdge, itope) { - CObjectEdge &oedThis = *itope->ope_Edge; + //CObjectEdge &oedThis = *itope->ope_Edge; CObjectVertex *povxStartThis, *povxEndThis; // get start and end vertices itope->GetVertices(povxStartThis, povxEndThis); @@ -715,7 +719,7 @@ void CObjectSector::RemapClonedPlanes(void) /* * Remap different vertices with same coordinates to use only one of each. */ -static BOOL bBug=FALSE; +//static BOOL bBug=FALSE; void CObjectSector::RemapClonedVertices(void) { // if there are no vertices in the sector @@ -1107,7 +1111,7 @@ void CObjectPolygon::JoinContinuingEdges(CDynamicArray &oedEdges) // create an empty array for newly created edges CDynamicArray aopeNew; // set the counter of edges to current number of edges - INDEX ctEdges = opo_PolygonEdges.Count(); + //INDEX ctEdges = opo_PolygonEdges.Count(); // for each edge {FOREACHINDYNAMICARRAY(opo_PolygonEdges, CObjectPolygonEdge, itope) { @@ -1186,10 +1190,10 @@ void CObjectSector::SplitCollinearEdgesRun(CStaticArray &apedxSortedE if (iFirstInRun>iLastInRun) { return; // this should not happen, but anyway! } - CEdgeEx &edxLine = *apedxSortedEdgeLines[iFirstInRun]; // representative line of the run /* set up array of vertex pointers */ /* + CEdgeEx &edxLine = *apedxSortedEdgeLines[iFirstInRun]; // representative line of the run // for each vertex in sector INDEX ctVerticesOnLine=0; {FOREACHINDYNAMICARRAY(osc_aovxVertices, CObjectVertex, itovx) { diff --git a/Sources/Engine/Math/TextureMapping.cpp b/Sources/Engine/Math/TextureMapping.cpp index 8065bb6..81723c3 100644 --- a/Sources/Engine/Math/TextureMapping.cpp +++ b/Sources/Engine/Math/TextureMapping.cpp @@ -138,7 +138,7 @@ void CMappingDefinition::TransformMappingVectors( const CMappingVectors &mvSrc, FLOAT vot2 = +sou2*ood2; FLOAT vos2 = -tou2*ood2; mvDst.mv_vO = mvSrc.mv_vO - + mvDst.mv_vU * (md_fUOffset*uos2 + md_fVOffset*vos2) + + mvDst.mv_vU * (md_fUOffset*uos2 + md_fVOffset*vos2) // FIXME: should vos2 have been uot2 here? + mvDst.mv_vV * (md_fUOffset*vos2 + md_fVOffset*vot2); } } @@ -263,9 +263,9 @@ void CMappingDefinition::ProjectMapping(const FLOATplane3D &plOriginal, const CM mv.mv_vO = pl.DeprojectPoint (plOriginal, mvOriginal.mv_vO); mv.mv_vU = pl.DeprojectDirection(plOriginal, mvOriginal.mv_vU); mv.mv_vV = pl.DeprojectDirection(plOriginal, mvOriginal.mv_vV); - FLOAT3D vOTest = plOriginal.ProjectPoint(mv.mv_vO); - FLOAT3D vUTest = plOriginal.ProjectDirection(mv.mv_vU); - FLOAT3D vVTest = plOriginal.ProjectDirection(mv.mv_vV); + //FLOAT3D vOTest = plOriginal.ProjectPoint(mv.mv_vO); + //FLOAT3D vUTest = plOriginal.ProjectDirection(mv.mv_vU); + //FLOAT3D vVTest = plOriginal.ProjectDirection(mv.mv_vV); // make mapping on this plane CMappingVectors mvDefault; diff --git a/Sources/Engine/Models/Model.cpp b/Sources/Engine/Models/Model.cpp index 1ea0dcb..198d809 100644 --- a/Sources/Engine/Models/Model.cpp +++ b/Sources/Engine/Models/Model.cpp @@ -1068,7 +1068,7 @@ void CModelData::IndicesToPtrs() { FOREACHINSTATICARRAY(it1.Current().mp_PolygonVertices, ModelPolygonVertex, it2) { - struct ModelPolygonVertex * pMPV = &it2.Current(); + //struct ModelPolygonVertex * pMPV = &it2.Current(); // DG: this looks like a 64-bit issue but is most probably ok, as the pointers // should contain indices from PtrToIndices() j = (INDEX) (size_t) it2.Current().mpv_ptvTransformedVertex; diff --git a/Sources/Engine/Models/RenderModel_Mask.cpp b/Sources/Engine/Models/RenderModel_Mask.cpp index 4ebfff8..5460351 100644 --- a/Sources/Engine/Models/RenderModel_Mask.cpp +++ b/Sources/Engine/Models/RenderModel_Mask.cpp @@ -43,7 +43,7 @@ static FLOAT fZoomI, fZoomJ; static FLOAT fFrontClipDistance, f1oFrontClipDistance; static FLOAT fBackClipDistance, f1oBackClipDistance; static FLOAT fDepthBufferFactor; -static BOOL bBackFaced, bDoubleSided; +//static BOOL bBackFaced, bDoubleSided; static BOOL bPerspective; static BOOL b16BitCompression; static ULONG ulColorMask; diff --git a/Sources/Engine/Models/RenderModel_View.cpp b/Sources/Engine/Models/RenderModel_View.cpp index 73fb5ef..fcd5f87 100644 --- a/Sources/Engine/Models/RenderModel_View.cpp +++ b/Sources/Engine/Models/RenderModel_View.cpp @@ -475,7 +475,7 @@ static void PrepareModelMipForRendering( CModelData &md, INDEX iMip) // for each surface INDEX iSrfVx = 0; - INDEX iSrfEl = 0; + //INDEX iSrfEl = 0; {FOREACHINSTATICARRAY( mmi.mmpi_MappingSurfaces, MappingSurface, itms) { MappingSurface &ms = *itms; @@ -2286,7 +2286,7 @@ diffColLoop: // for each vertex in the surface for( INDEX iSrfVx=0; iSrfVx &avVertices, FLO _vOffset = vOffset = pmd->md_vCompressedCenter; // check if object is inverted (in mirror) - BOOL bXInverted = vStretch(1)<0; - BOOL bYInverted = vStretch(2)<0; - BOOL bZInverted = vStretch(3)<0; - BOOL bInverted = bXInverted!=bYInverted!=bZInverted; + //BOOL bXInverted = vStretch(1)<0; + //BOOL bYInverted = vStretch(2)<0; + //BOOL bZInverted = vStretch(3)<0; + //BOOL bInverted = bXInverted!=bYInverted!=bZInverted; // if dynamic stretch factor should be applied if( mo_Stretch != FLOAT3D( 1.0f, 1.0f, 1.0f)) { @@ -113,7 +113,7 @@ void CModelObject::GetModelVertices( CStaticStackArray &avVertices, FLO // get current mip model using mip factor INDEX iMipLevel = GetMipModel( fMipFactor); // get current vertices mask - ULONG ulVtxMask = (1L) << iMipLevel; + //ULONG ulVtxMask = (1L) << iMipLevel; struct ModelMipInfo *pmmiMip = &pmd->md_MipInfos[iMipLevel]; // allocate space for vertices @@ -188,7 +188,7 @@ void CModelObject::GetModelVertices( CStaticStackArray &avVertices, FLO CAttachmentModelObject *pamo = itamo; CModelData *pmd=pamo->amo_moModelObject.GetData(); ASSERT(pmd!=NULL); - if(pmd==NULL || pmd->md_Flags&(MF_FACE_FORWARD|MF_HALF_FACE_FORWARD)) continue; + if(pmd==NULL || (pmd->md_Flags & (MF_FACE_FORWARD|MF_HALF_FACE_FORWARD))) continue; FLOATmatrix3D mNew = mRotation; FLOAT3D vNew = vPosition; // get new rotation and position matrices diff --git a/Sources/Engine/Network/ActionBuffer.cpp b/Sources/Engine/Network/ActionBuffer.cpp index df5dc08..457863d 100644 --- a/Sources/Engine/Network/ActionBuffer.cpp +++ b/Sources/Engine/Network/ActionBuffer.cpp @@ -92,7 +92,7 @@ void CActionBuffer::RemoveOldest(void) { // for each buffered action FORDELETELIST(CActionEntry, ae_ln, ab_lhActions, itae) { - CActionEntry &ae = *itae; + //CActionEntry &ae = *itae; // delete only first one delete &*itae; break; diff --git a/Sources/Engine/Network/ClientInterface.cpp b/Sources/Engine/Network/ClientInterface.cpp index 6b9b5d3..c80c896 100644 --- a/Sources/Engine/Network/ClientInterface.cpp +++ b/Sources/Engine/Network/ClientInterface.cpp @@ -402,7 +402,7 @@ BOOL CClientInterface::UpdateInputBuffers(void) // if there are packets in the input buffer, process them FORDELETELIST(CPacket,pa_lnListNode,ci_pbInputBuffer.pb_lhPacketStorage,ppaPacket) { - CPacket &paPacket = *ppaPacket; + //CPacket &paPacket = *ppaPacket; // if it's an acknowledge packet, remove the acknowledged packets from the wait acknowledge buffer if (ppaPacket->pa_ubReliable & UDP_PACKET_ACKNOWLEDGE) { @@ -552,7 +552,7 @@ BOOL CClientInterface::UpdateInputBuffersBroadcast(void) // if there are packets in the input buffer, process them FORDELETELIST(CPacket,pa_lnListNode,ci_pbInputBuffer.pb_lhPacketStorage,ppaPacket) { - CPacket &paPacket = *ppaPacket; + //CPacket &paPacket = *ppaPacket; // if it's an acknowledge packet, remove the acknowledged packets from the wait acknowledge buffer if (ppaPacket->pa_ubReliable & UDP_PACKET_ACKNOWLEDGE) { diff --git a/Sources/Engine/Network/Diff.cpp b/Sources/Engine/Network/Diff.cpp index 0663286..11d3541 100644 --- a/Sources/Engine/Network/Diff.cpp +++ b/Sources/Engine/Network/Diff.cpp @@ -124,7 +124,7 @@ UBYTE *FindFirstEntity(UBYTE *pubBlock, SLONG slSize) if (*(ULONG*)pub == ENT4) { UBYTE *pubTmp = pub; pubTmp+=sizeof(ULONG); - ULONG ulID = *(ULONG*)pubTmp; + //ULONG ulID = *(ULONG*)pubTmp; pubTmp+=sizeof(ULONG); SLONG slSizeChunk = *(SLONG*)pubTmp; pubTmp+=sizeof(ULONG); @@ -221,7 +221,7 @@ void MakeDiff_t(void) void UnDiff_t(void) { // start at beginning - UBYTE *pubOld = _pubOld; + //UBYTE *pubOld = _pubOld; UBYTE *pubNew = _pubNew; SLONG slSizeOldStream = 0; SLONG slSizeOutStream = 0; @@ -314,7 +314,7 @@ void Cleanup(void) void DIFF_Diff_t(CTStream *pstrmOld, CTStream *pstrmNew, CTStream *pstrmDiff) { try { - CTimerValue tv0 = _pTimer->GetHighPrecisionTimer(); + //CTimerValue tv0 = _pTimer->GetHighPrecisionTimer(); _slSizeOld = pstrmOld->GetStreamSize()-pstrmOld->GetPos_t(); _pubOld = (UBYTE*)AllocMemory(_slSizeOld); @@ -332,7 +332,7 @@ void DIFF_Diff_t(CTStream *pstrmOld, CTStream *pstrmNew, CTStream *pstrmDiff) MakeDiff_t(); - CTimerValue tv1 = _pTimer->GetHighPrecisionTimer(); + //CTimerValue tv1 = _pTimer->GetHighPrecisionTimer(); //CPrintF("diff encoded in %.2gs\n", (tv1-tv0).GetSeconds()); Cleanup(); @@ -347,7 +347,7 @@ void DIFF_Diff_t(CTStream *pstrmOld, CTStream *pstrmNew, CTStream *pstrmDiff) void DIFF_Undiff_t(CTStream *pstrmOld, CTStream *pstrmDiff, CTStream *pstrmNew) { try { - CTimerValue tv0 = _pTimer->GetHighPrecisionTimer(); + //CTimerValue tv0 = _pTimer->GetHighPrecisionTimer(); _slSizeOld = pstrmOld->GetStreamSize()-pstrmOld->GetPos_t(); _pubOld = (UBYTE*)AllocMemory(_slSizeOld); @@ -361,7 +361,7 @@ void DIFF_Undiff_t(CTStream *pstrmOld, CTStream *pstrmDiff, CTStream *pstrmNew) UnDiff_t(); - CTimerValue tv1 = _pTimer->GetHighPrecisionTimer(); + //CTimerValue tv1 = _pTimer->GetHighPrecisionTimer(); //CPrintF("diff decoded in %.2gs\n", (tv1-tv0).GetSeconds()); Cleanup(); diff --git a/Sources/Engine/Network/Server.cpp b/Sources/Engine/Network/Server.cpp index 42206c1..4229ec0 100644 --- a/Sources/Engine/Network/Server.cpp +++ b/Sources/Engine/Network/Server.cpp @@ -728,7 +728,7 @@ void CServer::ServerLoop(void) // handle all incoming messages HandleAll(); - INDEX iSpeed = 1; + //INDEX iSpeed = 1; extern INDEX ser_bWaitFirstPlayer; // if the local session is keeping up with time and not paused BOOL bPaused = srv_bPause || _pNetwork->ga_bLocalPause || _pNetwork->IsWaitingForPlayers() || @@ -1094,8 +1094,8 @@ void CServer::SendSessionStateData(INDEX iClient) void CServer::HandleAll() { // clear last accepted client info - INDEX iClient = -1; -/* if (_cmiComm.GetLastAccepted(iClient)) { + /* INDEX iClient = -1; + if (_cmiComm.GetLastAccepted(iClient)) { CPrintF(TRANSV("Server: Accepted session connection by '%s'\n"), (const char *) _cmiComm.Server_GetClientName(iClient)); } diff --git a/Sources/Engine/Rendering/RenCache.cpp b/Sources/Engine/Rendering/RenCache.cpp index 2984034..2297b58 100644 --- a/Sources/Engine/Rendering/RenCache.cpp +++ b/Sources/Engine/Rendering/RenCache.cpp @@ -118,7 +118,7 @@ void CRenderer::PreClipPlanes(void) const FLOAT fx = wpl.wpl_plRelative(1); const FLOAT fy = wpl.wpl_plRelative(2); const FLOAT fz = wpl.wpl_plRelative(3); - const FLOAT fd = wpl.wpl_plRelative.Distance(); + //const FLOAT fd = wpl.wpl_plRelative.Distance(); wpl.wpl_plView(1) = fx*m(1, 1)+fy*m(1, 2)+fz*m(1, 3); wpl.wpl_plView(2) = fx*m(2, 1)+fy*m(2, 2)+fz*m(2, 3); wpl.wpl_plView(3) = fx*m(3, 1)+fy*m(3, 2)+fz*m(3, 3); @@ -179,8 +179,8 @@ void CRenderer::PreClipPlanes(void) void CRenderer::PostClipVertices(void) { _pfRenderProfile.StartTimer(CRenderProfile::PTI_PROJECTVERTICES); - const FLOATmatrix3D &m = re_pbrCurrent->br_prProjection->pr_RotationMatrix; - const FLOAT3D &v = re_pbrCurrent->br_prProjection->pr_TranslationVector; + //const FLOATmatrix3D &m = re_pbrCurrent->br_prProjection->pr_RotationMatrix; + //const FLOAT3D &v = re_pbrCurrent->br_prProjection->pr_TranslationVector; // if the projection is perspective if (re_pbrCurrent->br_prProjection.IsPerspective()) { @@ -749,7 +749,7 @@ CScreenPolygon *CRenderer::MakeScreenPolygon(CBrushPolygon &bpo) sppo.spo_aubTextureFlags[0] = STXF_BLEND_ALPHA; } // get its mapping gradients from shadowmap and stretch - CWorkingPlane &wpl = *bpo.bpo_pbplPlane->bpl_pwplWorking; + //CWorkingPlane &wpl = *bpo.bpo_pbplPlane->bpl_pwplWorking; sppo.spo_amvMapping[0] = sppo.spo_amvMapping[3]; FLOAT fStretch = bpo.bpo_boxBoundingBox.Size().Length()/1000; sppo.spo_amvMapping[0].mv_vU *= fStretch; @@ -870,7 +870,7 @@ void CRenderer::AddSpansToScene(void) return; } - FLOAT fpixLastScanJOffseted = re_pixCurrentScanJ-1 +OFFSET_DN; + //FLOAT fpixLastScanJOffseted = re_pixCurrentScanJ-1 +OFFSET_DN; // first, little safety check - quit if zero spans in line! INDEX ctSpans = re_aspSpans.Count(); if( ctSpans==0) { diff --git a/Sources/Engine/Rendering/RendASER.cpp b/Sources/Engine/Rendering/RendASER.cpp index e5d52b0..5a642cd 100644 --- a/Sources/Engine/Rendering/RendASER.cpp +++ b/Sources/Engine/Rendering/RendASER.cpp @@ -810,7 +810,7 @@ void CRenderer::ScanEdges(void) CopyActiveCoordinates(); // if scan-line is not coherent with the last one - } else/**/ { + } else*/ { // scan list of active edges into spans pspoPortal = ScanOneLine(); diff --git a/Sources/Engine/Rendering/Render.cpp b/Sources/Engine/Rendering/Render.cpp index a29f723..62c1450 100644 --- a/Sources/Engine/Rendering/Render.cpp +++ b/Sources/Engine/Rendering/Render.cpp @@ -512,20 +512,20 @@ void CRenderer::RenderWireFrameTerrains(void) papr = &re_prProjection; BOOL bShowEdges = _wrpWorldRenderPrefs.wrp_ftEdges != CWorldRenderPrefs::FT_NONE; - BOOL bShowVertices = _wrpWorldRenderPrefs.wrp_ftVertices != CWorldRenderPrefs::FT_NONE; + //BOOL bShowVertices = _wrpWorldRenderPrefs.wrp_ftVertices != CWorldRenderPrefs::FT_NONE; // BOOL bForceRegenerate = _wrpWorldRenderPrefs.wrp_ftPolygons COLOR colEdges = _wrpWorldRenderPrefs.wrp_colEdges; - COLOR colVertices = 0xFF0000FF; + //COLOR colVertices = 0xFF0000FF; // for all active terrains {FORDELETELIST(CTerrain, tr_lnInActiveTerrains, re_lhActiveTerrains, ittr) { // render terrain if(bShowEdges) { ittr->RenderWireFrame(*papr, re_pdpDrawPort,colEdges); } - if(bShowVertices) { + /*if(bShowVertices) { //ittr->RenderVertices(*papr, re_pdpDrawPort,colVertices); - } + }*/ }} } // draw the prepared things to screen @@ -564,7 +564,7 @@ void CRenderer::DrawToScreen(void) &&_wrpWorldRenderPrefs.wrp_ftPolygons != CWorldRenderPrefs::FT_NONE) { // render translucent portals _pfRenderProfile.StartTimer(CRenderProfile::PTI_RENDERSCENE); - CPerspectiveProjection3D *pprPerspective = (CPerspectiveProjection3D*)(CProjection3D*)(re_prBackgroundProjection); + //CPerspectiveProjection3D *pprPerspective = (CPerspectiveProjection3D*)(CProjection3D*)(re_prBackgroundProjection); RenderScene( re_pdpDrawPort, SortTranslucentPolygons(re_pspoFirstBackgroundTranslucent), re_prBackgroundProjection, re_colSelection, TRUE); _pfRenderProfile.StopTimer(CRenderProfile::PTI_RENDERSCENE); @@ -583,7 +583,7 @@ void CRenderer::DrawToScreen(void) // render the spans to screen re_prProjection->Prepare(); _pfRenderProfile.StartTimer(CRenderProfile::PTI_RENDERSCENE); - CPerspectiveProjection3D *pprPerspective = (CPerspectiveProjection3D*)(CProjection3D*)re_prProjection; + //CPerspectiveProjection3D *pprPerspective = (CPerspectiveProjection3D*)(CProjection3D*)re_prProjection; RenderScene( re_pdpDrawPort, re_pspoFirst, re_prProjection, re_colSelection, FALSE); _pfRenderProfile.StopTimer(CRenderProfile::PTI_RENDERSCENE); } @@ -659,7 +659,7 @@ void CRenderer::FillMirrorDepth(CMirror &mi) // for each polygon FOREACHINDYNAMICCONTAINER(mi.mi_cspoPolygons, CScreenPolygon, itspo) { CScreenPolygon &spo = *itspo; - CBrushPolygon &bpo = *spo.spo_pbpoBrushPolygon; + //CBrushPolygon &bpo = *spo.spo_pbpoBrushPolygon; // create a new screen polygon CScreenPolygon &spoNew = re_aspoScreenPolygons.Push(); ScenePolygon &sppoNew = spoNew.spo_spoScenePolygon; diff --git a/Sources/Engine/Rendering/RenderBrushes.cpp b/Sources/Engine/Rendering/RenderBrushes.cpp index e810f9d..d8e8520 100644 --- a/Sources/Engine/Rendering/RenderBrushes.cpp +++ b/Sources/Engine/Rendering/RenderBrushes.cpp @@ -20,8 +20,8 @@ void CRenderer::DrawBrushPolygonVerticesAndEdges(CBrushPolygon &bpo) CBrushSector &bsc = *bpo.bpo_pbscSector; CBrushMip *pbm = bsc.bsc_pbmBrushMip; CBrush3D &br = *pbm->bm_pbrBrush; - INDEX iMinVx = bsc.bsc_ivvx0; - INDEX iMaxVx = bsc.bsc_ivvx0+bsc.bsc_awvxVertices.Count(); + //INDEX iMinVx = bsc.bsc_ivvx0; + //INDEX iMaxVx = bsc.bsc_ivvx0+bsc.bsc_awvxVertices.Count(); // set line type and color for edges and vertices ULONG ulEdgesLineType = EdgeLineType(wplPolygonPlane.wpl_bVisible); @@ -155,7 +155,7 @@ void CRenderer::DrawBrushPolygonVerticesAndEdges(CBrushPolygon &bpo) void CRenderer::DrawBrushSectorVerticesAndEdges(CBrushSector &bscSector) { CBrushMip *pbm = bscSector.bsc_pbmBrushMip; - CBrush3D &br = *pbm->bm_pbrBrush; + //CBrush3D &br = *pbm->bm_pbrBrush; // clear all vertex drawn flags FOREACHINSTATICARRAY(bscSector.bsc_abvxVertices, CBrushVertex, itbvx) { @@ -275,7 +275,7 @@ void CRenderer::PrepareBrush(CEntity *penBrush) // for static brushes CProjection3D &pr = *brBrush.br_prProjection; const FLOATmatrix3D &mRot = penBrush->en_mRotation; - const FLOAT3D &vRot = penBrush->en_plPlacement.pl_PositionVector; + //const FLOAT3D &vRot = penBrush->en_plPlacement.pl_PositionVector; // fixup projection to use placement of this brush pr.pr_mDirectionRotation = pr.pr_ViewerRotationMatrix*mRot; pr.pr_RotationMatrix = pr.pr_mDirectionRotation; diff --git a/Sources/Engine/Ska/RMRender.cpp b/Sources/Engine/Ska/RMRender.cpp index 827648a..576d1b8 100644 --- a/Sources/Engine/Ska/RMRender.cpp +++ b/Sources/Engine/Ska/RMRender.cpp @@ -263,6 +263,7 @@ static void GetHazeMapInVertex( GFXVertex4 &vtx, FLOAT &tx1) tx1 = (fD+_fHazeAdd) * _haze_fMul; } +#if 0 // DG: unused // check model's bounding box against fog static BOOL IsModelInFog( FLOAT3D &vMin, FLOAT3D &vMax) { @@ -294,6 +295,7 @@ static BOOL IsModelInHaze( FLOAT3D &vMin, FLOAT3D &vMax) vtx.x=vMax(1); vtx.y=vMax(2); vtx.z=vMax(3); GetHazeMapInVertex(vtx,fS); if(InHaze(fS)) return TRUE; return FALSE; } +#endif // 0 (unused) BOOL PrepareHaze(void) { @@ -312,7 +314,7 @@ BOOL PrepareHaze(void) // _fFogAddZ = _vViewer % (rm.rm_vObjectPosition - _aprProjection->pr_vViewerPosition); // BUG in compiler !!!! _fFogAddZ = -_mObjToView[11]; // get fog offset - _fFogAddH = _fog_fAddH;/*( + _fFogAddH = _fog_fAddH; // ( _vHDirView(1)*_mObjToView[3] + _vHDirView(2)*_mObjToView[7] + _vHDirView(3)*_mObjToView[11]) + _fog_fp.fp_fH3; @@ -2087,7 +2089,7 @@ static void RenderMesh(RenMesh &rmsh,RenModel &rm) // clamp surface texture count to max number of textrues in mesh INDEX cttx = pShaderParams->sp_aiTextureIDs.Count(); - INDEX cttxMax = rmsh.rmsh_pMeshInst->mi_tiTextures.Count(); + //INDEX cttxMax = rmsh.rmsh_pMeshInst->mi_tiTextures.Count(); // cttx = ClampUp(cttx,cttxMax); _patoTextures.PopAll(); @@ -2250,7 +2252,7 @@ static void PrepareMeshForRendering(RenMesh &rmsh, INDEX iSkeletonlod) } else { // blend absolute (1-f)*cur + f*dst INDEX vtx = rm.rmp_pmmmMorphMap->mmp_aMorphMap[ivx].mwm_iVxIndex; - MeshVertex &mvSrc = mlod.mlod_aVertices[vtx]; + //MeshVertex &mvSrc = mlod.mlod_aVertices[vtx]; MeshVertexMorph &mvmDst = rm.rmp_pmmmMorphMap->mmp_aMorphMap[ivx]; // blend vertices _aMorphedVtxs[vtx].x = (1.0f-rm.rmp_fFactor) * _aMorphedVtxs[vtx].x + rm.rmp_fFactor*mvmDst.mwm_x; diff --git a/Sources/Engine/Sound/SoundLibrary.cpp b/Sources/Engine/Sound/SoundLibrary.cpp index 1965024..52ef87a 100644 --- a/Sources/Engine/Sound/SoundLibrary.cpp +++ b/Sources/Engine/Sound/SoundLibrary.cpp @@ -103,18 +103,19 @@ static HINSTANCE _hInstDS = NULL; static CTString snd_strDeviceName; #endif -static INDEX _iWriteOffset = 0; -static INDEX _iWriteOffset2 = 0; static BOOL _bMuted = FALSE; static INDEX _iLastEnvType = 1234; static FLOAT _fLastEnvSize = 1234; -static FLOAT _fLastPanning = 1234; +#ifdef PLATFORM_WIN32 +static FLOAT _fLastPanning = 1234; +static INDEX _iWriteOffset = 0; +static INDEX _iWriteOffset2 = 0; // TEMP! - for writing mixer buffer to file static FILE *_filMixerBuffer; static BOOL _bOpened = FALSE; - +#endif #define WAVEOUTBLOCKSIZE 1024 #define MINPAN (1.0f) @@ -1467,10 +1468,10 @@ void CSoundTimerHandler::HandleTimer(void) // copying of mixer buffer to sound buffer(s) +#ifdef PLATFORM_WIN32 static LPVOID _lpData, _lpData2; static DWORD _dwSize, _dwSize2; -#ifdef PLATFORM_WIN32 static void CopyMixerBuffer_dsound( CSoundLibrary &sl, SLONG slMixedSize) { LPVOID lpData; diff --git a/Sources/Engine/Sound/SoundObject.cpp b/Sources/Engine/Sound/SoundObject.cpp index 8011ae5..cedd31e 100644 --- a/Sources/Engine/Sound/SoundObject.cpp +++ b/Sources/Engine/Sound/SoundObject.cpp @@ -51,6 +51,7 @@ extern BOOL _bPredictionActive; extern FLOAT snd_fSoundVolume; extern FLOAT snd_fMusicVolume; +#if 0 // DG: unused. static CTString GetPred(CEntity*pen) { CTString str1; @@ -67,6 +68,7 @@ static CTString GetPred(CEntity*pen) str.PrintF("%08x-%s", pen, (const char *) str1); return str; } +#endif // 0 (unused) /* ==================================================== * * Class global methods diff --git a/Sources/Engine/Templates/BSP.cpp b/Sources/Engine/Templates/BSP.cpp index 17f4c60..78b26ec 100644 --- a/Sources/Engine/Templates/BSP.cpp +++ b/Sources/Engine/Templates/BSP.cpp @@ -956,7 +956,6 @@ template BSPNode *BSPTree::CreateSubTree(CDynamicArray > &abpoPolygons) { // local declarations, to fix macro expansion in FOREACHINDYNAMICARRAY - typedef BSPEdge edge_t; typedef BSPPolygon polygon_t; ASSERT(abpoPolygons.Count()>=1); @@ -1042,8 +1041,6 @@ BSPNode *BSPTree::CreateSubTree(CDynamicAr template void BSPTree::Create(CDynamicArray > &abpoPolygons) { - typedef BSPPolygon polygon_t; // local declaration, to fix macro expansion in FOREACHINDYNAMICARRAY - // free eventual existing tree Destroy(); diff --git a/Sources/Engine/Templates/Stock.cpp b/Sources/Engine/Templates/Stock.cpp index 7351b15..395726f 100644 --- a/Sources/Engine/Templates/Stock.cpp +++ b/Sources/Engine/Templates/Stock.cpp @@ -142,7 +142,7 @@ SLONG CStock_TYPE::CalculateUsedMemory(void) void CStock_TYPE::DumpMemoryUsage_t(CTStream &strm) // throw char * { CTString strLine; - SLONG slUsedTotal = 0; + //SLONG slUsedTotal = 0; {FOREACHINDYNAMICCONTAINER(st_ctObjects, TYPE, itt) { SLONG slUsedByObject = itt->GetUsedMemory(); if (slUsedByObject<0) { diff --git a/Sources/Engine/Terrain/Terrain.cpp b/Sources/Engine/Terrain/Terrain.cpp index a406c3c..4789c85 100644 --- a/Sources/Engine/Terrain/Terrain.cpp +++ b/Sources/Engine/Terrain/Terrain.cpp @@ -359,15 +359,15 @@ static void CropMap(INDEX iNewWidth, INDEX iNewHeight, INDEX iOldWidth, INDEX iO template static void StretchMap(INDEX iNewWidth, INDEX iNewHeight, INDEX iOldWidth, INDEX iOldHeight, Type *pNewData, Type *pOldData) { - int a=0; + //int a=0; CropMap(iNewWidth,iNewHeight,iOldWidth,iOldHeight,pNewData,pOldData); } template static void ShrinkMap(INDEX iNewWidth, INDEX iNewHeight, INDEX iOldWidth, INDEX iOldHeight, Type *pNewData, Type *pOldData) { - FLOAT fWidth = iNewWidth; - FLOAT fHeight = iNewHeight; + //FLOAT fWidth = iNewWidth; + //FLOAT fHeight = iNewHeight; FLOAT fDiffX = (FLOAT)iNewWidth / iOldWidth; FLOAT fDiffY = (FLOAT)iNewHeight / iOldHeight; @@ -800,7 +800,7 @@ void CTerrain::AddAllTilesToRegenQueue() // for each terrain tile for(INDEX itt=0;ittub.a = 255; } +#if 0 // DG: unused. static INDEX _ctSavedTopMaps=0; static void SaveAsTga(CTextureData *ptdTex) { @@ -879,6 +880,7 @@ static void SaveAsTga(CTextureData *ptdTex) */ } +#endif // 0 static void AddTileLayerToTopMap(CTerrain *ptrTerrain, INDEX iTileIndex, INDEX iLayer) { @@ -1004,7 +1006,7 @@ void CTerrain::UpdateTopMap(INDEX iTileIndex, Rect *prcDest/*=NULL*/) INDEX iFirstInMask = 0; INDEX iMaskWidth = tr_pixHeightMapWidth; INDEX iTiling = 1; - INDEX iSrcMipWidth = 1; + //INDEX iSrcMipWidth = 1; // destionation texture (must have set allocated memory) @@ -1587,7 +1589,7 @@ void CTerrain::BuildQuadTree(void) INDEX ctQuadLevels = tr_aqtlQuadTreeLevels.Count(); // for each quadtree level after first for(INDEX iql=1;iqltr_pixHeightMapWidth*ptrTerrain->tr_pixHeightMapHeight*sizeof(UWORD); // Edge map usage diff --git a/Sources/Engine/Terrain/TerrainEditing.cpp b/Sources/Engine/Terrain/TerrainEditing.cpp index e425dcb..6ca5265 100644 --- a/Sources/Engine/Terrain/TerrainEditing.cpp +++ b/Sources/Engine/Terrain/TerrainEditing.cpp @@ -39,7 +39,7 @@ static FLOATaabbox3D CalculateAABBoxFromRect(CTerrain *ptrTerrain, Rect rcExtrac ASSERT(ptrTerrain->tr_penEntity!=NULL); // Get entity that holds this terrain - CEntity *penEntity = ptrTerrain->tr_penEntity; + //CEntity *penEntity = ptrTerrain->tr_penEntity; FLOATaabbox3D bboxExtract; FLOATaabbox3D bboxAllTerrain; @@ -60,7 +60,7 @@ static INDEX GetFirstTileInMidLod(CTerrain *ptrTerrain, Rect &rcExtract) // for each terrain tile for(INDEX itt=0;itttr_ctTiles;itt++) { QuadTreeNode &qtn = ptrTerrain->tr_aqtnQuadTreeNodes[itt]; - CTerrainTile &tt = ptrTerrain->tr_attTiles[itt]; + //CTerrainTile &tt = ptrTerrain->tr_attTiles[itt]; // if it is coliding with given box if(qtn.qtn_aabbox.HasContactWith(bboxExtract)) { // calculate its real distance factor @@ -367,8 +367,8 @@ void SetBufferForEditing(CTerrain *ptrTerrain, UWORD *puwEditedBuffer, Rect &rcE PIX pixTop = rcExtract.rc_iTop; PIX pixBottom = rcExtract.rc_iBottom; - PIX pixWidht = pixRight-pixLeft; - PIX pixHeight = pixBottom-pixTop; + //PIX pixWidht = pixRight-pixLeft; + //PIX pixHeight = pixBottom-pixTop; PIX pixMaxWidth = ptrTerrain->tr_pixHeightMapWidth; PIX pixMaxHeight = ptrTerrain->tr_pixHeightMapHeight; diff --git a/Sources/Engine/Terrain/TerrainMisc.cpp b/Sources/Engine/Terrain/TerrainMisc.cpp index 7544a79..3ff1753 100644 --- a/Sources/Engine/Terrain/TerrainMisc.cpp +++ b/Sources/Engine/Terrain/TerrainMisc.cpp @@ -53,6 +53,7 @@ FLOATaabbox3D _bboxDrawTwo; #define LEFT 1 #define MIDDLE 2 +#if 0 // DG: unused. // Test AABBox agains ray static BOOL HitBoundingBox(FLOAT3D &vOrigin, FLOAT3D &vDir, FLOAT3D &vHit, FLOATaabbox3D &bbox) { @@ -123,7 +124,6 @@ static BOOL HitBoundingBox(FLOAT3D &vOrigin, FLOAT3D &vDir, FLOAT3D &vHit, FLOAT return (TRUE); /* ray hits box */ } - // Test AABBox agains ray static BOOL RayHitsAABBox(FLOAT3D &vOrigin, FLOAT3D &vDir, FLOAT3D &vHit, FLOATaabbox3D &bbox) { @@ -201,11 +201,12 @@ static BOOL RayHitsAABBox(FLOAT3D &vOrigin, FLOAT3D &vDir, FLOAT3D &vHit, FLOATa vHit = FLOAT3D(coord[0],coord[1],coord[2]); return TRUE; } +#endif // 0 (unused) // Get exact hit location in tile FLOAT GetExactHitLocation(INDEX iTileIndex, FLOAT3D &vOrigin, FLOAT3D &vTarget, FLOAT3D &vHitLocation) { - CTerrainTile &tt = _ptrTerrain->tr_attTiles[iTileIndex]; + //CTerrainTile &tt = _ptrTerrain->tr_attTiles[iTileIndex]; QuadTreeNode &qtn = _ptrTerrain->tr_aqtnQuadTreeNodes[iTileIndex]; GFXVertex *pavVertices; @@ -341,7 +342,7 @@ Rect ExtractPolygonsInBox(CTerrain *ptrTerrain, const FLOATaabbox3D &bboxExtract INDEX iFirst = iStartX + iStartY * ptrTerrain->tr_pixHeightMapWidth; INDEX iPitchX = ptrTerrain->tr_pixHeightMapWidth - iWidth; - INDEX iPitchY = ptrTerrain->tr_pixHeightMapHeight - iHeight; + //INDEX iPitchY = ptrTerrain->tr_pixHeightMapHeight - iHeight; // get first pixel in height map UWORD *puwHeight = &ptrTerrain->tr_auwHeightMap[iFirst]; @@ -385,7 +386,7 @@ Rect ExtractPolygonsInBox(CTerrain *ptrTerrain, const FLOATaabbox3D &bboxExtract } INDEX ivx=0; - INDEX ind=0; + //INDEX ind=0; INDEX iFacing=iFirst; GFXVertex *pavExtVtx = &_avExtVertices[0]; @@ -493,7 +494,7 @@ void ExtractVerticesInRect(CTerrain *ptrTerrain, Rect &rc, GFXVertex4 **pavVtx, INDEX *pauiIndices = &_aiExtIndices[0]; INDEX ivx=0; - INDEX ind=0; + //INDEX ind=0; INDEX iFacing=iFirstHeight; // for each row for(iy=0;iyen_pwoWorld; - PIX pixWidth = ptrTerrain->GetShadowMapWidth(); - PIX pixHeight = ptrTerrain->GetShadowMapHeight(); + //PIX pixWidth = ptrTerrain->GetShadowMapWidth(); + //PIX pixHeight = ptrTerrain->GetShadowMapHeight(); CTextureData &tdShadowMap = ptrTerrain->tr_tdShadowMap; ASSERT(tdShadowMap.td_pulFrames!=NULL); diff --git a/Sources/Engine/Terrain/TerrainRender.cpp b/Sources/Engine/Terrain/TerrainRender.cpp index 61396ae..f11eb16 100644 --- a/Sources/Engine/Terrain/TerrainRender.cpp +++ b/Sources/Engine/Terrain/TerrainRender.cpp @@ -269,7 +269,7 @@ void PrepareSmothVertices(INDEX itt) GFXVertex *pvBorderSrc = pavSrc; for(INDEX ivx=tt.tt_ctNonBorderVertices;ivxtr_attTiles[iTerrainTile]; - CTerrainLayer &tl = _ptrTerrain->tr_atlLayers[iTileLayer]; + //CTerrainLayer &tl = _ptrTerrain->tr_atlLayers[iTileLayer]; TileLayer &ttl = tt.GetTileLayers()[iTileLayer]; ASSERT(tt.tt_iLod==0); @@ -1231,7 +1231,7 @@ void RenderTerrain(void) RenderBatchedTiles(); } - CEntity *pen = _ptrTerrain->tr_penEntity; + //CEntity *pen = _ptrTerrain->tr_penEntity; extern void ShowRayPath(CDrawPort *pdp); ShowRayPath(_pdp); diff --git a/Sources/Engine/Terrain/TerrainTile.cpp b/Sources/Engine/Terrain/TerrainTile.cpp index fea5b87..677551b 100644 --- a/Sources/Engine/Terrain/TerrainTile.cpp +++ b/Sources/Engine/Terrain/TerrainTile.cpp @@ -441,8 +441,8 @@ void CTerrainTile::ReGenerate() } } - INDEX ctVtxBefore = GetVertices().Count(); - INDEX ctTrisBefore = GetIndices().Count()/3; + //INDEX ctVtxBefore = GetVertices().Count(); + //INDEX ctTrisBefore = GetIndices().Count()/3; // tt_ctNormalVertices = GetVertexCount(); // Generate borders for tile @@ -535,7 +535,7 @@ INDEX CTerrainTile::CalculateLOD(void) INDEX ini = tt_aiNeighbours[in]; // if neighbour is valid if(ini>=0) { - CTerrainTile &ttNeigbour = _ptrTerrain->tr_attTiles[ini]; + //CTerrainTile &ttNeigbour = _ptrTerrain->tr_attTiles[ini]; // if neighbour is in higher lod if(TRUE) { /*ttNeigbour.tt_iLod > tt.tt_iNewLod*/ // add neighbour to regen queue diff --git a/Sources/Engine/World/World.cpp b/Sources/Engine/World/World.cpp index 50e35bc..d524e2f 100644 --- a/Sources/Engine/World/World.cpp +++ b/Sources/Engine/World/World.cpp @@ -51,6 +51,7 @@ extern BOOL _bPortalSectorLinksPreLoaded; extern BOOL _bEntitySectorLinksPreLoaded; extern INDEX _ctPredictorEntities; +#if 0 // DG: unused. // calculate ray placement from origin and target positions (obsolete?) static inline CPlacement3D CalculateRayPlacement( const FLOAT3D &vOrigin, const FLOAT3D &vTarget) @@ -65,6 +66,7 @@ static inline CPlacement3D CalculateRayPlacement( DirectionVectorToAngles(vDirection, plRay.pl_OrientationAngle); return plRay; } +#endif // 0 /* Constructor. */ CTextureTransformation::CTextureTransformation(void) diff --git a/Sources/EntitiesMP/Common/EmanatingParticles.cpp b/Sources/EntitiesMP/Common/EmanatingParticles.cpp index 8ff696c..9bc19ea 100644 --- a/Sources/EntitiesMP/Common/EmanatingParticles.cpp +++ b/Sources/EntitiesMP/Common/EmanatingParticles.cpp @@ -137,7 +137,7 @@ void CEmiter::AnimateParticles(void) ep.ep_fLastRot=ep.ep_fRot; ep.ep_fRot+=ep.ep_fRotSpeed*_pTimer->TickQuantum; // animate color - FLOAT fRatio=CalculateRatio(tmNow, ep.ep_tmEmitted, ep.ep_tmEmitted+ep.ep_tmLife, 1, 0); + //FLOAT fRatio=CalculateRatio(tmNow, ep.ep_tmEmitted, ep.ep_tmEmitted+ep.ep_tmLife, 1, 0); ep.ep_colLastColor=ep.ep_colColor; iCurrent++; } diff --git a/Sources/EntitiesMP/Common/HUD.cpp b/Sources/EntitiesMP/Common/HUD.cpp index e864c51..aeef67c 100644 --- a/Sources/EntitiesMP/Common/HUD.cpp +++ b/Sources/EntitiesMP/Common/HUD.cpp @@ -271,6 +271,7 @@ static int qsort_CompareFrags( const void *ppPEN0, const void *ppPEN1) { else return -qsort_CompareDeaths(ppPEN0, ppPEN1); } +#if 0 // DG: unused. static int qsort_CompareLatencies( const void *ppPEN0, const void *ppPEN1) { CPlayer &en0 = **(CPlayer**)ppPEN0; CPlayer &en1 = **(CPlayer**)ppPEN1; @@ -280,6 +281,7 @@ static int qsort_CompareLatencies( const void *ppPEN0, const void *ppPEN1) { else if( sl0>sl1) return -1; else return 0; } +#endif // 0 (unused) // prepare color transitions static void PrepareColorTransitions( COLOR colFine, COLOR colHigh, COLOR colMedium, COLOR colLow, @@ -560,7 +562,8 @@ static void DrawAspectCorrectTextureCentered( class CTextureObject *_pTO, FLOAT CTextureData *ptd = (CTextureData*)_pTO->GetData(); FLOAT fTexSizeI = ptd->GetPixWidth(); FLOAT fTexSizeJ = ptd->GetPixHeight(); - FLOAT fHeight = fWidth*fTexSizeJ/fTexSizeJ; + FLOAT fHeight = fWidth*fTexSizeJ/fTexSizeJ; // FIXME: not fTexSizeJ/fTexSizeI ?? + STUBBED("fWidth*fTexSizeJ/fTexSizeJ is most likely not intended!"); _pDP->InitTexture( _pTO); _pDP->AddTexture( fX-fWidth*0.5f, fY-fHeight*0.5f, fX+fWidth*0.5f, fY+fHeight*0.5f, 0, 0, 1, 1, col); @@ -580,8 +583,8 @@ static void HUD_DrawSniperMask( void ) COLOR colMask = C_WHITE|CT_OPAQUE; CTextureData *ptd = (CTextureData*)_toSniperMask.GetData(); - const FLOAT fTexSizeI = ptd->GetPixWidth(); - const FLOAT fTexSizeJ = ptd->GetPixHeight(); + //const FLOAT fTexSizeI = ptd->GetPixWidth(); + //const FLOAT fTexSizeJ = ptd->GetPixHeight(); // main sniper mask _pDP->InitTexture( &_toSniperMask); @@ -925,7 +928,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO _fCustomScaling = ClampDn( _fCustomScaling*0.8f, 0.5f); const FLOAT fOneUnitS = fOneUnit *0.8f; const FLOAT fAdvUnitS = fAdvUnit *0.8f; - const FLOAT fNextUnitS = fNextUnit *0.8f; + //const FLOAT fNextUnitS = fNextUnit *0.8f; const FLOAT fHalfUnitS = fHalfUnit *0.8f; // prepare postition and ammo quantities diff --git a/Sources/EntitiesMP/Common/Particles.cpp b/Sources/EntitiesMP/Common/Particles.cpp index 605db3c..8651db7 100755 --- a/Sources/EntitiesMP/Common/Particles.cpp +++ b/Sources/EntitiesMP/Common/Particles.cpp @@ -593,7 +593,7 @@ void Particles_RomboidTrail(CEntity *pen) for(INDEX iPos = 0; iPoslp_ctUsed; iPos++) { FLOAT3D vPos = plp->GetPosition(iPos); - FLOAT fRand = rand()/FLOAT(RAND_MAX); + //FLOAT fRand = rand()/FLOAT(RAND_MAX); FLOAT fAngle = fSeconds*256+iPos*2.0f*PI/ROMBOID_TRAIL_POSITIONS; FLOAT fSin = FLOAT(sin(fAngle)); vPos(2) += fSin*iPos/ROMBOID_TRAIL_POSITIONS; @@ -754,7 +754,7 @@ void Particles_WhiteLineTrail(CEntity *pen) vPos(1) += fSin*iPos*1.0f/WHITE_LINE_TRAIL_POSITIONS; vPos(2) += fCos*iPos*1.0f/WHITE_LINE_TRAIL_POSITIONS; - UBYTE ub = 255-iPos*256/WHITE_LINE_TRAIL_POSITIONS; + //UBYTE ub = 255-iPos*256/WHITE_LINE_TRAIL_POSITIONS; FLOAT fLerpFactor = FLOAT(iPos)/WHITE_LINE_TRAIL_POSITIONS; COLOR colColor = LerpColor( C_YELLOW, C_dRED, fLerpFactor); Particle_RenderLine( vPos, vOldPos, 0.05f, colColor); @@ -850,7 +850,7 @@ void Particles_CannonBall_Prepare(CEntity *pen) void Particles_CannonBall(CEntity *pen, FLOAT fSpeedRatio) { CLastPositions *plp = pen->GetLastPositions(CANNON_TRAIL_POSITIONS); - FLOAT fSeconds = _pTimer->GetLerpedCurrentTick(); + //FLOAT fSeconds = _pTimer->GetLerpedCurrentTick(); Particle_PrepareTexture(&_toCannonBall, PBT_BLEND); Particle_SetTexturePart( 512, 512, 0, 0); @@ -1133,7 +1133,7 @@ void Particles_RocketTrail_Prepare(CEntity *pen) void Particles_RocketTrail(CEntity *pen, FLOAT fStretch) { CLastPositions *plp = pen->GetLastPositions(ROCKET_TRAIL_POSITIONS); - FLOAT fSeconds = _pTimer->GetLerpedCurrentTick(); + //FLOAT fSeconds = _pTimer->GetLerpedCurrentTick(); Particle_PrepareTexture(&_toRocketTrail, PBT_ADD); Particle_SetTexturePart( 512, 512, 0, 0); @@ -1153,7 +1153,7 @@ void Particles_RocketTrail(CEntity *pen, FLOAT fStretch) } for (INDEX iInter=0; iInterGetLerpedCurrentTick(); const FLOATmatrix3D &m = pen->GetRotationMatrix(); FLOAT3D vY( m(1,2), m(2,2), m(3,2)); @@ -1355,7 +1355,7 @@ void Particles_ExplosionSmoke(CEntity *pen, FLOAT tmStart, FLOAT3D vStretch, COL FLOAT fTRnd=afStarsPositions[iRnd][0]; FLOAT tmBorn=tmStart+i*TM_ES_SMOKE_DELTA+(TM_ES_SMOKE_DELTA*fTRnd)/2.0f; FLOAT fT=fNow-tmBorn; - FLOAT fRatio=Clamp(fT/TM_ES_TOTAL_LIFE, 0.0f, 1.0f); + //FLOAT fRatio=Clamp(fT/TM_ES_TOTAL_LIFE, 0.0f, 1.0f); if( fT>0) { FLOAT3D vSpeed=FLOAT3D(afStarsPositions[iRnd][0]*0.15f, @@ -1455,7 +1455,7 @@ void DECL_DLL Particles_Waterfall(CEntity *pen, INDEX ctCount, FLOAT fStretchAll fT *= 1/fParam1; // get fraction part fT = fT-int(fT); - FLOAT fSlowFactor=1.0f-fT*0.25f; + //FLOAT fSlowFactor=1.0f-fT*0.25f; FLOAT3D vSpeed= vX*(afStarsPositions[iRnd][0]*0.25f)+ vY*(afStarsPositions[iRnd][0]*0.25f)+ @@ -1497,9 +1497,9 @@ void Particles_BloodTrail(CEntity *pen) { Particle_SetTexturePart( 256, 256, iPos%8, 0); FLOAT3D vPos = plp->GetPosition(iPos); - FLOAT fRand = rand()/FLOAT(RAND_MAX); + //FLOAT fRand = rand()/FLOAT(RAND_MAX); FLOAT fAngle = iPos*2.0f*PI/BLOOD01_TRAIL_POSITIONS; - FLOAT fSin = FLOAT(sin(fAngle)); + //FLOAT fSin = FLOAT(sin(fAngle)); FLOAT fT = iPos*_pTimer->TickQuantum; vPos += vGDir*fGA*fT*fT/8.0f; FLOAT fSize = 0.2f-iPos*0.15f/BLOOD01_TRAIL_POSITIONS; @@ -1735,8 +1735,8 @@ void Particles_FlameThrowerStart(const CPlacement3D &plPipe, FLOAT fStartTime, F fPowerFactor *= Clamp(1.0f+(fStopTime-fNow)/2.0f,0.0f,1.0f); INDEX ctParticles = (INDEX) (FLOAT(CT_FTSPARKS) * fPowerFactor); ASSERT( ctParticles<=CT_MAX_PARTICLES_TABLE); - FLOAT fHeight = 1.0f*fPowerFactor; - INDEX iParticle=0; + //FLOAT fHeight = 1.0f*fPowerFactor; + //INDEX iParticle=0; for( INDEX iSpark=0; iSparkGetLerpedPlacement().pl_PositionVector; - FLOAT3D vG=-vY; - FLOAT tmNow = _pTimer->GetLerpedCurrentTick(); + //FLOAT3D vG=-vY; + //FLOAT tmNow = _pTimer->GetLerpedCurrentTick(); FLOAT fT = _pTimer->GetLerpedCurrentTick()-tmStarted; FLOAT fStretch=vStretch.Length(); - INDEX ctParticles=(INDEX) (4+fSizeRatio*28); + //INDEX ctParticles=(INDEX) (4+fSizeRatio*28); for(INDEX iDust=0; iDust<32; iDust++) { INDEX iRnd = (pen->en_ulID*12345+iDust)%CT_MAX_PARTICLES_TABLE; @@ -2240,9 +2240,9 @@ void Particles_DustFall(CEntity *pen, FLOAT tmStarted, FLOAT3D vStretch) FLOAT fPower = CalculateRatio(fT, 0, fLifeTime, 0.1f, 0.4f); FLOAT fSpeed=0.351f+0.0506f*log(fRatio+0.001f); - FLOAT fRndAppearX = afStarsPositions[iRnd][0]*vStretch(1); - FLOAT fRndSpeedY = (afStarsPositions[iRnd][1]+0.5f)*0.125f*vStretch(2); - FLOAT fRndAppearZ = afStarsPositions[iRnd][2]*vStretch(3); + //FLOAT fRndAppearX = afStarsPositions[iRnd][0]*vStretch(1); + //FLOAT fRndSpeedY = (afStarsPositions[iRnd][1]+0.5f)*0.125f*vStretch(2); + //FLOAT fRndAppearZ = afStarsPositions[iRnd][2]*vStretch(3); FLOAT3D vRndDir=FLOAT3D(afStarsPositions[iRnd][0],0,afStarsPositions[iRnd][2]); vRndDir.Normalize(); FLOAT fRiseTime=Max(fRatio-0.5f,0.0f); @@ -2590,7 +2590,7 @@ BOOL UpdateGrowthCache(CEntity *pen, CTextureData *ptdGrowthMap, FLOATaabbox3D & FLOAT fGridStep; ULONG fXSpan; - UBYTE ubFade=0xff; + // UBYTE ubFade=0xff; fGridStep = GROWTH_RENDERING_STEP; fXSpan = 1234; @@ -2798,7 +2798,7 @@ void Particles_Growth(CEntity *pen, CTextureData *ptdGrowthMap, FLOATaabbox3D &b // calculate fade value FLOAT fFadeOutStrip = GROWTH_RENDERING_RADIUS_FADE - GROWTH_RENDERING_RADIUS_OPAQUE; - UBYTE ubFade = (UBYTE)(((GROWTH_RENDERING_RADIUS_FADE - cgParticle->fDistanceToViewer) / fFadeOutStrip)*255.0f); + //UBYTE ubFade = (UBYTE)(((GROWTH_RENDERING_RADIUS_FADE - cgParticle->fDistanceToViewer) / fFadeOutStrip)*255.0f); if ( cgParticle->fDistanceToViewer < GROWTH_RENDERING_RADIUS_OPAQUE) { cgParticle->ubFade = 255; acgDraw.Push() = *cgParticle; @@ -3166,7 +3166,7 @@ void Particles_Snow(CEntity *pen, FLOAT fGridSize, INDEX ctGrids, FLOAT fFactor, FLOAT fFlakeStartPos=vPos(2)-fFlakePath; FLOAT fSnapFlakeStartPos=fFlakeStartPos; SnapFloat(fSnapFlakeStartPos, YGRID_SIZE); - INDEX iRndFlakeStart=INDEX(fSnapFlakeStartPos)%CT_MAX_PARTICLES_TABLE; + //INDEX iRndFlakeStart=INDEX(fSnapFlakeStartPos)%CT_MAX_PARTICLES_TABLE; FLOAT tmSnapSnowFalling = tmSnowFalling; SnapFloat( tmSnapSnowFalling, SNOW_TILE_DROP_TIME); FLOAT fTileRatio = (tmSnowFalling-tmSnapSnowFalling)/SNOW_TILE_DROP_TIME; @@ -3552,9 +3552,9 @@ void Particles_BulletSpray(INDEX iRndBase, FLOAT3D vSource, FLOAT3D vGDir, enum fSpeedStart = 1.75f; fConeMultiplier = 0.125f; - FLOAT fFadeStart = BULLET_SPRAY_WATER_FADEOUT_START; - FLOAT fLifeTotal = BULLET_SPRAY_WATER_TOTAL_TIME; - FLOAT fFadeLen = fLifeTotal-fFadeStart; + //FLOAT fFadeStart = BULLET_SPRAY_WATER_FADEOUT_START; + //FLOAT fLifeTotal = BULLET_SPRAY_WATER_TOTAL_TIME; + //FLOAT fFadeLen = fLifeTotal-fFadeStart; break; } @@ -3784,7 +3784,7 @@ void Particles_EmptyShells( CEntity *pen, ShellLaunchData *asldData) { // render smoke INDEX iRnd = (INDEX(tmLaunch*1234))%CT_MAX_PARTICLES_TABLE; - FLOAT fTRatio = fT/fLife; + //FLOAT fTRatio = fT/fLife; INDEX iColumn = 4+INDEX( iShell)%4; Particle_SetTexturePart( 256, 256, iColumn, 2); @@ -3805,7 +3805,7 @@ void Particles_EmptyShells( CEntity *pen, ShellLaunchData *asldData) { // render smoke INDEX iRnd = (INDEX(tmLaunch*1234))%CT_MAX_PARTICLES_TABLE; - FLOAT fTRatio = fT/fLife; + //FLOAT fTRatio = fT/fLife; INDEX iColumn = 4+INDEX( iShell)%4; Particle_SetTexturePart( 256, 256, iColumn, 2); @@ -3832,7 +3832,7 @@ void Particles_EmptyShells( CEntity *pen, ShellLaunchData *asldData) FLOAT3D vUp( m(1,2), m(2,2), m(3,2)); INDEX iRnd = (INDEX(tmLaunch*1234))%CT_MAX_PARTICLES_TABLE; - FLOAT fTRatio = fT/fLife; + //FLOAT fTRatio = fT/fLife; INDEX iColumn = 4+INDEX( iShell)%4; Particle_SetTexturePart( 256, 256, iColumn, 2); @@ -4151,7 +4151,7 @@ void Particles_Appearing(CEntity *pen, TIME tmStart) if( (fTimeAPPEAR_OUT_END)) { return; } - FLOAT fPowerTime = pow(fTime-SPIRIT_SPIRAL_START, 2.5f); + //FLOAT fPowerTime = pow(fTime-SPIRIT_SPIRAL_START, 2.5f); // fill array with absolute vertices of entity's model and its attached models pen->GetModelVerticesAbsolute(avVertices, 0.05f, fMipFactor); @@ -4161,7 +4161,7 @@ void Particles_Appearing(CEntity *pen, TIME tmStart) FLOAT3D vX( m(1,1), m(2,1), m(3,1)); FLOAT3D vY( m(1,2), m(2,2), m(3,2)); FLOAT3D vZ( m(1,3), m(2,3), m(3,3)); - FLOAT3D vCenter = pen->GetLerpedPlacement().pl_PositionVector; + //FLOAT3D vCenter = pen->GetLerpedPlacement().pl_PositionVector; SetupParticleTexture( PT_STAR07); @@ -4180,12 +4180,12 @@ void Particles_Appearing(CEntity *pen, TIME tmStart) COLOR col = RGBToColor(ubColor,ubColor,ubColor)|CT_OPAQUE; INDEX ctVtx = avVertices.Count(); - FLOAT fSpeedFactor = 1.0f/ctVtx; + //FLOAT fSpeedFactor = 1.0f/ctVtx; // get corp size FLOATaabbox3D box; pen->en_pmoModelObject->GetCurrentFrameBBox(box); - FLOAT fHeightStretch = box.Size()(2); + //FLOAT fHeightStretch = box.Size()(2); FLOAT fStep = ClampDn( fMipFactor, 1.0f); for( FLOAT fVtx=0.0f; fVtxfMipDisappearDistance) return; - FLOAT fMipBlender=CalculateRatio(fMipFactor, 0.0f, fMipDisappearDistance, 0.0f, 0.1f); + //FLOAT fMipBlender=CalculateRatio(fMipFactor, 0.0f, fMipDisappearDistance, 0.0f, 0.1f); CPlacement3D pl = pen->GetLerpedPlacement(); const FLOATmatrix3D &m = pen->GetRotationMatrix(); @@ -4858,7 +4858,7 @@ void Particles_RocketMotorBurning(CEntity *pen, FLOAT tmSpawn, FLOAT3D vStretch, CTextureData *pTD = (CTextureData *) _toAfterBurnerGradient.GetData(); - ULONG *pcolFlare=pTD->GetRowPointer(0); // flare color + //ULONG *pcolFlare=pTD->GetRowPointer(0); // flare color ULONG *pcolExp=pTD->GetRowPointer(1); // explosion color ULONG *pcolSmoke=pTD->GetRowPointer(2); // smoke color FLOAT aFlare_sol[256], aFlare_vol[256], aFlare_wol[256], aFlare_rol[256]; @@ -5103,7 +5103,7 @@ void Particles_Twister( CEntity *pen, FLOAT fStretch, FLOAT fStartTime, FLOAT fF // get fraction part fT = fT-int(fT); INDEX iPos=(INDEX) (fT*255); - FLOAT fSlowFactor=1.0f-fT*0.25f; + //FLOAT fSlowFactor=1.0f-fT*0.25f; FLOAT fSpeed=25.0f+(afStarsPositions[iRnd][0]+0.5f)*2.0f; FLOAT fR=arol[iPos]*8.0f; FLOAT3D vPos=vCenter+vY*fSpeed*fT+ @@ -5235,7 +5235,7 @@ void Particles_Windblast( CEntity *pen, FLOAT fStretch, FLOAT fFadeOutStartTime) // get fraction part fT = fT-int(fT); INDEX iPos=(INDEX) (fT*255); - FLOAT fSlowFactor=1.0f-fT*0.25f; + //FLOAT fSlowFactor=1.0f-fT*0.25f; FLOAT fSpeed=25.0f+(afStarsPositions[iRnd][0]+0.5f)*2.0f; FLOAT fR=arol[iPos]*8.0f; fR=3.0f; @@ -5332,19 +5332,19 @@ void Particles_CollectEnergy(CEntity *pen, FLOAT tmStart, FLOAT tmStop) // calculate fraction part FLOAT fT=fPassedTime/fStarLife; fT=fT-INDEX(fT); - INDEX iRnd = iStar%CT_MAX_PARTICLES_TABLE; + //INDEX iRnd = iStar%CT_MAX_PARTICLES_TABLE; FLOAT fRadius=2; FLOAT3D vPos= vCenter+ vX*Sin(fT*360.0f)*fRadius+ vY*fT*2+ vZ*Cos(fT*360.0f)*fRadius; - UBYTE ubR = (UBYTE) (255); - UBYTE ubG = (UBYTE) (128+(1.0f-fT)*128); - UBYTE ubB = (UBYTE) (16+afStarsPositions[iRnd][2]*32+(1.0f-fT)*64); + //UBYTE ubR = (UBYTE) (255); + //UBYTE ubG = (UBYTE) (128+(1.0f-fT)*128); + //UBYTE ubB = (UBYTE) (16+afStarsPositions[iRnd][2]*32+(1.0f-fT)*64); FLOAT fFader=CalculateRatio( fT, 0.0f, 1.0f, 0.4f, 0.01f); FLOAT fPulser=(1.0f+(sin((fT*fT)/4.0f)))/2.0f; UBYTE ubA = (UBYTE) (fFader*fPulser*255); - COLOR colLine = RGBToColor( ubA, ubA, ubA) | CT_OPAQUE; + //COLOR colLine = RGBToColor( ubA, ubA, ubA) | CT_OPAQUE; FLOAT fSize = 2; Particle_RenderSquare( vPos, fSize, 0.0f, C_ORANGE|ubA); ctRendered++; @@ -5455,7 +5455,7 @@ void Particles_GrowingSwirl( CEntity *pen, FLOAT fStretch, FLOAT fStartTime) INDEX ctStars=(INDEX)(TM_GROWING_SWIRL_FX_LIFE/TM_SWIRL_SPARK_LAUNCH); for(INDEX i=0; ien_ulID+i)%CT_MAX_PARTICLES_TABLE; + //INDEX iRnd =(pen->en_ulID+i)%CT_MAX_PARTICLES_TABLE; FLOAT fBirth = fStartTime+i*TM_SWIRL_SPARK_LAUNCH-2.0f;//+afTimeOffsets[i]*TM_SWIRL_SPARK_LAUNCH/0.25f; FLOAT fT = tmNow-fBirth; FLOAT fFade=CalculateRatio(fT, 0, TM_GROWING_SWIRL_TOTAL_LIFE, 0.1f, 0.2f); @@ -5622,7 +5622,7 @@ void Particles_MeteorTrail(CEntity *pen, FLOAT fStretch, FLOAT fLength, FLOAT3D { Particle_PrepareTexture( &_toMeteorTrail, PBT_ADD); Particle_SetTexturePart( 1024, 2048, 0, 0); - CTextureData *pTD = (CTextureData *) _toExplosionDebrisGradient.GetData(); + //CTextureData *pTD = (CTextureData *) _toExplosionDebrisGradient.GetData(); FLOAT3D vPos0 = pen->GetLerpedPlacement().pl_PositionVector+vSpeed*0.05f; FLOAT3D vPos1 = pen->GetLerpedPlacement().pl_PositionVector+vSpeed*0.05f-vSpeed*0.125f; Particle_RenderLine( vPos1, vPos0, 3.0f, C_WHITE|CT_OPAQUE); @@ -5749,19 +5749,19 @@ void Particles_LarvaEnergy(CEntity *pen, FLOAT3D vOffset) // calculate fraction part FLOAT fT=fPassedTime/fStarLife; fT=fT-INDEX(fT); - INDEX iRnd = iStar%CT_MAX_PARTICLES_TABLE; + //INDEX iRnd = iStar%CT_MAX_PARTICLES_TABLE; FLOAT fRadius=2; FLOAT3D vPos= vCenter+ vX*Sin(fT*360.0f)*fRadius+ vY*fT*2+ vZ*Cos(fT*360.0f)*fRadius; - UBYTE ubR = (UBYTE) (255); - UBYTE ubG = (UBYTE) (128+(1.0f-fT)*128); - UBYTE ubB = (UBYTE) (16+afStarsPositions[iRnd][2]*32+(1.0f-fT)*64); + //UBYTE ubR = (UBYTE) (255); + //UBYTE ubG = (UBYTE) (128+(1.0f-fT)*128); + // UBYTE ubB = (UBYTE) (16+afStarsPositions[iRnd][2]*32+(1.0f-fT)*64); FLOAT fFader=CalculateRatio( fT, 0.0f, 1.0f, 0.4f, 0.01f); FLOAT fPulser=(1.0f+(sin((fT*fT)/4.0f)))/2.0f; UBYTE ubA = (UBYTE) (fFader*fPulser*255); - COLOR colLine = RGBToColor( ubA, ubA, ubA) | CT_OPAQUE; + //COLOR colLine = RGBToColor( ubA, ubA, ubA) | CT_OPAQUE; FLOAT fSize = 2; Particle_RenderSquare( vPos, fSize, 0.0f, C_ORANGE|ubA); ctRendered++; @@ -5792,7 +5792,7 @@ void Particles_AirElemental_Comp(CModelObject *mo, FLOAT fStretch, FLOAT fFade, FLOAT3D vG=-vY; FLOAT fSpeed=1.0f; - FLOAT fG=50.0f; + //FLOAT fG=50.0f; FLOAT fGValue=0.0f; Particle_PrepareTexture( &_toTwister, PBT_BLEND); @@ -5843,7 +5843,7 @@ void Particles_ModelGlow( CEntity *pen, FLOAT tmEnd, enum ParticleTexture ptText FLOAT3D vX( m(1,1), m(2,1), m(3,1)); FLOAT3D vY( m(1,2), m(2,2), m(3,2)); FLOAT3D vZ( m(1,3), m(2,3), m(3,3)); - FLOAT3D vCenter = pen->GetLerpedPlacement().pl_PositionVector; + //FLOAT3D vCenter = pen->GetLerpedPlacement().pl_PositionVector; UBYTE ubCol=255; if((tmEnd-tmNow)<5.0f) @@ -5884,7 +5884,7 @@ void Particles_ModelGlow2( CModelObject *mo, CPlacement3D pl, FLOAT tmEnd, enum FLOAT3D vX( m(1,1), m(2,1), m(3,1)); FLOAT3D vY( m(1,2), m(2,2), m(3,2)); FLOAT3D vZ( m(1,3), m(2,3), m(3,3)); - FLOAT3D vCenter = plPlacement.pl_PositionVector; + //FLOAT3D vCenter = plPlacement.pl_PositionVector; UBYTE ubCol=255; if((tmEnd-tmNow)<5.0f) @@ -5933,7 +5933,7 @@ void Particles_RunAfterBurner(CEntity *pen, FLOAT tmEnd, FLOAT fStretch, INDEX i const FLOAT3D *pvPos1; const FLOAT3D *pvPos2 = &plp->GetPosition(plp->lp_ctUsed-1); - ULONG *pcolFlare=pTD->GetRowPointer(0); // flare color + //ULONG *pcolFlare=pTD->GetRowPointer(0); // flare color ULONG *pcolExp=pTD->GetRowPointer(1); // explosion color ULONG *pcolSmoke=pTD->GetRowPointer(2); // smoke color FLOAT aFlare_sol[256], aFlare_vol[256], aFlare_wol[256], aFlare_rol[256]; diff --git a/Sources/GameMP/CompModels.cpp b/Sources/GameMP/CompModels.cpp index 7f3f655..0d131ce 100755 --- a/Sources/GameMP/CompModels.cpp +++ b/Sources/GameMP/CompModels.cpp @@ -733,7 +733,7 @@ extern void SetupCompModel_t(const CTString &strName) CTFILENAME("ModelsMP\\Weapons\\Chainsaw\\Blade.tex"), CTFILENAME("Models\\ReflectionTextures\\LightMetal01.tex"), CTFILENAME("Models\\SpecularTextures\\Medium.tex")); - CAttachmentModelObject *amo = pmo->GetAttachmentModel(CHAINSAWITEM_ATTACHMENT_BLADE); + //CAttachmentModelObject *amo = pmo->GetAttachmentModel(CHAINSAWITEM_ATTACHMENT_BLADE); AddAttachment_t(pmo, BLADEFORPLAYER_ATTACHMENT_TEETH, CTFILENAME("ModelsMP\\Weapons\\Chainsaw\\Teeth.mdl"), 0, CTFILENAME("ModelsMP\\Weapons\\Chainsaw\\Teeth.tex"), diff --git a/Sources/GameMP/Computer.cpp b/Sources/GameMP/Computer.cpp index 3757878..e1106e1 100644 --- a/Sources/GameMP/Computer.cpp +++ b/Sources/GameMP/Computer.cpp @@ -181,8 +181,8 @@ static PIXaabbox2D GetTextSliderBox(void) return PIXaabbox2D(); } INDEX ctTextLines = _acmMessages[_iActiveMessage].cm_ctFormattedLines; - PIX pixSizeI = _boxMsgText.Size()(1); - PIX pixSizeJ = _boxMsgText.Size()(2); + //PIX pixSizeI = _boxMsgText.Size()(1); + //PIX pixSizeJ = _boxMsgText.Size()(2); return GetSliderBox( _iTextLineOnScreen, _ctTextLinesOnScreen, ctTextLines, GetTextSliderSpace()); } @@ -190,8 +190,8 @@ static PIXaabbox2D GetTextSliderBox(void) static PIXaabbox2D GetMsgSliderBox(void) { INDEX ctLines = _acmMessages.Count(); - PIX pixSizeI = _boxMsgList.Size()(1); - PIX pixSizeJ = _boxMsgList.Size()(2); + //PIX pixSizeI = _boxMsgList.Size()(1); + //PIX pixSizeJ = _boxMsgList.Size()(2); return GetSliderBox( _iFirstMessageOnScreen, _ctMessagesOnScreen, ctLines, GetMsgSliderSpace()); } @@ -755,7 +755,7 @@ void RenderMessageStats(CDrawPort *pdp) { CSessionProperties *psp = (CSessionProperties *)_pNetwork->GetSessionProperties(); ULONG ulLevelMask = psp->sp_ulLevelsMask; - INDEX iLevel = -1; + //INDEX iLevel = -1; if (psp->sp_bCooperative) { extern void RenderMap( CDrawPort *pdp, ULONG ulLevelMask, CProgressHookInfo *pphi); if (pdp->Lock()) { @@ -1244,8 +1244,8 @@ void CGame::ComputerRender(CDrawPort *pdp) MarkCurrentRead(); // get current time and alpha value - FLOAT tmNow = (FLOAT)tvNow.GetSeconds(); - ULONG ulA = NormFloatToByte(fComputerFadeValue); + //FLOAT tmNow = (FLOAT)tvNow.GetSeconds(); + //ULONG ulA = NormFloatToByte(fComputerFadeValue); _colLight = LCDFadedColor(C_WHITE|255); _colMedium = LCDFadedColor(SE_COL_BLUE_LIGHT|255); diff --git a/Sources/GameMP/Game.cpp b/Sources/GameMP/Game.cpp index 2befdbf..47bc642 100755 --- a/Sources/GameMP/Game.cpp +++ b/Sources/GameMP/Game.cpp @@ -252,6 +252,7 @@ static void PlayScriptSound(INDEX iChannel, const CTString &strSound, FLOAT fVol CPrintF("%s\n", strError); } } +#if 0 // DG: unused. static void PlayScriptSoundCfunc(void* pArgs) { INDEX iChannel = NEXTARGUMENT(INDEX); @@ -261,6 +262,7 @@ static void PlayScriptSoundCfunc(void* pArgs) BOOL bLooping = NEXTARGUMENT(INDEX); PlayScriptSound(iChannel, strSound, fVolume, fPitch, bLooping); } +#endif // 0 (unused) static void StopScriptSound(void* pArgs) { INDEX iChannel = NEXTARGUMENT(INDEX); @@ -2148,7 +2150,7 @@ void CGame::GameRedrawView( CDrawPort *pdpDrawPort, ULONG ulFlags) CTFileName fnm = _fnmThumb; _fnmThumb = CTString(""); // render one game view to a small cloned drawport - PIX pixSizeJ = pdpDrawPort->GetHeight(); + //PIX pixSizeJ = pdpDrawPort->GetHeight(); PIXaabbox2D boxThumb( PIX2D(0,0), PIX2D(128,128)); CDrawPort dpThumb( pdpDrawPort, boxThumb); _bPlayerViewRendered = FALSE; @@ -2180,7 +2182,7 @@ void CGame::GameRedrawView( CDrawPort *pdpDrawPort, ULONG ulFlags) } // if game is started and computer isn't on - BOOL bClientJoined = FALSE; + //BOOL bClientJoined = FALSE; if( gm_bGameOn && (_pGame->gm_csComputerState==CS_OFF || pdpDrawPort->IsDualHead()) && gm_CurrentSplitScreenCfg!=SSC_DEDICATED ) { diff --git a/Sources/GameMP/Map.cpp b/Sources/GameMP/Map.cpp index dee6069..f46bdf2 100644 --- a/Sources/GameMP/Map.cpp +++ b/Sources/GameMP/Map.cpp @@ -613,9 +613,10 @@ void RenderMap( CDrawPort *pdp, ULONG ulLevelMask, CProgressHookInfo *pphi) if (ulLevelMask == 0x00000001 && !map_bIsFirstEncounter) { // render the book - PIX pixX = (PIX) (aIconCoords[0][0]*fStretch+pixC1S); - PIX pixY = (PIX) (aIconCoords[0][1]*fStretch+pixR1S); + //PIX pixX = (PIX) (aIconCoords[0][0]*fStretch+pixC1S); + //PIX pixY = (PIX) (aIconCoords[0][1]*fStretch+pixR1S); CTextureObject *pto = &atoIcons[0]; + // FIXME: DG: or was the line below supposed to use pixX and pixY? pdp->PutTexture( pto, PIXaabbox2D( PIX2D(pixC1S,pixR1S), PIX2D(pixC2E,pixR2E)), C_WHITE|255); } else { diff --git a/Sources/SeriousSam/GLSettings.cpp b/Sources/SeriousSam/GLSettings.cpp index 2b17080..535ef9d 100644 --- a/Sources/SeriousSam/GLSettings.cpp +++ b/Sources/SeriousSam/GLSettings.cpp @@ -70,7 +70,7 @@ void InitGLSettings(void) try { strmFile.Open_t( CTString("Scripts\\GLSettings\\GLSettings.lst"), CTStream::OM_READ); - INDEX iIndex = 0; + //INDEX iIndex = 0; do { achrLine [0] = 0; diff --git a/Sources/SeriousSam/Menu.cpp b/Sources/SeriousSam/Menu.cpp index 74be8fb..ee546cb 100644 --- a/Sources/SeriousSam/Menu.cpp +++ b/Sources/SeriousSam/Menu.cpp @@ -2198,8 +2198,8 @@ void InitializeMenus(void) ((CTextureData*)_toLogoMenuB.GetData())->Force(TEX_CONSTANT); // menu's relative placement - CPlacement3D plRelative = CPlacement3D( FLOAT3D( 0.0f, 0.0f, -9.0f), - ANGLE3D( AngleDeg(0.0f), AngleDeg(0.0f), AngleDeg(0.0f))); + //CPlacement3D plRelative = CPlacement3D( FLOAT3D( 0.0f, 0.0f, -9.0f), + // ANGLE3D( AngleDeg(0.0f), AngleDeg(0.0f), AngleDeg(0.0f))); try { TRANSLATERADIOARRAY(astrNoYes); @@ -2464,7 +2464,7 @@ void MenuUpdateMouseFocus(void) CMenuGadget *pmgActive = NULL; // for all gadgets in menu FOREACHINLIST( CMenuGadget, mg_lnNode, pgmCurrentMenu->gm_lhGadgets, itmg) { - CMenuGadget &mg = *itmg; + //CMenuGadget &mg = *itmg; // if focused if( itmg->mg_bFocused) { // remember it @@ -2596,11 +2596,11 @@ BOOL DoMenu( CDrawPort *pdp) if( bMenuActive) { // get current time - TIME tmNow = _pTimer->GetLerpedCurrentTick(); - UBYTE ubH1 = (INDEX)(tmNow*08.7f) & 255; - UBYTE ubH2 = (INDEX)(tmNow*27.6f) & 255; - UBYTE ubH3 = (INDEX)(tmNow*16.5f) & 255; - UBYTE ubH4 = (INDEX)(tmNow*35.4f) & 255; + //TIME tmNow = _pTimer->GetLerpedCurrentTick(); + //UBYTE ubH1 = (INDEX)(tmNow*08.7f) & 255; + //UBYTE ubH2 = (INDEX)(tmNow*27.6f) & 255; + //UBYTE ubH3 = (INDEX)(tmNow*16.5f) & 255; + //UBYTE ubH4 = (INDEX)(tmNow*35.4f) & 255; // clear screen with background texture _pGame->LCDPrepare(1.0f); @@ -2751,7 +2751,7 @@ BOOL DoMenu( CDrawPort *pdp) if (!_bMouseUsedLast) { // find focused gadget FOREACHINLIST( CMenuGadget, mg_lnNode, pgmCurrentMenu->gm_lhGadgets, itmg) { - CMenuGadget &mg = *itmg; + //CMenuGadget &mg = *itmg; // if focused if( itmg->mg_bFocused) { // it is active @@ -2969,8 +2969,8 @@ void CGameMenu::ScrollList(INDEX iDir) } // set new focus - const INDEX iFirst = 0; - const INDEX iLast = gm_ctListVisible-1; + //const INDEX iFirst = 0; + //const INDEX iLast = gm_ctListVisible-1; switch(iDir) { case +1: gm_pmgListBottom->OnSetFocus(); @@ -5444,7 +5444,7 @@ void CServersMenu::Initialize_t(void) mgServerRefresh.mg_pActivatedFunction = &RefreshServerList; gm_lhGadgets.AddTail( mgServerRefresh.mg_lnNode); - CTString astrColumns[7]; + //CTString astrColumns[7]; mgServerColumn[0].mg_strText = TRANS("Server") ; mgServerColumn[1].mg_strText = TRANS("Map") ; mgServerColumn[2].mg_strText = TRANS("Ping") ; diff --git a/Sources/SeriousSam/MenuGadgets.cpp b/Sources/SeriousSam/MenuGadgets.cpp index 3834563..858b0e4 100644 --- a/Sources/SeriousSam/MenuGadgets.cpp +++ b/Sources/SeriousSam/MenuGadgets.cpp @@ -266,7 +266,7 @@ void CMGButton::Render( CDrawPort *pdp) CTString str = mg_strText; if (pdp->dp_FontData->fd_bFixedWidth) { 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), 1); if (iCursor>=iMaxLen) { str.TrimRight(iCursor); @@ -768,7 +768,7 @@ void CMGTrigger::Render( CDrawPort *pdp) CTextureObject to; try { to.SetData_t(mg_strValue); - CTextureData *ptd = (CTextureData *)to.GetData(); + //CTextureData *ptd = (CTextureData *)to.GetData(); PIX pixSize = box.Size()(2); PIX pixCX = box.Max()(1)-pixSize/2; PIX pixCY = box.Center()(2); @@ -1393,7 +1393,7 @@ void CMGServerList::Render(CDrawPort *pdp) BOOL bFocusedBefore = mg_bFocused; mg_bFocused = FALSE; - PIXaabbox2D box = FloatBoxToPixBox(pdp, mg_boxOnScreen); + //PIXaabbox2D box = FloatBoxToPixBox(pdp, mg_boxOnScreen); COLOR col = GetCurrentColor(); PIX pixDPSizeI = pdp->GetWidth(); @@ -1404,7 +1404,7 @@ void CMGServerList::Render(CDrawPort *pdp) PIX pixSliderSizeI = 10; PIX pixOuterMargin = 20; - INDEX ctSessions = _lhServers.Count(); + //INDEX ctSessions = _lhServers.Count(); INDEX iSession=0; INDEX ctColumns[7]; @@ -1430,7 +1430,7 @@ void CMGServerList::Render(CDrawPort *pdp) apixSeparatorI[2] = apixSeparatorI[3]-pixSizePing-pixLineSize; apixSeparatorI[1] = apixSeparatorI[2]-pixSizeMapName-pixLineSize; apixSeparatorI[1] = apixSeparatorI[2]-pixSizeMapName-pixLineSize; - PIX pixSizeServerName = apixSeparatorI[1]-apixSeparatorI[0]-pixLineSize; + //PIX pixSizeServerName = apixSeparatorI[1]-apixSeparatorI[0]-pixLineSize; PIX pixTopJ = (PIX) (pixDPSizeJ*0.15f); PIX pixBottomJ = (PIX) (pixDPSizeJ*0.82f); @@ -1470,7 +1470,7 @@ void CMGServerList::Render(CDrawPort *pdp) PIXaabbox2D boxHandle = GetScrollBarHandleBox(); pdp->Fill(boxHandle.Min()(1)+2, boxHandle.Min()(2)+2, boxHandle.Size()(1)-3, boxHandle.Size()(2)-3, col|CT_OPAQUE); - PIX pixJ = pixTopJ+pixLineSize*2+1; + //PIX pixJ = pixTopJ+pixLineSize*2+1; mg_ctOnScreen = ctSessionsOnScreen; AdjustFirstOnScreen(); @@ -1755,7 +1755,7 @@ void CMGKeyDefinition::SetBindingNames(BOOL bDefining) { // find the button INDEX ict=0; - INDEX iDik=0; + //INDEX iDik=0; FOREACHINLIST( CButtonAction, ba_lnNode, _pGame->gm_ctrlControlsExtra->ctrl_lhButtonActions, itba) { if( ict == mg_iControlNumber) { CButtonAction &ba = *itba; diff --git a/Sources/Shaders/ColorShader.cpp b/Sources/Shaders/ColorShader.cpp index 34bd348..4490c22 100644 --- a/Sources/Shaders/ColorShader.cpp +++ b/Sources/Shaders/ColorShader.cpp @@ -33,7 +33,7 @@ SHADER_MAIN(Color) shaDepthFunc(GFX_LESS_EQUAL); BOOL bDoubleSided = shaGetFlags()&BASE_DOUBLE_SIDED; - BOOL bFullBright = shaGetFlags()&BASE_FULL_BRIGHT; + //BOOL bFullBright = shaGetFlags()&BASE_FULL_BRIGHT; if(bDoubleSided) { shaCullFace(GFX_NONE); diff --git a/Sources/Shaders/Common.cpp b/Sources/Shaders/Common.cpp index 957c422..83d660d 100644 --- a/Sources/Shaders/Common.cpp +++ b/Sources/Shaders/Common.cpp @@ -18,7 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc., void DoSpecularLayer(INDEX iSpeculaTexture,INDEX iSpecularColor) { - GFXVertex4 *paVertices = shaGetVertexArray(); + //GFXVertex4 *paVertices = shaGetVertexArray(); GFXNormal *paNormals = shaGetNormalArray(); INDEX ctVertices = shaGetVertexCount(); FLOAT3D vLightDir = -shaGetLightDirection().Normalize(); @@ -106,7 +106,7 @@ void DoReflectionLayer(INDEX iReflectionTexture,INDEX iReflectionColor,BOOL bFul paNormals = shaGetNormalArray(); INDEX ctVertices = shaGetVertexCount(); GFXTexCoord *ptcUVMap = shaGetNewTexCoordArray(); - Matrix12 &mObjToView = *shaGetObjToViewMatrix(); + //Matrix12 &mObjToView = *shaGetObjToViewMatrix(); Matrix12 &mObjToAbs = *shaGetObjToAbsMatrix(); CAnyProjection3D &apr = *shaGetProjection(); From dbe524f0b2697d6af060a944137c7da326a61402 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sat, 23 Apr 2016 20:25:08 +0200 Subject: [PATCH 14/34] Fix more warnings, mostly about logical op parenthesis (TSE only) except for EntitiesMP/Fish.es which I'm not sure about, and in Computer.cpp the weird "if (_iActiveMessage < _acmMessages.Count()==0)" construct whichs intention I didn't fully grasp, either. --- Sources/CMakeLists.txt | 11 +++++----- Sources/Engine/Base/Lists.cpp | 6 ++--- Sources/Engine/Classes/MovableEntity.es | 22 +++++++++---------- Sources/Engine/Entities/Entity.cpp | 12 +++++----- Sources/Engine/Math/Object3D.cpp | 2 +- Sources/Engine/Math/Projection_Isometric.cpp | 4 +++- Sources/Engine/Math/Projection_Parallel.cpp | 2 +- .../Engine/Math/Projection_Perspective.cpp | 2 +- Sources/Engine/Models/RenderModel.cpp | 4 ++-- Sources/Engine/Network/Server.cpp | 4 ++-- Sources/Engine/Rendering/RenCache.cpp | 4 ++-- Sources/Engine/Rendering/Render.cpp | 6 ++--- Sources/Engine/Rendering/RenderAdding.cpp | 2 +- Sources/Engine/Sound/SoundLibrary.cpp | 2 +- Sources/Engine/World/World.cpp | 6 ++--- Sources/EntitiesMP/Common/HUD.cpp | 2 +- Sources/EntitiesMP/Debris.es | 2 +- Sources/EntitiesMP/Dragonman.es | 4 ++-- Sources/EntitiesMP/Effector.es | 8 ++++--- Sources/EntitiesMP/Elemental.es | 2 +- Sources/EntitiesMP/Fish.es | 3 +++ Sources/EntitiesMP/Player.es | 9 ++++---- Sources/EntitiesMP/PlayerWeapons.es | 4 ++-- Sources/GameMP/Computer.cpp | 8 +++---- Sources/GameMP/Game.cpp | 8 +++---- Sources/GameMP/Game.h | 2 +- Sources/GameMP/WEDInterface.cpp | 2 +- Sources/SeriousSam/SeriousSam.cpp | 7 +++--- 28 files changed, 79 insertions(+), 71 deletions(-) diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index e40679a..e0c8929 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -110,6 +110,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -Os -fno-unsafe-math-optimizations") # TODO fix these warnings + # !!! FIXME: turn a bunch of these off, this is just for now. I hope. --ryan. add_compile_options(-Wno-sign-compare) add_compile_options(-Wno-switch) add_compile_options(-Wno-char-subscripts) @@ -117,16 +118,14 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") add_compile_options(-Wno-unused-variable) # TODO: maybe only enable this for Entities add_compile_options(-Wno-unused-value) # same here (the Scripts generate tons of unused variables and values) add_compile_options(-Wno-missing-braces) - add_compile_options(-Wno-parentheses) + add_compile_options(-Wno-overloaded-virtual) MESSAGE(WARNING, "re-enable some of the warnings some day!") if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "AppleClang") - # !!! FIXME: turn a bunch of these off, this is just for now. I hope. --ryan. - add_compile_options(-Wno-tautological-undefined-compare) + add_compile_options(-Wno-tautological-undefined-compare) # don't complain about if(this!=NULL) add_compile_options(-Wno-c++11-compat-deprecated-writable-strings) - add_compile_options(-Wno-logical-op-parentheses) # FIXME: this too should be re-enabled - else() - add_compile_options(-Wno-unused-but-set-variable) # my clang doesn't know this + else() # most probably GCC + add_compile_options(-Wno-unused-but-set-variable) # my clang doesn't know this FIXME: re-enable? endif() if(MACOSX) diff --git a/Sources/Engine/Base/Lists.cpp b/Sources/Engine/Base/Lists.cpp index c6ff234..5fe33bd 100755 --- a/Sources/Engine/Base/Lists.cpp +++ b/Sources/Engine/Base/Lists.cpp @@ -40,8 +40,8 @@ BOOL CListHead::IsValid(void) const { ASSERT(this!=NULL); ASSERT(lh_NULL == NULL); - ASSERT((lh_Head == (CListNode *) &lh_NULL) && (lh_Tail == (CListNode *) &lh_Head) - || lh_Tail->IsValid() && lh_Head->IsValid() ); + ASSERT(((lh_Head == (CListNode *) &lh_NULL) && (lh_Tail == (CListNode *) &lh_Head)) + || (lh_Tail->IsValid() && lh_Head->IsValid()) ); return TRUE; } @@ -211,7 +211,7 @@ BOOL CListNode::IsValid(void) const ASSERT((ln_Pred==NULL && ln_Succ==NULL) || (ln_Pred!=NULL && ln_Succ!=NULL)); // it is valid if it is cleared or if it is linked return (ln_Pred==NULL && ln_Succ==NULL) - || (ln_Pred->ln_Succ == this) && (ln_Succ->ln_Pred == this); + || ((ln_Pred->ln_Succ == this) && (ln_Succ->ln_Pred == this)); } /* diff --git a/Sources/Engine/Classes/MovableEntity.es b/Sources/Engine/Classes/MovableEntity.es index be11ae5..4a4a901 100644 --- a/Sources/Engine/Classes/MovableEntity.es +++ b/Sources/Engine/Classes/MovableEntity.es @@ -1009,8 +1009,8 @@ functions: } // find current breathing parameters BOOL bCanBreathe = - (ctUp.ct_ulFlags&CTF_BREATHABLE_LUNGS) && (en_ulPhysicsFlags&EPF_HASLUNGS) || - (ctUp.ct_ulFlags&CTF_BREATHABLE_GILLS) && (en_ulPhysicsFlags&EPF_HASGILLS); + ((ctUp.ct_ulFlags&CTF_BREATHABLE_LUNGS) && (en_ulPhysicsFlags&EPF_HASLUNGS)) || + ((ctUp.ct_ulFlags&CTF_BREATHABLE_GILLS) && (en_ulPhysicsFlags&EPF_HASGILLS)); TIME tmNow = _pTimer->CurrentTick(); TIME tmBreathDelay = tmNow-en_tmLastBreathed; // if entity can breathe now @@ -1207,8 +1207,8 @@ functions: // if polygon's steepness is too high CSurfaceType &stReference = en_pwoWorld->wo_astSurfaceTypes[pbpo->bpo_bppProperties.bpp_ubSurfaceType]; - if (fCos>=-stReference.st_fClimbSlopeCos&&fCos<0 - ||stReference.st_ulFlags&STF_SLIDEDOWNSLOPE) { + if ((fCos >= -stReference.st_fClimbSlopeCos && fCos<0) + || stReference.st_ulFlags&STF_SLIDEDOWNSLOPE) { // it cannot be below _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); return FALSE; @@ -1529,11 +1529,11 @@ out:; // going up or iStep==0 || // going forward and hit stairs or - iStep==1 && bHitStairsNow || + (iStep==1 && bHitStairsNow) || // going down and ends on something that is not high slope - iStep==2 && + (iStep==2 && (vHitPlane%en_vGravityDir<-stHit.st_fClimbSlopeCos || - bHitStairsNow); + bHitStairsNow)); // if early clip is allowed if (bEarlyClipAllowed || bSlidingAllowed) { @@ -2322,8 +2322,8 @@ out:; FLOAT fPlaneYAbs = Abs(fPlaneY); FLOAT fFriction = stReference.st_fFriction; // if on a steep slope - if (fPlaneY>=-stReference.st_fClimbSlopeCos&&fPlaneY<0 - ||(stReference.st_ulFlags&STF_SLIDEDOWNSLOPE)&&fPlaneY>-0.99f) { + if ((fPlaneY>=-stReference.st_fClimbSlopeCos&&fPlaneY<0) + ||((stReference.st_ulFlags&STF_SLIDEDOWNSLOPE)&&fPlaneY>-0.99f)) { en_ulPhysicsFlags|=EPF_ONSTEEPSLOPE; // accellerate horizontaly towards desired absolute translation AddAccelerationOnPlane2( @@ -2737,8 +2737,8 @@ out:; /* old */ FLOAT fPlaneYAbs = Abs(fPlaneY); /* old */ FLOAT fFriction = stReference.st_fFriction; /* old */ // if on a steep slope -/* old */ if (fPlaneY>=-stReference.st_fClimbSlopeCos&&fPlaneY<0 -/* old */ ||(stReference.st_ulFlags&STF_SLIDEDOWNSLOPE)&&fPlaneY>-0.99f) { +/* old */ if ((fPlaneY>=-stReference.st_fClimbSlopeCos&&fPlaneY<0) +/* old */ ||((stReference.st_ulFlags&STF_SLIDEDOWNSLOPE)&&fPlaneY>-0.99f)) { /* old */ en_ulPhysicsFlags|=EPF_ONSTEEPSLOPE; /* old */ // accellerate horizontaly towards desired absolute translation /* old */ AddAccelerationOnPlane2( diff --git a/Sources/Engine/Entities/Entity.cpp b/Sources/Engine/Entities/Entity.cpp index c88789b..de3acfe 100644 --- a/Sources/Engine/Entities/Entity.cpp +++ b/Sources/Engine/Entities/Entity.cpp @@ -1925,9 +1925,9 @@ void CEntity::FindSectorsAroundEntityNear(void) // (use more detailed testing for moving brushes) (en_RenderType!=RT_BRUSH|| // oriented box touches box of sector - (oboxEntity.HasContactWith(FLOATobbox3D(pbsc->bsc_boxBoundingBox)))&& + ((oboxEntity.HasContactWith(FLOATobbox3D(pbsc->bsc_boxBoundingBox)))&& // oriented box is in bsp - (pbsc->bsc_bspBSPTree.TestBox(oboxdEntity)>=0)); + (pbsc->bsc_bspBSPTree.TestBox(oboxdEntity)>=0))); // if it is not if (!bIn) { // if it has link @@ -3104,11 +3104,11 @@ void CEntity::InflictRangeDamage(CEntity *penInflictor, enum DamageType dmtType, FLOAT3D vHitPos; FLOAT fMinD; if ( - (en.en_RenderType==RT_MODEL || en.en_RenderType==RT_EDITORMODEL || + ((en.en_RenderType==RT_MODEL || en.en_RenderType==RT_EDITORMODEL || en.en_RenderType==RT_SKAMODEL || en.en_RenderType==RT_SKAEDITORMODEL )&& - CheckModelRangeDamage(en, vCenter, fMinD, vHitPos) || - (en.en_RenderType==RT_BRUSH)&& - CheckBrushRangeDamage(en, vCenter, fMinD, vHitPos)) { + CheckModelRangeDamage(en, vCenter, fMinD, vHitPos)) || + ((en.en_RenderType==RT_BRUSH)&& + CheckBrushRangeDamage(en, vCenter, fMinD, vHitPos))) { // find damage ammount FLOAT fAmmount = IntensityAtDistance(fDamageAmmount, fHotSpotRange, fFallOffRange, fMinD); diff --git a/Sources/Engine/Math/Object3D.cpp b/Sources/Engine/Math/Object3D.cpp index fb38369..0928c2f 100644 --- a/Sources/Engine/Math/Object3D.cpp +++ b/Sources/Engine/Math/Object3D.cpp @@ -81,7 +81,7 @@ void CObject3D::Project(CSimpleProjection3D_DOUBLE &pr) BOOL bXInverted = vObjectStretch(1)<0; BOOL bYInverted = vObjectStretch(2)<0; BOOL bZInverted = vObjectStretch(3)<0; - BOOL bInverted = bXInverted!=bYInverted!=bZInverted; + BOOL bInverted = (bXInverted != bYInverted) != bZInverted; // for all sectors FOREACHINDYNAMICARRAY(ob_aoscSectors, CObjectSector, itsc) { diff --git a/Sources/Engine/Math/Projection_Isometric.cpp b/Sources/Engine/Math/Projection_Isometric.cpp index 364a676..92f35d6 100644 --- a/Sources/Engine/Math/Projection_Isometric.cpp +++ b/Sources/Engine/Math/Projection_Isometric.cpp @@ -43,7 +43,9 @@ void CIsometricProjection3D::Prepare(void) BOOL bYInverted = pr_ObjectStretch(2)<0; BOOL bZInverted = pr_ObjectStretch(3)<0; - pr_bInverted = bXInverted!=bYInverted!=bZInverted; + // DG: this is true if either one of X,Y,Z is inverted, or all three + // but not if two or none are inverted. + pr_bInverted = (bXInverted != bYInverted) != bZInverted; // if the projection is mirrored if (pr_bMirror) { diff --git a/Sources/Engine/Math/Projection_Parallel.cpp b/Sources/Engine/Math/Projection_Parallel.cpp index fa0044c..2cc6ffe 100644 --- a/Sources/Engine/Math/Projection_Parallel.cpp +++ b/Sources/Engine/Math/Projection_Parallel.cpp @@ -43,7 +43,7 @@ void CParallelProjection3D::Prepare(void) BOOL bYInverted = pr_ObjectStretch(2)<0; BOOL bZInverted = pr_ObjectStretch(3)<0; - pr_bInverted = bXInverted!=bYInverted!=bZInverted; + pr_bInverted = (bXInverted != bYInverted) != bZInverted; // if the projection is mirrored if (pr_bMirror) { diff --git a/Sources/Engine/Math/Projection_Perspective.cpp b/Sources/Engine/Math/Projection_Perspective.cpp index 6d18df4..d26303a 100644 --- a/Sources/Engine/Math/Projection_Perspective.cpp +++ b/Sources/Engine/Math/Projection_Perspective.cpp @@ -52,7 +52,7 @@ void CPerspectiveProjection3D::Prepare(void) BOOL bYInverted = pr_ObjectStretch(2)<0; BOOL bZInverted = pr_ObjectStretch(3)<0; - pr_bInverted = bXInverted!=bYInverted!=bZInverted; + pr_bInverted = (bXInverted != bYInverted) != bZInverted; // if the projection is mirrored if (pr_bMirror) { diff --git a/Sources/Engine/Models/RenderModel.cpp b/Sources/Engine/Models/RenderModel.cpp index c148968..7b62f37 100644 --- a/Sources/Engine/Models/RenderModel.cpp +++ b/Sources/Engine/Models/RenderModel.cpp @@ -240,7 +240,7 @@ BOOL CModelObject::CreateAttachment( CRenderModel &rmMain, CAttachmentModelObjec _pfModelProfile.StartTimer( CModelProfile::PTI_CREATEATTACHMENT); _pfModelProfile.IncrementTimerAveragingCounter( CModelProfile::PTI_CREATEATTACHMENT); CRenderModel &rmAttached = *amo.amo_prm; - rmAttached.rm_ulFlags = rmMain.rm_ulFlags&(RMF_FOG|RMF_HAZE|RMF_WEAPON) | RMF_ATTACHMENT; + rmAttached.rm_ulFlags = (rmMain.rm_ulFlags & (RMF_FOG|RMF_HAZE|RMF_WEAPON)) | RMF_ATTACHMENT; // get the position rmMain.rm_pmdModelData->md_aampAttachedPosition.Lock(); @@ -493,7 +493,7 @@ void CModelObject::SetupModelRendering( CRenderModel &rm) BOOL bYInverted = rm.rm_vStretch(2) < 0; BOOL bZInverted = rm.rm_vStretch(3) < 0; rm.rm_ulFlags &= ~RMF_INVERTED; - if( bXInverted != bYInverted != bZInverted != _aprProjection->pr_bInverted) rm.rm_ulFlags |= RMF_INVERTED; + if( ((bXInverted != bYInverted) != bZInverted) != _aprProjection->pr_bInverted) rm.rm_ulFlags |= RMF_INVERTED; // prepare projections _pfModelProfile.StartTimer( CModelProfile::PTI_INITPROJECTION); diff --git a/Sources/Engine/Network/Server.cpp b/Sources/Engine/Network/Server.cpp index 4229ec0..084e417 100644 --- a/Sources/Engine/Network/Server.cpp +++ b/Sources/Engine/Network/Server.cpp @@ -459,8 +459,8 @@ void CServer::SendGameStreamBlocks(INDEX iClient) nmGameStreamBlocks.PackDefault(nmPackedBlocksNew); // if some blocks written already and the batch is too large if (iBlocksOk>0) { - if (iStep>0 && nmPackedBlocksNew.nm_slSize>=ctMaxBytes || - iStep<0 && nmPackedBlocksNew.nm_slSize>=ctMinBytes ) { + if ((iStep>0 && nmPackedBlocksNew.nm_slSize>=ctMaxBytes) || + (iStep<0 && nmPackedBlocksNew.nm_slSize>=ctMinBytes) ) { // stop // CPrintF("toomuch "); break; diff --git a/Sources/Engine/Rendering/RenCache.cpp b/Sources/Engine/Rendering/RenCache.cpp index 2297b58..dfc631d 100644 --- a/Sources/Engine/Rendering/RenCache.cpp +++ b/Sources/Engine/Rendering/RenCache.cpp @@ -449,8 +449,8 @@ inline void CRenderer::MakeScreenEdge( sed.sed_xI = (FIX16_16) (fI0 + ((FLOAT)sed.sed_pixTopJ-fJ0) * fDIoDJ ); } - ASSERT( sed.sed_xI > FIX16_16(-1.0f) - && sed.sed_xI < FIX16_16(re_fbbClipBox.Max()(1) + SENTINELEDGE_EPSILON) + ASSERT( (sed.sed_xI > FIX16_16(-1.0f) + && sed.sed_xI < FIX16_16(re_fbbClipBox.Max()(1) + SENTINELEDGE_EPSILON)) || (sed.sed_pixTopJ >= sed.sed_pixBottomJ)); // return the screen edge diff --git a/Sources/Engine/Rendering/Render.cpp b/Sources/Engine/Rendering/Render.cpp index 62c1450..7c23e99 100644 --- a/Sources/Engine/Rendering/Render.cpp +++ b/Sources/Engine/Rendering/Render.cpp @@ -870,9 +870,9 @@ void CRenderer::Render(void) // or not rendering second layer in world editor // and not in wireframe mode if( re_iIndex>0 - || !re_bRenderingShadows - && !re_pdpDrawPort->IsOverlappedRendering() - && _wrpWorldRenderPrefs.wrp_ftPolygons != CWorldRenderPrefs::FT_NONE) { + || (!re_bRenderingShadows + && !re_pdpDrawPort->IsOverlappedRendering() + && _wrpWorldRenderPrefs.wrp_ftPolygons != CWorldRenderPrefs::FT_NONE)) { re_pdpDrawPort->FillZBuffer(ZBUF_BACK); } // draw the prepared things to screen and finish diff --git a/Sources/Engine/Rendering/RenderAdding.cpp b/Sources/Engine/Rendering/RenderAdding.cpp index 50f7827..807f428 100644 --- a/Sources/Engine/Rendering/RenderAdding.cpp +++ b/Sources/Engine/Rendering/RenderAdding.cpp @@ -762,7 +762,7 @@ void CRenderer::AddZoningSectorsAroundBox(const FLOATaabbox3D &boxNear) continue; } // if it is not zoning brush - if (iten->en_RenderType!=CEntity::RT_BRUSH && iten->en_RenderType!=CEntity::RT_FIELDBRUSH + if ((iten->en_RenderType!=CEntity::RT_BRUSH && iten->en_RenderType!=CEntity::RT_FIELDBRUSH) ||!(iten->en_ulFlags&ENF_ZONING)) { // skip it continue; diff --git a/Sources/Engine/Sound/SoundLibrary.cpp b/Sources/Engine/Sound/SoundLibrary.cpp index 52ef87a..f1e4df3 100644 --- a/Sources/Engine/Sound/SoundLibrary.cpp +++ b/Sources/Engine/Sound/SoundLibrary.cpp @@ -1661,7 +1661,7 @@ void CSoundLibrary::MixSounds(void) _pfSoundProfile.IncrementCounter(CSoundProfile::PCI_MIXINGS, 1); ResetMixer( sl_pslMixerBuffer, slDataToMix); - BOOL bGamePaused = _pNetwork->IsPaused() || _pNetwork->IsServer() && _pNetwork->GetLocalPause(); + BOOL bGamePaused = _pNetwork->IsPaused() || (_pNetwork->IsServer() && _pNetwork->GetLocalPause()); // for each sound FOREACHINLIST( CSoundData, sd_Node, sl_ClhAwareList, itCsdSoundData) { diff --git a/Sources/Engine/World/World.cpp b/Sources/Engine/World/World.cpp index d524e2f..bff7b76 100644 --- a/Sources/Engine/World/World.cpp +++ b/Sources/Engine/World/World.cpp @@ -546,7 +546,7 @@ void CWorld::FindShadowLayers( CLightSource *pls = iten->GetLightSource(); if (pls!=NULL) { FLOATaabbox3D boxLight(iten->en_plPlacement.pl_PositionVector, pls->ls_rFallOff); - if ( bDirectional && (pls->ls_ulFlags &LSF_DIRECTIONAL) + if ( (bDirectional && (pls->ls_ulFlags & LSF_DIRECTIONAL)) ||boxLight.HasContactWith(boxNear)) { // find layers for that light source pls->FindShadowLayers(bSelectedOnly); @@ -970,8 +970,8 @@ void CWorld::MarkForPrediction(void) // find whether it is local BOOL bLocal = _pNetwork->IsPlayerLocal(pen); // if allowed for prediction - if ( bLocal && cli_bPredictLocalPlayers - || !bLocal && cli_bPredictRemotePlayers) { + if ( (bLocal && cli_bPredictLocalPlayers) + || (!bLocal && cli_bPredictRemotePlayers)) { // add it pen->AddToPrediction(); } diff --git a/Sources/EntitiesMP/Common/HUD.cpp b/Sources/EntitiesMP/Common/HUD.cpp index aeef67c..e4360d6 100644 --- a/Sources/EntitiesMP/Common/HUD.cpp +++ b/Sources/EntitiesMP/Common/HUD.cpp @@ -1181,7 +1181,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO if( iHealth>25) colHealth = _colHUD; if( iArmor >25) colArmor = _colHUD; // eventually print it out - if( hud_iShowPlayers==1 || hud_iShowPlayers==-1 && !bSinglePlay) { + if( hud_iShowPlayers==1 || (hud_iShowPlayers==-1 && !bSinglePlay)) { // printout location and info aren't the same for deathmatch and coop play const FLOAT fCharWidth = (PIX)((_pfdDisplayFont->GetWidth()-2) *fTextScale); if( bCooperative) { diff --git a/Sources/EntitiesMP/Debris.es b/Sources/EntitiesMP/Debris.es index 7354e2a..4a6cd59 100644 --- a/Sources/EntitiesMP/Debris.es +++ b/Sources/EntitiesMP/Debris.es @@ -99,7 +99,7 @@ functions: { // cannot be damaged immediately after spawning if ((_pTimer->CurrentTick()-m_tmStarted<1.0f) - ||(dmtType==DMT_CANNONBALL_EXPLOSION) && (_pTimer->CurrentTick()-m_tmStarted<5.0f)) { + ||((dmtType==DMT_CANNONBALL_EXPLOSION) && (_pTimer->CurrentTick()-m_tmStarted<5.0f))) { return; } CMovableModelEntity::ReceiveDamage(penInflictor, dmtType, fDamageAmmount, vHitPoint, vDirection); diff --git a/Sources/EntitiesMP/Dragonman.es b/Sources/EntitiesMP/Dragonman.es index 4f03e16..fb6052c 100644 --- a/Sources/EntitiesMP/Dragonman.es +++ b/Sources/EntitiesMP/Dragonman.es @@ -459,8 +459,8 @@ procedures: Hit(EVoid) : CEnemyBase::Hit { // burn enemy - if (m_EdtType == DT_SERGEANT && CalcDist(m_penEnemy) <= 6.0f || - m_EdtType == DT_MONSTER && CalcDist(m_penEnemy) <= 20.0f) { + if ((m_EdtType == DT_SERGEANT && CalcDist(m_penEnemy) <= 6.0f) || + (m_EdtType == DT_MONSTER && CalcDist(m_penEnemy) <= 20.0f)) { jump BurnEnemy(); } diff --git a/Sources/EntitiesMP/Effector.es b/Sources/EntitiesMP/Effector.es index 0d9d873..f75b28e 100644 --- a/Sources/EntitiesMP/Effector.es +++ b/Sources/EntitiesMP/Effector.es @@ -125,7 +125,7 @@ functions: void AdjustMipFactor(FLOAT &fMipFactor) { - if (m_eetType==ET_DISAPPEAR_MODEL || m_eetType==ET_DISAPPEAR_MODEL_NOW && m_penModel!=NULL) + if (m_eetType==ET_DISAPPEAR_MODEL || (m_eetType==ET_DISAPPEAR_MODEL_NOW && m_penModel!=NULL)) { CModelObject *pmo = m_penModel->GetModelObject(); TIME tmDelta = _pTimer->GetLerpedCurrentTick()-m_tmStarted; @@ -146,7 +146,7 @@ functions: COLOR col = C_WHITE|ubAlpha; pmo->mo_colBlendColor = col; } - if (m_eetType==ET_APPEAR_MODEL || m_eetType==ET_APPEAR_MODEL_NOW && m_penModel!=NULL) + if (m_eetType==ET_APPEAR_MODEL || (m_eetType==ET_APPEAR_MODEL_NOW && m_penModel!=NULL)) { CModelObject *pmo = m_penModel->GetModelObject(); TIME tmDelta = _pTimer->GetLerpedCurrentTick()-m_tmStarted; @@ -449,7 +449,9 @@ procedures: // setup light source if (m_bLightSource) { SetupLightSource(); } - while(_pTimer->CurrentTick()CurrentTick()CurrentTick()CurrentTick()CurrentTick()IsPredicted()||IsPredictor()&&m_penView->IsPredictor()||!IsPredicted()&&!m_penView->IsPredicted()&&!IsPredictor()&&!m_penView->IsPredictor()); + ASSERT((IsPredicted()&&m_penView->IsPredicted()) || (IsPredictor()&&m_penView->IsPredictor()) + || (!IsPredicted()&&!m_penView->IsPredicted()&&!IsPredictor()&&!m_penView->IsPredictor())); en_plViewpoint.pl_PositionVector = FLOAT3D(0, 1, 0); en_plViewpoint.pl_OrientationAngle += (ANGLE3D( (ANGLE)((FLOAT)paAction.pa_aRotation(1)*_pTimer->TickQuantum), diff --git a/Sources/EntitiesMP/PlayerWeapons.es b/Sources/EntitiesMP/PlayerWeapons.es index 4ab5858..1b2176a 100755 --- a/Sources/EntitiesMP/PlayerWeapons.es +++ b/Sources/EntitiesMP/PlayerWeapons.es @@ -1101,7 +1101,7 @@ functions: } } // apply cannon draw - else if( (m_iCurrentWeapon == WEAPON_IRONCANNON) /*|| + else if( m_iCurrentWeapon == WEAPON_IRONCANNON /*|| (m_iCurrentWeapon == WEAPON_NUKECANNON) */) { FLOAT fLerpedMovement = Lerp(m_fWeaponDrawPowerOld, m_fWeaponDrawPower, _pTimer->GetLerpFactor()); @@ -4008,7 +4008,7 @@ procedures: GetAnimator()->FireAnimation(BODY_ANIM_SHOTGUN_FIRESHORT, AOF_LOOPING); } else if (m_iCurrentWeapon==WEAPON_TOMMYGUN) { autocall TommyGunStart() EEnd; - } else if ((m_iCurrentWeapon==WEAPON_IRONCANNON) /*|| (m_iCurrentWeapon==WEAPON_NUKECANNON)*/) { + } else if (m_iCurrentWeapon==WEAPON_IRONCANNON /*|| (m_iCurrentWeapon==WEAPON_NUKECANNON)*/) { jump CannonFireStart(); } diff --git a/Sources/GameMP/Computer.cpp b/Sources/GameMP/Computer.cpp index e1106e1..fa6cba2 100644 --- a/Sources/GameMP/Computer.cpp +++ b/Sources/GameMP/Computer.cpp @@ -246,7 +246,7 @@ void LastUnreadMessage(void) // go to next/previous message void PrevMessage(void) { - if (_iActiveMessage<_acmMessages.Count()==0) { + if (_iActiveMessage < _acmMessages.Count()==0) { // FIXME: DG: what is this about? return; } _iActiveMessage--; @@ -258,7 +258,7 @@ void PrevMessage(void) void NextMessage(void) { - if (_iActiveMessage<_acmMessages.Count()==0) { + if (_iActiveMessage < _acmMessages.Count()==0) { // FIXME: DG: what is this about? return; } _iActiveMessage++; @@ -305,7 +305,7 @@ void MessageTextUp(INDEX ctLines) void MessageTextDn(INDEX ctLines) { // if no message do nothing - if (_iActiveMessage<_acmMessages.Count()==0) { + if (_iActiveMessage < _acmMessages.Count()==0) { // FIXME: DG: what is this about? return; } // find text lines count @@ -874,7 +874,7 @@ static void ComputerOff(void) static void ExitRequested(void) { // if end of game - if (_ppenPlayer!=NULL && _ppenPlayer->m_bEndOfGame || _pNetwork->IsGameFinished()) { + if ((_ppenPlayer!=NULL && _ppenPlayer->m_bEndOfGame) || _pNetwork->IsGameFinished()) { // if in single player if (GetSP()->sp_bSinglePlayer) { // request app to show high score diff --git a/Sources/GameMP/Game.cpp b/Sources/GameMP/Game.cpp index 47bc642..0b9a2dd 100755 --- a/Sources/GameMP/Game.cpp +++ b/Sources/GameMP/Game.cpp @@ -1987,12 +1987,12 @@ static void MakeSplitDrawports(enum CGame::SplitScreenCfg ssc, INDEX iCount, CDr } // if one player or observer with one screen - if (ssc==CGame::SSC_PLAY1 || ssc==CGame::SSC_OBSERVER && iCount==1) { + if (ssc==CGame::SSC_PLAY1 || (ssc==CGame::SSC_OBSERVER && iCount==1)) { // the only drawport covers entire screen adpDrawPorts[0] = CDrawPort( pdp, 0.0, 0.0, 1.0, 1.0); apdpDrawPorts[0] = &adpDrawPorts[0]; // if two players or observer with two screens - } else if (ssc==CGame::SSC_PLAY2 || ssc==CGame::SSC_OBSERVER && iCount==2) { + } else if (ssc==CGame::SSC_PLAY2 || (ssc==CGame::SSC_OBSERVER && iCount==2)) { // if the drawport is not dualhead if (!pdp->IsDualHead()) { // need two drawports for filling the empty spaces left and right @@ -2016,7 +2016,7 @@ static void MakeSplitDrawports(enum CGame::SplitScreenCfg ssc, INDEX iCount, CDr apdpDrawPorts[1] = &adpDrawPorts[1]; } // if three players or observer with three screens - } else if (ssc==CGame::SSC_PLAY3 || ssc==CGame::SSC_OBSERVER && iCount==3) { + } else if (ssc==CGame::SSC_PLAY3 || (ssc==CGame::SSC_OBSERVER && iCount==3)) { // if the drawport is not dualhead if (!pdp->IsDualHead()) { // need two drawports for filling the empty spaces left and right @@ -2053,7 +2053,7 @@ static void MakeSplitDrawports(enum CGame::SplitScreenCfg ssc, INDEX iCount, CDr apdpDrawPorts[2] = &adpDrawPorts[2]; } // if four players or observer with four screens - } else if (ssc==CGame::SSC_PLAY4 || ssc==CGame::SSC_OBSERVER && iCount==4) { + } else if (ssc==CGame::SSC_PLAY4 || (ssc==CGame::SSC_OBSERVER && iCount==4)) { // if the drawport is not dualhead if (!pdp->IsDualHead()) { // first of four draw ports covers upper-left part of the screen diff --git a/Sources/GameMP/Game.h b/Sources/GameMP/Game.h index f2289a1..5821ae2 100644 --- a/Sources/GameMP/Game.h +++ b/Sources/GameMP/Game.h @@ -76,7 +76,7 @@ class CButtonAction { public: // default constructor CButtonAction(); - ~CButtonAction() {} + virtual ~CButtonAction() {} CListNode ba_lnNode; INDEX ba_iFirstKey; BOOL ba_bFirstKeyDown; diff --git a/Sources/GameMP/WEDInterface.cpp b/Sources/GameMP/WEDInterface.cpp index fc6e8e0..7caf78b 100644 --- a/Sources/GameMP/WEDInterface.cpp +++ b/Sources/GameMP/WEDInterface.cpp @@ -116,7 +116,7 @@ void CGame::QuickTest(const CTFileName &fnMapName, // if it is not a mouse message if( !(msg.message>=WM_MOUSEFIRST && msg.message<=WM_MOUSELAST)) { // if not system key messages - if( !(msg.message==WM_KEYDOWN && msg.wParam==VK_F10 + if( !((msg.message==WM_KEYDOWN && msg.wParam==VK_F10) ||msg.message==WM_SYSKEYDOWN)) { // dispatch it TranslateMessage(&msg); diff --git a/Sources/SeriousSam/SeriousSam.cpp b/Sources/SeriousSam/SeriousSam.cpp index 9b76471..1a15bcf 100644 --- a/Sources/SeriousSam/SeriousSam.cpp +++ b/Sources/SeriousSam/SeriousSam.cpp @@ -744,8 +744,8 @@ void DoGame(void) // set flag if not in game if( !_pGame->gm_bGameOn) _gmRunningGameMode = GM_NONE; - if( _gmRunningGameMode==GM_DEMO && _pNetwork->IsDemoPlayFinished() - ||_gmRunningGameMode==GM_INTRO && _pNetwork->IsGameFinished()) { + if( (_gmRunningGameMode==GM_DEMO && _pNetwork->IsDemoPlayFinished()) + ||(_gmRunningGameMode==GM_INTRO && _pNetwork->IsGameFinished())) { _pGame->StopGame(); _gmRunningGameMode = GM_NONE; @@ -942,7 +942,7 @@ int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int // if it is not a mouse message if( !(msg.message>=WM_MOUSEFIRST && msg.message<=WM_MOUSELAST) ) { // if not system key messages - if( !(msg.message==WM_KEYDOWN && msg.wParam==VK_F10 + if( !((msg.message==WM_KEYDOWN && msg.wParam==VK_F10) ||msg.message==WM_SYSKEYDOWN)) { // dispatch it TranslateMessage(&msg); @@ -1171,6 +1171,7 @@ int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int // if toggling console BOOL bConsoleKey = sam_bToggleConsole || msg.message==WM_KEYDOWN && // !!! FIXME: rcg11162001 This sucks. + // FIXME: DG: we could use SDL_SCANCODE_GRAVE ? #ifdef PLATFORM_UNIX (msg.wParam == SDLK_BACKQUOTE #else From 1bfc6d5d8194bc6e527cff5d187920f27dfbc041 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sun, 24 Apr 2016 00:53:13 +0200 Subject: [PATCH 15/34] Fix "unused but set variable" warnings from GCC --- Sources/Engine/Base/Anim.cpp | 4 ++-- Sources/Engine/Graphics/Gfx_OpenGL.cpp | 4 ++-- Sources/Engine/Graphics/Graphics.cpp | 4 ++-- Sources/Engine/Models/RenderModel_View.cpp | 4 ++-- Sources/Engine/Network/ClientInterface.cpp | 8 ++++---- Sources/Engine/Network/Diff.cpp | 4 ++-- Sources/Engine/Network/SessionState.cpp | 4 ++-- Sources/Engine/Ska/Mesh.cpp | 6 +++--- Sources/Engine/Templates/BSP.cpp | 2 ++ Sources/Engine/Terrain/Terrain.cpp | 6 ++++-- Sources/Engine/World/WorldCSG.cpp | 3 +++ Sources/EntitiesMP/Common/Particles.cpp | 6 +++--- Sources/EntitiesMP/CreditsHolder.es | 4 ++-- Sources/EntitiesMP/Elemental.es | 18 +++++++++--------- Sources/EntitiesMP/Fish.es | 2 +- Sources/EntitiesMP/Item.es | 8 ++++---- Sources/EntitiesMP/ModelHolder2.es | 2 +- Sources/EntitiesMP/PlayerAnimator.es | 2 +- Sources/EntitiesMP/PlayerWeapons.es | 2 +- Sources/EntitiesMP/PyramidSpaceShip.es | 2 +- Sources/EntitiesMP/SpawnerProjectile.es | 3 ++- Sources/GameMP/Controls.cpp | 4 ++-- Sources/SeriousSam/Menu.cpp | 1 + Sources/Shaders/Common.cpp | 4 ++-- 24 files changed, 58 insertions(+), 49 deletions(-) diff --git a/Sources/Engine/Base/Anim.cpp b/Sources/Engine/Base/Anim.cpp index d686832..e491e12 100644 --- a/Sources/Engine/Base/Anim.cpp +++ b/Sources/Engine/Base/Anim.cpp @@ -296,13 +296,13 @@ void CAnimData::LoadFromScript_t( CTStream *File, CListHead *pFrameFileList) // char ld_line[ 128]; CTmpListHead TempAnimationList; SLONG lc; - BOOL ret_val; + //BOOL ret_val; //ASSERT( ad_Anims == NULL); // clears possible animations CAnimData::Clear(); - ret_val = TRUE; + //ret_val = TRUE; FOREVER { // Repeat reading of one line of script file until it is not empty or comment diff --git a/Sources/Engine/Graphics/Gfx_OpenGL.cpp b/Sources/Engine/Graphics/Gfx_OpenGL.cpp index e0696e4..dd549d9 100644 --- a/Sources/Engine/Graphics/Gfx_OpenGL.cpp +++ b/Sources/Engine/Graphics/Gfx_OpenGL.cpp @@ -505,9 +505,9 @@ extern void SetTBufferEffect( BOOL bEnable) if( ogl_iTBufferEffect==0 || _pGfx->go_ctSampleBuffers<2 || !bEnable) pglDisable( GL_MULTISAMPLE_3DFX); else { pglEnable( GL_MULTISAMPLE_3DFX); - UINT uiMask = 0xFFFFFFFF; + //UINT uiMask = 0xFFFFFFFF; // set one buffer in case of motion-blur - if( ogl_iTBufferEffect==2) uiMask = (1UL) << _pGfx->go_iCurrentWriteBuffer; + //if( ogl_iTBufferEffect==2) uiMask = (1UL) << _pGfx->go_iCurrentWriteBuffer; //pglTBufferMask3DFX(uiMask); } } diff --git a/Sources/Engine/Graphics/Graphics.cpp b/Sources/Engine/Graphics/Graphics.cpp index b1d6f13..4f3dc06 100644 --- a/Sources/Engine/Graphics/Graphics.cpp +++ b/Sources/Engine/Graphics/Graphics.cpp @@ -548,7 +548,7 @@ void ColorizeMipmaps( INDEX i1stMipmapToColorize, ULONG *pulMipmaps, PIX pixWidt { // prepare ... ULONG *pulSrcMipmap = pulMipmaps + GetMipmapOffset( i1stMipmapToColorize, pixWidth, pixHeight); - ULONG *pulDstMipmap; + //ULONG *pulDstMipmap; PIX pixCurrWidth = pixWidth >>i1stMipmapToColorize; PIX pixCurrHeight = pixHeight>>i1stMipmapToColorize; PIX pixMipSize; @@ -561,7 +561,7 @@ void ColorizeMipmaps( INDEX i1stMipmapToColorize, ULONG *pulMipmaps, PIX pixWidt while( pixCurrWidth>1 && pixCurrHeight>1) { // prepare current mip-level pixMipSize = pixCurrWidth*pixCurrHeight; - pulDstMipmap = pulSrcMipmap + pixMipSize; + //pulDstMipmap = pulSrcMipmap + pixMipSize; // mask mipmap const ULONG ulColorMask = ByteSwap( _acolMips[iTableOfs] | 0x3F3F3FFF); for( INDEX iPix=0; iPixpa_ulSequence,FALSE); delete ppaPacket; - bSomethingDone = TRUE; + //bSomethingDone = TRUE; // if the packet is reliable } else if (ppaPacket->pa_ubReliable & UDP_PACKET_RELIABLE) { @@ -547,7 +547,7 @@ BOOL CClientInterface::UpdateInputBuffers(void) // packet separately, instead of grouping them together BOOL CClientInterface::UpdateInputBuffersBroadcast(void) { - BOOL bSomethingDone; + //BOOL bSomethingDone; CTimerValue tvNow; // if there are packets in the input buffer, process them @@ -585,7 +585,7 @@ BOOL CClientInterface::UpdateInputBuffersBroadcast(void) } ci_pbInputBuffer.RemovePacket(ppaPacket->pa_ulSequence,FALSE); - bSomethingDone = TRUE; + //bSomethingDone = TRUE; delete ppaPacket; // if the packet is reliable } else if (ppaPacket->pa_ubReliable & UDP_PACKET_RELIABLE) { diff --git a/Sources/Engine/Network/Diff.cpp b/Sources/Engine/Network/Diff.cpp index 11d3541..cd1c084 100644 --- a/Sources/Engine/Network/Diff.cpp +++ b/Sources/Engine/Network/Diff.cpp @@ -224,14 +224,14 @@ void UnDiff_t(void) //UBYTE *pubOld = _pubOld; UBYTE *pubNew = _pubNew; SLONG slSizeOldStream = 0; - SLONG slSizeOutStream = 0; + //SLONG slSizeOutStream = 0; // get header with size of files if (*(SLONG*)pubNew!=DIFF) { ThrowF_t(TRANS("Not a DIFF stream!")); } pubNew+=sizeof(SLONG); slSizeOldStream = *(SLONG*)pubNew; pubNew+=sizeof(SLONG); - slSizeOutStream = *(SLONG*)pubNew; pubNew+=sizeof(SLONG); + /* slSizeOutStream = *(SLONG*)pubNew; */ pubNew+=sizeof(SLONG); ULONG ulCRC = *(ULONG*)pubNew; pubNew+=sizeof(ULONG); CRC_Start(_ulCRC); diff --git a/Sources/Engine/Network/SessionState.cpp b/Sources/Engine/Network/SessionState.cpp index 4475483..cdc3b9e 100644 --- a/Sources/Engine/Network/SessionState.cpp +++ b/Sources/Engine/Network/SessionState.cpp @@ -695,7 +695,7 @@ void CSessionState::HandleMovers(void) void CSessionState::HandleTimers(TIME tmCurrentTick) { #define TIME_EPSILON 0.0001f - IFDEBUG(TIME tmLast = 0.0f); + //IFDEBUG(TIME tmLast = 0.0f); _pfPhysicsProfile.StartTimer(CPhysicsProfile::PTI_HANDLETIMERS); // repeat @@ -729,7 +729,7 @@ void CSessionState::HandleTimers(TIME tmCurrentTick) // check that timers are propertly handled ASSERT(penTimer->en_timeTimer>tmCurrentTick-_pTimer->TickQuantum-TIME_EPSILON); //ASSERT(penTimer->en_timeTimer>=tmLast); - IFDEBUG(tmLast=penTimer->en_timeTimer); + //IFDEBUG(tmLast=penTimer->en_timeTimer); // remove the timer from the list penTimer->en_timeTimer = THINKTIME_NEVER; diff --git a/Sources/Engine/Ska/Mesh.cpp b/Sources/Engine/Ska/Mesh.cpp index 769b4fe..b5fe256 100644 --- a/Sources/Engine/Ska/Mesh.cpp +++ b/Sources/Engine/Ska/Mesh.cpp @@ -789,7 +789,7 @@ void CMesh::Read_t(CTStream *istrFile) // read float count (*istrFile)>>ctfl; - CShader *pshMeshShader = NULL; + //CShader *pshMeshShader = NULL; ShaderParams *pshpShaderParams = NULL; CShader shDummyShader; // dummy shader if shader is not found ShaderParams shpDummyShaderParams;// dummy shader params if shader is not found @@ -799,12 +799,12 @@ void CMesh::Read_t(CTStream *istrFile) // try to load shader try{ msrf.msrf_pShader = _pShaderStock->Obtain_t(strShaderName); - pshMeshShader = msrf.msrf_pShader; + //pshMeshShader = msrf.msrf_pShader; pshpShaderParams = &msrf.msrf_ShadingParams; } catch(char *strErr) { CPrintF("%s\n",strErr); msrf.msrf_pShader = NULL; - pshMeshShader = &shDummyShader; + //pshMeshShader = &shDummyShader; pshpShaderParams = &shpDummyShaderParams; } diff --git a/Sources/Engine/Templates/BSP.cpp b/Sources/Engine/Templates/BSP.cpp index 78b26ec..32dce0e 100644 --- a/Sources/Engine/Templates/BSP.cpp +++ b/Sources/Engine/Templates/BSP.cpp @@ -186,6 +186,8 @@ void BSPVertexContainer::Sort(void) template void BSPVertexContainer::ElliminatePairedVertices(void) { + // FIXME: DG: am I missing something or is this function not actually changing anything? + // if there are no vertices, or the container is not line if (bvc_aVertices.Count()==0 || IsPlannar()) { // do not attempt to sort diff --git a/Sources/Engine/Terrain/Terrain.cpp b/Sources/Engine/Terrain/Terrain.cpp index 4789c85..9af3da6 100644 --- a/Sources/Engine/Terrain/Terrain.cpp +++ b/Sources/Engine/Terrain/Terrain.cpp @@ -202,13 +202,14 @@ void CTerrain::CreateEmptyTerrain_t(PIX pixWidth,PIX pixHeight) void CTerrain::ImportHeightMap_t(CTFileName fnHeightMap, BOOL bUse16b/*=TRUE*/) { _ptrTerrain = this; - BOOL bResizeTerrain = FALSE; + //BOOL bResizeTerrain = FALSE; // Load targa file CImageInfo iiHeightMap; iiHeightMap.LoadAnyGfxFormat_t(fnHeightMap); - // if new width and height are same + // if new width and height are same + /* unused if(tr_pixHeightMapWidth==iiHeightMap.ii_Width && tr_pixHeightMapHeight==iiHeightMap.ii_Height) { // Clear terrain data without removing layers bResizeTerrain = FALSE; @@ -217,6 +218,7 @@ void CTerrain::ImportHeightMap_t(CTFileName fnHeightMap, BOOL bUse16b/*=TRUE*/) bResizeTerrain = TRUE; } bResizeTerrain = TRUE; + */ FLOAT fLogWidht = Log2(iiHeightMap.ii_Width-1); FLOAT fLogHeight = Log2(iiHeightMap.ii_Height-1); diff --git a/Sources/Engine/World/WorldCSG.cpp b/Sources/Engine/World/WorldCSG.cpp index 6db1a7f..f68e55c 100644 --- a/Sources/Engine/World/WorldCSG.cpp +++ b/Sources/Engine/World/WorldCSG.cpp @@ -1004,6 +1004,9 @@ void CWorld::DeleteSectors(CBrushSectorSelection &selbscSectorsToDelete, BOOL bC void CheckOnePolygon(CBrushSector &bsc, CBrushPolygon &bpo) { + // NOTE: This function has no side effects, but I think "Check" means + // "try to access stuff and make sure it doesn't segfault", so keep it + // like it is even if the compiler complains about unused values? CBrushPlane *pbplPlane=bpo.bpo_pbplPlane; INDEX ctEdges=bpo.bpo_abpePolygonEdges.Count(); INDEX ctVertices=bpo.bpo_apbvxTriangleVertices.Count(); diff --git a/Sources/EntitiesMP/Common/Particles.cpp b/Sources/EntitiesMP/Common/Particles.cpp index 8651db7..c369d05 100755 --- a/Sources/EntitiesMP/Common/Particles.cpp +++ b/Sources/EntitiesMP/Common/Particles.cpp @@ -1035,9 +1035,9 @@ void Particles_BeastProjectileTrail( CEntity *pen, FLOAT fSize, FLOAT fHeight, I fT *= 1/BEAST_PROJECTILE_TOTAL_TIME; // get fraction part fT = fT-int(fT); - FLOAT fFade; - if (fT>(1.0f-BEAST_PROJECTILE_FADE_OUT)) fFade=(1-fT)*(1/BEAST_PROJECTILE_FADE_OUT); - else fFade=1.0f; + //FLOAT fFade; + //if (fT>(1.0f-BEAST_PROJECTILE_FADE_OUT)) fFade=(1-fT)*(1/BEAST_PROJECTILE_FADE_OUT); + //else fFade=1.0f; #define GET_POS( time) vCenter + \ vX*(afStarsPositions[iStar][0]*time*fSize*1.5) +\ diff --git a/Sources/EntitiesMP/CreditsHolder.es b/Sources/EntitiesMP/CreditsHolder.es index 019d4d2..86a36ac 100644 --- a/Sources/EntitiesMP/CreditsHolder.es +++ b/Sources/EntitiesMP/CreditsHolder.es @@ -198,7 +198,7 @@ functions: return 1; } - PIX pixW = 0; + //PIX pixW = 0; PIX pixH = 0; //FLOAT fResolutionScaling; CTString strEmpty; @@ -209,7 +209,7 @@ functions: pdp->Unlock(); pdpCurr->Lock(); - pixW = pdpCurr->GetWidth(); + //pixW = pdpCurr->GetWidth(); pixH = pdpCurr->GetHeight(); FLOAT fResFactor = pixH/480.0f; diff --git a/Sources/EntitiesMP/Elemental.es b/Sources/EntitiesMP/Elemental.es index df30d95..1c65808 100644 --- a/Sources/EntitiesMP/Elemental.es +++ b/Sources/EntitiesMP/Elemental.es @@ -873,20 +873,20 @@ functions: GetBoundingBox(box); FLOAT fEntitySize = box.Size().MaxNorm()/2; - INDEX iCount = 1; + FLOAT3D vNormalizedDamage = m_vDamage-m_vDamage*(m_fBlowUpAmount/m_vDamage.Length()); + vNormalizedDamage /= Sqrt(vNormalizedDamage.Length()); + vNormalizedDamage *= 1.75f; +/* + FLOAT3D vBodySpeed = en_vCurrentTranslationAbsolute-en_vGravityDir*(en_vGravityDir%en_vCurrentTranslationAbsolute); + + // spawn debris + + INDEX iCount = 1; switch (m_EecChar) { case ELC_SMALL: iCount = 3; break; case ELC_BIG: iCount = 5; break; case ELC_LARGE: iCount = 7; break; } - - FLOAT3D vNormalizedDamage = m_vDamage-m_vDamage*(m_fBlowUpAmount/m_vDamage.Length()); - vNormalizedDamage /= Sqrt(vNormalizedDamage.Length()); - vNormalizedDamage *= 1.75f; - FLOAT3D vBodySpeed = en_vCurrentTranslationAbsolute-en_vGravityDir*(en_vGravityDir%en_vCurrentTranslationAbsolute); - - // spawn debris -/* switch (m_EetType) { case ELT_ICE: { Debris_Begin(EIBT_ICE, DPT_NONE, BET_NONE, fEntitySize, vNormalizedDamage, vBodySpeed, 1.0f, 0.0f); diff --git a/Sources/EntitiesMP/Fish.es b/Sources/EntitiesMP/Fish.es index 8ab8a6e..9d3e60a 100755 --- a/Sources/EntitiesMP/Fish.es +++ b/Sources/EntitiesMP/Fish.es @@ -140,7 +140,7 @@ functions: // render one lightning toward enemy FLOAT3D vSource = GetPlacement().pl_PositionVector; FLOAT3D vTarget = m_penEnemy->GetPlacement().pl_PositionVector; - FLOAT3D vDirection = (vTarget-vSource).Normalize(); + //FLOAT3D vDirection = (vTarget-vSource).Normalize(); Particles_Ghostbuster(vSource, vTarget, 32, 1.0f); // random lightnings arround diff --git a/Sources/EntitiesMP/Item.es b/Sources/EntitiesMP/Item.es index e07f23b..284cd97 100644 --- a/Sources/EntitiesMP/Item.es +++ b/Sources/EntitiesMP/Item.es @@ -73,7 +73,7 @@ functions: return; } - BOOL bFlare = TRUE; + //BOOL bFlare = TRUE; // if current player has already picked this item if (_ulPlayerRenderingMask&m_ulPickedMask) { // if picked items are not rendered @@ -83,11 +83,11 @@ functions: fMipFactor = UpperLimit(0.0f); } // if picked item particles are not rendered - extern INDEX plr_bRenderPickedParticles; + /*extern INDEX plr_bRenderPickedParticles; if (!plr_bRenderPickedParticles) { // kill flare - bFlare = FALSE; - } + bFlare = FALSE; // DG: bFlare is otherwise unused! + }*/ } // implement flare on/off ? diff --git a/Sources/EntitiesMP/ModelHolder2.es b/Sources/EntitiesMP/ModelHolder2.es index 2c51ab4..21df4ec 100644 --- a/Sources/EntitiesMP/ModelHolder2.es +++ b/Sources/EntitiesMP/ModelHolder2.es @@ -217,7 +217,7 @@ functions: } else { vDirectionFixed = FLOAT3D(0,1,0); } - FLOAT3D vDamageOld = m_vDamage; + //FLOAT3D vDamageOld = m_vDamage; m_vDamage += vDirectionFixed*fKickDamage; // NOTE: we don't receive damage here, but handle death differently diff --git a/Sources/EntitiesMP/PlayerAnimator.es b/Sources/EntitiesMP/PlayerAnimator.es index 13c65df..6aef7ae 100644 --- a/Sources/EntitiesMP/PlayerAnimator.es +++ b/Sources/EntitiesMP/PlayerAnimator.es @@ -1054,7 +1054,7 @@ functions: FLOAT3D vDesiredTranslation = pl.en_vDesiredTranslationRelative; FLOAT3D vCurrentTranslation = pl.en_vCurrentTranslationAbsolute * !pl.en_mRotation; ANGLE3D aDesiredRotation = pl.en_aDesiredRotationRelative; - ANGLE3D aCurrentRotation = pl.en_aCurrentRotationAbsolute; + //ANGLE3D aCurrentRotation = pl.en_aCurrentRotationAbsolute; // if player is moving if (vDesiredTranslation.ManhattanNorm()>0.01f diff --git a/Sources/EntitiesMP/PlayerWeapons.es b/Sources/EntitiesMP/PlayerWeapons.es index 1b2176a..d98a9de 100755 --- a/Sources/EntitiesMP/PlayerWeapons.es +++ b/Sources/EntitiesMP/PlayerWeapons.es @@ -1988,7 +1988,7 @@ functions: FLOATmatrix3D m; MakeRotationMatrixFast(m, plKnife.pl_OrientationAngle); FLOAT3D vRight = m.GetColumn(1)*fWide; - FLOAT3D vUp = m.GetColumn(2)*fWide; + //FLOAT3D vUp = m.GetColumn(2)*fWide; FLOAT3D vFront = -m.GetColumn(3)*fRange; FLOAT3D vDest[3]; diff --git a/Sources/EntitiesMP/PyramidSpaceShip.es b/Sources/EntitiesMP/PyramidSpaceShip.es index 42c579a..ec62ae4 100644 --- a/Sources/EntitiesMP/PyramidSpaceShip.es +++ b/Sources/EntitiesMP/PyramidSpaceShip.es @@ -486,7 +486,7 @@ functions: void SpawnBeamMachineMainFlare(void) { // spawn main flare - CPlacement3D plSpaceShip = GetPlacement(); + //CPlacement3D plSpaceShip = GetPlacement(); CPlacement3D plFlare = CPlacement3D( FLOAT3D(0, BM_MASTER_Y+BM_FLARE_DY, 0), ANGLE3D(0,0,0)); plFlare.RelativeToAbsolute(GetPlacement()); CEntity *penFlare = CreateEntity( plFlare, CLASS_EFFECTOR); diff --git a/Sources/EntitiesMP/SpawnerProjectile.es b/Sources/EntitiesMP/SpawnerProjectile.es index f654581..a3048cb 100644 --- a/Sources/EntitiesMP/SpawnerProjectile.es +++ b/Sources/EntitiesMP/SpawnerProjectile.es @@ -83,10 +83,11 @@ functions: pen->Initialize(); // adjust circle radii to account for enemy size + /* unused FLOAT fEntityR = 0; if (pen->en_pciCollisionInfo!=NULL) { fEntityR = pen->en_pciCollisionInfo->GetMaxFloorRadius(); - } + } */ // teleport back pen->Teleport(GetPlacement(), FALSE); diff --git a/Sources/GameMP/Controls.cpp b/Sources/GameMP/Controls.cpp index fa0df01..9147ff0 100644 --- a/Sources/GameMP/Controls.cpp +++ b/Sources/GameMP/Controls.cpp @@ -222,8 +222,8 @@ void CControls::Load_t( CTFileName fnFile) achrIfInverted[ 0] = 0; char achrIfRelative[ 1024]; achrIfRelative[ 0] = 0; - char achrIfSmooth[ 1024]; - achrIfSmooth[ 0] = 0; + //char achrIfSmooth[ 1024]; + //achrIfSmooth[ 0] = 0; achrActionName[ 0] = 0; FLOAT fSensitivity = 50; FLOAT fDeadZone = 0; diff --git a/Sources/SeriousSam/Menu.cpp b/Sources/SeriousSam/Menu.cpp index ee546cb..a2f992d 100644 --- a/Sources/SeriousSam/Menu.cpp +++ b/Sources/SeriousSam/Menu.cpp @@ -4077,6 +4077,7 @@ void CPlayerProfileMenu::SelectPlayer(INDEX iPlayer) mgPlayerModel.mg_strTip = TRANS("cannot change model for single-player game"); mgPlayerModel.mg_bEnabled = FALSE; } + (void)bSet; // ignore gender flags, if any strName.RemovePrefix("#female#"); strName.RemovePrefix("#male#"); diff --git a/Sources/Shaders/Common.cpp b/Sources/Shaders/Common.cpp index 83d660d..10d7a7a 100644 --- a/Sources/Shaders/Common.cpp +++ b/Sources/Shaders/Common.cpp @@ -100,9 +100,9 @@ void DoSpecularLayer(INDEX iSpeculaTexture,INDEX iSpecularColor) void DoReflectionLayer(INDEX iReflectionTexture,INDEX iReflectionColor,BOOL bFullBright) { - GFXVertex4 *paVertices = NULL; + //GFXVertex4 *paVertices = NULL; GFXNormal *paNormals = NULL; - paVertices = shaGetVertexArray(); + //paVertices = shaGetVertexArray(); paNormals = shaGetNormalArray(); INDEX ctVertices = shaGetVertexCount(); GFXTexCoord *ptcUVMap = shaGetNewTexCoordArray(); From 40213b3e03829cb849d3a982c6fd738f1ae4feb4 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sun, 24 Apr 2016 01:05:23 +0200 Subject: [PATCH 16/34] Ignore some more files (build dirs and generated) --- .gitignore | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index defd53b..5fafc31 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,10 @@ Build/ Debug/ +# custom user build dirs +/*build* +/Sources/*build* + # Visual Studio *.vs *.opendb @@ -70,20 +74,22 @@ Sources/Entities/*.cpp # Other generated files: Sources/Engine/Ska/smcScan.cpp Sources/Engine/Ska/smcPars.h +Sources/Engine/Ska/smcPars.hpp Sources/Engine/Ska/smcPars.cpp Sources/Engine/Base/Parser.cpp Sources/Engine/Base/Parser.h +Sources/Engine/Base/Parser.hpp Sources/Engine/Base/Scanner.cpp Sources/Ecc/Parser.cpp Sources/Ecc/Parser.h +Sources/Ecc/Parser.hpp Sources/Ecc/Scanner.cpp Sources/SeriousSkaStudio/Parser.cpp Sources/SeriousSkaStudio/Parser.h +Sources/SeriousSkaStudio/Parser.hpp Sources/SeriousSkaStudio/Scanner.cpp # vim swap files *.swp *.swo - - From 8106aedd9f4eb81c104ca8a78a0646a702610640 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sun, 24 Apr 2016 16:06:57 +0200 Subject: [PATCH 17/34] Use at least 16bit for Depth-Buffer (fixes #37) Seems like on Windows 0 bits is handled as "Let Windows/Driver decide", so handle that case by setting a reasonable value of 16. --- Sources/Engine/Graphics/SDL/SDLOpenGL.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Sources/Engine/Graphics/SDL/SDLOpenGL.cpp b/Sources/Engine/Graphics/SDL/SDLOpenGL.cpp index 4bf398f..fa75240 100644 --- a/Sources/Engine/Graphics/SDL/SDLOpenGL.cpp +++ b/Sources/Engine/Graphics/SDL/SDLOpenGL.cpp @@ -95,11 +95,7 @@ BOOL CGfxLibrary::SetupPixelFormat_OGL( HDC hdc, BOOL bReport/*=FALSE*/) // clamp depth/stencil values extern INDEX gap_iDepthBits; extern INDEX gap_iStencilBits; - if( gap_iDepthBits <12) { - ASSERT(gap_iDepthBits >= 12 && "Using gap_iDepthBits=0, that's probably bad?!"); - gap_iDepthBits = 0; - } - else if( gap_iDepthBits <22) gap_iDepthBits = 16; + if( gap_iDepthBits <22) gap_iDepthBits = 16; // this includes 0; 16 is a safe default else if( gap_iDepthBits <28) gap_iDepthBits = 24; else gap_iDepthBits = 32; if( gap_iStencilBits<3) gap_iStencilBits = 0; From de4f96d2089a9ca5242ed301b7745bf3ccf2ff75 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Mon, 25 Apr 2016 00:17:08 +0200 Subject: [PATCH 18/34] Remove FIXMEs/silence Fish.es warnings Thanks to @SLAwww's explanations it's clear now :) --- Sources/Engine/Brushes/BrushPolygon.cpp | 2 +- Sources/Entities/Fish.es | 2 +- Sources/EntitiesMP/Fish.es | 5 +---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Sources/Engine/Brushes/BrushPolygon.cpp b/Sources/Engine/Brushes/BrushPolygon.cpp index b5a4342..e5b971b 100644 --- a/Sources/Engine/Brushes/BrushPolygon.cpp +++ b/Sources/Engine/Brushes/BrushPolygon.cpp @@ -509,7 +509,7 @@ CBrushPolygon &CBrushPolygon::CopyPolygon(CBrushPolygon &bp) bpo_boxBoundingBox=bp.bpo_boxBoundingBox; bpo_pbscSector=bp.bpo_pbscSector; bpo_rsOtherSideSectors.Clear(); - //bpo_lhShadingInfos; // FIXME: DG: was this missing "= bp.bpo_lhShadingInfos" or something like that? + //bpo_lhShadingInfos; // don't copy or anything, it's a CListHead which must not be copied bpo_iInWorld=bp.bpo_iInWorld; return *this; } diff --git a/Sources/Entities/Fish.es b/Sources/Entities/Fish.es index 93d3eb5..4a969a5 100644 --- a/Sources/Entities/Fish.es +++ b/Sources/Entities/Fish.es @@ -268,7 +268,7 @@ procedures: // declare yourself as a model InitAsModel(); // fish must not go upstairs, or it will get out of water - SetPhysicsFlags((EPF_MODEL_WALKING|EPF_HASGILLS)&~EPF_ONBLOCK_CLIMBORSLIDE|EPF_ONBLOCK_SLIDE); + SetPhysicsFlags(((EPF_MODEL_WALKING|EPF_HASGILLS)&~EPF_ONBLOCK_CLIMBORSLIDE)|EPF_ONBLOCK_SLIDE); SetCollisionFlags(ECF_MODEL); SetFlags(GetFlags()|ENF_ALIVE); SetHealth(30.0f); diff --git a/Sources/EntitiesMP/Fish.es b/Sources/EntitiesMP/Fish.es index 9d3e60a..52a8abe 100755 --- a/Sources/EntitiesMP/Fish.es +++ b/Sources/EntitiesMP/Fish.es @@ -283,10 +283,7 @@ procedures: // declare yourself as a model InitAsModel(); // fish must not go upstairs, or it will get out of water - // FIXME: DG: should it really be - // (EPF_MODEL_WALKING|EPF_HASGILLS) & ~EPF_ONBLOCK_CLIMBORSLIDE ) | EPF_ONBLOCK_SLIDE - // or rather (EPF_MODEL_WALKING|EPF_HASGILLS) & ~(EPF_ONBLOCK_CLIMBORSLIDE|EPF_ONBLOCK_SLIDE) ?? - SetPhysicsFlags((EPF_MODEL_WALKING|EPF_HASGILLS)&~EPF_ONBLOCK_CLIMBORSLIDE|EPF_ONBLOCK_SLIDE); + SetPhysicsFlags(((EPF_MODEL_WALKING|EPF_HASGILLS)&~EPF_ONBLOCK_CLIMBORSLIDE)|EPF_ONBLOCK_SLIDE); SetCollisionFlags(ECF_MODEL); SetFlags(GetFlags()|ENF_ALIVE); SetHealth(30.0f); From b64df456b6c213d0ba46a318792f011119513a5f Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Mon, 25 Apr 2016 01:44:09 +0200 Subject: [PATCH 19/34] Fix TFE warnings and lots of unused variable warnings .. still, didn't look at unused variable warnings from *.es because so many are generated. --- Sources/CMakeLists.txt | 3 +- Sources/Engine/Base/Stream.cpp | 4 +- Sources/Engine/Brushes/BrushTriangularize.cpp | 2 +- Sources/Engine/Classes/MovableEntity.es | 4 +- Sources/Engine/Graphics/DrawPort.cpp | 6 +-- .../Engine/Graphics/DrawPort_RenderScene.cpp | 3 +- Sources/Engine/Graphics/Graphics.cpp | 1 + Sources/Engine/Models/Model.cpp | 7 +++ Sources/Engine/Rendering/RendASER.cpp | 2 +- Sources/Engine/Rendering/RenderBrushes.cpp | 2 +- Sources/Engine/Terrain/TerrainArchive.cpp | 2 +- Sources/Engine/World/WorldCSG.cpp | 4 ++ Sources/Engine/World/WorldIO.cpp | 4 +- Sources/Entities/Common/HUD.cpp | 6 ++- Sources/Entities/Common/Particles.cpp | 46 +++++++++---------- Sources/Entities/Debris.es | 2 +- Sources/Entities/Dragonman.es | 4 +- Sources/Entities/Effector.es | 6 +-- Sources/Entities/Elemental.es | 10 +++- Sources/Entities/Fish.es | 2 +- Sources/Entities/Item.es | 8 ++-- Sources/Entities/ModelHolder2.es | 2 +- Sources/Entities/Player.es | 13 +++--- Sources/Entities/PlayerAnimator.es | 2 +- Sources/Entities/PlayerWeapons.es | 4 +- Sources/Entities/Projectile.es | 4 +- Sources/Entities/PyramidSpaceShip.es | 2 +- 27 files changed, 88 insertions(+), 67 deletions(-) diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index e0c8929..83d9fd5 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -119,13 +119,12 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") add_compile_options(-Wno-unused-value) # same here (the Scripts generate tons of unused variables and values) add_compile_options(-Wno-missing-braces) add_compile_options(-Wno-overloaded-virtual) + add_compile_options(-Wno-invalid-offsetof) MESSAGE(WARNING, "re-enable some of the warnings some day!") if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "AppleClang") add_compile_options(-Wno-tautological-undefined-compare) # don't complain about if(this!=NULL) add_compile_options(-Wno-c++11-compat-deprecated-writable-strings) - else() # most probably GCC - add_compile_options(-Wno-unused-but-set-variable) # my clang doesn't know this FIXME: re-enable? endif() if(MACOSX) diff --git a/Sources/Engine/Base/Stream.cpp b/Sources/Engine/Base/Stream.cpp index 5e79967..d48f827 100755 --- a/Sources/Engine/Base/Stream.cpp +++ b/Sources/Engine/Base/Stream.cpp @@ -934,7 +934,7 @@ void CTFileStream::Create_t(const CTFileName &fnFileName, } CTFileName fnmFullFileName; - INDEX iFile = ExpandFilePath(EFP_WRITE, fnFileNameAbsolute, fnmFullFileName); + /* INDEX iFile = */ ExpandFilePath(EFP_WRITE, fnFileNameAbsolute, fnmFullFileName); // check parameters ASSERT(strlen(fnFileNameAbsolute)>0); @@ -1317,7 +1317,7 @@ BOOL FileExistsForWriting(const CTFileName &fnmFile) } // expand the filename to full path for writing CTFileName fnmFullFileName; - INDEX iFile = ExpandFilePath(EFP_WRITE, fnmFile, fnmFullFileName); + /* INDEX iFile = */ ExpandFilePath(EFP_WRITE, fnmFile, fnmFullFileName); // check if it exists FILE *f = fopen(fnmFullFileName, "rb"); diff --git a/Sources/Engine/Brushes/BrushTriangularize.cpp b/Sources/Engine/Brushes/BrushTriangularize.cpp index 51d16ad..ddb29c4 100644 --- a/Sources/Engine/Brushes/BrushTriangularize.cpp +++ b/Sources/Engine/Brushes/BrushTriangularize.cpp @@ -337,7 +337,7 @@ void CTriangularizer::MakeEdgesForTriangularization(void) // get number of edges in polygon INDEX ctEdges = tr_abpeOriginalEdges.Count(); // create that much edges in the array - CBrushEdge *pbedEdges = tr_abedEdges.New(ctEdges); + /* CBrushEdge *pbedEdges = */ tr_abedEdges.New(ctEdges); tr_abedEdges.Lock(); diff --git a/Sources/Engine/Classes/MovableEntity.es b/Sources/Engine/Classes/MovableEntity.es index 4a4a901..7bc441e 100644 --- a/Sources/Engine/Classes/MovableEntity.es +++ b/Sources/Engine/Classes/MovableEntity.es @@ -2863,7 +2863,7 @@ out:; _pfPhysicsProfile.IncrementCounter((INDEX) CPhysicsProfile::PCI_DOMOVING); - FLOAT fTickQuantum=_pTimer->TickQuantum; // used for normalizing from SI units to game ticks + //FLOAT fTickQuantum=_pTimer->TickQuantum; // used for normalizing from SI units to game ticks // if rotation and translation are synchronized if (en_ulPhysicsFlags&EPF_RT_SYNCHRONIZED) { @@ -2878,7 +2878,7 @@ out:; if ((en_ulPhysicsFlags&EPF_ONBLOCK_MASK)==EPF_ONBLOCK_PUSH) { penPusher = this; } - BOOL bMoveSuccessfull = TryToMove(penPusher, TRUE, TRUE); + /* BOOL bMoveSuccessfull = */ TryToMove(penPusher, TRUE, TRUE); // if rotation and translation are asynchronious } else { diff --git a/Sources/Engine/Graphics/DrawPort.cpp b/Sources/Engine/Graphics/DrawPort.cpp index 0722ce3..ce03348 100755 --- a/Sources/Engine/Graphics/DrawPort.cpp +++ b/Sources/Engine/Graphics/DrawPort.cpp @@ -799,7 +799,7 @@ void CDrawPort::Fill( PIX pixI, PIX pixJ, PIX pixWidth, PIX pixHeight, // thru OpenGL gfxResetArrays(); GFXVertex *pvtx = _avtxCommon.Push(4); - GFXTexCoord *ptex = _atexCommon.Push(4); + /* GFXTexCoord *ptex = */ _atexCommon.Push(4); GFXColor *pcol = _acolCommon.Push(4); const GFXColor glcolUL(colUL); const GFXColor glcolUR(colUR); const GFXColor glcolDL(colDL); const GFXColor glcolDR(colDR); @@ -1617,7 +1617,7 @@ void CDrawPort::AddTriangle( const FLOAT fI0, const FLOAT fJ0, const GFXColor glCol( AdjustColor( col, _slTexHueShift, _slTexSaturation)); const INDEX iStart = _avtxCommon.Count(); GFXVertex *pvtx = _avtxCommon.Push(3); - GFXTexCoord *ptex = _atexCommon.Push(3); + /* GFXTexCoord *ptex = */ _atexCommon.Push(3); GFXColor *pcol = _acolCommon.Push(3); INDEX *pelm = _aiCommonElements.Push(3); pvtx[0].x = fI0; pvtx[0].y = fJ0; pvtx[0].z = 0; @@ -1699,7 +1699,7 @@ void CDrawPort::BlendScreen(void) // set arrays gfxResetArrays(); GFXVertex *pvtx = _avtxCommon.Push(4); - GFXTexCoord *ptex = _atexCommon.Push(4); + /* GFXTexCoord *ptex = */ _atexCommon.Push(4); GFXColor *pcol = _acolCommon.Push(4); const INDEX iW = dp_Width; const INDEX iH = dp_Height; diff --git a/Sources/Engine/Graphics/DrawPort_RenderScene.cpp b/Sources/Engine/Graphics/DrawPort_RenderScene.cpp index 579c53e..18c0033 100644 --- a/Sources/Engine/Graphics/DrawPort_RenderScene.cpp +++ b/Sources/Engine/Graphics/DrawPort_RenderScene.cpp @@ -816,6 +816,7 @@ static void RSSetTextureCoords( ScenePolygon *pspoGroup, INDEX iLayer, INDEX iUn // generate tex coord for all scene polygons in list const FLOATmatrix3D &mViewer = _ppr->pr_ViewerRotationMatrix; const INDEX iMappingOffset = iLayer * sizeof(CMappingVectors); + (void)iMappingOffset; // shut up compiler, this is used if inline ASM is used for( ScenePolygon *pspo=pspoGroup; pspo!=NULL; pspo=pspo->spo_pspoSucc) { @@ -1979,7 +1980,7 @@ void RenderSceneBackground(CDrawPort *pDP, COLOR col) // set arrays gfxResetArrays(); GFXVertex *pvtx = _avtxCommon.Push(4); - GFXTexCoord *ptex = _atexCommon.Push(4); + /* GFXTexCoord *ptex = */ _atexCommon.Push(4); GFXColor *pcol = _acolCommon.Push(4); pvtx[0].x = 0; pvtx[0].y = 0; pvtx[0].z = 1; pvtx[1].x = 0; pvtx[1].y = iH; pvtx[1].z = 1; diff --git a/Sources/Engine/Graphics/Graphics.cpp b/Sources/Engine/Graphics/Graphics.cpp index 4f3dc06..440c27f 100644 --- a/Sources/Engine/Graphics/Graphics.cpp +++ b/Sources/Engine/Graphics/Graphics.cpp @@ -665,6 +665,7 @@ void DitherBitmap( INDEX iDitherType, ULONG *pulSrc, ULONG *pulDst, PIX pixWidth ASSERT( pixCanvasWidth>=pixWidth && pixCanvasHeight>=pixHeight); SLONG slModulo = (pixCanvasWidth-pixWidth) *BYTES_PER_TEXEL; SLONG slWidthModulo = pixWidth*BYTES_PER_TEXEL +slModulo; + (void)slWidthModulo; // shut up compiler, this is used if inline ASM is used // if bitmap is smaller than 4x2 pixels if( pixWidth<4 || pixHeight<2) diff --git a/Sources/Engine/Models/Model.cpp b/Sources/Engine/Models/Model.cpp index 198d809..e3847d2 100644 --- a/Sources/Engine/Models/Model.cpp +++ b/Sources/Engine/Models/Model.cpp @@ -1397,9 +1397,11 @@ void CModelData::Read_t( CTStream *pFile) // throw char * if( cidVerticesChunk == CChunkID("AV16")) { CChunkID cidDummy = pFile->GetID_t(); + (void)cidDummy; // shut up about unused variable, compiler. ULONG ulDummy; // skip chunk size *pFile >> ulDummy; + (void)ulDummy; // shut up about unused variable, compiler. for( INDEX iVtx=0; iVtx>md_FrameVertices16[iVtx]; @@ -2859,22 +2861,26 @@ void CModelObject::AutoSetTextures(void) if( id == CChunkID("WTEX")) { CChunkID idDummy = strmIni.GetID_t(); + (void)idDummy; // shut up about unused variable, compiler. strmIni >> ctDiffuseTextures; strmIni >> fnDiffuse; } else if( id == CChunkID("FXTR")) { CChunkID idDummy = strmIni.GetID_t(); + (void)idDummy; // shut up about unused variable, compiler. strmIni >> fnReflection; } else if( id == CChunkID("FXTS")) { CChunkID idDummy = strmIni.GetID_t(); + (void)idDummy; // shut up about unused variable, compiler. strmIni >> fnSpecular; } else if( id == CChunkID("FXTB")) { CChunkID idDummy = strmIni.GetID_t(); + (void)idDummy; // shut up about unused variable, compiler. strmIni >> fnBump; } else @@ -2914,6 +2920,7 @@ void CModelObject::AutoSetAttachments(void) if( id == CChunkID("ATTM")) { CChunkID idDummy = strmIni.GetID_t(); + (void)idDummy; // shut up about unused variable, compiler. // try to load attached models INDEX ctAttachedModels; strmIni >> ctAttachedModels; diff --git a/Sources/Engine/Rendering/RendASER.cpp b/Sources/Engine/Rendering/RendASER.cpp index 5a642cd..67fee4f 100644 --- a/Sources/Engine/Rendering/RendASER.cpp +++ b/Sources/Engine/Rendering/RendASER.cpp @@ -763,7 +763,7 @@ CScreenPolygon *CRenderer::ScanOneLine(void) } // remove all left-over polygons from stack do { - BOOL bWasTop = RemPolygonFromSurfaceStack(*pspoTop); + /* BOOL bWasTop = */ RemPolygonFromSurfaceStack(*pspoTop); pspoTop = LIST_HEAD(re_lhSurfaceStack, CScreenPolygon, spo_lnInStack); } while (&re_spoFarSentinel != pspoTop); // mark start of background span at right border diff --git a/Sources/Engine/Rendering/RenderBrushes.cpp b/Sources/Engine/Rendering/RenderBrushes.cpp index d8e8520..e9b45a9 100644 --- a/Sources/Engine/Rendering/RenderBrushes.cpp +++ b/Sources/Engine/Rendering/RenderBrushes.cpp @@ -154,7 +154,7 @@ void CRenderer::DrawBrushPolygonVerticesAndEdges(CBrushPolygon &bpo) */ void CRenderer::DrawBrushSectorVerticesAndEdges(CBrushSector &bscSector) { - CBrushMip *pbm = bscSector.bsc_pbmBrushMip; + //CBrushMip *pbm = bscSector.bsc_pbmBrushMip; //CBrush3D &br = *pbm->bm_pbrBrush; // clear all vertex drawn flags diff --git a/Sources/Engine/Terrain/TerrainArchive.cpp b/Sources/Engine/Terrain/TerrainArchive.cpp index c0e3fa8..ee0a137 100644 --- a/Sources/Engine/Terrain/TerrainArchive.cpp +++ b/Sources/Engine/Terrain/TerrainArchive.cpp @@ -44,7 +44,7 @@ void CTerrainArchive::Read_t( CTStream *istrFile) // throw char * // if there are some terrains if (ctTerrains!=0) { // create that much terrains - CTerrain *atrBrushes = ta_atrTerrains.New(ctTerrains); + /* CTerrain *atrBrushes = */ ta_atrTerrains.New(ctTerrains); // for each of the new terrains for (INDEX iTerrain=0; iTerrain>iEntityClass>>plPlacement; // create an entity of that class - CEntity *penNew = CreateEntity_t(plPlacement, cecClasses[iEntityClass]); + /* CEntity *penNew = */ CreateEntity_t(plPlacement, cecClasses[iEntityClass]); }} // for each entity @@ -498,7 +498,7 @@ void CWorld::ReadState_old_t( CTStream *istr) // throw char * // read entity class index and entity placement (*istr)>>iEntityClass>>plPlacement; // create an entity of that class - CEntity *penNew = CreateEntity_t(plPlacement, cecClasses[iEntityClass]); + /* CEntity *penNew = */ CreateEntity_t(plPlacement, cecClasses[iEntityClass]); }} // for each entity diff --git a/Sources/Entities/Common/HUD.cpp b/Sources/Entities/Common/HUD.cpp index 60598a5..a776e57 100644 --- a/Sources/Entities/Common/HUD.cpp +++ b/Sources/Entities/Common/HUD.cpp @@ -234,6 +234,7 @@ static int qsort_CompareDeaths( const void *ppPEN0, const void *ppPEN1) { else return 0; } +#if 0 // DG: unused static int qsort_CompareLatencies( const void *ppPEN0, const void *ppPEN1) { CPlayer &en0 = **(CPlayer**)ppPEN0; CPlayer &en1 = **(CPlayer**)ppPEN1; @@ -243,6 +244,7 @@ static int qsort_CompareLatencies( const void *ppPEN0, const void *ppPEN1) { else if( sl0>sl1) return -1; else return 0; } +#endif // 0 (unused) // prepare color transitions static void PrepareColorTransitions( COLOR colFine, COLOR colHigh, COLOR colMedium, COLOR colLow, @@ -690,7 +692,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO _fCustomScaling = ClampDn( _fCustomScaling*0.8f, 0.5f); const FLOAT fOneUnitS = fOneUnit *0.8f; const FLOAT fAdvUnitS = fAdvUnit *0.8f; - const FLOAT fNextUnitS = fNextUnit *0.8f; + //const FLOAT fNextUnitS = fNextUnit *0.8f; const FLOAT fHalfUnitS = fHalfUnit *0.8f; // prepare postition and ammo quantities @@ -868,7 +870,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO if( iHealth>25) colHealth = _colHUD; if( iArmor >25) colArmor = _colHUD; // eventually print it out - if( hud_iShowPlayers==1 || hud_iShowPlayers==-1 && !bSinglePlay) { + if( hud_iShowPlayers==1 || (hud_iShowPlayers==-1 && !bSinglePlay)) { // printout location and info aren't the same for deathmatch and coop play const FLOAT fCharWidth = (PIX)((_pfdDisplayFont->GetWidth()-2) *fTextScale); if( bCooperative) { diff --git a/Sources/Entities/Common/Particles.cpp b/Sources/Entities/Common/Particles.cpp index 204948b..a7a956c 100644 --- a/Sources/Entities/Common/Particles.cpp +++ b/Sources/Entities/Common/Particles.cpp @@ -276,7 +276,7 @@ void Particles_RomboidTrail(CEntity *pen) for(INDEX iPos = 0; iPoslp_ctUsed; iPos++) { FLOAT3D vPos = plp->GetPosition(iPos); - FLOAT fRand = rand()/FLOAT(RAND_MAX); + //FLOAT fRand = rand()/FLOAT(RAND_MAX); FLOAT fAngle = fSeconds*256+iPos*2.0f*PI/ROMBOID_TRAIL_POSITIONS; FLOAT fSin = FLOAT(sin(fAngle)); vPos(2) += fSin*iPos/ROMBOID_TRAIL_POSITIONS; @@ -437,7 +437,7 @@ void Particles_WhiteLineTrail(CEntity *pen) vPos(1) += fSin*iPos*1.0f/WHITE_LINE_TRAIL_POSITIONS; vPos(2) += fCos*iPos*1.0f/WHITE_LINE_TRAIL_POSITIONS; - UBYTE ub = 255-iPos*256/WHITE_LINE_TRAIL_POSITIONS; + //UBYTE ub = 255-iPos*256/WHITE_LINE_TRAIL_POSITIONS; FLOAT fLerpFactor = FLOAT(iPos)/WHITE_LINE_TRAIL_POSITIONS; COLOR colColor = LerpColor( C_YELLOW, C_dRED, fLerpFactor); Particle_RenderLine( vPos, vOldPos, 0.05f, colColor); @@ -533,7 +533,7 @@ void Particles_CannonBall_Prepare(CEntity *pen) void Particles_CannonBall(CEntity *pen, FLOAT fSpeedRatio) { CLastPositions *plp = pen->GetLastPositions(CANNON_TRAIL_POSITIONS); - FLOAT fSeconds = _pTimer->GetLerpedCurrentTick(); + // FLOAT fSeconds = _pTimer->GetLerpedCurrentTick(); Particle_PrepareTexture(&_toCannonBall, PBT_BLEND); Particle_SetTexturePart( 512, 512, 0, 0); @@ -718,9 +718,9 @@ void Particles_BeastProjectileTrail( CEntity *pen, FLOAT fSize, FLOAT fHeight, I fT *= 1/BEAST_PROJECTILE_TOTAL_TIME; // get fraction part fT = fT-int(fT); - FLOAT fFade; - if (fT>(1.0f-BEAST_PROJECTILE_FADE_OUT)) fFade=(1-fT)*(1/BEAST_PROJECTILE_FADE_OUT); - else fFade=1.0f; + //FLOAT fFade; + //if (fT>(1.0f-BEAST_PROJECTILE_FADE_OUT)) fFade=(1-fT)*(1/BEAST_PROJECTILE_FADE_OUT); + //else fFade=1.0f; #define GET_POS( time) vCenter + \ vX*(afStarsPositions[iStar][0]*time*fSize*1.5) +\ @@ -816,7 +816,7 @@ void Particles_RocketTrail_Prepare(CEntity *pen) void Particles_RocketTrail(CEntity *pen, FLOAT fStretch) { CLastPositions *plp = pen->GetLastPositions(ROCKET_TRAIL_POSITIONS); - FLOAT fSeconds = _pTimer->GetLerpedCurrentTick(); + //FLOAT fSeconds = _pTimer->GetLerpedCurrentTick(); Particle_PrepareTexture(&_toRocketTrail, PBT_ADD); Particle_SetTexturePart( 512, 512, 0, 0); @@ -835,7 +835,7 @@ void Particles_RocketTrail(CEntity *pen, FLOAT fStretch) } for (INDEX iInter=0; iInterGetPosition(iPos); - FLOAT fRand = rand()/FLOAT(RAND_MAX); + //FLOAT fRand = rand()/FLOAT(RAND_MAX); FLOAT fAngle = iPos*2.0f*PI/BLOOD01_TRAIL_POSITIONS; - FLOAT fSin = FLOAT(sin(fAngle)); + //FLOAT fSin = FLOAT(sin(fAngle)); FLOAT fT = iPos*_pTimer->TickQuantum; vPos += vGDir*fGA*fT*fT/8.0f; FLOAT fSize = 0.2f-iPos*0.15f/BLOOD01_TRAIL_POSITIONS; @@ -1709,7 +1709,7 @@ void Particles_Rain(CEntity *pen, FLOAT fGridSize, INDEX ctGrids, FLOAT fFactor, pixRainMapH = ptdRainMap->GetPixHeight(); } - INDEX ctDiscarded=0; + //INDEX ctDiscarded=0; for( INDEX iZ=0; iZAPPEAR_OUT_END)) { return; } - FLOAT fPowerTime = pow(fTime-SPIRIT_SPIRAL_START, 2.5f); + //FLOAT fPowerTime = pow(fTime-SPIRIT_SPIRAL_START, 2.5f); // fill array with absolute vertices of entity's model and its attached models pen->GetModelVerticesAbsolute(avVertices, 0.05f, fMipFactor); @@ -2505,7 +2505,7 @@ void Particles_Appearing(CEntity *pen, TIME tmStart) FLOAT3D vX( m(1,1), m(2,1), m(3,1)); FLOAT3D vY( m(1,2), m(2,2), m(3,2)); FLOAT3D vZ( m(1,3), m(2,3), m(3,3)); - FLOAT3D vCenter = pen->GetLerpedPlacement().pl_PositionVector; + //FLOAT3D vCenter = pen->GetLerpedPlacement().pl_PositionVector; SetupParticleTexture( PT_STAR07); @@ -2524,12 +2524,12 @@ void Particles_Appearing(CEntity *pen, TIME tmStart) COLOR col = RGBToColor(ubColor,ubColor,ubColor)|CT_OPAQUE; INDEX ctVtx = avVertices.Count(); - FLOAT fSpeedFactor = 1.0f/ctVtx; + //FLOAT fSpeedFactor = 1.0f/ctVtx; // get corp size FLOATaabbox3D box; pen->en_pmoModelObject->GetCurrentFrameBBox(box); - FLOAT fHeightStretch = box.Size()(2); + //FLOAT fHeightStretch = box.Size()(2); FLOAT fStep = ClampDn( fMipFactor, 1.0f); for( FLOAT fVtx=0.0f; fVtxCurrentTick()-m_tmStarted<1.0f) - ||(dmtType==DMT_CANNONBALL_EXPLOSION) && (_pTimer->CurrentTick()-m_tmStarted<5.0f)) { + ||((dmtType==DMT_CANNONBALL_EXPLOSION) && (_pTimer->CurrentTick()-m_tmStarted<5.0f))) { return; } CMovableModelEntity::ReceiveDamage(penInflictor, dmtType, fDamageAmmount, vHitPoint, vDirection); diff --git a/Sources/Entities/Dragonman.es b/Sources/Entities/Dragonman.es index 59d2301..a20680b 100644 --- a/Sources/Entities/Dragonman.es +++ b/Sources/Entities/Dragonman.es @@ -444,8 +444,8 @@ procedures: Hit(EVoid) : CEnemyBase::Hit { // burn enemy - if (m_EdtType == DT_SERGEANT && CalcDist(m_penEnemy) <= 6.0f || - m_EdtType == DT_MONSTER && CalcDist(m_penEnemy) <= 20.0f) { + if ((m_EdtType == DT_SERGEANT && CalcDist(m_penEnemy) <= 6.0f) || + (m_EdtType == DT_MONSTER && CalcDist(m_penEnemy) <= 20.0f)) { jump BurnEnemy(); } diff --git a/Sources/Entities/Effector.es b/Sources/Entities/Effector.es index 09bcd59..027d1d3 100644 --- a/Sources/Entities/Effector.es +++ b/Sources/Entities/Effector.es @@ -110,7 +110,7 @@ functions: void AdjustMipFactor(FLOAT &fMipFactor) { - if (m_eetType==ET_DISAPPEAR_MODEL || m_eetType==ET_DISAPPEAR_MODEL_NOW && m_penModel!=NULL) + if (m_eetType==ET_DISAPPEAR_MODEL || (m_eetType==ET_DISAPPEAR_MODEL_NOW && m_penModel!=NULL)) { CModelObject *pmo = m_penModel->GetModelObject(); TIME tmDelta = _pTimer->GetLerpedCurrentTick()-m_tmStarted; @@ -131,7 +131,7 @@ functions: COLOR col = C_WHITE|ubAlpha; pmo->mo_colBlendColor = col; } - if (m_eetType==ET_APPEAR_MODEL || m_eetType==ET_APPEAR_MODEL_NOW && m_penModel!=NULL) + if (m_eetType==ET_APPEAR_MODEL || (m_eetType==ET_APPEAR_MODEL_NOW && m_penModel!=NULL)) { CModelObject *pmo = m_penModel->GetModelObject(); TIME tmDelta = _pTimer->GetLerpedCurrentTick()-m_tmStarted; @@ -434,7 +434,7 @@ procedures: // setup light source if (m_bLightSource) { SetupLightSource(); } - while(_pTimer->CurrentTick()CurrentTick()GetPlacement().pl_PositionVector; - FLOAT3D vDirection = (vTarget-vSource).Normalize(); + //FLOAT3D vDirection = (vTarget-vSource).Normalize(); Particles_Ghostbuster(vSource, vTarget, 32, 1.0f); // random lightnings arround diff --git a/Sources/Entities/Item.es b/Sources/Entities/Item.es index fe88424..f0bc149 100644 --- a/Sources/Entities/Item.es +++ b/Sources/Entities/Item.es @@ -56,7 +56,7 @@ functions: return; } - BOOL bFlare = TRUE; + //BOOL bFlare = TRUE; // if current player has already picked this item if (_ulPlayerRenderingMask&m_ulPickedMask) { // if picked items are not rendered @@ -67,10 +67,10 @@ functions: } // if picked item particles are not rendered extern INDEX plr_bRenderPickedParticles; - if (!plr_bRenderPickedParticles) { + /*if (!plr_bRenderPickedParticles) { // kill flare - bFlare = FALSE; - } + bFlare = FALSE; // DG: bFlare is not otherwise used! + }*/ } // implement flare on/off ? diff --git a/Sources/Entities/ModelHolder2.es b/Sources/Entities/ModelHolder2.es index f07188a..f54bdfe 100644 --- a/Sources/Entities/ModelHolder2.es +++ b/Sources/Entities/ModelHolder2.es @@ -173,7 +173,7 @@ functions: } else { vDirectionFixed = FLOAT3D(0,1,0); } - FLOAT3D vDamageOld = m_vDamage; + //FLOAT3D vDamageOld = m_vDamage; m_vDamage += vDirectionFixed*fKickDamage; // NOTE: we don't receive damage here, but handle death differently diff --git a/Sources/Entities/Player.es b/Sources/Entities/Player.es index d02be99..b1f58ac 100644 --- a/Sources/Entities/Player.es +++ b/Sources/Entities/Player.es @@ -462,10 +462,10 @@ DECL_DLL void ctl_ComposeActionPacket(const CPlayerCharacter &pc, CPlayerAction } // add button movement/rotation/look actions to the axis actions - if(pctlCurrent.bMoveForward || pctlCurrent.bStrafeFB&&pctlCurrent.bTurnUp ) paAction.pa_vTranslation(3) -= plr_fSpeedForward; - if(pctlCurrent.bMoveBackward || pctlCurrent.bStrafeFB&&pctlCurrent.bTurnDown) paAction.pa_vTranslation(3) += plr_fSpeedBackward; - if(pctlCurrent.bMoveLeft || pctlCurrent.bStrafe&&pctlCurrent.bTurnLeft) paAction.pa_vTranslation(1) -= plr_fSpeedSide; - if(pctlCurrent.bMoveRight || pctlCurrent.bStrafe&&pctlCurrent.bTurnRight) paAction.pa_vTranslation(1) += plr_fSpeedSide; + if(pctlCurrent.bMoveForward || (pctlCurrent.bStrafeFB&&pctlCurrent.bTurnUp) ) paAction.pa_vTranslation(3) -= plr_fSpeedForward; + if(pctlCurrent.bMoveBackward || (pctlCurrent.bStrafeFB&&pctlCurrent.bTurnDown)) paAction.pa_vTranslation(3) += plr_fSpeedBackward; + if(pctlCurrent.bMoveLeft || (pctlCurrent.bStrafe&&pctlCurrent.bTurnLeft) ) paAction.pa_vTranslation(1) -= plr_fSpeedSide; + if(pctlCurrent.bMoveRight || (pctlCurrent.bStrafe&&pctlCurrent.bTurnRight)) paAction.pa_vTranslation(1) += plr_fSpeedSide; if(pctlCurrent.bMoveUp ) paAction.pa_vTranslation(2) += plr_fSpeedUp; if(pctlCurrent.bMoveDown ) paAction.pa_vTranslation(2) -= plr_fSpeedUp; @@ -3702,7 +3702,7 @@ functions: } // if just started swimming - if (m_pstState == PST_SWIM && _pTimer->CurrentTick()CurrentTick()CurrentTick()IsPredicted()||IsPredictor()&&m_penView->IsPredictor()||!IsPredicted()&&!m_penView->IsPredicted()&&!IsPredictor()&&!m_penView->IsPredictor()); + ASSERT((IsPredicted()&&m_penView->IsPredicted()) || (IsPredictor()&&m_penView->IsPredictor()) + || (!IsPredicted()&&!m_penView->IsPredicted()&&!IsPredictor()&&!m_penView->IsPredictor())); en_plViewpoint.pl_PositionVector = FLOAT3D(0, 1, 0); en_plViewpoint.pl_OrientationAngle += (ANGLE3D( (ANGLE)((FLOAT)paAction.pa_aRotation(1)*_pTimer->TickQuantum), diff --git a/Sources/Entities/PlayerAnimator.es b/Sources/Entities/PlayerAnimator.es index 1ec5529..919dfd0 100644 --- a/Sources/Entities/PlayerAnimator.es +++ b/Sources/Entities/PlayerAnimator.es @@ -981,7 +981,7 @@ functions: FLOAT3D vDesiredTranslation = pl.en_vDesiredTranslationRelative; FLOAT3D vCurrentTranslation = pl.en_vCurrentTranslationAbsolute * !pl.en_mRotation; ANGLE3D aDesiredRotation = pl.en_aDesiredRotationRelative; - ANGLE3D aCurrentRotation = pl.en_aCurrentRotationAbsolute; + //ANGLE3D aCurrentRotation = pl.en_aCurrentRotationAbsolute; // if player is moving if (vDesiredTranslation.ManhattanNorm()>0.01f diff --git a/Sources/Entities/PlayerWeapons.es b/Sources/Entities/PlayerWeapons.es index debfb7f..92266b9 100644 --- a/Sources/Entities/PlayerWeapons.es +++ b/Sources/Entities/PlayerWeapons.es @@ -908,7 +908,7 @@ functions: } } // apply cannon draw - else if( (m_iCurrentWeapon == WEAPON_IRONCANNON) /*|| + else if( m_iCurrentWeapon == WEAPON_IRONCANNON /*|| (m_iCurrentWeapon == WEAPON_NUKECANNON) */) { FLOAT fLerpedMovement = Lerp(m_fWeaponDrawPowerOld, m_fWeaponDrawPower, _pTimer->GetLerpFactor()); @@ -3385,7 +3385,7 @@ procedures: GetAnimator()->FireAnimation(BODY_ANIM_SHOTGUN_FIRESHORT, AOF_LOOPING); } else if (m_iCurrentWeapon==WEAPON_TOMMYGUN) { autocall TommyGunStart() EEnd; - } else if ((m_iCurrentWeapon==WEAPON_IRONCANNON) /*|| (m_iCurrentWeapon==WEAPON_NUKECANNON)*/) { + } else if (m_iCurrentWeapon==WEAPON_IRONCANNON /*|| (m_iCurrentWeapon==WEAPON_NUKECANNON)*/) { jump CannonFireStart(); } diff --git a/Sources/Entities/Projectile.es b/Sources/Entities/Projectile.es index 84de6f9..6ae1582 100644 --- a/Sources/Entities/Projectile.es +++ b/Sources/Entities/Projectile.es @@ -2281,7 +2281,7 @@ procedures: ANGLE aHeading = GetRotationSpeed( aWantedHeading, m_aRotateSpeed, fWaitFrequency); // factor used to decrease speed of projectiles oriented opposite of its target - FLOAT fSpeedDecreasingFactor = ((180-abs(aWantedHeading))/180.0f); + FLOAT fSpeedDecreasingFactor = ((180-fabsf(aWantedHeading))/180.0f); // factor used to increase speed when far away from target FLOAT fSpeedIncreasingFactor = (vDesiredPosition-GetPlacement().pl_PositionVector).Length()/100; fSpeedIncreasingFactor = ClampDn(fSpeedIncreasingFactor, 1.0f); @@ -2302,7 +2302,7 @@ procedures: FLOAT fRNDPitch = (FRnd()-0.5f)*90*fDistanceFactor; // if we are looking near direction of target - if( abs( aWantedHeading) < 30.0f) + if( fabsf( aWantedHeading) < 30.0f) { // calculate pitch speed ANGLE aWantedPitch = GetRelativePitch( vDesiredDirection); diff --git a/Sources/Entities/PyramidSpaceShip.es b/Sources/Entities/PyramidSpaceShip.es index 2573221..702b322 100644 --- a/Sources/Entities/PyramidSpaceShip.es +++ b/Sources/Entities/PyramidSpaceShip.es @@ -461,7 +461,7 @@ functions: void SpawnBeamMachineMainFlare(void) { // spawn main flare - CPlacement3D plSpaceShip = GetPlacement(); + //CPlacement3D plSpaceShip = GetPlacement(); CPlacement3D plFlare = CPlacement3D( FLOAT3D(0, BM_MASTER_Y+BM_FLARE_DY, 0), ANGLE3D(0,0,0)); plFlare.RelativeToAbsolute(GetPlacement()); CEntity *penFlare = CreateEntity( plFlare, CLASS_EFFECTOR); From 7e7ab3e70e1d29105308e9b8ec3e00bf54a08bd0 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Tue, 26 Apr 2016 17:54:57 +0200 Subject: [PATCH 20/34] remove FIXMEs in GameMP/Computer.cpp and replace the corresponding conditions with more readable (but equivalent) ones. --- Sources/GameMP/Computer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/GameMP/Computer.cpp b/Sources/GameMP/Computer.cpp index fa6cba2..60bf3cc 100644 --- a/Sources/GameMP/Computer.cpp +++ b/Sources/GameMP/Computer.cpp @@ -246,7 +246,7 @@ void LastUnreadMessage(void) // go to next/previous message void PrevMessage(void) { - if (_iActiveMessage < _acmMessages.Count()==0) { // FIXME: DG: what is this about? + if (_iActiveMessage >= _acmMessages.Count()) { return; } _iActiveMessage--; @@ -258,7 +258,7 @@ void PrevMessage(void) void NextMessage(void) { - if (_iActiveMessage < _acmMessages.Count()==0) { // FIXME: DG: what is this about? + if (_iActiveMessage >= _acmMessages.Count()) { return; } _iActiveMessage++; @@ -305,7 +305,7 @@ void MessageTextUp(INDEX ctLines) void MessageTextDn(INDEX ctLines) { // if no message do nothing - if (_iActiveMessage < _acmMessages.Count()==0) { // FIXME: DG: what is this about? + if (_iActiveMessage >= _acmMessages.Count()) { return; } // find text lines count From 7b470d30ab2cc150d1420bc69374bb3b407f5f01 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Wed, 11 May 2016 19:04:01 +0200 Subject: [PATCH 21/34] Elemental.es/Computer.cpp changes according to @SLAwww's suggestions --- Sources/Entities/Elemental.es | 2 +- Sources/EntitiesMP/Elemental.es | 2 +- Sources/GameMP/Computer.cpp | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/Entities/Elemental.es b/Sources/Entities/Elemental.es index c5b4194..16efed6 100644 --- a/Sources/Entities/Elemental.es +++ b/Sources/Entities/Elemental.es @@ -1324,7 +1324,7 @@ procedures: autocall FallOnFloor() EReturn; } - if (m_EecChar==ELC_LARGE || (m_EecChar==ELC_BIG && m_EetType==ELT_LAVA)) + if ((m_EecChar==ELC_LARGE || m_EecChar==ELC_BIG) && m_EetType==ELT_LAVA) { PlaySound(m_soBackground, SOUND_LAVA_LAVABURN, SOF_3D|SOF_LOOP); } diff --git a/Sources/EntitiesMP/Elemental.es b/Sources/EntitiesMP/Elemental.es index 1c65808..2d155d8 100644 --- a/Sources/EntitiesMP/Elemental.es +++ b/Sources/EntitiesMP/Elemental.es @@ -1373,7 +1373,7 @@ procedures: autocall FallOnFloor() EReturn; } - if (m_EecChar==ELC_LARGE || (m_EecChar==ELC_BIG && m_EetType==ELT_LAVA)) + if ((m_EecChar==ELC_LARGE || m_EecChar==ELC_BIG) && m_EetType==ELT_LAVA) { PlaySound(m_soBackground, SOUND_LAVA_LAVABURN, SOF_3D|SOF_LOOP); } diff --git a/Sources/GameMP/Computer.cpp b/Sources/GameMP/Computer.cpp index 60bf3cc..8a899d7 100644 --- a/Sources/GameMP/Computer.cpp +++ b/Sources/GameMP/Computer.cpp @@ -177,7 +177,7 @@ static PIXaabbox2D GetMsgSliderSpace(void) static PIXaabbox2D GetTextSliderBox(void) { - if (_iActiveMessage>=_acmMessages.Count()) { + if ((_iActiveMessage >= _acmMessages.Count()) || (_iActiveMessage < 0)) { return PIXaabbox2D(); } INDEX ctTextLines = _acmMessages[_iActiveMessage].cm_ctFormattedLines; @@ -246,7 +246,7 @@ void LastUnreadMessage(void) // go to next/previous message void PrevMessage(void) { - if (_iActiveMessage >= _acmMessages.Count()) { + if ((_iActiveMessage >= _acmMessages.Count()) || (_iActiveMessage < 0)) { return; } _iActiveMessage--; @@ -258,7 +258,7 @@ void PrevMessage(void) void NextMessage(void) { - if (_iActiveMessage >= _acmMessages.Count()) { + if ((_iActiveMessage >= _acmMessages.Count()) || (_iActiveMessage < 0)) { return; } _iActiveMessage++; @@ -305,7 +305,7 @@ void MessageTextUp(INDEX ctLines) void MessageTextDn(INDEX ctLines) { // if no message do nothing - if (_iActiveMessage >= _acmMessages.Count()) { + if ((_iActiveMessage >= _acmMessages.Count()) || (_iActiveMessage < 0)) { return; } // find text lines count @@ -336,7 +336,7 @@ void MessageTextUpDn(INDEX ctLines) // mark current message as read void MarkCurrentRead(void) { - if (_iActiveMessage>=_acmMessages.Count()) { + if ((_iActiveMessage >= _acmMessages.Count()) || (_iActiveMessage < 0)) { return; } // if running in background From ba8d82efafa55279022f6788aff183eb1e51c4db Mon Sep 17 00:00:00 2001 From: Manuel K Date: Sun, 22 May 2016 01:16:38 +0200 Subject: [PATCH 22/34] fix compilation errors with gcc 6.1.1 on Arch Linux --- Sources/Entities/Bullet.es | 4 ++-- Sources/Entities/Player.es | 2 +- Sources/EntitiesMP/Common/Common.cpp | 2 +- Sources/EntitiesMP/Player.es | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/Entities/Bullet.es b/Sources/Entities/Bullet.es index a9347ed..2c7c990 100644 --- a/Sources/Entities/Bullet.es +++ b/Sources/Entities/Bullet.es @@ -344,7 +344,7 @@ functions: GetNormalComponent( vDistance/fDistance, vHitNormal, ese.vDirection); FLOAT fLength = ese.vDirection.Length(); fLength = Clamp( fLength*3, 1.0f, 3.0f); - fDistance = Clamp( log10(fDistance), 0.5, 2.0); + fDistance = Clamp( log10(fDistance), 0.5f, 2.0f); ese.vStretch = FLOAT3D( fDistance, fLength*fDistance, 1.0f); SpawnEffect(vHitPoint, ese); } @@ -417,4 +417,4 @@ procedures: m_iBullet = 0; return; }; -}; \ No newline at end of file +}; diff --git a/Sources/Entities/Player.es b/Sources/Entities/Player.es index d02be99..09c808a 100644 --- a/Sources/Entities/Player.es +++ b/Sources/Entities/Player.es @@ -4587,7 +4587,7 @@ void TeleportPlayer(enum WorldLinkType EwltType) TIME tmLevelTime = _pTimer->CurrentTick()-m_tmLevelStarted; m_psLevelStats.ps_tmTime = tmLevelTime; m_psGameStats.ps_tmTime += tmLevelTime; - FLOAT fTimeDelta = ClampDn(floor(m_tmEstTime)-floor(tmLevelTime), 0.0); + FLOAT fTimeDelta = ClampDn(floor(m_tmEstTime)-floor(tmLevelTime), 0.0f); m_iTimeScore = floor(fTimeDelta*100.0f); m_psLevelStats.ps_iScore+=m_iTimeScore; m_psGameStats.ps_iScore+=m_iTimeScore; diff --git a/Sources/EntitiesMP/Common/Common.cpp b/Sources/EntitiesMP/Common/Common.cpp index af04321..75dd98e 100755 --- a/Sources/EntitiesMP/Common/Common.cpp +++ b/Sources/EntitiesMP/Common/Common.cpp @@ -386,7 +386,7 @@ void SpawnHitTypeEffect(CEntity *pen, enum BulletHitType bhtType, BOOL bSound, F GetNormalComponent( vDistance/fDistance, vHitNormal, ese.vDirection); FLOAT fLength = ese.vDirection.Length(); fLength = Clamp( fLength*3, 1.0f, 3.0f); - fDistance = Clamp( log10(fDistance), 0.5, 2.0); + fDistance = Clamp( log10(fDistance), 0.5f, 2.0f); ese.vStretch = FLOAT3D( fDistance, fLength*fDistance, 1.0f); try { diff --git a/Sources/EntitiesMP/Player.es b/Sources/EntitiesMP/Player.es index a249fe5..b0bc183 100755 --- a/Sources/EntitiesMP/Player.es +++ b/Sources/EntitiesMP/Player.es @@ -5380,7 +5380,7 @@ functions: TIME tmLevelTime = _pTimer->CurrentTick()-m_tmLevelStarted; m_psLevelStats.ps_tmTime = tmLevelTime; m_psGameStats.ps_tmTime += tmLevelTime; - FLOAT fTimeDelta = ClampDn(floor(m_tmEstTime)-floor(tmLevelTime), 0.0); + FLOAT fTimeDelta = ClampDn(floor(m_tmEstTime)-floor(tmLevelTime), 0.0f); m_iTimeScore = (INDEX) floor(fTimeDelta*100.0f); m_psLevelStats.ps_iScore+=m_iTimeScore; m_psGameStats.ps_iScore+=m_iTimeScore; From fe23b05aa22d3164d6f6388436258d67df7cf3f9 Mon Sep 17 00:00:00 2001 From: Emil Laine Date: Sat, 23 Apr 2016 04:05:17 +0300 Subject: [PATCH 23/34] Fix ASSERT() That would never trigger the ASSERT. Now they always do. Conflicts: Sources/EntitiesMP/Summoner.es --- Sources/Engine/Base/Assert.h | 2 +- Sources/EntitiesMP/Common/Particles.cpp | 2 +- Sources/EntitiesMP/Grunt.es | 2 +- Sources/EntitiesMP/GruntSka.es | 2 +- Sources/EntitiesMP/PlayerWeapons.es | 2 +- Sources/EntitiesMP/Summoner.es | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/Engine/Base/Assert.h b/Sources/Engine/Base/Assert.h index 80f4aa3..c1b45de 100644 --- a/Sources/Engine/Base/Assert.h +++ b/Sources/Engine/Base/Assert.h @@ -83,7 +83,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define BREAKPOINT \ if (1) { \ SAFEBREAKPOINT; \ - _assert("hard-coded breakpoint (CroTeam)",__FILE__,__LINE__); \ + _assert(false && "hard-coded breakpoint (CroTeam)",__FILE__,__LINE__); \ } else NOTHING /* CT DEBUG macro -- the expression is executed only in debug version */ diff --git a/Sources/EntitiesMP/Common/Particles.cpp b/Sources/EntitiesMP/Common/Particles.cpp index c369d05..73980c1 100755 --- a/Sources/EntitiesMP/Common/Particles.cpp +++ b/Sources/EntitiesMP/Common/Particles.cpp @@ -527,7 +527,7 @@ void Particles_ViewerLocal(CEntity *penView) break; default: - ASSERT("Unknown environment particle type!"); + ASSERT(false && "Unknown environment particle type!"); break; } // for those EPHs that are not rendered, clear possible diff --git a/Sources/EntitiesMP/Grunt.es b/Sources/EntitiesMP/Grunt.es index 5a7c84e..e2acee1 100644 --- a/Sources/EntitiesMP/Grunt.es +++ b/Sources/EntitiesMP/Grunt.es @@ -99,7 +99,7 @@ functions: } else if (m_gtType==GT_COMMANDER) { return &eiGruntSoldier; } else { - ASSERT("Unknown grunt type!"); + ASSERT(false && "Unknown grunt type!"); return NULL; } }; diff --git a/Sources/EntitiesMP/GruntSka.es b/Sources/EntitiesMP/GruntSka.es index 880cafd..021ff35 100644 --- a/Sources/EntitiesMP/GruntSka.es +++ b/Sources/EntitiesMP/GruntSka.es @@ -280,7 +280,7 @@ functions: } else if (m_gtType==GT_COMMANDER) { return &eiGruntSoldier; } else { - ASSERT("Unknown grunt type!"); + ASSERT(false && "Unknown grunt type!"); return NULL; } }; diff --git a/Sources/EntitiesMP/PlayerWeapons.es b/Sources/EntitiesMP/PlayerWeapons.es index d98a9de..49693d2 100755 --- a/Sources/EntitiesMP/PlayerWeapons.es +++ b/Sources/EntitiesMP/PlayerWeapons.es @@ -3442,7 +3442,7 @@ functions: return (WeaponType)i; } } - ASSERT("Non-existant weapon in remap array!"); + ASSERT(false && "Non-existant weapon in remap array!"); return (WeaponType)0; } diff --git a/Sources/EntitiesMP/Summoner.es b/Sources/EntitiesMP/Summoner.es index 1c5469c..22e6181 100755 --- a/Sources/EntitiesMP/Summoner.es +++ b/Sources/EntitiesMP/Summoner.es @@ -618,7 +618,7 @@ functions: pen = &m_penGroup03Template01; iCount = IRnd()%m_iGroup03Count+1; } else { - ASSERT("Invalid group!"); + ASSERT(false && "Invalid group!"); iCount = 0; // DG: this should have a deterministic value in case this happens after all! } ASSERT(iCount>0); From 24d61d1cccac8c9b8e0b37781bda630a65f5f803 Mon Sep 17 00:00:00 2001 From: Emil Laine Date: Sat, 23 Apr 2016 23:32:03 +0300 Subject: [PATCH 24/34] Use ASSERTALWAYS(msg) instead of ASSERT(false && msg) Thanks @SLAwww (The first parameter to _assert is actually the message, not the expression to evaluate, so "false &&" doesn't belong in there.) Conflicts: Sources/EntitiesMP/Summoner.es --- Sources/Engine/Base/Assert.h | 2 +- Sources/EntitiesMP/Common/Particles.cpp | 2 +- Sources/EntitiesMP/Grunt.es | 2 +- Sources/EntitiesMP/GruntSka.es | 2 +- Sources/EntitiesMP/PlayerWeapons.es | 2 +- Sources/EntitiesMP/Summoner.es | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/Engine/Base/Assert.h b/Sources/Engine/Base/Assert.h index c1b45de..80f4aa3 100644 --- a/Sources/Engine/Base/Assert.h +++ b/Sources/Engine/Base/Assert.h @@ -83,7 +83,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define BREAKPOINT \ if (1) { \ SAFEBREAKPOINT; \ - _assert(false && "hard-coded breakpoint (CroTeam)",__FILE__,__LINE__); \ + _assert("hard-coded breakpoint (CroTeam)",__FILE__,__LINE__); \ } else NOTHING /* CT DEBUG macro -- the expression is executed only in debug version */ diff --git a/Sources/EntitiesMP/Common/Particles.cpp b/Sources/EntitiesMP/Common/Particles.cpp index 73980c1..d8ad616 100755 --- a/Sources/EntitiesMP/Common/Particles.cpp +++ b/Sources/EntitiesMP/Common/Particles.cpp @@ -527,7 +527,7 @@ void Particles_ViewerLocal(CEntity *penView) break; default: - ASSERT(false && "Unknown environment particle type!"); + ASSERTALWAYS("Unknown environment particle type!"); break; } // for those EPHs that are not rendered, clear possible diff --git a/Sources/EntitiesMP/Grunt.es b/Sources/EntitiesMP/Grunt.es index e2acee1..d66015e 100644 --- a/Sources/EntitiesMP/Grunt.es +++ b/Sources/EntitiesMP/Grunt.es @@ -99,7 +99,7 @@ functions: } else if (m_gtType==GT_COMMANDER) { return &eiGruntSoldier; } else { - ASSERT(false && "Unknown grunt type!"); + ASSERTALWAYS("Unknown grunt type!"); return NULL; } }; diff --git a/Sources/EntitiesMP/GruntSka.es b/Sources/EntitiesMP/GruntSka.es index 021ff35..e142d8f 100644 --- a/Sources/EntitiesMP/GruntSka.es +++ b/Sources/EntitiesMP/GruntSka.es @@ -280,7 +280,7 @@ functions: } else if (m_gtType==GT_COMMANDER) { return &eiGruntSoldier; } else { - ASSERT(false && "Unknown grunt type!"); + ASSERTALWAYS("Unknown grunt type!"); return NULL; } }; diff --git a/Sources/EntitiesMP/PlayerWeapons.es b/Sources/EntitiesMP/PlayerWeapons.es index 49693d2..0ebc4eb 100755 --- a/Sources/EntitiesMP/PlayerWeapons.es +++ b/Sources/EntitiesMP/PlayerWeapons.es @@ -3442,7 +3442,7 @@ functions: return (WeaponType)i; } } - ASSERT(false && "Non-existant weapon in remap array!"); + ASSERTALWAYS("Non-existant weapon in remap array!"); return (WeaponType)0; } diff --git a/Sources/EntitiesMP/Summoner.es b/Sources/EntitiesMP/Summoner.es index 22e6181..5fa1ae9 100755 --- a/Sources/EntitiesMP/Summoner.es +++ b/Sources/EntitiesMP/Summoner.es @@ -618,7 +618,7 @@ functions: pen = &m_penGroup03Template01; iCount = IRnd()%m_iGroup03Count+1; } else { - ASSERT(false && "Invalid group!"); + ASSERTALWAYS("Invalid group!"); iCount = 0; // DG: this should have a deterministic value in case this happens after all! } ASSERT(iCount>0); From 5badefaf900165feb7196ee78343ceb5ba3d3a4a Mon Sep 17 00:00:00 2001 From: Emil Laine Date: Sun, 24 Apr 2016 00:17:29 +0300 Subject: [PATCH 25/34] Change remaining "if (this!=NULL)" to "ASSERT(this!=NULL)" Also changed all "if (this==NULL) return;"s. Fixes some -Wtautological-undefined-compare warnings. Quoting Clang: "'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to false" --- Sources/Engine/Base/Anim.cpp | 10 ++--- Sources/Engine/Base/Console.cpp | 40 +++++-------------- Sources/Engine/Entities/Entity.cpp | 5 +-- Sources/Engine/Entities/Entity.h | 18 ++++----- Sources/Engine/Entities/EntityClass.cpp | 10 ++--- Sources/Engine/Network/Network.cpp | 18 ++++++--- Sources/Engine/Sound/SoundData.cpp | 10 ++--- Sources/Engine/Sound/SoundLibrary.cpp | 3 +- Sources/Engine/World/World.cpp | 9 +++-- Sources/Entities/Common/PathFinding.cpp | 6 ++- Sources/EntitiesMP/Common/PathFinding.cpp | 8 ++-- .../Modeler/DlgPgInfoAttachingPlacement.cpp | 2 +- 12 files changed, 58 insertions(+), 81 deletions(-) diff --git a/Sources/Engine/Base/Anim.cpp b/Sources/Engine/Base/Anim.cpp index e491e12..10d04e8 100644 --- a/Sources/Engine/Base/Anim.cpp +++ b/Sources/Engine/Base/Anim.cpp @@ -173,16 +173,14 @@ BOOL CAnimData::IsAutoFreed(void) // Reference counting functions void CAnimData::AddReference(void) { - if (this!=NULL) { - MarkUsed(); - } + ASSERT(this!=NULL); + MarkUsed(); } void CAnimData::RemReference(void) { - if (this!=NULL) { - RemReference_internal(); - } + ASSERT(this!=NULL); + RemReference_internal(); } void CAnimData::RemReference_internal(void) diff --git a/Sources/Engine/Base/Console.cpp b/Sources/Engine/Base/Console.cpp index 208fa49..a8d613a 100644 --- a/Sources/Engine/Base/Console.cpp +++ b/Sources/Engine/Base/Console.cpp @@ -44,9 +44,7 @@ CConsole::CConsole(void) // Destructor. CConsole::~CConsole(void) { - if (this==NULL) { - return; - } + ASSERT(this!=NULL); if (con_fLog!=NULL) { fclose(con_fLog); con_fLog = NULL; @@ -102,25 +100,19 @@ void CConsole::Initialize(const CTFileName &fnmLog, INDEX ctCharsPerLine, INDEX // Get current console buffer. const char *CConsole::GetBuffer(void) { - if (this==NULL) { - return ""; - } + ASSERT(this!=NULL); return con_strBuffer+(con_ctLines-con_ctLinesPrinted)*(con_ctCharsPerLine+1); } INDEX CConsole::GetBufferSize(void) { - if (this==NULL) { - return 1; - } + ASSERT(this!=NULL); return (con_ctCharsPerLine+1)*con_ctLines+1; } // Discard timing info for last lines void CConsole::DiscardLastLineTimes(void) { - if (this==NULL) { - return; - } + ASSERT(this!=NULL); for(INDEX i=0; i=con_ctLinesPrinted) { return ""; } @@ -166,9 +154,7 @@ CTString CConsole::GetLastLine(INDEX iLine) // clear one given line in buffer void CConsole::ClearLine(INDEX iLine) { - if (this==NULL) { - return; - } + ASSERT(this!=NULL); // line must be valid ASSERT(iLine>=0 && iLine0 && ctLines _aseSentEvents; // delayed events /* Send an event to this entity. */ void CEntity::SendEvent(const CEntityEvent &ee) { - if (this==NULL) { - ASSERT(FALSE); - return; - } + ASSERT(this!=NULL); CSentEvent &se = _aseSentEvents.Push(); se.se_penEntity = this; se.se_peeEvent = ((CEntityEvent&)ee).MakeCopy(); // discard const qualifier diff --git a/Sources/Engine/Entities/Entity.h b/Sources/Engine/Entities/Entity.h index b2bd944..5f98d38 100644 --- a/Sources/Engine/Entities/Entity.h +++ b/Sources/Engine/Entities/Entity.h @@ -694,18 +694,16 @@ inline CEntity& CEntityPointer::operator*(void) const { return *ep_pen; } ///////////////////////////////////////////////////////////////////// // Reference counting functions inline void CEntity::AddReference(void) { - if (this!=NULL) { - ASSERT(en_ctReferences>=0); - en_ctReferences++; - } + ASSERT(this!=NULL); + ASSERT(en_ctReferences>=0); + en_ctReferences++; }; inline void CEntity::RemReference(void) { - if (this!=NULL) { - ASSERT(en_ctReferences>0); - en_ctReferences--; - if(en_ctReferences==0) { - delete this; - } + ASSERT(this!=NULL); + ASSERT(en_ctReferences>0); + en_ctReferences--; + if(en_ctReferences==0) { + delete this; } }; diff --git a/Sources/Engine/Entities/EntityClass.cpp b/Sources/Engine/Entities/EntityClass.cpp index a0e6163..1fb1881 100644 --- a/Sources/Engine/Entities/EntityClass.cpp +++ b/Sources/Engine/Entities/EntityClass.cpp @@ -64,14 +64,12 @@ CEntityClass::~CEntityClass(void) ///////////////////////////////////////////////////////////////////// // Reference counting functions void CEntityClass::AddReference(void) { - if (this!=NULL) { - MarkUsed(); - } + ASSERT(this!=NULL); + MarkUsed(); }; void CEntityClass::RemReference(void) { - if (this!=NULL) { - _pEntityClassStock->Release(this); - } + ASSERT(this!=NULL); + _pEntityClassStock->Release(this); }; /* diff --git a/Sources/Engine/Network/Network.cpp b/Sources/Engine/Network/Network.cpp index e6e2b43..d283a1a 100644 --- a/Sources/Engine/Network/Network.cpp +++ b/Sources/Engine/Network/Network.cpp @@ -655,7 +655,8 @@ extern void FreeUnusedStock(void) */ void CNetworkTimerHandler::HandleTimer(void) { - if (this==NULL || _bTempNetwork) { + ASSERT(this!=NULL); + if (_bTempNetwork) { return; // this can happen during NET_MakeDefaultState_t()! } // enable stream handling during timer @@ -902,7 +903,8 @@ void CNetworkLibrary::Init(const CTString &strGameID) */ void CNetworkLibrary::AddTimerHandler(void) { - if (this==NULL || _bTempNetwork) { + ASSERT(this!=NULL); + if (_bTempNetwork) { return; // this can happen during NET_MakeDefaultState_t()! } _pTimer->AddHandler(&ga_thTimerHandler); @@ -912,7 +914,8 @@ void CNetworkLibrary::AddTimerHandler(void) */ void CNetworkLibrary::RemoveTimerHandler(void) { - if (this==NULL || _bTempNetwork) { + ASSERT(this!=NULL); + if (_bTempNetwork) { return; // this can happen during NET_MakeDefaultState_t()! } _pTimer->RemHandler(&ga_thTimerHandler); @@ -1390,7 +1393,8 @@ void CNetworkLibrary::TogglePause(void) // test if game is paused BOOL CNetworkLibrary::IsPaused(void) { - if (this==NULL || _bTempNetwork) { + ASSERT(this!=NULL); + if (_bTempNetwork) { return TRUE; // this can happen during NET_MakeDefaultState_t()! } return ga_sesSessionState.ses_bPause; @@ -1427,7 +1431,8 @@ void CNetworkLibrary::SetLocalPause(BOOL bPause) BOOL CNetworkLibrary::GetLocalPause(void) { - if (this==NULL || _bTempNetwork) { + ASSERT(this!=NULL); + if (_bTempNetwork) { return TRUE; // this can happen during NET_MakeDefaultState_t()! } return ga_bLocalPause; @@ -2033,7 +2038,8 @@ void CNetworkLibrary::SendActionsToServer(void) */ void CNetworkLibrary::TimerLoop(void) { - if (this==NULL || _bTempNetwork) { + ASSERT(this!=NULL); + if (_bTempNetwork) { return; // this can happen during NET_MakeDefaultState_t()! } _pfNetworkProfile.StartTimer(CNetworkProfile::PTI_TIMERLOOP); diff --git a/Sources/Engine/Sound/SoundData.cpp b/Sources/Engine/Sound/SoundData.cpp index f022ebb..c9852c4 100644 --- a/Sources/Engine/Sound/SoundData.cpp +++ b/Sources/Engine/Sound/SoundData.cpp @@ -252,16 +252,14 @@ SLONG CSoundData::GetUsedMemory(void) // Add one reference void CSoundData::AddReference(void) { - if (this!=NULL) { - MarkUsed(); - } + ASSERT(this!=NULL); + MarkUsed(); } // Remove one reference void CSoundData::RemReference(void) { - if (this!=NULL) { - _pSoundStock->Release(this); - } + ASSERT(this!=NULL); + _pSoundStock->Release(this); } diff --git a/Sources/Engine/Sound/SoundLibrary.cpp b/Sources/Engine/Sound/SoundLibrary.cpp index f1e4df3..8bf8133 100644 --- a/Sources/Engine/Sound/SoundLibrary.cpp +++ b/Sources/Engine/Sound/SoundLibrary.cpp @@ -1233,6 +1233,7 @@ BOOL CSoundLibrary::SetEnvironment( INDEX iEnvNo, FLOAT fEnvSize/*=0*/) // mute all sounds (erase playing buffer(s) and supress mixer) void CSoundLibrary::Mute(void) { + ASSERT(this!=NULL); // stop all IFeel effects IFeel_StopEffect(NULL); @@ -1244,7 +1245,7 @@ void CSoundLibrary::Mute(void) #ifdef PLATFORM_WIN32 // erase direct sound buffer (waveout will shut-up by itself), but skip if there's no more sound library - if( this==NULL || !sl_bUsingDirectSound) return; + if(!sl_bUsingDirectSound) return; // synchronize access to sounds CTSingleLock slSounds(&sl_csSound, TRUE); diff --git a/Sources/Engine/World/World.cpp b/Sources/Engine/World/World.cpp index bff7b76..405904c 100644 --- a/Sources/Engine/World/World.cpp +++ b/Sources/Engine/World/World.cpp @@ -936,10 +936,11 @@ void CWorld::TriangularizeForVertices( CBrushVertexSelection &selVertex) // add this entity to prediction void CEntity::AddToPrediction(void) { - // this function may be called even for NULLs - so ignore it - if (this==NULL) { - return; - } + // this function may be called even for NULLs - TODO: fix those cases + // (The compiler is free to assume that "this" is never NULL and optimize + // based on that assumption. For example, an "if (this==NULL) {...}" could + // be optimized away completely.) + ASSERT(this!=NULL); // if already added if (en_ulFlags&ENF_WILLBEPREDICTED) { // do nothing diff --git a/Sources/Entities/Common/PathFinding.cpp b/Sources/Entities/Common/PathFinding.cpp index e4099b2..91742a6 100644 --- a/Sources/Entities/Common/PathFinding.cpp +++ b/Sources/Entities/Common/PathFinding.cpp @@ -35,8 +35,9 @@ CPathNode::~CPathNode(void) // get name of this node const CTString &CPathNode::GetName(void) { + ASSERT(this!=NULL); static CTString strNone=""; - if (this==NULL || pn_pnmMarker==NULL) { + if (pn_pnmMarker==NULL) { return strNone; } else { return pn_pnmMarker->GetName(); @@ -46,7 +47,8 @@ const CTString &CPathNode::GetName(void) // get link with given index or null if no more (for iteration along the graph) CPathNode *CPathNode::GetLink(INDEX i) { - if (this==NULL || pn_pnmMarker==NULL) { + ASSERT(this!=NULL); + if (pn_pnmMarker==NULL) { ASSERT(FALSE); return NULL; } diff --git a/Sources/EntitiesMP/Common/PathFinding.cpp b/Sources/EntitiesMP/Common/PathFinding.cpp index 54a68f0..3504155 100644 --- a/Sources/EntitiesMP/Common/PathFinding.cpp +++ b/Sources/EntitiesMP/Common/PathFinding.cpp @@ -50,8 +50,9 @@ CPathNode::~CPathNode(void) // get name of this node const CTString &CPathNode::GetName(void) { + ASSERT(this!=NULL); static CTString strNone=""; - if (this==NULL || pn_pnmMarker==NULL) { + if (pn_pnmMarker==NULL) { return strNone; } else { return pn_pnmMarker->GetName(); @@ -61,10 +62,7 @@ const CTString &CPathNode::GetName(void) // get link with given index or null if no more (for iteration along the graph) CPathNode *CPathNode::GetLink(INDEX i) { - if (this==NULL || pn_pnmMarker==NULL) { - ASSERT(FALSE); - return NULL; - } + ASSERT(this!=NULL && pn_pnmMarker!=NULL); CNavigationMarker *pnm = pn_pnmMarker->GetLink(i); if (pnm==NULL) { return NULL; diff --git a/Sources/Modeler/DlgPgInfoAttachingPlacement.cpp b/Sources/Modeler/DlgPgInfoAttachingPlacement.cpp index 3d9b0df..8fbd8a2 100644 --- a/Sources/Modeler/DlgPgInfoAttachingPlacement.cpp +++ b/Sources/Modeler/DlgPgInfoAttachingPlacement.cpp @@ -69,7 +69,7 @@ INDEX CDlgPgInfoAttachingPlacement::GetCurrentAttachingPlacement(void) void CDlgPgInfoAttachingPlacement::SetPlacementReferenceVertex(INDEX iCenter, INDEX iFront, INDEX iUp) { // patch for calling before page is refreshed - if(this == NULL) return; + ASSERT(this!=NULL); CModelerView *pModelerView = CModelerView::GetActiveView(); if(pModelerView == NULL) return; CModelerDoc* pDoc = pModelerView->GetDocument(); From 13ba79ea5f5d496dbc80f16d8ba492e4f9e768f9 Mon Sep 17 00:00:00 2001 From: Emil Laine Date: Sun, 24 Apr 2016 01:28:13 +0300 Subject: [PATCH 26/34] Remove unneeded -Wno-sign-compare (I didn't receive any warnings after enabling -Wsign-compare.) Conflicts: Sources/CMakeLists.txt --- Sources/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 83d9fd5..5683ced 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -110,8 +110,6 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -Os -fno-unsafe-math-optimizations") # TODO fix these warnings - # !!! FIXME: turn a bunch of these off, this is just for now. I hope. --ryan. - add_compile_options(-Wno-sign-compare) add_compile_options(-Wno-switch) add_compile_options(-Wno-char-subscripts) add_compile_options(-Wno-unknown-pragmas) From 16a2048a2cc6a766b36d1e90f7d8f160563dc140 Mon Sep 17 00:00:00 2001 From: Emil Laine Date: Sun, 24 Apr 2016 01:33:27 +0300 Subject: [PATCH 27/34] Fix warning -Wchar-subscripts --- Sources/Engine/Graphics/Font.cpp | 4 ++-- Sources/Engine/Graphics/Font.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Engine/Graphics/Font.cpp b/Sources/Engine/Graphics/Font.cpp index f3fe2c7..d5fd8d4 100644 --- a/Sources/Engine/Graphics/Font.cpp +++ b/Sources/Engine/Graphics/Font.cpp @@ -99,7 +99,7 @@ void CFontData::Read_t( CTStream *inFile) // throw char * SetCharSpacing(+1); SetLineSpacing(+1); SetSpaceWidth(0.5f); - fd_fcdFontCharData[' '].fcd_pixStart = 0; + fd_fcdFontCharData[(int)' '].fcd_pixStart = 0; } void CFontData::Write_t( CTStream *outFile) // throw char * @@ -201,7 +201,7 @@ void CFontData::Make_t( const CTFileName &fnTexture, PIX pixCharWidth, PIX pixCh iLetter++; // skip carriage return } // set default space width - fd_fcdFontCharData[' '].fcd_pixStart = 0; + fd_fcdFontCharData[(int)' '].fcd_pixStart = 0; SetSpaceWidth(0.5f); // all done diff --git a/Sources/Engine/Graphics/Font.h b/Sources/Engine/Graphics/Font.h index cacb307..f5056a5 100644 --- a/Sources/Engine/Graphics/Font.h +++ b/Sources/Engine/Graphics/Font.h @@ -71,7 +71,7 @@ public: inline void SetFixedWidth(void) { fd_bFixedWidth = TRUE; }; inline void SetVariableWidth(void) { fd_bFixedWidth = FALSE; }; inline void SetSpaceWidth( FLOAT fWidthRatio) { // relative to char cell width (1/2 is default) - fd_fcdFontCharData[' '].fcd_pixEnd = (PIX)(fd_pixCharWidth*fWidthRatio); } + fd_fcdFontCharData[(int)' '].fcd_pixEnd = (PIX)(fd_pixCharWidth*fWidthRatio); } void Read_t( CTStream *inFile); // throw char * void Write_t( CTStream *outFile); // throw char * From 4b0e01145e2d9e394788b4a42e7c48fff3a43217 Mon Sep 17 00:00:00 2001 From: Emil Laine Date: Sun, 24 Apr 2016 00:57:23 +0300 Subject: [PATCH 28/34] Fix warning -Wtautological-undefined-compare Quoting Clang: "reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false" Conflicts: Sources/CMakeLists.txt --- Sources/CMakeLists.txt | 2 +- Sources/Engine/Brushes/BrushShadows.cpp | 8 ++--- Sources/Engine/Entities/Entity.h | 1 + Sources/Engine/Entities/EntityPointer.h | 1 + Sources/Engine/Light/LayerMixer.cpp | 6 ++-- Sources/Engine/Math/ObjectSector.cpp | 10 +++--- Sources/Engine/Rendering/RenCache.cpp | 14 ++++---- Sources/Engine/World/WorldCSG.cpp | 46 ++++++++++++------------- Sources/EntitiesMP/Summoner.es | 8 ++--- 9 files changed, 50 insertions(+), 46 deletions(-) diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 5683ced..ef8aee2 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -121,7 +121,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") MESSAGE(WARNING, "re-enable some of the warnings some day!") if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "AppleClang") - add_compile_options(-Wno-tautological-undefined-compare) # don't complain about if(this!=NULL) + # !!! FIXME: turn a bunch of these off, this is just for now. I hope. --ryan. add_compile_options(-Wno-c++11-compat-deprecated-writable-strings) endif() diff --git a/Sources/Engine/Brushes/BrushShadows.cpp b/Sources/Engine/Brushes/BrushShadows.cpp index d0d832f..8cf91d9 100644 --- a/Sources/Engine/Brushes/BrushShadows.cpp +++ b/Sources/Engine/Brushes/BrushShadows.cpp @@ -562,9 +562,9 @@ void CBrushShadowMap::CheckLayersUpToDate(void) CBrushShadowLayer &bsl = *itbsl; if( bsl.bsl_ulFlags&BSLF_ALLDARK) continue; // light source must be valid + ASSERT( bsl.bsl_plsLightSource!=NULL); + if( bsl.bsl_plsLightSource==NULL) continue; CLightSource &ls = *bsl.bsl_plsLightSource; - ASSERT( &ls!=NULL); - if( &ls==NULL) continue; // if the layer is not up to date if( bsl.bsl_colLastAnim != ls.GetLightColor()) { // invalidate entire shadow map @@ -581,9 +581,9 @@ BOOL CBrushShadowMap::HasDynamicLayers(void) // for each layer FOREACHINLIST( CBrushShadowLayer, bsl_lnInShadowMap, bsm_lhLayers, itbsl) { // light source must be valid + ASSERT( itbsl->bsl_plsLightSource!=NULL); + if( itbsl->bsl_plsLightSource==NULL) continue; CLightSource &ls = *itbsl->bsl_plsLightSource; - ASSERT( &ls!=NULL); - if( &ls==NULL) continue; // if the layer is dynamic, it has if( ls.ls_ulFlags&LSF_DYNAMIC) return TRUE; } diff --git a/Sources/Engine/Entities/Entity.h b/Sources/Engine/Entities/Entity.h index 5f98d38..57d174d 100644 --- a/Sources/Engine/Entities/Entity.h +++ b/Sources/Engine/Entities/Entity.h @@ -688,6 +688,7 @@ inline const CEntityPointer &CEntityPointer::operator=(const CEntityPointer &pen return *this; } inline CEntity* CEntityPointer::operator->(void) const { return ep_pen; } +inline CEntity* CEntityPointer::get(void) const { return ep_pen; } inline CEntityPointer::operator CEntity*(void) const { return ep_pen; } inline CEntity& CEntityPointer::operator*(void) const { return *ep_pen; } diff --git a/Sources/Engine/Entities/EntityPointer.h b/Sources/Engine/Entities/EntityPointer.h index 349982a..614387b 100644 --- a/Sources/Engine/Entities/EntityPointer.h +++ b/Sources/Engine/Entities/EntityPointer.h @@ -35,6 +35,7 @@ public: inline const CEntityPointer &operator=(CEntity *pen); inline const CEntityPointer &operator=(const CEntityPointer &penOther); inline CEntity* operator->(void) const; + inline CEntity* get(void) const; inline operator CEntity*(void) const; inline CEntity& operator*(void) const; }; diff --git a/Sources/Engine/Light/LayerMixer.cpp b/Sources/Engine/Light/LayerMixer.cpp index 5d8750f..9b9992d 100755 --- a/Sources/Engine/Light/LayerMixer.cpp +++ b/Sources/Engine/Light/LayerMixer.cpp @@ -1770,8 +1770,9 @@ void CLayerMixer::MixOneMipmap(CBrushShadowMap *pbsm, INDEX iMipmap) if( lm_pbpoPolygon->bpo_ulFlags&BPOF_HASDIRECTIONALAMBIENT) { {FOREACHINLIST( CBrushShadowLayer, bsl_lnInShadowMap, lm_pbsmShadowMap->bsm_lhLayers, itbsl) { CBrushShadowLayer &bsl = *itbsl; + ASSERT( bsl.bsl_plsLightSource!=NULL); + if( bsl.bsl_plsLightSource==NULL) continue; // safety check CLightSource &ls = *bsl.bsl_plsLightSource; - ASSERT( &ls!=NULL); if( &ls==NULL) continue; // safety check if( !(ls.ls_ulFlags&LSF_DIRECTIONAL)) continue; // skip non-directional layers COLOR col = AdjustColor( ls.GetLightAmbient(), _slShdHueShift, _slShdSaturation); colAmbient = AddColors( colAmbient, col); @@ -1843,8 +1844,9 @@ void CLayerMixer::MixOneMipmap(CBrushShadowMap *pbsm, INDEX iMipmap) {FORDELETELIST( CBrushShadowLayer, bsl_lnInShadowMap, lm_pbsmShadowMap->bsm_lhLayers, itbsl) { CBrushShadowLayer &bsl = *itbsl; + ASSERT( bsl.bsl_plsLightSource!=NULL); + if( bsl.bsl_plsLightSource==NULL) continue; // safety check CLightSource &ls = *bsl.bsl_plsLightSource; - ASSERT( &ls!=NULL); if( &ls==NULL) continue; // safety check // skip if should not be applied if( (bDynamicOnly && !(ls.ls_ulFlags&LSF_NONPERSISTENT)) || (ls.ls_ulFlags & LSF_DYNAMIC)) continue; diff --git a/Sources/Engine/Math/ObjectSector.cpp b/Sources/Engine/Math/ObjectSector.cpp index f02d59b..960fb63 100644 --- a/Sources/Engine/Math/ObjectSector.cpp +++ b/Sources/Engine/Math/ObjectSector.cpp @@ -1115,10 +1115,10 @@ void CObjectPolygon::JoinContinuingEdges(CDynamicArray &oedEdges) // for each edge {FOREACHINDYNAMICARRAY(opo_PolygonEdges, CObjectPolygonEdge, itope) { - CObjectEdge &oedThis = *itope->ope_Edge; + CObjectEdge *poedThis = itope->ope_Edge; // if not already marked for removal - if (&oedThis != NULL) { + if (poedThis != NULL) { CObjectVertex *povxStartThis, *povxEndThis; // get start and end vertices itope->GetVertices(povxStartThis, povxEndThis); @@ -1133,12 +1133,12 @@ void CObjectPolygon::JoinContinuingEdges(CDynamicArray &oedEdges) // for each edge {FOREACHINDYNAMICARRAY(opo_PolygonEdges, CObjectPolygonEdge, itope2) { - CObjectEdge &oedOther = *itope2->ope_Edge; + CObjectEdge *poedOther = itope2->ope_Edge; // if not already marked for removal - if (&oedOther != NULL) { + if (poedOther != NULL) { // if the two edges are collinear - if ( CompareEdgeLines(*oedThis.colinear2.oed_pedxLine, *oedOther.colinear2.oed_pedxLine)==0) { + if ( CompareEdgeLines(*poedThis->colinear2.oed_pedxLine, *poedOther->colinear2.oed_pedxLine)==0) { CObjectVertex *povxStartOther, *povxEndOther; // get start and end vertices itope2->GetVertices(povxStartOther, povxEndOther); diff --git a/Sources/Engine/Rendering/RenCache.cpp b/Sources/Engine/Rendering/RenCache.cpp index dfc631d..3b6fba0 100644 --- a/Sources/Engine/Rendering/RenCache.cpp +++ b/Sources/Engine/Rendering/RenCache.cpp @@ -779,23 +779,23 @@ CScreenPolygon *CRenderer::MakeScreenPolygon(CBrushPolygon &bpo) void CRenderer::AddPolygonToScene( CScreenPolygon *pspo) { // if the polygon is not falid or occluder and not selected - CBrushPolygon &bpo = *pspo->spo_pbpoBrushPolygon; - if( &bpo==NULL || ((bpo.bpo_ulFlags&BPOF_OCCLUDER) && (!(bpo.bpo_ulFlags&BPOF_SELECTED) || + CBrushPolygon *pbpo = pspo->spo_pbpoBrushPolygon; + if(pbpo==NULL || ((pbpo->bpo_ulFlags&BPOF_OCCLUDER) && (!(pbpo->bpo_ulFlags&BPOF_SELECTED) || _wrpWorldRenderPrefs.GetSelectionType()!=CWorldRenderPrefs::ST_POLYGONS))) { // do not add it to rendering return; } - CBrushSector &bsc = *bpo.bpo_pbscSector; + CBrushSector &bsc = *pbpo->bpo_pbscSector; ScenePolygon &sppo = pspo->spo_spoScenePolygon; const CViewVertex *pvvx0 = &re_avvxViewVertices[bsc.bsc_ivvx0]; - const INDEX ctVtx = bpo.bpo_apbvxTriangleVertices.Count(); + const INDEX ctVtx = pbpo->bpo_apbvxTriangleVertices.Count(); sppo.spo_iVtx0 = _avtxScene.Count(); GFXVertex3 *pvtx = _avtxScene.Push(ctVtx); // find vertex with nearest Z distance while copying vertices FLOAT fNearestZ = 123456789.0f; for( INDEX i=0; ibpo_apbvxTriangleVertices[i]; const INDEX iVtx = bsc.bsc_abvxVertices.Index(pbvx); const FLOAT3D &v = pvvx0[iVtx].vvx_vView; if( -v(3)bpo_aiTriangleElements.Count(); + sppo.spo_piElements = sppo.spo_ctElements ? &pbpo->bpo_aiTriangleElements[0] : NULL; _sfStats.IncrementCounter(CStatForm::SCI_SCENE_TRIANGLES, sppo.spo_ctElements/3); } diff --git a/Sources/Engine/World/WorldCSG.cpp b/Sources/Engine/World/WorldCSG.cpp index d69e846..1732afa 100644 --- a/Sources/Engine/World/WorldCSG.cpp +++ b/Sources/Engine/World/WorldCSG.cpp @@ -172,15 +172,15 @@ void CWorld::DoCSGOperation( AssureFPT_53(); // get relevant brush mips in each brush - CBrushMip &bmThis = *GetBrushMip(enThis); - CBrushMip &bmOther = *GetBrushMip(enOther); - if (&bmThis==NULL || &bmOther==NULL) { + CBrushMip *pbmThis = GetBrushMip(enThis); + CBrushMip *pbmOther = GetBrushMip(enOther); + if (pbmThis==NULL || pbmOther==NULL) { return; } // get open sector of the other brush to object CBrushSectorSelectionForCSG selbscOtherOpen; - bmOther.SelectOpenSector(selbscOtherOpen); + pbmOther->SelectOpenSector(selbscOtherOpen); CObject3D obOtherOpen; DOUBLEaabbox3D boxOtherOpen; woOther.CopySourceBrushSectorsToObject(enOther, selbscOtherOpen, plOther, @@ -193,7 +193,7 @@ void CWorld::DoCSGOperation( obOtherOpen.TurnPortalsToWalls(); // if there are any sectors in this brush - if (bmThis.bm_abscSectors.Count()>0) { + if (pbmThis->bm_abscSectors.Count()>0) { // move affected part of this brush to an object3d object CObject3D obThis; MoveTargetBrushPartToObject(enThis, boxOtherOpen, obThis); @@ -213,7 +213,7 @@ void CWorld::DoCSGOperation( // get closed sectors of the other brush to object CBrushSectorSelectionForCSG selbscOtherClosed; - bmOther.SelectClosedSectors(selbscOtherClosed); + pbmOther->SelectClosedSectors(selbscOtherClosed); CObject3D obOtherClosed; DOUBLEaabbox3D boxOtherClosed; woOther.CopySourceBrushSectorsToObject(enOther, selbscOtherClosed, plOther, @@ -224,7 +224,7 @@ void CWorld::DoCSGOperation( CObject3D obResult; // if there are any sectors in this brush - if (bmThis.bm_abscSectors.Count()>0) { + if (pbmThis->bm_abscSectors.Count()>0) { // move affected part of this brush to an object3d object CObject3D obThis; MoveTargetBrushPartToObject(enThis, boxOtherClosed, obThis); @@ -304,16 +304,16 @@ void CWorld::CSGRemove(CEntity &enThis, CWorld &woOther, CEntity &enOther, AssureFPT_53(); // get relevant brush mip in other brush - CBrushMip &bmOther = *GetBrushMip(enOther); - if (&bmOther==NULL) { + CBrushMip *pbmOther = GetBrushMip(enOther); + if (pbmOther==NULL) { return; } // if other brush has more than one sector - if (bmOther.bm_abscSectors.Count()>1) { + if (pbmOther->bm_abscSectors.Count()>1) { // join all sectors of the other brush together CBrushSectorSelection selbscOtherAll; - bmOther.SelectAllSectors(selbscOtherAll); + pbmOther->SelectAllSectors(selbscOtherAll); woOther.JoinSectors(selbscOtherAll); } @@ -380,15 +380,15 @@ void CWorld::SplitSectors(CEntity &enThis, CBrushSectorSelection &selbscSectorsT AssureFPT_53(); // get relevant brush mip in this brush - CBrushMip &bmThis = *GetBrushMip(enThis); - if (&bmThis==NULL) { + CBrushMip *pbmThis = GetBrushMip(enThis); + if (pbmThis==NULL) { _pfWorldEditingProfile.StopTimer(CWorldEditingProfile::PTI_CSGTOTAL); return; } // get relevant brush mip in other brush - CBrushMip &bmOther = *GetBrushMip(enOther); - if (&bmOther==NULL) { + CBrushMip *pbmOther = GetBrushMip(enOther); + if (pbmOther==NULL) { _pfWorldEditingProfile.StopTimer(CWorldEditingProfile::PTI_CSGTOTAL); return; } @@ -396,10 +396,10 @@ void CWorld::SplitSectors(CEntity &enThis, CBrushSectorSelection &selbscSectorsT /* Assure that the other brush has only one sector. */ // if other brush has more than one sector - if (bmOther.bm_abscSectors.Count()>1) { + if (pbmOther->bm_abscSectors.Count()>1) { // join all sectors of the other brush together CBrushSectorSelection selbscOtherAll; - bmOther.SelectAllSectors(selbscOtherAll); + pbmOther->SelectAllSectors(selbscOtherAll); woOther.JoinSectors(selbscOtherAll); } @@ -407,7 +407,7 @@ void CWorld::SplitSectors(CEntity &enThis, CBrushSectorSelection &selbscSectorsT // get the sector of the other brush to object CBrushSectorSelectionForCSG selbscOther; - bmOther.SelectAllSectors(selbscOther); + pbmOther->SelectAllSectors(selbscOther); CObject3D obOther; DOUBLEaabbox3D boxOther; woOther.CopySourceBrushSectorsToObject(enOther, selbscOther, plOther, @@ -416,7 +416,7 @@ void CWorld::SplitSectors(CEntity &enThis, CBrushSectorSelection &selbscSectorsT // if the selection is empty if (selbscSectorsToSplit.Count()==0) { // select all sectors near the splitting tool - bmThis.SelectSectorsInRange(selbscSectorsToSplit, DOUBLEtoFLOAT(boxOther)); + pbmThis->SelectSectorsInRange(selbscSectorsToSplit, DOUBLEtoFLOAT(boxOther)); } // for all sectors in the selection FOREACHINDYNAMICCONTAINER(selbscSectorsToSplit, CBrushSector, itbsc) { @@ -426,7 +426,7 @@ void CWorld::SplitSectors(CEntity &enThis, CBrushSectorSelection &selbscSectorsT } // update the bounding boxes of this brush - bmThis.bm_pbrBrush->CalculateBoundingBoxes(); + pbmThis->bm_pbrBrush->CalculateBoundingBoxes(); // find possible shadow layers near affected area FindShadowLayers(DOUBLEtoFLOAT(boxOther)); @@ -574,8 +574,8 @@ void CWorld::SplitPolygons(CEntity &enThis, CBrushPolygonSelection &selbpoPolygo _pfWorldEditingProfile.IncrementAveragingCounter(); // get relevant brush mip in other brush - CBrushMip &bmOther = *GetBrushMip(enOther); - if (&bmOther==NULL) { + CBrushMip *pbmOther = GetBrushMip(enOther); + if (pbmOther==NULL) { _pfWorldEditingProfile.StopTimer(CWorldEditingProfile::PTI_CSGTOTAL); return; } @@ -596,7 +596,7 @@ void CWorld::SplitPolygons(CEntity &enThis, CBrushPolygonSelection &selbpoPolygo // get the sector of the other brush to object CBrushSectorSelectionForCSG selbscOther; - bmOther.SelectAllSectors(selbscOther); + pbmOther->SelectAllSectors(selbscOther); CObject3D obOther; DOUBLEaabbox3D boxOther; woOther.CopySourceBrushSectorsToObject(enOther, selbscOther, plOther, diff --git a/Sources/EntitiesMP/Summoner.es b/Sources/EntitiesMP/Summoner.es index 5fa1ae9..02fe1c6 100755 --- a/Sources/EntitiesMP/Summoner.es +++ b/Sources/EntitiesMP/Summoner.es @@ -627,7 +627,7 @@ functions: while (iCount>0) { i++; - while (&*pen[i]==NULL) { + while (pen[i].get()==NULL) { i++; } iCount--; @@ -1337,17 +1337,17 @@ procedures: m_iGroup01Count = 0; pen = &m_penGroup01Template01; for (i=0; i Date: Mon, 30 May 2016 01:06:10 +0200 Subject: [PATCH 29/34] Fix compilation from changes for GCC 6.1.1 At least on my system floor() and log10() return double, so the other arguments to Clamp() and ClampDn() didn't match anymore, now being float instead of double. I replaced the calls to log10f() and floorf() to avoid any ambiguities. --- Sources/Entities/Bullet.es | 2 +- Sources/Entities/Player.es | 2 +- Sources/EntitiesMP/Common/Common.cpp | 2 +- Sources/EntitiesMP/Player.es | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/Entities/Bullet.es b/Sources/Entities/Bullet.es index 2c7c990..c245f8d 100644 --- a/Sources/Entities/Bullet.es +++ b/Sources/Entities/Bullet.es @@ -344,7 +344,7 @@ functions: GetNormalComponent( vDistance/fDistance, vHitNormal, ese.vDirection); FLOAT fLength = ese.vDirection.Length(); fLength = Clamp( fLength*3, 1.0f, 3.0f); - fDistance = Clamp( log10(fDistance), 0.5f, 2.0f); + fDistance = Clamp( log10f(fDistance), 0.5f, 2.0f); ese.vStretch = FLOAT3D( fDistance, fLength*fDistance, 1.0f); SpawnEffect(vHitPoint, ese); } diff --git a/Sources/Entities/Player.es b/Sources/Entities/Player.es index 2a09bff..e62c7f3 100644 --- a/Sources/Entities/Player.es +++ b/Sources/Entities/Player.es @@ -4588,7 +4588,7 @@ void TeleportPlayer(enum WorldLinkType EwltType) TIME tmLevelTime = _pTimer->CurrentTick()-m_tmLevelStarted; m_psLevelStats.ps_tmTime = tmLevelTime; m_psGameStats.ps_tmTime += tmLevelTime; - FLOAT fTimeDelta = ClampDn(floor(m_tmEstTime)-floor(tmLevelTime), 0.0f); + FLOAT fTimeDelta = ClampDn(floorf(m_tmEstTime)-floorf(tmLevelTime), 0.0f); m_iTimeScore = floor(fTimeDelta*100.0f); m_psLevelStats.ps_iScore+=m_iTimeScore; m_psGameStats.ps_iScore+=m_iTimeScore; diff --git a/Sources/EntitiesMP/Common/Common.cpp b/Sources/EntitiesMP/Common/Common.cpp index 75dd98e..14d23db 100755 --- a/Sources/EntitiesMP/Common/Common.cpp +++ b/Sources/EntitiesMP/Common/Common.cpp @@ -386,7 +386,7 @@ void SpawnHitTypeEffect(CEntity *pen, enum BulletHitType bhtType, BOOL bSound, F GetNormalComponent( vDistance/fDistance, vHitNormal, ese.vDirection); FLOAT fLength = ese.vDirection.Length(); fLength = Clamp( fLength*3, 1.0f, 3.0f); - fDistance = Clamp( log10(fDistance), 0.5f, 2.0f); + fDistance = Clamp( log10f(fDistance), 0.5f, 2.0f); ese.vStretch = FLOAT3D( fDistance, fLength*fDistance, 1.0f); try { diff --git a/Sources/EntitiesMP/Player.es b/Sources/EntitiesMP/Player.es index 02067a9..505a270 100755 --- a/Sources/EntitiesMP/Player.es +++ b/Sources/EntitiesMP/Player.es @@ -5381,7 +5381,7 @@ functions: TIME tmLevelTime = _pTimer->CurrentTick()-m_tmLevelStarted; m_psLevelStats.ps_tmTime = tmLevelTime; m_psGameStats.ps_tmTime += tmLevelTime; - FLOAT fTimeDelta = ClampDn(floor(m_tmEstTime)-floor(tmLevelTime), 0.0f); + FLOAT fTimeDelta = ClampDn(floorf(m_tmEstTime)-floorf(tmLevelTime), 0.0f); m_iTimeScore = (INDEX) floor(fTimeDelta*100.0f); m_psLevelStats.ps_iScore+=m_iTimeScore; m_psGameStats.ps_iScore+=m_iTimeScore; From 882c7773b56647c98e5656331699a299a8a74614 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Mon, 6 Jun 2016 03:53:57 +0200 Subject: [PATCH 30/34] Game can be executed and quit without crashes mostly checks before calling AddReference()/RemReference() --- Sources/Engine/Base/Anim.cpp | 6 +++--- Sources/Engine/Entities/Entity.cpp | 2 +- Sources/Engine/Entities/Entity.h | 14 +++++++------- Sources/Engine/Graphics/GfxLibrary.cpp | 2 +- Sources/Engine/Sound/SoundObject.cpp | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Sources/Engine/Base/Anim.cpp b/Sources/Engine/Base/Anim.cpp index 10d04e8..8eff66e 100644 --- a/Sources/Engine/Base/Anim.cpp +++ b/Sources/Engine/Base/Anim.cpp @@ -615,7 +615,7 @@ CAnimObject::CAnimObject(void) /* Destructor. */ CAnimObject::~CAnimObject(void) { - ao_AnimData->RemReference(); + if(ao_AnimData != NULL) ao_AnimData->RemReference(); } // copy from another object of same class @@ -818,9 +818,9 @@ BOOL CAnimObject::IsUpToDate(const CUpdateable &ud) const void CAnimObject::SetData(CAnimData *pAD) { // mark new data as referenced once more - pAD->AddReference(); + if(pAD != NULL) pAD->AddReference(); // mark old data as referenced once less - ao_AnimData->RemReference(); + if(ao_AnimData != NULL) ao_AnimData->RemReference(); // remember new data ao_AnimData = pAD; if( pAD != NULL) StartAnim( 0); diff --git a/Sources/Engine/Entities/Entity.cpp b/Sources/Engine/Entities/Entity.cpp index 89bf604..9117b76 100644 --- a/Sources/Engine/Entities/Entity.cpp +++ b/Sources/Engine/Entities/Entity.cpp @@ -186,7 +186,7 @@ CEntity::~CEntity(void) } // clear entity type en_RenderType = RT_NONE; - en_pecClass->RemReference(); + if(en_pecClass != NULL) en_pecClass->RemReference(); en_pecClass = NULL; en_fSpatialClassificationRadius = -1.0f; diff --git a/Sources/Engine/Entities/Entity.h b/Sources/Engine/Entities/Entity.h index 57d174d..e473049 100644 --- a/Sources/Engine/Entities/Entity.h +++ b/Sources/Engine/Entities/Entity.h @@ -670,20 +670,20 @@ BOOL ENGINE_API IsDerivedFromClass(CEntity *pen, const char *pstrClassName); // all standard smart pointer functions are here as inlines inline CEntityPointer::CEntityPointer(void) : ep_pen(NULL) {}; -inline CEntityPointer::~CEntityPointer(void) { ep_pen->RemReference(); }; +inline CEntityPointer::~CEntityPointer(void) { if(ep_pen != NULL) ep_pen->RemReference(); }; inline CEntityPointer::CEntityPointer(const CEntityPointer &penOther) : ep_pen(penOther.ep_pen) { - ep_pen->AddReference(); }; + if(ep_pen != NULL) ep_pen->AddReference(); }; inline CEntityPointer::CEntityPointer(CEntity *pen) : ep_pen(pen) { - ep_pen->AddReference(); }; + if(ep_pen != NULL) ep_pen->AddReference(); }; inline const CEntityPointer &CEntityPointer::operator=(CEntity *pen) { - pen->AddReference(); // must first add, then remove! - ep_pen->RemReference(); + if(pen != NULL) pen->AddReference(); // must first add, then remove! + if(ep_pen != NULL) ep_pen->RemReference(); ep_pen = pen; return *this; } inline const CEntityPointer &CEntityPointer::operator=(const CEntityPointer &penOther) { - penOther.ep_pen->AddReference(); // must first add, then remove! - ep_pen->RemReference(); + if(penOther.ep_pen != NULL) penOther.ep_pen->AddReference(); // must first add, then remove! + if(ep_pen != NULL) ep_pen->RemReference(); ep_pen = penOther.ep_pen; return *this; } diff --git a/Sources/Engine/Graphics/GfxLibrary.cpp b/Sources/Engine/Graphics/GfxLibrary.cpp index 9c03272..7bd6422 100644 --- a/Sources/Engine/Graphics/GfxLibrary.cpp +++ b/Sources/Engine/Graphics/GfxLibrary.cpp @@ -807,7 +807,7 @@ extern BOOL ProbeMode( CTimerValue tvLast) extern void UncacheShadows(void) { // mute all sounds - _pSound->Mute(); + if(_pSound != NULL) _pSound->Mute(); // prepare new saturation factors for shadowmaps gfx_fSaturation = ClampDn( gfx_fSaturation, 0.0f); shd_fSaturation = ClampDn( shd_fSaturation, 0.0f); diff --git a/Sources/Engine/Sound/SoundObject.cpp b/Sources/Engine/Sound/SoundObject.cpp index cedd31e..1eeb581 100644 --- a/Sources/Engine/Sound/SoundObject.cpp +++ b/Sources/Engine/Sound/SoundObject.cpp @@ -240,9 +240,9 @@ void CSoundObject::Play_internal( CSoundData *pCsdLink, SLONG slFlags) Stop_internal(); // mark new data as referenced once more - pCsdLink->AddReference(); + if(pCsdLink != NULL) pCsdLink->AddReference(); // mark old data as referenced once less - so_pCsdLink->RemReference(); + if(so_pCsdLink != NULL) so_pCsdLink->RemReference(); // store init SoundData so_pCsdLink = pCsdLink; From 1b895d7478d01e3ed3f0986635e88a26328dd6b3 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Mon, 6 Jun 2016 04:28:42 +0200 Subject: [PATCH 31/34] Support both ModExt.txt and ModEXT.txt --- Sources/Engine/Base/Stream.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sources/Engine/Base/Stream.cpp b/Sources/Engine/Base/Stream.cpp index 6c08446..79cc5d6 100755 --- a/Sources/Engine/Base/Stream.cpp +++ b/Sources/Engine/Base/Stream.cpp @@ -169,7 +169,13 @@ void InitStreams(void) } // find eventual extension for the mod's dlls _strModExt = ""; - LoadStringVar(CTString("ModEXT.txt"), _strModExt); + // DG: apparently both ModEXT.txt and ModExt.txt exist in the wild. + CTFileName tmp; + if(ExpandFilePath(EFP_READ, CTString("ModEXT.txt"), tmp) != EFP_NONE) { + LoadStringVar(CTString("ModEXT.txt"), _strModExt); + } else { + LoadStringVar(CTString("ModExt.txt"), _strModExt); + } CPrintF(TRANSV("Loading group files...\n")); From b4d1daa320755c41266820146b1fd6cb4e958dea Mon Sep 17 00:00:00 2001 From: Tan Wang Leng Date: Thu, 16 Jun 2016 22:12:38 +0800 Subject: [PATCH 32/34] Update README.md to include Linux --- README.md | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/README.md b/README.md index 90a3ad3..6f34b7d 100644 --- a/README.md +++ b/README.md @@ -28,12 +28,61 @@ These have been modified to run correctly under the recent version of Windows. ( Building -------- +### Windows + To build Serious Engine 1, you'll need Visual Studio 2013 or 2015, Professional or Community edition ( https://www.visualstudio.com/post-download-vs?sku=community ). Do not use spaces in the path to the solution. Once you've installed Visual Studio and (optionally) DirectX8 SDK, you can build the engine solution (`/Sources/All.sln`). Press F7 or Build -> Build solution. The libraries and executables will be put into `\Bin\` directory (or `\Bin\Debug\` if you are using the Debug configuration). +### Linux + +#### Setting up the repository + +Type this in your terminal: + +``` +git clone https://github.com/rcgordon/Serious-Engine.git +cd Serious-Engine +``` + +#### Copy official game data (optional) + +If you have access to a copy of the game (either by CD or through Steam), +you can copy the *.gro files from the game directory to the repository. + +#### Building (only for SS:TSE) + +Type this in your terminal: + +``` +Sources/build-linux64.sh # use build-linux32.sh for 32-bits +cp Sources/cmake-build/ssam Bin/ +cp Sources/cmake-build/Debug/* Bin/Debug/ +``` + +#### Building (only for SS:TFE) + +Same as SS:SE, but note the following: + +- Before running build-linux64.sh, modify the file by passing `-DTFE=TRUE` to cmake. +- After building, you need to copy 'ssam**-tfe**' instead of 'ssam', as shown: + + ``` + cp Sources/cmake-build/ssam-tfe Bin/ + ``` + +#### Running + +Type this in your terminal: + +``` +Bin/ssam +``` + +(or `ssam-tfe` if you are running TFE) + Optional features ----------------- From e70a5bb92b4c8270d9e225fbf3411b5f1e549e86 Mon Sep 17 00:00:00 2001 From: comicfans44 Date: Sun, 3 Jul 2016 04:33:41 -0400 Subject: [PATCH 33/34] fix sscanf stack buffer overflow. string should have '\0' --- Sources/GameMP/Controls.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/GameMP/Controls.cpp b/Sources/GameMP/Controls.cpp index 9147ff0..17c90f1 100644 --- a/Sources/GameMP/Controls.cpp +++ b/Sources/GameMP/Controls.cpp @@ -180,7 +180,7 @@ void CControls::Load_t( CTFileName fnFile) char achrLine[ 1024]; char achrName[ 1024]; char achrID[ 1024]; - char achrActionName[ 1024]; + char achrActionName[ 1025]; // open script file for reading CTFileStream strmFile; @@ -216,13 +216,13 @@ void CControls::Load_t( CTFileName fnFile) // if this is axis action } else if( CTString( achrID) == "Axis") { - char achrAxis[ 1024]; + char achrAxis[ 1025]; achrAxis[ 0] = 0; - char achrIfInverted[ 1024]; + char achrIfInverted[ 1025]; achrIfInverted[ 0] = 0; - char achrIfRelative[ 1024]; + char achrIfRelative[ 1025]; achrIfRelative[ 0] = 0; - //char achrIfSmooth[ 1024]; + //char achrIfSmooth[ 1025]; //achrIfSmooth[ 0] = 0; achrActionName[ 0] = 0; FLOAT fSensitivity = 50; From 57cd734dbcc5c2e6529f824dbe38f6370b930f00 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Tue, 19 Apr 2016 07:20:41 +0200 Subject: [PATCH 34/34] Don't regulate Framerate on Pandora Restrict the Eps precision change only to Pandora platform fix Inverted Right and Middle button on certain case with SDL Added some Failsafe. Fixed a crash in the new game intro cinematic (when Boss of TFE die and Sam goes to the UFO) on the Pandora Some Pandora fine-tunning Tried some asynchronus input method, but doesn't seems to works --- Sources/Engine/Base/SDL/SDLInput.cpp | 38 +++++++++++++++------------ Sources/Engine/Engine.cpp | 15 +++++++++++ Sources/Engine/Math/Quaternion.h | 4 +++ Sources/Engine/Rendering/RendASER.cpp | 5 ++-- Sources/SeriousSam/SeriousSam.cpp | 3 +++ 5 files changed, 45 insertions(+), 20 deletions(-) mode change 100644 => 100755 Sources/Engine/Engine.cpp mode change 100644 => 100755 Sources/Engine/Rendering/RendASER.cpp mode change 100644 => 100755 Sources/SeriousSam/SeriousSam.cpp diff --git a/Sources/Engine/Base/SDL/SDLInput.cpp b/Sources/Engine/Base/SDL/SDLInput.cpp index d378cc1..17ebefa 100755 --- a/Sources/Engine/Base/SDL/SDLInput.cpp +++ b/Sources/Engine/Base/SDL/SDLInput.cpp @@ -251,6 +251,10 @@ static int _iMouseZ = 0; static BOOL _bWheelUp = FALSE; static BOOL _bWheelDn = FALSE; +// emulate Win32: A single mouse wheel rotation +// is +120 (upwards) or -120 (downwards) +#define MOUSE_SCROLL_INTERVAL 120 + CTCriticalSection csInput; // which keys are pressed, as recorded by message interception (by KIDs) @@ -314,15 +318,20 @@ static void sdl_event_handler(const SDL_Event *event) case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: - if (event->button.button <= 5) - _abKeysPressed[KID_MOUSE1 + (event->button.button-1)] = (event->button.state == SDL_PRESSED) ? TRUE : FALSE; + if (event->button.button <= 5) { + int button = KID_MOUSE1; + switch(event->button.button) { + case SDL_BUTTON_RIGHT: button = KID_MOUSE2; break; + case SDL_BUTTON_MIDDLE: button = KID_MOUSE3; break; + case 4: button = KID_MOUSE4; break; + case 5: button = KID_MOUSE5; break; + } + _abKeysPressed[button] = (event->button.state == SDL_PRESSED) ? TRUE : FALSE; + } break; case SDL_MOUSEWHEEL: - if (event->wheel.y > 0) - _abKeysPressed[KID_MOUSEWHEELUP] = TRUE; - else if (event->wheel.y < 0) - _abKeysPressed[KID_MOUSEWHEELDOWN] = TRUE; + _iMouseZ += event->wheel.y * MOUSE_SCROLL_INTERVAL; break; case SDL_KEYDOWN: @@ -715,6 +724,7 @@ void CInput::GetInput(BOOL bPreScan) // clear button's buffer memset( inp_ubButtonsBuffer, 0, sizeof( inp_ubButtonsBuffer)); + Uint8 *keystate = SDL_GetKeyboardState(NULL); // for each Key for (INDEX iKey=0; iKey=0) { // is state is pressed - if (SDL_GetKeyboardState(NULL)[SDL_GetScancodeFromKey((SDL_Keycode)iVirt)]) { + if (keystate[SDL_GetScancodeFromKey((SDL_Keycode)iVirt)]) { // mark it as pressed inp_ubButtonsBuffer[iKID] = 0xFF; } @@ -744,10 +754,6 @@ void CInput::GetInput(BOOL bPreScan) } } - // reset this every frame (since we explicitly ignore the button-up events). - _abKeysPressed[KID_MOUSEWHEELUP] = FALSE; - _abKeysPressed[KID_MOUSEWHEELDOWN] = FALSE; - // read mouse position #ifdef USE_MOUSEWARP int iMx, iMy; @@ -816,17 +822,16 @@ void CInput::GetInput(BOOL bPreScan) } #endif -/* // if not pre-scanning if (!bPreScan) { // detect wheel up/down movement - _bWheelDn = FALSE; + if (_iMouseZ>0) { if (_bWheelUp) { inp_ubButtonsBuffer[KID_MOUSEWHEELUP] = 0x00; } else { inp_ubButtonsBuffer[KID_MOUSEWHEELUP] = 0xFF; - _iMouseZ = ClampDn(_iMouseZ-120, 0); + _iMouseZ = ClampDn(_iMouseZ-MOUSE_SCROLL_INTERVAL, 0); } } _bWheelUp = inp_ubButtonsBuffer[KID_MOUSEWHEELUP]; @@ -835,12 +840,11 @@ void CInput::GetInput(BOOL bPreScan) inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN] = 0x00; } else { inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN] = 0xFF; - _iMouseZ = ClampUp(_iMouseZ+120, 0); + _iMouseZ = ClampUp(_iMouseZ+MOUSE_SCROLL_INTERVAL, 0); } } _bWheelDn = inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN]; } -*/ inp_bLastPrescan = bPreScan; diff --git a/Sources/Engine/Engine.cpp b/Sources/Engine/Engine.cpp old mode 100644 new mode 100755 index 15021ca..84e5944 --- a/Sources/Engine/Engine.cpp +++ b/Sources/Engine/Engine.cpp @@ -127,6 +127,9 @@ static void DetectCPU(void) { #if (defined USE_PORTABLE_C) // rcg10072001 CPrintF(TRANSV(" (No CPU detection in this binary.)\n")); + #ifdef PLATFORM_PANDORA + sys_iCPUMHz = 400; // conservative, ARM -> x86 cpu translation is not 1 to 1. + #endif #else char strVendor[12+1]; @@ -398,7 +401,19 @@ static void SetupMemoryManager(void) sys_iRAMSwap = ms.dwTotalPageFile/MB; #elif (defined PLATFORM_UNIX) + #ifdef PLATFORM_PANDORA + sys_iRAMPhys = 256; // conservative here, there is 256MB models and 512MB... + FILE* esrev = fopen("/etc/powervr-esrev", "r"); + if (esrev) { + int rev = 0; + fscanf(esrev,"%d", &rev); + if (rev==3 || rev==5) + sys_iRAMPhys = 512; + fclose(esrev); + }; + #else sys_iRAMPhys = 1; // !!! FIXME: This is bad. Bad. BAD. + #endif sys_iRAMSwap = 1; #else diff --git a/Sources/Engine/Math/Quaternion.h b/Sources/Engine/Math/Quaternion.h index b46c078..19dbae5 100755 --- a/Sources/Engine/Math/Quaternion.h +++ b/Sources/Engine/Math/Quaternion.h @@ -370,7 +370,11 @@ void Quaternion::FromEuler(const Vector &a) template Type Quaternion::EPS(Type orig) const { +#ifdef PLATFORM_PANDORA + if ((orig <= 1e-4f) && (orig >= -1e-4f)) +#else if ((orig <= 10e-6f) && (orig >= -10e-6f)) +#endif return(0.0f); return(orig); diff --git a/Sources/Engine/Rendering/RendASER.cpp b/Sources/Engine/Rendering/RendASER.cpp old mode 100644 new mode 100755 index e5d52b0..7428a11 --- a/Sources/Engine/Rendering/RendASER.cpp +++ b/Sources/Engine/Rendering/RendASER.cpp @@ -34,7 +34,6 @@ void CRenderer::AddAddListToActiveList(INDEX iScanLine) // allocate space in destination for sum of source and add INDEX ctActiveEdges = re_aaceActiveEdges.Count(); re_aaceActiveEdgesTmp.Push(ctAddEdges+ctActiveEdges); - // check that the add list is sorted right #if ASER_EXTREME_CHECKING { @@ -66,18 +65,18 @@ void CRenderer::AddAddListToActiveList(INDEX iScanLine) // start at begining of add list, source active list and destination active list LISTITER(CAddEdge, ade_lnInAdd) itadeAdd(lhAdd); CActiveEdge *paceSrc = &re_aaceActiveEdges[0]; + CActiveEdge *paceEnd = &re_aaceActiveEdges[re_aaceActiveEdges.Count()-1]; CActiveEdge *paceDst = &re_aaceActiveEdgesTmp[0]; IFDEBUG(INDEX ctNewActive=0); IFDEBUG(INDEX ctOldActive1=0); IFDEBUG(INDEX ctOldActive2=0); - // for each edge in add list while(!itadeAdd.IsPastEnd()) { CAddEdge &ade = *itadeAdd; // while the edge in active list is left of the edge in add list - while (paceSrc->ace_xI.slHolder < itadeAdd->ade_xI.slHolder) { + while ((paceSrc->ace_xI.slHolder < ade.ade_xI.slHolder) && (paceSrc!=paceEnd)) { // copy the active edge ASSERT(paceSrc<=&re_aaceActiveEdges[ctActiveEdges-1]); *paceDst++=*paceSrc++; diff --git a/Sources/SeriousSam/SeriousSam.cpp b/Sources/SeriousSam/SeriousSam.cpp old mode 100644 new mode 100755 index 9b76471..b28ffff --- a/Sources/SeriousSam/SeriousSam.cpp +++ b/Sources/SeriousSam/SeriousSam.cpp @@ -281,6 +281,8 @@ static void UpdatePauseState(void) // limit current frame rate if neeeded void LimitFrameRate(void) { + // do not limit FPS on the Pandora, it's not powerfull enough and doesn't "iconise" games either + #ifndef PLATFORM_PANDORA // measure passed time for each loop static CTimerValue tvLast(-1.0f); CTimerValue tvNow = _pTimer->GetHighPrecisionTimer(); @@ -299,6 +301,7 @@ void LimitFrameRate(void) // remember new time tvLast = _pTimer->GetHighPrecisionTimer(); + #endif } // load first demo