From 352172e41b24e0bcaf40b7f24ab97ed153f5661b Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Fri, 6 Feb 2015 21:54:47 -0800 Subject: [PATCH 1/6] Fix HS_DEBUGGING for non-MSVC compilers. --- Sources/Plasma/CoreLib/HeadSpin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Plasma/CoreLib/HeadSpin.cpp b/Sources/Plasma/CoreLib/HeadSpin.cpp index 0b218d0c..db933b3e 100644 --- a/Sources/Plasma/CoreLib/HeadSpin.cpp +++ b/Sources/Plasma/CoreLib/HeadSpin.cpp @@ -119,7 +119,7 @@ void ErrorAssert(int line, const char* file, const char* fmt, ...) va_list args; va_start(args, fmt); vsnprintf(msg, arrsize(msg), fmt, args); -#ifdef HS_DEBUGGING +#if defined(HS_DEBUGGING) && defined(_MSC_VER) if (s_GuiAsserts) { if(_CrtDbgReport(_CRT_ASSERT, file, line, NULL, msg)) From 8010f5d05149424c2572121b48fdd0796051f901 Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Sun, 8 Feb 2015 23:20:37 -0800 Subject: [PATCH 2/6] MinGW fix for plGLight isnan usage. --- .../PubUtilLib/plGLight/plPerspDirSlave.cpp | 16 ++++++---------- .../Plasma/PubUtilLib/plGLight/plShadowSlave.cpp | 10 +++------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plGLight/plPerspDirSlave.cpp b/Sources/Plasma/PubUtilLib/plGLight/plPerspDirSlave.cpp index 8fff1ee6..04ee1257 100644 --- a/Sources/Plasma/PubUtilLib/plGLight/plPerspDirSlave.cpp +++ b/Sources/Plasma/PubUtilLib/plGLight/plPerspDirSlave.cpp @@ -50,10 +50,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include -#ifdef HS_BUILD_FOR_WIN32 -#define isnan _isnan -#endif - void plPerspDirSlave::Init() { plShadowSlave::Init(); @@ -187,10 +183,10 @@ bool plPerspDirSlave::SetupViewTransform(plPipeline* pipe) // This is my hack to get the Nexus age working. The real problem // is probably data-side. I take full responsibility for this // hack-around breaking the entire system, loosing data, causing - // unauthorized credit card transactions, etc. - if (isnan(bnd.GetMins().fX) || isnan(bnd.GetMins().fY)) + // unauthorized credit card transactions, etc. + if (std::isnan(bnd.GetMins().fX) || std::isnan(bnd.GetMins().fY)) return false; - if (isnan(bnd.GetMaxs().fX) || isnan(bnd.GetMaxs().fY)) + if (std::isnan(bnd.GetMaxs().fX) || std::isnan(bnd.GetMaxs().fY)) return false; // THIS IS EVEN MORE WRONG @@ -248,10 +244,10 @@ bool plPerspDirSlave::SetupViewTransform(plPipeline* pipe) // This is my hack to get the Nexus age working. The real problem // is probably data-side. I take full responsibility for this // hack-around breaking the entire system, loosing data, causing - // unauthorized credit card transactions, etc. - if (isnan(bnd.GetMins().fX) || isnan(bnd.GetMins().fY)) + // unauthorized credit card transactions, etc. + if (std::isnan(bnd.GetMins().fX) || std::isnan(bnd.GetMins().fY)) return false; - if (isnan(bnd.GetMaxs().fX) || isnan(bnd.GetMaxs().fY)) + if (std::isnan(bnd.GetMaxs().fX) || std::isnan(bnd.GetMaxs().fY)) return false; plConst(float) kMinMinZ(1.f); diff --git a/Sources/Plasma/PubUtilLib/plGLight/plShadowSlave.cpp b/Sources/Plasma/PubUtilLib/plGLight/plShadowSlave.cpp index bf95e40d..6e9123d9 100644 --- a/Sources/Plasma/PubUtilLib/plGLight/plShadowSlave.cpp +++ b/Sources/Plasma/PubUtilLib/plGLight/plShadowSlave.cpp @@ -48,10 +48,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include -#ifdef HS_BUILD_FOR_WIN32 -#define isnan _isnan -#endif - static const float kMinMinZ = 1.f; // totally random arbitrary number (has to be > 0). bool plShadowSlave::ISetupOrthoViewTransform() @@ -136,10 +132,10 @@ bool plShadowSlave::ISetupPerspViewTransform() // This is my hack to get the Nexus age working. The real problem // is probably data-side. I take full responsibility for this // hack-around breaking the entire system, loosing data, causing - // unauthorized credit card transactions, etc. - if (isnan(bnd.GetMins().fX) || isnan(bnd.GetMins().fY)) + // unauthorized credit card transactions, etc. + if (std::isnan(bnd.GetMins().fX) || std::isnan(bnd.GetMins().fY)) return false; - if (isnan(bnd.GetMaxs().fX) || isnan(bnd.GetMaxs().fY)) + if (std::isnan(bnd.GetMaxs().fX) || std::isnan(bnd.GetMaxs().fY)) return false; float cotX, cotY; From 79a470d31c0d45a3ae8f42447f36018f7ba8f6d8 Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Sun, 8 Feb 2015 23:24:23 -0800 Subject: [PATCH 3/6] Some cross-platform MinGW/gcc fixes. --- Sources/Plasma/PubUtilLib/plDrawable/plMorphSequence.cpp | 4 ++-- .../Plasma/PubUtilLib/plDrawable/plMorphSequenceSDLMod.cpp | 2 +- Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plMorphSequence.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plMorphSequence.cpp index e200d1c0..0b9bba90 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plMorphSequence.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plMorphSequence.cpp @@ -131,7 +131,7 @@ bool plMorphSequence::MsgReceive(plMessage* msg) // Can always add it in later if desired. if( fTgtWgts.GetCount() ) { - float delWgt = hsTimer::GetDelSysSeconds() / (kMorphTime > 0 ? kMorphTime : 1.e-3f); + float delWgt = hsTimer::GetDelSysSeconds() / (kMorphTime > 0 ? float(kMorphTime) : 1.e-3f); int i; for( i = 0; i < fTgtWgts.GetCount(); i++ ) { @@ -820,4 +820,4 @@ void plMorphSequence::ISetSingleSharedToGlobal(int idx) int i; for (i = 0; i < fSharedMeshes[fGlobalLayerRef].fArrayWeights[0].fDeltaWeights.GetCount(); i++) SetWeight(0, i, fSharedMeshes[fGlobalLayerRef].fArrayWeights[0].fDeltaWeights[i], fSharedMeshes[idx].fMesh->GetKey()); -} \ No newline at end of file +} diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plMorphSequenceSDLMod.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plMorphSequenceSDLMod.cpp index d3cc3c5e..4c381d27 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plMorphSequenceSDLMod.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plMorphSequenceSDLMod.cpp @@ -154,7 +154,7 @@ void plMorphSequenceSDLMod::ISetCurrentStateFrom(const plStateDataRecord* srcSta { plKey meshKey; morphSD->GetStateDataRecord(i)->FindVar(kStrMesh)->Get(&meshKey); - if (meshKey && !meshKey->GetUoid().GetClassType() == plSharedMesh::Index()) + if (meshKey && meshKey->GetUoid().GetClassType() != plSharedMesh::Index()) continue; // meshKey will be nil when dealing with non-sharedMesh data diff --git a/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp b/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp index 3aa975c4..d65a6074 100644 --- a/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp +++ b/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp @@ -325,7 +325,10 @@ uint32_t plSecureStream::IRead(uint32_t bytes, void* buffer) } else { + // TODO: errno equivalent for *nix +#if HS_BUILD_FOR_WIN32 hsDebugMessage("Error on Windows read", GetLastError()); +#endif } } return numItems; From 598f5f47ecc82ab18d034c534f43f6c61a2aefb3 Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Fri, 6 Feb 2015 21:55:18 -0800 Subject: [PATCH 4/6] Fix compiler error in pnUtArray. --- Sources/Plasma/NucleusLib/pnUtils/pnUtArray.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtArray.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtArray.h index 6d7fea92..078c5c31 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtArray.h +++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtArray.h @@ -829,8 +829,8 @@ template void TArray::Copy (unsigned destIndex, unsigned sourceIndex, unsigned count) { // Copy the data to the destination - ASSERT(destIndex + count <= m_count); - ASSERT(sourceIndex + count <= m_count); + ASSERT(destIndex + count <= this->m_count); + ASSERT(sourceIndex + count <= this->m_count); C::Assign(this->m_data + destIndex, this->m_data + sourceIndex, count); } From 9b37590ca8904cf84a86f2c8d2d5895d5ecfda30 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Fri, 13 Feb 2015 20:47:49 -0800 Subject: [PATCH 5/6] Set HS_DEBUGGING properly on non-MSVC compilers --- Sources/Plasma/CoreLib/HeadSpin.h | 4 ++-- cmake/CompilerChecks.cmake | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Sources/Plasma/CoreLib/HeadSpin.h b/Sources/Plasma/CoreLib/HeadSpin.h index 41985112..76a98e8d 100644 --- a/Sources/Plasma/CoreLib/HeadSpin.h +++ b/Sources/Plasma/CoreLib/HeadSpin.h @@ -45,9 +45,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com // Ensure these get set consistently regardless of what module includes it #include "hsCompilerSpecific.h" -#if (defined(_DEBUG) || defined(UNIX_DEBUG)) +#if defined(_DEBUG) # define HS_DEBUGGING -#endif // defined(_DEBUG) || defined(UNIX_DENUG) +#endif //====================================== // Some standard includes diff --git a/cmake/CompilerChecks.cmake b/cmake/CompilerChecks.cmake index aa85866c..973b671c 100644 --- a/cmake/CompilerChecks.cmake +++ b/cmake/CompilerChecks.cmake @@ -11,6 +11,13 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) endif() endif() +# MSVC automatically defines -D_DEBUG when /MTd or /MDd is set, so we +# need to make sure it gets added for other compilers too +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") +endif() + # Compile-time type size checks include(CheckTypeSize) From ff9fc451496ac0503809e83638bf470e763fe250 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Fri, 13 Feb 2015 21:04:34 -0800 Subject: [PATCH 6/6] Add POSIX version of error message in plSecureStream::IRead --- Sources/Plasma/CoreLib/HeadSpin.cpp | 11 +++++------ Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp | 4 +++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Sources/Plasma/CoreLib/HeadSpin.cpp b/Sources/Plasma/CoreLib/HeadSpin.cpp index db933b3e..a9919dea 100644 --- a/Sources/Plasma/CoreLib/HeadSpin.cpp +++ b/Sources/Plasma/CoreLib/HeadSpin.cpp @@ -93,15 +93,14 @@ void hsDebugMessage (const char* message, long val) gHSDebugProc(&s[1]); else #if HS_BUILD_FOR_WIN32 - { OutputDebugString(&s[1]); + { + OutputDebugString(&s[1]); OutputDebugString("\n"); } -#elif HS_BUILD_FOR_UNIX - { fprintf(stderr, "%s\n", &s[1]); -// hsThrow(&s[1]); - } #else - hsThrow(&s[1]); + { + fprintf(stderr, "%s\n", &s[1]); + } #endif } #endif diff --git a/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp b/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp index d65a6074..25d47a8c 100644 --- a/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp +++ b/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp @@ -48,6 +48,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "hsSTLStream.h" #if !HS_BUILD_FOR_WIN32 +#include #define INVALID_HANDLE_VALUE 0 #endif @@ -325,9 +326,10 @@ uint32_t plSecureStream::IRead(uint32_t bytes, void* buffer) } else { - // TODO: errno equivalent for *nix #if HS_BUILD_FOR_WIN32 hsDebugMessage("Error on Windows read", GetLastError()); +#else + hsDebugMessage("Error on POSIX read", errno); #endif } }