Browse Source

Merge pull request #460 from dpogue/fixes

Some cross-platform code cleanups.
Michael Hansen 10 years ago
parent
commit
86717a9962
  1. 13
      Sources/Plasma/CoreLib/HeadSpin.cpp
  2. 4
      Sources/Plasma/CoreLib/HeadSpin.h
  3. 4
      Sources/Plasma/NucleusLib/pnUtils/pnUtArray.h
  4. 4
      Sources/Plasma/PubUtilLib/plDrawable/plMorphSequence.cpp
  5. 2
      Sources/Plasma/PubUtilLib/plDrawable/plMorphSequenceSDLMod.cpp
  6. 5
      Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp
  7. 16
      Sources/Plasma/PubUtilLib/plGLight/plPerspDirSlave.cpp
  8. 10
      Sources/Plasma/PubUtilLib/plGLight/plShadowSlave.cpp
  9. 7
      cmake/CompilerChecks.cmake

13
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
@ -119,7 +118,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))

4
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

4
Sources/Plasma/NucleusLib/pnUtils/pnUtArray.h

@ -829,8 +829,8 @@ template<class T, class C>
void TArray<T,C>::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);
}

4
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());
}
}

2
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

5
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 <errno.h>
#define INVALID_HANDLE_VALUE 0
#endif
@ -325,7 +326,11 @@ uint32_t plSecureStream::IRead(uint32_t bytes, void* buffer)
}
else
{
#if HS_BUILD_FOR_WIN32
hsDebugMessage("Error on Windows read", GetLastError());
#else
hsDebugMessage("Error on POSIX read", errno);
#endif
}
}
return numItems;

16
Sources/Plasma/PubUtilLib/plGLight/plPerspDirSlave.cpp

@ -50,10 +50,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <cfloat>
#include <cmath>
#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);

10
Sources/Plasma/PubUtilLib/plGLight/plShadowSlave.cpp

@ -48,10 +48,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <cfloat>
#include <cmath>
#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;

7
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)

Loading…
Cancel
Save