Skip to content

Commit

Permalink
Merge pull request #460 from dpogue/fixes
Browse files Browse the repository at this point in the history
Some cross-platform code cleanups.
  • Loading branch information
zrax committed Feb 14, 2015
2 parents 645135b + c1e50a9 commit 86717a9
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 31 deletions.
13 changes: 6 additions & 7 deletions Sources/Plasma/CoreLib/HeadSpin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions Sources/Plasma/CoreLib/HeadSpin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Sources/Plasma/NucleusLib/pnUtils/pnUtArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Plasma/PubUtilLib/plDrawable/plMorphSequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++ )
{
Expand Down Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand Down
16 changes: 6 additions & 10 deletions Sources/Plasma/PubUtilLib/plGLight/plPerspDirSlave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 3 additions & 7 deletions Sources/Plasma/PubUtilLib/plGLight/plShadowSlave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions cmake/CompilerChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 86717a9

Please sign in to comment.