From ead5da376dc6a898128ffede174b8a34c3a73ce0 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Wed, 6 Apr 2016 22:43:08 +0200 Subject: [PATCH 1/3] Cannot cast a Float to Unsigned integer directly on ARM, of sign will be lost, so double cast --- Sources/Engine/Network/EMsgBuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 Sources/Engine/Network/EMsgBuffer.cpp diff --git a/Sources/Engine/Network/EMsgBuffer.cpp b/Sources/Engine/Network/EMsgBuffer.cpp old mode 100644 new mode 100755 index befe836..81b61fc --- a/Sources/Engine/Network/EMsgBuffer.cpp +++ b/Sources/Engine/Network/EMsgBuffer.cpp @@ -41,7 +41,7 @@ void AngleToUL(ANGLE3D &Angle,ULONG &ulResult) ubDir = (UBYTE) (AxisAngles(2)/90*127); ulResult = ulResult << 8; ulResult |= ubDir; - swAngle = (UWORD) (fRotAngle * 180); // after rounding, angle is precise up to 1/180 degrees (65536/360 ~ 180) + swAngle = (UWORD) (SWORD) (fRotAngle * 180); // after rounding, angle is precise up to 1/180 degrees (65536/360 ~ 180) ulResult = (ulResult << 16) | swAngle; }; From efde059273da7907e113c5d246f8b085d121a750 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Wed, 6 Apr 2016 22:43:51 +0200 Subject: [PATCH 2/3] Getting paranoid with mixed integer / float operations --- Sources/EntitiesMP/Common/Particles.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 Sources/EntitiesMP/Common/Particles.cpp diff --git a/Sources/EntitiesMP/Common/Particles.cpp b/Sources/EntitiesMP/Common/Particles.cpp old mode 100644 new mode 100755 index f92a763..50aa05c --- a/Sources/EntitiesMP/Common/Particles.cpp +++ b/Sources/EntitiesMP/Common/Particles.cpp @@ -1731,7 +1731,7 @@ void Particles_FlameThrowerStart(const CPlacement3D &plPipe, FLOAT fStartTime, F FLOAT3D vCenter = plPipe.pl_PositionVector; FLOAT fPowerFactor = Clamp((fNow - fStartTime)/2.0f,0.0f,1.0f); - fPowerFactor *= Clamp(1+(fStopTime-fNow)/2.0f,0.0f,1.0f); + 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; From 2ccc3378987158c76aa239354d9d806df3de0f00 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Wed, 6 Apr 2016 22:44:45 +0200 Subject: [PATCH 3/3] The control87 is a fake one when using USE_PORTABLE_C, regardless the architecture --- Sources/Engine/Math/Float.cpp | 50 +++++++++++++++-------------------- 1 file changed, 21 insertions(+), 29 deletions(-) mode change 100644 => 100755 Sources/Engine/Math/Float.cpp diff --git a/Sources/Engine/Math/Float.cpp b/Sources/Engine/Math/Float.cpp old mode 100644 new mode 100755 index 1466160..7770d37 --- a/Sources/Engine/Math/Float.cpp +++ b/Sources/Engine/Math/Float.cpp @@ -17,32 +17,30 @@ with this program; if not, write to the Free Software Foundation, Inc., #include -#if (defined __GNU_INLINE__) -#define MCW_PC 0x0300 +#define MCW_PC 0x0300 #define _MCW_PC MCW_PC -#define _PC_24 0x0000 -#define _PC_53 0x0200 -#define _PC_64 0x0300 +#define _PC_24 0x0000 +#define _PC_53 0x0200 +#define _PC_64 0x0300 + +#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); +} +#else + +#if (defined __GNU_INLINE__) inline ULONG _control87(WORD newcw, WORD mask) { -#if __POWERPC__ - static WORD fpw=_PC_64; - if (mask != 0) - { - fpw &= ~mask; - fpw |= (newcw & mask); - } - return(fpw); -#elif defined(__arm__) - static WORD fpw=_PC_64; - if (mask != 0) - { - fpw &= ~mask; - fpw |= (newcw & mask); - } - return(fpw); -#else WORD fpw = 0; // get the current FPU control word... @@ -55,16 +53,10 @@ inline ULONG _control87(WORD newcw, WORD mask) __asm__ __volatile__ (" fldcw %0" : : "m" (fpw) : "memory"); } return(fpw); -#endif } // (for intel compiler...) #elif ((defined __MSVC_INLINE__) && (!defined _MSC_VER)) -#define MCW_PC 0x0300 -#define _MCW_PC MCW_PC -#define _PC_24 0x0000 -#define _PC_53 0x0200 -#define _PC_64 0x0300 inline ULONG _control87(WORD newcw, WORD mask) { @@ -85,7 +77,7 @@ inline ULONG _control87(WORD newcw, WORD mask) #elif (!defined _MSC_VER) #error Implement for your platform, or add a stub conditional here. #endif - +#endif /* Get current precision setting of FPU. */ enum FPUPrecisionType GetFPUPrecision(void) {