From e36220cca5eaf57c30fc2aeca5a7cdcc565f10c0 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Tue, 22 Jul 2014 21:12:09 -0700 Subject: [PATCH 1/9] Use std::min and std::max --- Sources/Plasma/CoreLib/HeadSpin.h | 3 +- Sources/Plasma/CoreLib/hsBounds.cpp | 4 +-- Sources/Plasma/CoreLib/hsBounds.h | 4 +-- Sources/Plasma/CoreLib/hsStream.cpp | 14 ++++----- Sources/Plasma/CoreLib/hsTemplates.h | 2 +- Sources/Plasma/CoreLib/plViewTransform.cpp | 8 ++--- .../FeatureLib/pfConsole/pfDispatchLog.cpp | 2 +- .../FeatureLib/pfSurface/plLayerAVI.cpp | 29 +++++++++---------- Sources/Plasma/NucleusLib/inc/plProfile.h | 2 +- .../NucleusLib/inc/plProfileManager.cpp | 2 +- .../plAvatar/plPhysicalControllerCore.cpp | 4 +-- .../PubUtilLib/plDrawable/plDynaRippleMgr.cpp | 2 +- .../plDrawable/plDynaRippleMgrVS.cpp | 2 +- .../plDrawable/plSpaceTreeMaker.cpp | 2 +- .../PubUtilLib/plFile/plEncryptedStream.cpp | 2 +- .../PubUtilLib/plFile/plSecureStream.cpp | 2 +- .../Plasma/PubUtilLib/plGImage/plMipmap.cpp | 4 +-- .../PubUtilLib/plGLight/plLightInfo.cpp | 2 +- .../PubUtilLib/plGLight/plShadowMaster.cpp | 2 +- .../Plasma/PubUtilLib/plInterp/plAnimPath.cpp | 2 +- .../PubUtilLib/plInterp/plController.cpp | 2 +- Sources/Plasma/PubUtilLib/plMath/plAvg.cpp | 2 +- .../plNetClient/plNetClientMgrShow.cpp | 4 +-- .../plParticleSystem/plParticleEffect.cpp | 14 ++++----- .../plParticleSystem/plParticleEmitter.cpp | 2 +- .../PubUtilLib/plPhysX/plSimulationMgr.cpp | 2 +- .../PubUtilLib/plPipeline/DX/plDXPipeline.cpp | 2 +- .../PubUtilLib/plPipeline/DX/plDXShader.cpp | 3 +- .../plPipeline/plStatusLogDrawer.cpp | 2 +- .../plStatGather/plProfileManagerFull.cpp | 10 +++---- Sources/Tools/MaxConvert/plDistributor.cpp | 8 ++--- Sources/Tools/MaxMain/plMaxMeshExtractor.cpp | 12 ++++---- Sources/Tools/MaxMain/plMaxNode.cpp | 26 ++++++++--------- Sources/Tools/MaxMain/plPhysXCooking.cpp | 24 +++++++-------- .../MaxPlasmaLights/plRealTimeLights.cpp | 2 +- 35 files changed, 101 insertions(+), 108 deletions(-) diff --git a/Sources/Plasma/CoreLib/HeadSpin.h b/Sources/Plasma/CoreLib/HeadSpin.h index f14cabc6..471d9efc 100644 --- a/Sources/Plasma/CoreLib/HeadSpin.h +++ b/Sources/Plasma/CoreLib/HeadSpin.h @@ -59,6 +59,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include #include +#include //====================================== // Winblows Hacks @@ -132,8 +133,6 @@ typedef uint32_t hsGSeedValue; #define hsLongAlign(n) (((n) + 3) & ~3L) -#define hsMaximum(a, b) ((a) > (b) ? (a) : (b)) -#define hsMinimum(a, b) ((a) < (b) ? (a) : (b)) #define hsABS(x) ((x) < 0 ? -(x) : (x)) #define hsSGN(x) (((x) < 0) ? -1 : ( ((x) > 0) ? 1 : 0 )) diff --git a/Sources/Plasma/CoreLib/hsBounds.cpp b/Sources/Plasma/CoreLib/hsBounds.cpp index dabd8b12..95d28211 100644 --- a/Sources/Plasma/CoreLib/hsBounds.cpp +++ b/Sources/Plasma/CoreLib/hsBounds.cpp @@ -195,9 +195,9 @@ void hsBounds3::MakeSymmetric(const hsPoint3* p) float delUp; delUp = fMaxs[i] - (*p)[i]; - delMax = hsMaximum(delMax, delUp); + delMax = std::max(delMax, delUp); delUp = (*p)[i] - fMins[i]; - delMax = hsMaximum(delMax, delUp); + delMax = std::max(delMax, delUp); } const float sqrtTwo = 1.41421f; delMax *= sqrtTwo; diff --git a/Sources/Plasma/CoreLib/hsBounds.h b/Sources/Plasma/CoreLib/hsBounds.h index 82e91efd..3fc56837 100644 --- a/Sources/Plasma/CoreLib/hsBounds.h +++ b/Sources/Plasma/CoreLib/hsBounds.h @@ -42,7 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #ifndef hsBounds_inc #define hsBounds_inc - + #include "hsGeometry3.h" #include "hsPoint2.h" #include "hsMatrix44.h" @@ -186,7 +186,7 @@ inline const hsPoint3& hsBounds3::GetCenter() const inline float hsBounds3::GetMaxDim() const { hsAssert(kBoundsNormal == fType, "Invalid type for GetMaxDim"); - return hsMaximum(hsMaximum(fMaxs.fX-fMins.fX, fMaxs.fY-fMins.fY), fMaxs.fZ-fMins.fZ); + return std::max({ fMaxs.fX - fMins.fX, fMaxs.fY - fMins.fY, fMaxs.fZ - fMins.fZ }); } // diff --git a/Sources/Plasma/CoreLib/hsStream.cpp b/Sources/Plasma/CoreLib/hsStream.cpp index f93d04dc..72f4f65f 100644 --- a/Sources/Plasma/CoreLib/hsStream.cpp +++ b/Sources/Plasma/CoreLib/hsStream.cpp @@ -1054,7 +1054,7 @@ uint32_t hsQueueStream::Read(uint32_t byteCount, void * buffer) int32_t limit, length, total; limit = fWriteCursor >= fReadCursor ? fWriteCursor : fSize; - length = hsMinimum(limit-fReadCursor,byteCount); + length = std::min(limit-fReadCursor, byteCount); HSMemory::BlockMove(fQueue+fReadCursor,buffer,length); fReadCursor += length; fReadCursor %= fSize; @@ -1063,7 +1063,7 @@ uint32_t hsQueueStream::Read(uint32_t byteCount, void * buffer) if (length < byteCount && limit != fWriteCursor) { limit = fWriteCursor; - length = hsMinimum(limit,byteCount-length); + length = std::min(limit, static_cast(byteCount)-length); HSMemory::BlockMove(fQueue,static_cast(buffer)+total,length); fReadCursor = length; total += length; @@ -1079,7 +1079,7 @@ uint32_t hsQueueStream::Write(uint32_t byteCount, const void* buffer) int32_t length; - length = hsMinimum(fSize-fWriteCursor,byteCount); + length = std::min(fSize-fWriteCursor, byteCount); HSMemory::BlockMove(buffer,fQueue+fWriteCursor,length); if (fReadCursor > fWriteCursor) { @@ -1087,7 +1087,7 @@ uint32_t hsQueueStream::Write(uint32_t byteCount, const void* buffer) if (fReadCursor < fWriteCursor+length+1) hsStatusMessage("ReadCursor wrapped\n"); #endif - fReadCursor = hsMaximum(fReadCursor,fWriteCursor+length+1); + fReadCursor = std::min(fReadCursor, fWriteCursor+length+1); fReadCursor %= fSize; } fWriteCursor += length; @@ -1106,19 +1106,19 @@ void hsQueueStream::Skip(uint32_t deltaByteCount) int32_t limit, length; limit = fWriteCursor >= fReadCursor ? fWriteCursor : fSize; - length = hsMinimum(limit-fReadCursor,deltaByteCount); + length = std::min(limit-fReadCursor, deltaByteCount); fReadCursor += length; if (length < deltaByteCount && limit != fWriteCursor) { limit = fWriteCursor; - length = hsMinimum(limit,deltaByteCount-length); + length = std::min(limit, static_cast(deltaByteCount)-length); fReadCursor = length; } else { fReadCursor %= fSize; -} + } } void hsQueueStream::Rewind() diff --git a/Sources/Plasma/CoreLib/hsTemplates.h b/Sources/Plasma/CoreLib/hsTemplates.h index f25d4261..f5f0ffe4 100644 --- a/Sources/Plasma/CoreLib/hsTemplates.h +++ b/Sources/Plasma/CoreLib/hsTemplates.h @@ -238,7 +238,7 @@ void hsDynamicArray::SetCount(int32_t count) { T* newArray = new T[count]; if (fArray) - { int copyCount = hsMinimum(count, fCount); + { int copyCount = std::min(count, fCount); for (int i = 0; i < copyCount; i++) newArray[i] = fArray[i]; diff --git a/Sources/Plasma/CoreLib/plViewTransform.cpp b/Sources/Plasma/CoreLib/plViewTransform.cpp index 78579da7..d76f6907 100644 --- a/Sources/Plasma/CoreLib/plViewTransform.cpp +++ b/Sources/Plasma/CoreLib/plViewTransform.cpp @@ -270,9 +270,9 @@ bool plViewTransform::Intersect(const plViewTransform& view) int i; for( i = 0; i < 3; i++ ) { - mins[i] = hsMaximum(fMin[i], view.fMin[i]); + mins[i] = std::max(fMin[i], view.fMin[i]); - maxs[i] = hsMinimum(fMax[i], view.fMax[i]); + maxs[i] = std::min(fMax[i], view.fMax[i]); if( mins[i] >= maxs[i] ) { @@ -292,9 +292,9 @@ bool plViewTransform::Union(const plViewTransform& view) int i; for( i = 0; i < 3; i++ ) { - mins[i] = hsMinimum(fMin[i], view.fMin[i]); + mins[i] = std::min(fMin[i], view.fMin[i]); - maxs[i] = hsMaximum(fMax[i], view.fMax[i]); + maxs[i] = std::max(fMax[i], view.fMax[i]); } SetView(mins, maxs); diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp index 96c0bb9e..1f76944a 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp @@ -133,7 +133,7 @@ void plDispatchLog::DumpMsg(plMessage* msg, int numReceivers, int sendTimeMs, in float sendTime = hsTimer::GetMilliSeconds(hsTimer::GetTicks() - fStartTicks); char indentStr[50]; - indent = hsMinimum(indent, sizeof(indentStr)-1); + indent = std::min(indent, static_cast(sizeof(indentStr)-1)); memset(indentStr, ' ', indent); indentStr[indent] = '\0'; diff --git a/Sources/Plasma/FeatureLib/pfSurface/plLayerAVI.cpp b/Sources/Plasma/FeatureLib/pfSurface/plLayerAVI.cpp index 99e9b1d2..416fd68e 100644 --- a/Sources/Plasma/FeatureLib/pfSurface/plLayerAVI.cpp +++ b/Sources/Plasma/FeatureLib/pfSurface/plLayerAVI.cpp @@ -162,21 +162,20 @@ static bool ICopySourceToTexture16(BITMAPINFO* bmi, plMipmap* b) uint32_t* pix = (uint32_t*)b->GetImage(); pix += b->GetWidth() * b->GetHeight(); - int width = bmi->bmiHeader.biWidth; - int height = bmi->bmiHeader.biHeight; + uint32_t width = bmi->bmiHeader.biWidth; + uint32_t height = bmi->bmiHeader.biHeight; - int useHeight = hsMinimum(height, b->GetHeight()); - int useWidth = hsMinimum(width, b->GetWidth()); - int i; - for( i = 0; i < useHeight; i++ ) + uint32_t useHeight = std::min(height, b->GetHeight()); + uint32_t useWidth = std::min(width, b->GetWidth()); + + for (uint32_t i = 0; i < useHeight; i++) { uint16_t* src = pSrc; pSrc += width; pix -= b->GetWidth(); uint32_t* tPix = pix; - int j; - for( j = 0; j < useWidth; j++ ) + for (uint32_t j = 0; j < useWidth; j++) { *tPix = ((*src & 0x001f) << 3) // up 3 | ((*src & 0x03e0) << 6) // down 5 up 3 up 8 @@ -199,22 +198,20 @@ static bool ICopySourceToTexture24(BITMAPINFO* bmi, plMipmap* b) hsRGBAColor32* pix = (hsRGBAColor32*)b->GetImage(); pix += b->GetWidth() * b->GetHeight(); - int width = bmi->bmiHeader.biWidth; - int height = bmi->bmiHeader.biHeight; + uint32_t width = bmi->bmiHeader.biWidth; + uint32_t height = bmi->bmiHeader.biHeight; - int useHeight = hsMinimum(height, b->GetHeight()); - int useWidth = hsMinimum(width, b->GetWidth()); - int i; + uint32_t useHeight = std::min(height, b->GetHeight()); + uint32_t useWidth = std::min(width, b->GetWidth()); - for( i = 0; i < useHeight; i++ ) + for (uint32_t i = 0; i < useHeight; i++) { unsigned char* src = pSrc; pSrc += width * 3; pix -= b->GetWidth(); hsRGBAColor32* tPix = pix; - int j; - for( j = 0; j < useWidth; j++ ) + for (uint32_t j = 0; j < useWidth; j++) { tPix->b = *src++; tPix->g = *src++; diff --git a/Sources/Plasma/NucleusLib/inc/plProfile.h b/Sources/Plasma/NucleusLib/inc/plProfile.h index 9dc7cbd0..6ccba04c 100644 --- a/Sources/Plasma/NucleusLib/inc/plProfile.h +++ b/Sources/Plasma/NucleusLib/inc/plProfile.h @@ -158,7 +158,7 @@ protected: uint32_t fAvgCount; uint64_t fAvgTotal; uint32_t fLastAvg; - uint32_t fMax; + uint64_t fMax; bool fActive; bool fRunning; uint8_t fDisplayFlags; diff --git a/Sources/Plasma/NucleusLib/inc/plProfileManager.cpp b/Sources/Plasma/NucleusLib/inc/plProfileManager.cpp index 1c6f2eea..d8a380bd 100644 --- a/Sources/Plasma/NucleusLib/inc/plProfileManager.cpp +++ b/Sources/Plasma/NucleusLib/inc/plProfileManager.cpp @@ -161,7 +161,7 @@ void plProfileBase::EndFrame() { fAvgCount++; fAvgTotal += fValue; - fMax = hsMaximum(fMax, fValue); + fMax = std::max(fMax, fValue); } void plProfileBase::UpdateAvg() diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp index ea9dc96f..c515e7f1 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp @@ -402,7 +402,7 @@ void plWalkingStrategy::Apply(float delSecs) // the largest, so we won't launch into the air if we're running uphill. float prevZVel = achievedVelocity.fZ; if (IsOnGround()) - prevZVel = hsMinimum(prevZVel, 0.0f); + prevZVel = std::min(prevZVel, 0.0f); velocity.fZ = prevZVel + (kGravity * delSecs); } @@ -716,7 +716,7 @@ void plDynamicWalkingStrategy::Apply(float delSecs) // the largest, so we won't launch into the air if we're running uphill. float prevZVel = achievedVelocity.fZ; if (IsOnGround()) - prevZVel = hsMinimum(prevZVel, 0.f); + prevZVel = std::min(prevZVel, 0.f); velocity.fZ = prevZVel + (kGravity * delSecs); } diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgr.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgr.cpp index e6fbd8e5..9e246c68 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgr.cpp @@ -219,7 +219,7 @@ bool plDynaRippleMgr::IRippleFromShape(const plPrintShape* shape, bool force) plConst(float) kHeightScale = 1.f; pos.fZ += (shape->GetHeight() * fScale.fZ * kHeightScale) * 0.25f; - float wid = hsMaximum(shape->GetWidth(), shape->GetLength()); + float wid = std::max(shape->GetWidth(), shape->GetLength()); hsVector3 size(wid * fScale.fX, wid * fScale.fY, shape->GetHeight() * fScale.fZ * kHeightScale); fCutter->SetLength(size); fCutter->Set(pos, dir, up); diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgrVS.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgrVS.cpp index a6cd0ce9..96b2547b 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgrVS.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgrVS.cpp @@ -212,7 +212,7 @@ bool plDynaRippleVSMgr::IRippleFromShape(const plPrintShape* shape, bool force) hsVector3 dir(fWaveSetBase->GetWindDir()); hsVector3 up(0.f, 0.f, 1.f); - float wid = hsMaximum(shape->GetWidth(), shape->GetLength()); + float wid = std::max(shape->GetWidth(), shape->GetLength()); plConst(float) kMaxWaterDepth(1000.f); diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plSpaceTreeMaker.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plSpaceTreeMaker.cpp index d93cd59b..c8c2da1d 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plSpaceTreeMaker.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plSpaceTreeMaker.cpp @@ -591,7 +591,7 @@ int plSpaceTreeMaker::ITreeDepth(plSpacePrepNode* subRoot) int dep0 = ITreeDepth(subRoot->fChildren[0]); int dep1 = ITreeDepth(subRoot->fChildren[1]); - int dep = hsMaximum(dep0, dep1); + int dep = std::max(dep0, dep1); return dep+1; } diff --git a/Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp b/Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp index 217aafab..e6b96279 100644 --- a/Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp +++ b/Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp @@ -301,7 +301,7 @@ uint32_t plEncryptedStream::Read(uint32_t bytes, void* buffer) // Offset into the first buffer (0 if we are aligned on a chunk, which means no extra block read) uint32_t startChunkPos = startPos % kEncryptChunkSize; // Amount of data in the partial first chunk (0 if we're aligned) - uint32_t startAmt = (startChunkPos != 0) ? hsMinimum(kEncryptChunkSize - startChunkPos, bytes) : 0; + uint32_t startAmt = (startChunkPos != 0) ? std::min(kEncryptChunkSize - startChunkPos, bytes) : 0; uint32_t totalNumRead = IRead(bytes, buffer); diff --git a/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp b/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp index 391bb807..c99c4b19 100644 --- a/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp +++ b/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp @@ -434,7 +434,7 @@ uint32_t plSecureStream::Read(uint32_t bytes, void* buffer) // Offset into the first buffer (0 if we are aligned on a chunk, which means no extra block read) uint32_t startChunkPos = startPos % kEncryptChunkSize; // Amount of data in the partial first chunk (0 if we're aligned) - uint32_t startAmt = (startChunkPos != 0) ? hsMinimum(kEncryptChunkSize - startChunkPos, bytes) : 0; + uint32_t startAmt = (startChunkPos != 0) ? std::min(kEncryptChunkSize - startChunkPos, bytes) : 0; uint32_t totalNumRead = IRead(bytes, buffer); diff --git a/Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp b/Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp index 9ec4a70a..5cdf684c 100644 --- a/Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp +++ b/Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp @@ -994,9 +994,9 @@ float plMipmap::IGetDetailLevelAlpha( uint8_t level, float dropStart, float drop detailAlpha = ( level - dropStart ) * ( min - max ) / ( dropStop - dropStart ) + max; if( min < max ) - detailAlpha = hsMinimum( max, hsMaximum( min, detailAlpha ) ); + detailAlpha = std::min(max, std::max(min, detailAlpha)); else - detailAlpha = hsMinimum( min, hsMaximum( max, detailAlpha ) ); + detailAlpha = std::min(min, std::max(max, detailAlpha)); return detailAlpha; } diff --git a/Sources/Plasma/PubUtilLib/plGLight/plLightInfo.cpp b/Sources/Plasma/PubUtilLib/plGLight/plLightInfo.cpp index a284092c..b22eb1ec 100644 --- a/Sources/Plasma/PubUtilLib/plGLight/plLightInfo.cpp +++ b/Sources/Plasma/PubUtilLib/plGLight/plLightInfo.cpp @@ -951,7 +951,7 @@ void plSpotLightInfo::IRefresh() float yon = GetRadius(); if( yon < kMinHither ) yon = kMaxYon; - float hither = hsMinimum(kMinHither, yon * 0.5f); + float hither = std::min(kMinHither, yon * 0.5f); float sinFOV, cosFOV; hsFastMath::SinCos(effFOV, sinFOV, cosFOV); diff --git a/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp b/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp index 49464f7b..40d99dcd 100644 --- a/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp +++ b/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp @@ -373,7 +373,7 @@ plShadowSlave* plShadowMaster::ILastChanceToBail(plShadowCastMsg* castMsg, plSha float maxDist = fMaxDist > 0 ? (fGlobalMaxDist > 0 - ? hsMinimum(fMaxDist, fGlobalMaxDist) + ? std::min(fMaxDist, fGlobalMaxDist) : fMaxDist) : fGlobalMaxDist; diff --git a/Sources/Plasma/PubUtilLib/plInterp/plAnimPath.cpp b/Sources/Plasma/PubUtilLib/plInterp/plAnimPath.cpp index d921772e..e25ba89c 100644 --- a/Sources/Plasma/PubUtilLib/plInterp/plAnimPath.cpp +++ b/Sources/Plasma/PubUtilLib/plInterp/plAnimPath.cpp @@ -271,7 +271,7 @@ float plAnimPath::GetExtremePoint(hsPoint3 &worldPt) const { float fore = keyTimes[i + 1] - t; float back = t - keyTimes[i - 1]; - delTime = hsMaximum(fore, back); + delTime = std::max(fore, back); } } } diff --git a/Sources/Plasma/PubUtilLib/plInterp/plController.cpp b/Sources/Plasma/PubUtilLib/plInterp/plController.cpp index 3a29b82c..79baf8a9 100644 --- a/Sources/Plasma/PubUtilLib/plInterp/plController.cpp +++ b/Sources/Plasma/PubUtilLib/plInterp/plController.cpp @@ -816,7 +816,7 @@ float plCompoundController::GetLength() const for(i=0; i<3; i++) { if (GetController(i)) - len = hsMaximum(len, GetController(i)->GetLength()); + len = std::max(len, GetController(i)->GetLength()); } return len; } diff --git a/Sources/Plasma/PubUtilLib/plMath/plAvg.cpp b/Sources/Plasma/PubUtilLib/plMath/plAvg.cpp index cefae7fd..9e7be7cf 100644 --- a/Sources/Plasma/PubUtilLib/plMath/plAvg.cpp +++ b/Sources/Plasma/PubUtilLib/plMath/plAvg.cpp @@ -153,7 +153,7 @@ void TimeBasedAvgRing::AddItem(T value, double time) } // update the max avg - fMaxAvg = hsMaximum( fMaxAvg, fAvg ); + fMaxAvg = std::max(fMaxAvg, fAvg); } diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrShow.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrShow.cpp index 42279dfa..5c370143 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrShow.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrShow.cpp @@ -234,7 +234,7 @@ void plNetClientMgr::IShowRelevanceRegions() uint32_t maxPlayerName = 0; txt.DrawString(x, y, GetPlayerName().c_str()); - maxPlayerName = hsMaximum(maxPlayerName, txt.CalcStringWidth(GetPlayerName().c_str())); + maxPlayerName = std::max(maxPlayerName, txt.CalcStringWidth(GetPlayerName().c_str())); y += yOff; int i; @@ -247,7 +247,7 @@ void plNetClientMgr::IShowRelevanceRegions() const plString& name = mbr->GetPlayerName(); txt.DrawString(x, y, name.c_str()); - maxPlayerName = hsMaximum(maxPlayerName, txt.CalcStringWidth(name.c_str())); + maxPlayerName = std::max(maxPlayerName, txt.CalcStringWidth(name.c_str())); y += yOff; } diff --git a/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp b/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp index d2db210a..78a662ab 100644 --- a/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp +++ b/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp @@ -681,12 +681,11 @@ plParticleFlockEffect::~plParticleFlockEffect() void plParticleFlockEffect::IUpdateDistances(const plEffectTargetInfo& target) { - int i, j; - int numParticles = hsMinimum(fMaxParticles, target.fNumValidParticles); + uint32_t numParticles = std::min(static_cast(fMaxParticles), target.fNumValidParticles); - for (i = 0; i < numParticles; i++) + for (uint32_t i = 0; i < numParticles; i++) { - for (j = i + 1; j < numParticles; j++) + for (uint32_t j = i + 1; j < numParticles; j++) { hsVector3 diff((hsPoint3*)(target.fPos + i * target.fPosStride), (hsPoint3*)(target.fPos + j * target.fPosStride)); fDistSq[i * fMaxParticles + j] = fDistSq[j * fMaxParticles + i] = diff.MagnitudeSquared(); @@ -696,17 +695,16 @@ void plParticleFlockEffect::IUpdateDistances(const plEffectTargetInfo& target) void plParticleFlockEffect::IUpdateInfluences(const plEffectTargetInfo &target) { - int i, j; - int numParticles = hsMinimum(fMaxParticles, target.fNumValidParticles); + uint32_t numParticles = std::min(static_cast(fMaxParticles), target.fNumValidParticles); - for (i = 0; i < numParticles; i++) + for (uint32_t i = 0; i < numParticles; i++) { int numAvg = 0; int numRep = 0; fInfluences[i].fAvgVel.Set(0.f, 0.f, 0.f); fInfluences[i].fRepDir.Set(0.f, 0.f, 0.f); - for (j = 0; j < numParticles; j++) + for (uint32_t j = 0; j < numParticles; j++) { if (i == j) continue; diff --git a/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEmitter.cpp b/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEmitter.cpp index aeeb15ac..ec5c51dd 100644 --- a/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEmitter.cpp +++ b/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEmitter.cpp @@ -261,7 +261,7 @@ void plParticleEmitter::UpdateGenerator(uint32_t paramID, float paramValue) uint16_t plParticleEmitter::StealParticlesFrom(plParticleEmitter *victim, uint16_t num) { uint16_t spaceAvail = (uint16_t)(fMaxParticles - fNumValidParticles); - uint16_t numToCopy = (uint16_t)(hsMinimum(num, (victim ? victim->fNumValidParticles : 0))); + uint16_t numToCopy = std::min(num, static_cast(victim ? victim->fNumValidParticles : 0)); if (spaceAvail < numToCopy) numToCopy = spaceAvail; diff --git a/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp b/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp index 468c5a8d..23531fb0 100644 --- a/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp @@ -701,7 +701,7 @@ void plSimulationMgr::ConsiderSynch(plPXPhysical* physical, plPXPhysical* other) // If both objects are capable of syncing, we want to do it at the same // time, so no interpenetration issues pop up on other clients if (syncOther) - timeElapsed = hsMaximum(timeElapsed, timeNow - other->GetLastSyncTime()); + timeElapsed = std::max(timeElapsed, timeNow - other->GetLastSyncTime()); // Set the sync time to 1 second from the last sync double syncTime = 0.0; diff --git a/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXPipeline.cpp b/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXPipeline.cpp index 733297a1..23de0275 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXPipeline.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXPipeline.cpp @@ -6421,7 +6421,7 @@ plLayerInterface* plDXPipeline::IPopOverAllLayer(plLayerInterface* li) // Calculate the number of active piggy backs. int plDXPipeline::ISetNumActivePiggyBacks() { - return fActivePiggyBacks = hsMinimum(fSettings.fMaxPiggyBacks, fPiggyBackStack.GetCount()); + return fActivePiggyBacks = std::min(static_cast(fSettings.fMaxPiggyBacks), fPiggyBackStack.GetCount()); } // IPushProjPiggyBack ////////////////////////////////////////////////// diff --git a/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXShader.cpp b/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXShader.cpp index ef5f9b1b..2f9def01 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXShader.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXShader.cpp @@ -41,11 +41,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com *==LICENSE==*/ #include "HeadSpin.h" +#define NOMINMAX #include #include -#include "HeadSpin.h" - #include "plDXShader.h" #include "plSurface/plShader.h" diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plStatusLogDrawer.cpp b/Sources/Plasma/PubUtilLib/plPipeline/plStatusLogDrawer.cpp index 8a996b79..72ab227c 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plStatusLogDrawer.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/plStatusLogDrawer.cpp @@ -62,7 +62,7 @@ void plStatusLogDrawer::IDrawLogNames(plStatusLog* curLog, plStatusLog* firstLog plStatusLog* iLog = firstLog; while (iLog) { - width = hsMaximum(drawText.CalcStringWidth_TEMP(iLog->GetFileName().AsString()) + 4, width); + width = std::max(drawText.CalcStringWidth_TEMP(iLog->GetFileName().AsString()) + 4, width); iLog = iLog->fNext; numLogs++; } diff --git a/Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp b/Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp index 004c7807..0e3b0644 100644 --- a/Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp +++ b/Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp @@ -189,7 +189,7 @@ static void PrintColumn(ProfileGroup& group, const char* groupName, int column, height = 0; width = 0; - width = hsMaximum(width, txt.CalcStringWidth(groupName) + 1); + width = std::max(width, static_cast(txt.CalcStringWidth(groupName) + 1)); txt.DrawString(x, y+height, groupName, 255, 255, 255, 255, plDebugText::kStyleBold); height += yInc; @@ -209,7 +209,7 @@ static void PrintColumn(ProfileGroup& group, const char* groupName, int column, // 1 sample the width of the column will jump around. So we calculate the // width based on the stat name plus the width of the widest sample we should // get - width = hsMaximum(width, txt.CalcStringWidth(str) + samplesWidth + 1); + width = std::max(width, static_cast(txt.CalcStringWidth(str) + samplesWidth + 1)); // Now add on the samples text, if we have any if (group[i]->GetTimerSamples()) @@ -235,12 +235,12 @@ static void PrintColumn(ProfileGroup& group, const char* groupName, int column, txt.DrawString(x, y+height, str); if (column != kColName) - width = hsMaximum(width, txt.CalcStringWidth(str) + 1); + width = std::max(width, static_cast(txt.CalcStringWidth(str) + 1)); height += yInc; } // So the columns don't jump around as much as values change, pad them out to a certain width - width = hsMaximum(width, txt.CalcStringWidth("000.0 ms") + 1); + width = std::max(width, static_cast(txt.CalcStringWidth("000.0 ms") + 1)); } static void PrintGroup(ProfileGroup& group, const char* groupName, int& x, int& y) @@ -315,7 +315,7 @@ void plProfileManagerFull::Update() int x = 10; PrintGroup(group, groupName.c_str(), x, y); - maxX = hsMaximum(maxX, x); + maxX = std::max(maxX, x); y += 10; } diff --git a/Sources/Tools/MaxConvert/plDistributor.cpp b/Sources/Tools/MaxConvert/plDistributor.cpp index 517eeb3b..9cbdfbce 100644 --- a/Sources/Tools/MaxConvert/plDistributor.cpp +++ b/Sources/Tools/MaxConvert/plDistributor.cpp @@ -501,16 +501,16 @@ bool plDistributor::IFailsProbBitmap(int iFace, const Point3& bary) const break; case kMax: case kMaxColor: - frac = hsMaximum(evCol.r, hsMaximum(evCol.g, evCol.b)); + frac = std::max({ evCol.r, evCol.g, evCol.b }); break; case kMaxColorTimesAlpha: - frac = hsMaximum(evCol.r, hsMaximum(evCol.g, evCol.b)) * evCol.a; + frac = std::max({ evCol.r, evCol.g, evCol.b }) * evCol.a; break; case kMaxRedGreen: - frac = hsMaximum(evCol.r, evCol.g); + frac = std::max(evCol.r, evCol.g); break; case kMaxRedGreenTimesAlpha: - frac = hsMaximum(evCol.r, evCol.g) * evCol.a; + frac = std::max(evCol.r, evCol.g) * evCol.a; break; } diff --git a/Sources/Tools/MaxMain/plMaxMeshExtractor.cpp b/Sources/Tools/MaxMain/plMaxMeshExtractor.cpp index 0c70956f..703747ac 100644 --- a/Sources/Tools/MaxMain/plMaxMeshExtractor.cpp +++ b/Sources/Tools/MaxMain/plMaxMeshExtractor.cpp @@ -83,12 +83,12 @@ static void MeshMinMax(hsPoint3& min, hsPoint3& max, int numVerts, hsPoint3* pVe for (int i = 0; i < numVerts; i++) { hsPoint3* vert = &pVerts[i]; - min.fX = hsMinimum(vert->fX, min.fX); - min.fY = hsMinimum(vert->fY, min.fY); - min.fZ = hsMinimum(vert->fZ, min.fZ); - max.fX = hsMaximum(vert->fX, max.fX); - max.fY = hsMaximum(vert->fY, max.fY); - max.fZ = hsMaximum(vert->fZ, max.fZ); + min.fX = std::min(vert->fX, min.fX); + min.fY = std::min(vert->fY, min.fY); + min.fZ = std::min(vert->fZ, min.fZ); + max.fX = std::max(vert->fX, max.fX); + max.fY = std::max(vert->fY, max.fY); + max.fZ = std::max(vert->fZ, max.fZ); } } diff --git a/Sources/Tools/MaxMain/plMaxNode.cpp b/Sources/Tools/MaxMain/plMaxNode.cpp index fc576665..97b6d400 100644 --- a/Sources/Tools/MaxMain/plMaxNode.cpp +++ b/Sources/Tools/MaxMain/plMaxNode.cpp @@ -699,12 +699,12 @@ bool plMaxNode::MakePhysical(plErrorMsg *pErrMsg, plConvertSettings *settings) hsPoint3 minV(FLT_MAX, FLT_MAX, FLT_MAX), maxV(-FLT_MAX, -FLT_MAX, -FLT_MAX); for (int i = 0; i < mesh.fNumVerts; i++) { - minV.fX = hsMinimum(mesh.fVerts[i].fX, minV.fX); - minV.fY = hsMinimum(mesh.fVerts[i].fY, minV.fY); - minV.fZ = hsMinimum(mesh.fVerts[i].fZ, minV.fZ); - maxV.fX = hsMaximum(mesh.fVerts[i].fX, maxV.fX); - maxV.fY = hsMaximum(mesh.fVerts[i].fY, maxV.fY); - maxV.fZ = hsMaximum(mesh.fVerts[i].fZ, maxV.fZ); + minV.fX = std::min(mesh.fVerts[i].fX, minV.fX); + minV.fY = std::min(mesh.fVerts[i].fY, minV.fY); + minV.fZ = std::min(mesh.fVerts[i].fZ, minV.fZ); + maxV.fX = std::max(mesh.fVerts[i].fX, maxV.fX); + maxV.fY = std::max(mesh.fVerts[i].fY, maxV.fY); + maxV.fZ = std::max(mesh.fVerts[i].fZ, maxV.fZ); } hsPoint3 width = maxV - minV; recipe.bDimensions = width / 2; @@ -770,15 +770,15 @@ bool plMaxNode::MakePhysical(plErrorMsg *pErrMsg, plConvertSettings *settings) hsPoint3 minV(FLT_MAX, FLT_MAX, FLT_MAX), maxV(-FLT_MAX, -FLT_MAX, -FLT_MAX); for (int i = 0; i < mesh.fNumVerts; i++) { - minV.fX = hsMinimum(mesh.fVerts[i].fX, minV.fX); - minV.fY = hsMinimum(mesh.fVerts[i].fY, minV.fY); - minV.fZ = hsMinimum(mesh.fVerts[i].fZ, minV.fZ); - maxV.fX = hsMaximum(mesh.fVerts[i].fX, maxV.fX); - maxV.fY = hsMaximum(mesh.fVerts[i].fY, maxV.fY); - maxV.fZ = hsMaximum(mesh.fVerts[i].fZ, maxV.fZ); + minV.fX = std::min(mesh.fVerts[i].fX, minV.fX); + minV.fY = std::min(mesh.fVerts[i].fY, minV.fY); + minV.fZ = std::min(mesh.fVerts[i].fZ, minV.fZ); + maxV.fX = std::max(mesh.fVerts[i].fX, maxV.fX); + maxV.fY = std::max(mesh.fVerts[i].fY, maxV.fY); + maxV.fZ = std::max(mesh.fVerts[i].fZ, maxV.fZ); } hsPoint3 width = maxV - minV; - recipe.radius = hsMaximum(width.fX, hsMaximum(width.fY, width.fZ)); + recipe.radius = std::max({ width.fX, width.fY, width.fZ }); recipe.radius /= 2.f; recipe.offset = minV + (width / 2.f); } diff --git a/Sources/Tools/MaxMain/plPhysXCooking.cpp b/Sources/Tools/MaxMain/plPhysXCooking.cpp index 874fbfbd..62990dc8 100644 --- a/Sources/Tools/MaxMain/plPhysXCooking.cpp +++ b/Sources/Tools/MaxMain/plPhysXCooking.cpp @@ -304,12 +304,12 @@ void ReadBoxFromHull(hsStream* stream, NxBoxShapeDesc& box) for (int i = 0; i < nVertices; i++) { hsPoint3& vec = pVertices[i]; - minX = hsMinimum(minX, vec.fX); - minY = hsMinimum(minY, vec.fY); - minZ = hsMinimum(minZ, vec.fZ); - maxX = hsMaximum(maxX, vec.fX); - maxY = hsMaximum(maxY, vec.fY); - maxZ = hsMaximum(maxZ, vec.fZ); + minX = std::min(minX, vec.fX); + minY = std::min(minY, vec.fY); + minZ = std::min(minZ, vec.fZ); + maxX = std::max(maxX, vec.fX); + maxY = std::max(maxY, vec.fY); + maxZ = std::max(maxZ, vec.fZ); } delete[] pVertices; @@ -453,12 +453,12 @@ hsVectorStream* plPhysXCooking::IMakePolytope(const plMaxMeshExtractor::NeutralM } for(int i=0;iGetDecayRadius(t); projector = gl->GetProjector(); - fov = hsMaximum(fs,hs); + fov = std::max(fs, hs); float aspect = 1.0f; From 72f18e8ebb092f2b66c63f180b3dafe6a951c4fe Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Tue, 22 Jul 2014 22:22:22 -0700 Subject: [PATCH 2/9] Complete the previous commit by also removing the inline min and max functions defined in HeadSpin.h without breaking (3ds)Max compilation --- Sources/Plasma/Apps/plFileSecure/main.cpp | 2 +- Sources/Plasma/CoreLib/HeadSpin.h | 45 ------------------- Sources/Plasma/CoreLib/hsWindows.h | 8 ++++ .../Private/Nt/pnAceNtSocket.cpp | 8 ++-- .../pnEncryption/plChallengeHash.cpp | 4 +- .../NucleusLib/pnNetCli/pnNcChannel.cpp | 4 +- .../Plasma/NucleusLib/pnNetCli/pnNcCli.cpp | 8 ++-- .../Plasma/NucleusLib/pnUtils/pnUtArray.cpp | 4 +- Sources/Plasma/NucleusLib/pnUtils/pnUtArray.h | 16 +++---- Sources/Plasma/NucleusLib/pnUtils/pnUtCmd.cpp | 4 +- Sources/Plasma/NucleusLib/pnUtils/pnUtHash.h | 4 +- .../PubUtilLib/plAvatar/plArmatureMod.cpp | 4 +- .../PubUtilLib/plAvatar/plAvBehaviors.cpp | 2 +- .../PubUtilLib/plAvatar/plAvBrainSwim.cpp | 2 +- .../plAvatar/plPhysicalControllerCore.cpp | 2 +- .../PubUtilLib/plFile/plSecureStream.cpp | 4 +- .../plNetGameLib/Private/plNglAuth.cpp | 6 +-- .../plNetGameLib/Private/plNglFile.cpp | 4 +- .../plNetGameLib/Private/plNglGateKeeper.cpp | 2 +- .../plSockets/plBufferedSocketWriter.cpp | 2 +- 20 files changed, 49 insertions(+), 86 deletions(-) diff --git a/Sources/Plasma/Apps/plFileSecure/main.cpp b/Sources/Plasma/Apps/plFileSecure/main.cpp index ee69b5aa..e3fecce6 100644 --- a/Sources/Plasma/Apps/plFileSecure/main.cpp +++ b/Sources/Plasma/Apps/plFileSecure/main.cpp @@ -75,7 +75,7 @@ void GenerateKey(bool useDefault) uint32_t key[4]; if (useDefault) { - unsigned memSize = min(arrsize(key), arrsize(plSecureStream::kDefaultKey)); + unsigned memSize = std::min(arrsize(key), arrsize(plSecureStream::kDefaultKey)); memSize *= sizeof(uint32_t); memcpy(key, plSecureStream::kDefaultKey, memSize); } diff --git a/Sources/Plasma/CoreLib/HeadSpin.h b/Sources/Plasma/CoreLib/HeadSpin.h index 471d9efc..201075d8 100644 --- a/Sources/Plasma/CoreLib/HeadSpin.h +++ b/Sources/Plasma/CoreLib/HeadSpin.h @@ -242,51 +242,6 @@ inline void hsSwap(float& a, float& b) # define NULL_STMT ((void)0) #endif -//=========================================================================== -template -inline T max (const T & a, const T & b) { - return (a > b) ? a : b; -} - -//=========================================================================== -inline unsigned max (int a, unsigned b) { - return ((unsigned)a > b) ? a : b; -} - -//=========================================================================== -inline unsigned max (unsigned a, int b) { - return (a > (unsigned)b) ? a : b; -} - -//=========================================================================== -template -inline T min (const T & a, const T & b) { - return (a < b) ? a : b; -} - -//=========================================================================== -inline unsigned min (int a, unsigned b) { - return ((unsigned)a < b) ? a : b; -} - -//=========================================================================== -inline unsigned min (unsigned a, int b) { - return (a < (unsigned)b) ? a : b; -} - - -/**************************************************************************** -* -* MAX/MIN macros -* These are less safe than the inline function versions, since they -* evaluate parameters twice. However, they can be used to produce -* compile-time constants. -* -***/ -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) - - /**************************************************************************** * * SWAP diff --git a/Sources/Plasma/CoreLib/hsWindows.h b/Sources/Plasma/CoreLib/hsWindows.h index 5e8702f3..fb5dddc1 100644 --- a/Sources/Plasma/CoreLib/hsWindows.h +++ b/Sources/Plasma/CoreLib/hsWindows.h @@ -61,8 +61,16 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com # define _WIN32_IE 0x400 # endif + // HACK: Max headers depend on the min() and max() macros normally pulled + // in by windows.h... However, we usually disable those, since they break + // std::min and std::max. Therefore, we bring the std:: versions down to + // the global namespace so we can still compile max code without breaking + // everything else :/ # ifndef NOMINMAX # define NOMINMAX +# include + using std::min; + using std::max; # endif # define WIN32_LEAN_AND_MEAN diff --git a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp index ab4cd404..a0214eca 100644 --- a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp +++ b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp @@ -338,7 +338,7 @@ static NtOpSocketWrite * SocketQueueAsyncWrite ( NtOpSocketWrite * lastQueuedWrite = (NtOpSocketWrite *) opCurr; unsigned bytesLeft = lastQueuedWrite->bytesAlloc - lastQueuedWrite->write.bytes; - bytesLeft = min(bytesLeft, bytes); + bytesLeft = std::min(bytesLeft, bytes); if (bytesLeft) { PerfAddCounter(kAsyncPerfSocketBytesWaitQueued, bytesLeft); memcpy(lastQueuedWrite->write.buffer + lastQueuedWrite->write.bytes, data, bytesLeft); @@ -353,8 +353,8 @@ static NtOpSocketWrite * SocketQueueAsyncWrite ( // allocate a buffer large enough to hold the data, plus // extra space in case more data needs to be queued later - unsigned bytesAlloc = max(bytes, sock->backlogAlloc); - bytesAlloc = max(bytesAlloc, kMinBacklogBytes); + unsigned bytesAlloc = std::max(bytes, sock->backlogAlloc); + bytesAlloc = std::max(bytesAlloc, kMinBacklogBytes); NtOpSocketWrite * op = new(malloc(sizeof(NtOpSocketWrite) + bytesAlloc)) NtOpSocketWrite; // init Operation @@ -883,7 +883,7 @@ static unsigned SocketCloseTimerCallback (void *) { HardCloseSocket(*cur); // Don't run too frequently - return max(sleepMs, 2000); + return std::max(sleepMs, 2000u); } diff --git a/Sources/Plasma/NucleusLib/pnEncryption/plChallengeHash.cpp b/Sources/Plasma/NucleusLib/pnEncryption/plChallengeHash.cpp index 92e72e59..300f7bcd 100644 --- a/Sources/Plasma/NucleusLib/pnEncryption/plChallengeHash.cpp +++ b/Sources/Plasma/NucleusLib/pnEncryption/plChallengeHash.cpp @@ -48,8 +48,8 @@ void CryptCreateRandomSeed(size_t length, uint8_t* data) { uint32_t seedIdx = 0; uint32_t dataIdx = 0; - uint32_t cur = 0; - uint32_t end = max(length, sizeof(ShaDigest)); + size_t cur = 0; + size_t end = std::max(length, sizeof(ShaDigest)); // Combine seed with input data for (; cur < end; cur++) { diff --git a/Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp b/Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp index 91d5fdf6..e1bc67ae 100644 --- a/Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp +++ b/Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp @@ -205,7 +205,7 @@ static unsigned MaxMsgId (const T msgs[], unsigned count) { for (unsigned i = 0; i < count; i++) { ASSERT(msgs[i].msg.count); - maxMsgId = max(msgs[i].msg.messageId, maxMsgId); + maxMsgId = std::max(msgs[i].msg.messageId, maxMsgId); } return maxMsgId; } @@ -248,7 +248,7 @@ static void AddRecvMsgs_CS ( *dst = *src; const uint32_t bytes = ValidateMsg(dst->msg); - channel->m_largestRecv = max(channel->m_largestRecv, bytes); + channel->m_largestRecv = std::max(channel->m_largestRecv, bytes); } } diff --git a/Sources/Plasma/NucleusLib/pnNetCli/pnNcCli.cpp b/Sources/Plasma/NucleusLib/pnNetCli/pnNcCli.cpp index 2ecd793a..b1f6fc7b 100644 --- a/Sources/Plasma/NucleusLib/pnNetCli/pnNcCli.cpp +++ b/Sources/Plasma/NucleusLib/pnNetCli/pnNcCli.cpp @@ -244,7 +244,7 @@ static void AddToSendBuffer ( // calculate the space left in the output buffer and use it // to determine the maximum number of bytes that will fit unsigned const left = &cli->sendBuffer[arrsize(cli->sendBuffer)] - cli->sendCurr; - unsigned const copy = min(bytes, left); + unsigned const copy = std::min(bytes, left); // copy the data into the buffer for (unsigned i = 0; i < copy; ++i) @@ -678,7 +678,7 @@ static void ClientConnect (NetCli * cli) { memset(&cli->seed, 0, sizeof(cli->seed)); unsigned bytes; unsigned char * data = clientSeed.GetData_LE(&bytes); - memcpy(cli->seed, data, min(bytes, sizeof(cli->seed))); + memcpy(cli->seed, data, std::min(bytes, sizeof(cli->seed))); delete [] data; } @@ -740,7 +740,7 @@ static bool ServerRecvConnect ( memset(&clientSeed, 0, sizeof(clientSeed)); unsigned bytes; unsigned char * data = clientSeedValue.GetData_LE(&bytes); - memcpy(clientSeed, data, min(bytes, sizeof(clientSeed))); + memcpy(clientSeed, data, std::min(bytes, sizeof(clientSeed))); delete [] data; } @@ -964,7 +964,7 @@ static void SetConnSeed ( const uint8_t seedData[] ) { if (seedBytes) - memcpy(cli->seed, seedData, min(sizeof(cli->seed), seedBytes)); + memcpy(cli->seed, seedData, std::min(sizeof(cli->seed), seedBytes)); else CryptCreateRandomSeed(sizeof(cli->seed), cli->seed); } diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtArray.cpp b/Sources/Plasma/NucleusLib/pnUtils/pnUtArray.cpp index c7450c99..7c4c1aa3 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtArray.cpp +++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtArray.cpp @@ -60,7 +60,7 @@ unsigned CBaseArray::CalcAllocGrowth (unsigned newAlloc, unsigned oldAlloc, unsi // If this is the initial allocation, or if the new allocation is more // than twice as big as the old allocation and larger than the chunk // size, then allocate exactly the amount of memory requested - if (!oldAlloc || (newAlloc >= max(2 * oldAlloc, *chunkSize))) + if (!oldAlloc || (newAlloc >= std::max(2 * oldAlloc, *chunkSize))) return newAlloc; // Otherwise, allocate memory beyond what was requested in preparation @@ -69,7 +69,7 @@ unsigned CBaseArray::CalcAllocGrowth (unsigned newAlloc, unsigned oldAlloc, unsi // For small allocations, double the size of the buffer each time if (newAlloc < *chunkSize) - return max(newAlloc, 2 * oldAlloc); + return std::max(newAlloc, 2 * oldAlloc); // For larger allocations, grow by the chunk size each time if (oldAlloc + *chunkSize > newAlloc) { diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtArray.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtArray.h index 01346f99..0d4537b4 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtArray.h +++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtArray.h @@ -740,25 +740,25 @@ public: //=========================================================================== template TArray::TArray () : TFArray() { - m_chunkSize = max(1, 256 / sizeof(T)); + m_chunkSize = std::max(1u, 256 / sizeof(T)); } //=========================================================================== template TArray::TArray (const char file[], int line) : TFArray(file, line) { - m_chunkSize = max(1, 256 / sizeof(T)); + m_chunkSize = std::max(1u, 256 / sizeof(T)); } //=========================================================================== template TArray::TArray (unsigned count) : TFArray(count) { - m_chunkSize = max(1, 256 / sizeof(T)); + m_chunkSize = std::max(1u, 256 / sizeof(T)); } //=========================================================================== template TArray::TArray (const T * source, unsigned count) : TFArray(source, count) { - m_chunkSize = max(1, 256 / sizeof(T)); + m_chunkSize = std::max(1u, 256 / sizeof(T)); } //=========================================================================== @@ -890,8 +890,8 @@ void TArray::Move (unsigned destIndex, unsigned sourceIndex, unsigned count // Remove it from the source if (destIndex >= sourceIndex) { - C::Destruct(this->m_data + sourceIndex, min(count, destIndex - sourceIndex)); - C::Construct(this->m_data + sourceIndex, min(count, destIndex - sourceIndex)); + C::Destruct(this->m_data + sourceIndex, std::min(count, destIndex - sourceIndex)); + C::Construct(this->m_data + sourceIndex, std::min(count, destIndex - sourceIndex)); } else { unsigned overlap = (destIndex + count > sourceIndex) ? (destIndex + count - sourceIndex) : 0; @@ -936,7 +936,7 @@ T TArray::Pop () { //=========================================================================== template void TArray::Reserve (unsigned additionalCount) { - AdjustSizeChunked(max(this->m_alloc, this->m_count + additionalCount), this->m_count); + AdjustSizeChunked(std::max(this->m_alloc, this->m_count + additionalCount), this->m_count); } //=========================================================================== @@ -956,7 +956,7 @@ void TArray::SetChunkSize (unsigned chunkSize) { //=========================================================================== template void TArray::SetCount (unsigned count) { - AdjustSizeChunked(max(this->m_alloc, count), count); + AdjustSizeChunked(std::max(this->m_alloc, count), count); } //=========================================================================== diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtCmd.cpp b/Sources/Plasma/NucleusLib/pnUtils/pnUtCmd.cpp index cea8367a..a11dca75 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtCmd.cpp +++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtCmd.cpp @@ -158,7 +158,7 @@ CICmdParser::CICmdParser (const CmdArgDef def[], unsigned defCount) { arg.nameChars = def[loop].name ? StrLen(def[loop].name) : 0; arg.isSpecified = false; SetDefaultValue(arg); - maxId = max(maxId, def[loop].id); + maxId = std::max(maxId, def[loop].id); // Track the number of unflagged arguments if (!flagged) @@ -167,7 +167,7 @@ CICmdParser::CICmdParser (const CmdArgDef def[], unsigned defCount) { } // Build the id lookup table - unsigned idTableSize = min(maxId + 1, defCount * 2); + unsigned idTableSize = std::min(maxId + 1, defCount * 2); m_idLookupArray.SetCount(idTableSize); m_idLookupArray.Zero(); for (loop = 0; loop < defCount; ++loop) diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtHash.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtHash.h index 6c5f34d5..b7313c05 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtHash.h +++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtHash.h @@ -432,7 +432,7 @@ void TBaseHashTable::SetLinkOffset (int linkOffset, unsigned maxSize) { v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; - SetSlotCount(max(kSlotMinCount, v)); + SetSlotCount(std::max(static_cast(kSlotMinCount), v)); } } @@ -459,7 +459,7 @@ void TBaseHashTable::SetSlotCount (unsigned count) { template void TBaseHashTable::SetSlotMaxCount (unsigned count) { if (count) - m_slotMaxCount = max(kSlotMinCount, count); + m_slotMaxCount = std::max(static_cast(kSlotMinCount), count); } //=========================================================================== diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp index 1cfff012..b5956c0c 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp @@ -439,9 +439,9 @@ void plArmatureModBase::AdjustLOD() hsPoint3 delta = ourPos - camPos; float distanceSquared = delta.MagnitudeSquared(); if (distanceSquared < fLODDistance * fLODDistance) - SetLOD(max(0, fMinLOD)); + SetLOD(std::max(0, fMinLOD)); else if (distanceSquared < fLODDistance * fLODDistance * 4.0) - SetLOD(max(1, fMinLOD)); + SetLOD(std::max(1, fMinLOD)); else SetLOD(2); } diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp index bb78bf1c..63594843 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp @@ -106,7 +106,7 @@ void plArmatureBehavior::DumpDebug(int &x, int &y, int lineHeight, plDebugText & float strength = GetStrength(); const char *onOff = strength > 0 ? "on" : "off"; char blendBar[] = "||||||||||"; - int bars = (int)min(10 * strength, 10); + int bars = std::min(static_cast(10 * strength), 10); blendBar[bars] = '\0'; plString details; diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp index 94b7b77a..8db5b732 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp @@ -179,7 +179,7 @@ public: float oldSpeed = fabs(fSwimBrain->fSwimStrategy->GetTurnStrength()); float thisInc = elapsed * incPerSec; - float newSpeed = min(oldSpeed + thisInc, maxTurnSpeed); + float newSpeed = std::min(oldSpeed + thisInc, maxTurnSpeed); fSwimBrain->fSwimStrategy->SetTurnStrength(newSpeed * fAvMod->GetKeyTurnStrength() + fAvMod->GetAnalogTurnStrength()); // the turn is actually applied during PhysicsUpdate } diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp index c515e7f1..8a4a5903 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp @@ -577,7 +577,7 @@ bool plWalkingStrategy::EnableControlledFlight(bool status) ++fControlledFlight; } else - fControlledFlight = max(--fControlledFlight, 0); + fControlledFlight = std::max(--fControlledFlight, 0); return status; } diff --git a/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp b/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp index c99c4b19..b3dc5622 100644 --- a/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp +++ b/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp @@ -713,7 +713,7 @@ bool plSecureStream::GetSecureEncryptionKey(const plFileName& filename, uint32_t file.Close(); - unsigned memSize = min(bytesToRead, bytesRead); + unsigned memSize = std::min(bytesToRead, bytesRead); memcpy(key, buffer, memSize); free(buffer); @@ -721,7 +721,7 @@ bool plSecureStream::GetSecureEncryptionKey(const plFileName& filename, uint32_t } // file doesn't exist, use default key - unsigned memSize = min(length, arrsize(plSecureStream::kDefaultKey)); + unsigned memSize = std::min(length, arrsize(plSecureStream::kDefaultKey)); memSize *= sizeof(uint32_t); memcpy(key, plSecureStream::kDefaultKey, memSize); diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp index ff0bc694..eb4d37a0 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp @@ -2701,7 +2701,7 @@ bool LoginRequestTrans::Recv ( m_accountFlags = reply.accountFlags; m_billingType = reply.billingType; - unsigned memSize = min(arrsize(s_encryptionKey), arrsize(reply.encryptionKey)); + unsigned memSize = std::min(arrsize(s_encryptionKey), arrsize(reply.encryptionKey)); memSize *= sizeof(uint32_t); memcpy(s_encryptionKey, reply.encryptionKey, memSize); } @@ -5130,7 +5130,7 @@ void NetCliAuthStartConnect ( ) { // TEMP: Only connect to one auth server until we fill out this module // to choose the "best" auth connection. - authAddrCount = min(authAddrCount, 1); + authAddrCount = std::min(authAddrCount, 1u); for (unsigned i = 0; i < authAddrCount; ++i) { // Do we need to lookup the address? @@ -5273,7 +5273,7 @@ void NetCliAuthGetEncryptionKey ( uint32_t key[], unsigned size ) { - unsigned memSize = min(arrsize(s_encryptionKey), size); + unsigned memSize = std::min(arrsize(s_encryptionKey), size); memSize *= sizeof(uint32_t); memcpy(key, s_encryptionKey, memSize); } diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp index 8086f4c5..cff25405 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp @@ -1350,7 +1350,7 @@ void NetCliFileStartConnect ( ) { // TEMP: Only connect to one file server until we fill out this module // to choose the "best" file connection. - fileAddrCount = min(fileAddrCount, 1); + fileAddrCount = std::min(fileAddrCount, 1u); s_connectBuildId = isPatcher ? kFileSrvBuildId : plProduct::BuildId(); s_serverType = kSrvTypeNone; @@ -1387,7 +1387,7 @@ void NetCliFileStartConnectAsServer ( ) { // TEMP: Only connect to one file server until we fill out this module // to choose the "best" file connection. - fileAddrCount = min(fileAddrCount, 1); + fileAddrCount = std::min(fileAddrCount, 1u); s_connectBuildId = serverBuildId; s_serverType = serverType; diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp index 4606f883..3d5673c3 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp @@ -1062,7 +1062,7 @@ void NetCliGateKeeperStartConnect ( const char* gateKeeperAddrList[], uint32_t gateKeeperAddrCount ) { - gateKeeperAddrCount = min(gateKeeperAddrCount, 1); + gateKeeperAddrCount = std::min(gateKeeperAddrCount, 1u); for (unsigned i = 0; i < gateKeeperAddrCount; ++i) { // Do we need to lookup the address? diff --git a/Sources/Plasma/PubUtilLib/plSockets/plBufferedSocketWriter.cpp b/Sources/Plasma/PubUtilLib/plSockets/plBufferedSocketWriter.cpp index 609e8902..5468c00b 100644 --- a/Sources/Plasma/PubUtilLib/plSockets/plBufferedSocketWriter.cpp +++ b/Sources/Plasma/PubUtilLib/plSockets/plBufferedSocketWriter.cpp @@ -79,7 +79,7 @@ int plBufferedSocketWriter::Flush(plTcpSocket & sck) // this is where things { int ans = kSuccessNoDataSent; - int writeSize = MIN(FastAmountBuffered(),fBytesPerFlush); + int writeSize = std::min(FastAmountBuffered(), fBytesPerFlush); if(writeSize > 0) { From 1a987173d6d100c7c27d43306f2e8cd8c5bbd17b Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Tue, 22 Jul 2014 22:34:43 -0700 Subject: [PATCH 3/9] Use std::swap --- Sources/Plasma/CoreLib/HeadSpin.h | 36 ------------------- Sources/Plasma/NucleusLib/pnUtils/pnUtSort.h | 6 ++-- .../plNetGameLib/Private/plNglFile.cpp | 2 +- .../plNetGameLib/Private/plNglGame.cpp | 2 +- .../plNetGameLib/Private/plNglGateKeeper.cpp | 2 +- 5 files changed, 6 insertions(+), 42 deletions(-) diff --git a/Sources/Plasma/CoreLib/HeadSpin.h b/Sources/Plasma/CoreLib/HeadSpin.h index 201075d8..513d153f 100644 --- a/Sources/Plasma/CoreLib/HeadSpin.h +++ b/Sources/Plasma/CoreLib/HeadSpin.h @@ -212,27 +212,6 @@ inline double hsSwapEndianDouble(double dvalue) #define hsToLEDouble(n) hsSwapEndianDouble(n) #endif -inline void hsSwap(int32_t& a, int32_t& b) -{ - int32_t c = a; - a = b; - b = c; -} - -inline void hsSwap(uint32_t& a, uint32_t& b) -{ - uint32_t c = a; - a = b; - b = c; -} - -inline void hsSwap(float& a, float& b) -{ - float c = a; - a = b; - b = c; -} - //=========================================================================== // Define a NOOP (null) statement //=========================================================================== @@ -242,21 +221,6 @@ inline void hsSwap(float& a, float& b) # define NULL_STMT ((void)0) #endif -/**************************************************************************** -* -* SWAP -* Swaps the values of two variables -* -***/ - -//=========================================================================== -template -void SWAP (T & a, T & b) { - T temp = a; - a = b; - b = temp; -} - /**************************************************************************** * diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtSort.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtSort.h index dd20e76c..4f639670 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtSort.h +++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtSort.h @@ -97,7 +97,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com T * mid = lo + (hi - lo) / 2; \ \ /* Swap it to the beginning of the array */ \ - SWAP(*mid, *lo); \ + std::swap(*mid, *lo); \ \ /* Partition the array into three pieces, one consisting of */ \ /* elements <= the partitioning element, one of elements */ \ @@ -134,7 +134,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com /* val(loPart) > val(lo) */ \ /* val(hiPart) < val(lo) */ \ \ - SWAP(*loPart, *hiPart); \ + std::swap(*loPart, *hiPart); \ \ /* val(loPart) < val(lo) */ \ /* val(hiPart) > val(lo) */ \ @@ -145,7 +145,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com /* val(i) >= val(lo) for loPart <= i <= hi */ \ \ /* Put the partitioning element in place */ \ - SWAP(*lo, *hiPart); \ + std::swap(*lo, *hiPart); \ \ /* val(i) <= val(hiPart) for lo <= i < hiPart */ \ /* val(i) == val(lo) for hiPart <= i < loPart */ \ diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp index cff25405..276c98a7 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp @@ -760,7 +760,7 @@ void CliFileConn::Destroy () { { hsLockForWriting lock(sockLock); - SWAP(oldSock, sock); + std::swap(oldSock, sock); } if (oldSock) diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp index 6ecf1dfc..d24a1f80 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp @@ -218,7 +218,7 @@ static bool ConnEncrypt (ENetError error, void * param) { if (IS_NET_SUCCESS(error)) { s_critsect.Enter(); { - SWAP(s_active, conn); + std::swap(s_active, conn); } s_critsect.Leave(); } diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp index 3d5673c3..4264c46e 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp @@ -267,7 +267,7 @@ static bool ConnEncrypt (ENetError error, void * param) { s_critsect.Enter(); { - SWAP(s_active, conn); + std::swap(s_active, conn); } s_critsect.Leave(); From ce53a719906399900def02cdcd68bd6a7a8b5df8 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Tue, 22 Jul 2014 22:38:05 -0700 Subject: [PATCH 4/9] There is no benefit to the hsFopen macro --- Sources/Plasma/CoreLib/HeadSpin.h | 2 -- Sources/Plasma/PubUtilLib/plInputCore/plInputInterfaceMgr.cpp | 3 +-- Sources/Tools/MaxExport/plExportLogErrorMsg.cpp | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Sources/Plasma/CoreLib/HeadSpin.h b/Sources/Plasma/CoreLib/HeadSpin.h index 513d153f..f4a6e7fe 100644 --- a/Sources/Plasma/CoreLib/HeadSpin.h +++ b/Sources/Plasma/CoreLib/HeadSpin.h @@ -366,8 +366,6 @@ inline float hsRadiansToDegrees(float rad) { return float(rad * (180 / M_PI)); } # define ALIGN(n) __atribute__(aligned(n)) #endif -#define hsFopen(name, mode) fopen(name, mode) - /************************ Debug/Error Macros **************************/ typedef void (*hsDebugMessageProc)(const char message[]); diff --git a/Sources/Plasma/PubUtilLib/plInputCore/plInputInterfaceMgr.cpp b/Sources/Plasma/PubUtilLib/plInputCore/plInputInterfaceMgr.cpp index 6fa46f62..9a4f9b88 100644 --- a/Sources/Plasma/PubUtilLib/plInputCore/plInputInterfaceMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plInputCore/plInputInterfaceMgr.cpp @@ -765,8 +765,7 @@ void plInputInterfaceMgr::WriteKeyMap( void ) #ifdef PLASMA_EXTERNAL_RELEASE return; #endif - FILE* gKeyFile = 0; - gKeyFile = hsFopen( "init\\keyboard.fni", "wt" ); + FILE* gKeyFile = fopen("init\\keyboard.fni", "wt"); if (gKeyFile) { diff --git a/Sources/Tools/MaxExport/plExportLogErrorMsg.cpp b/Sources/Tools/MaxExport/plExportLogErrorMsg.cpp index bc0e0761..571c408b 100644 --- a/Sources/Tools/MaxExport/plExportLogErrorMsg.cpp +++ b/Sources/Tools/MaxExport/plExportLogErrorMsg.cpp @@ -74,7 +74,7 @@ plExportLogErrorMsg::~plExportLogErrorMsg() #ifdef ERRORLOG_ALWAYS_WRITE_SOMETHING else { - fErrfile = hsFopen(fErrfile_name, "wt"); + fErrfile = fopen(fErrfile_name, "wt"); setbuf(fErrfile, nil); fprintf(fErrfile, "No errors found! Good job."); fclose(fErrfile); @@ -170,7 +170,7 @@ void plExportLogErrorMsg::IWriteErrorFile(const char* label, const char* msg) if ( !fErrfile ) { // must be the first write... open the error file - fErrfile = hsFopen(fErrfile_name, "wt"); + fErrfile = fopen(fErrfile_name, "wt"); setbuf(fErrfile, nil); fNumberErrors = 0; } From fced942020f575ae905c95462f25cc10fe1e8048 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Tue, 22 Jul 2014 23:24:49 -0700 Subject: [PATCH 5/9] Safer type-punning --- Sources/Plasma/CoreLib/HeadSpin.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Sources/Plasma/CoreLib/HeadSpin.h b/Sources/Plasma/CoreLib/HeadSpin.h index f4a6e7fe..9a883e09 100644 --- a/Sources/Plasma/CoreLib/HeadSpin.h +++ b/Sources/Plasma/CoreLib/HeadSpin.h @@ -177,15 +177,25 @@ inline uint64_t hsSwapEndian64(uint64_t value) } inline float hsSwapEndianFloat(float fvalue) { - uint32_t value = *(uint32_t*)&fvalue; - value = hsSwapEndian32(value); - return *(float*)&value; + union { + uint32_t i; + float f; + } value; + + value.f = fvalue; + value.i = hsSwapEndian32(value.i); + return value.f; } inline double hsSwapEndianDouble(double dvalue) { - uint64_t value = *(uint64_t*)&dvalue; - value = hsSwapEndian64(value); - return *(double*)&value; + union { + uint64_t i; + double f; + } value; + + value.f = dvalue; + value.i = hsSwapEndian64(value.i); + return value.f; } #if LITTLE_ENDIAN From 751d7607726ec2affc0da930a659a4a858325569 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Tue, 22 Jul 2014 23:26:54 -0700 Subject: [PATCH 6/9] Use standard (f)abs functions --- Sources/Plasma/CoreLib/HeadSpin.h | 1 - Sources/Plasma/CoreLib/hsQuat.cpp | 2 +- .../FeatureLib/pfCamera/plCameraBrain.cpp | 10 ++--- .../FeatureLib/pfCamera/plCameraModifier.cpp | 2 +- .../FeatureLib/pfCamera/plVirtualCamNeu.cpp | 2 +- .../pnNetCommon/plSynchedObject.cpp | 2 +- .../NucleusLib/pnNetCommon/plSynchedValue.h | 2 +- .../PubUtilLib/plAvatar/plAvTaskSeek.cpp | 2 +- .../plAvatar/plPhysicalControllerCore.cpp | 8 ++-- .../plInputCore/plAvatarInputInterface.cpp | 16 ++++---- .../plInputCore/plDebugInputInterface.cpp | 16 ++++---- .../plInputCore/plSceneInputInterface.cpp | 2 +- Sources/Plasma/PubUtilLib/plInterp/hsKeys.cpp | 40 +++++++++---------- .../PubUtilLib/plSDL/plStateVariable.cpp | 17 +++++++- 14 files changed, 68 insertions(+), 54 deletions(-) diff --git a/Sources/Plasma/CoreLib/HeadSpin.h b/Sources/Plasma/CoreLib/HeadSpin.h index 9a883e09..ab9c72af 100644 --- a/Sources/Plasma/CoreLib/HeadSpin.h +++ b/Sources/Plasma/CoreLib/HeadSpin.h @@ -133,7 +133,6 @@ typedef uint32_t hsGSeedValue; #define hsLongAlign(n) (((n) + 3) & ~3L) -#define hsABS(x) ((x) < 0 ? -(x) : (x)) #define hsSGN(x) (((x) < 0) ? -1 : ( ((x) > 0) ? 1 : 0 )) #define hsBitTst2Bool(value, mask) (((value) & (mask)) != 0) diff --git a/Sources/Plasma/CoreLib/hsQuat.cpp b/Sources/Plasma/CoreLib/hsQuat.cpp index 1acf0982..7741d020 100644 --- a/Sources/Plasma/CoreLib/hsQuat.cpp +++ b/Sources/Plasma/CoreLib/hsQuat.cpp @@ -81,7 +81,7 @@ hsPoint3 hsQuat::Rotate(const hsScalarTriple* v) const hsQuat qVec(v->fX, v->fY, v->fZ, 0); hsQuat t = qInv * qVec; hsQuat res = (t * (*this)); - //hsAssert(hsABS(res.fW)<1e-5, "Error rotating vector"); + //hsAssert(fabs(res.fW)<1e-5, "Error rotating vector"); return hsPoint3(res.fX, res.fY, res.fZ); } diff --git a/Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.cpp b/Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.cpp index d5caf08a..4297f284 100644 --- a/Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.cpp +++ b/Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.cpp @@ -301,7 +301,7 @@ void plCameraBrain1::IMoveTowardGoal(double elapsedTime) if (distToGoal <= 5.0f && distToGoal > 0.1f) { float mult = (distToGoal - 5.0f)*0.1f; - adjMaxVel = fVelocity - hsABS(fVelocity*mult); + adjMaxVel = fVelocity - fabs(fVelocity*mult); } @@ -380,7 +380,7 @@ void plCameraBrain1::IPointTowardGoal(double elapsedTime) if (distToGoal <= 5.0f && distToGoal > 0.1f) { float mult = (distToGoal - 5.0f)*0.1f; - adjMaxVel = fPOAVelocity - hsABS(fPOAVelocity*mult); + adjMaxVel = fPOAVelocity - fabs(fPOAVelocity*mult); } @@ -483,7 +483,7 @@ bool plCameraBrain1::IShouldDecelerate(float decelSpeed, float curSpeed, float d float avgSpeed = curSpeed * .5f; float stopDist = avgSpeed * stopTime; - return (hsABS(distToGoal) <= hsABS(stopDist)); // stopDist+avgSpeed? + return (fabs(distToGoal) <= fabs(stopDist)); // stopDist+avgSpeed? } // @@ -560,7 +560,7 @@ float plCameraBrain1::IMakeFOVwZoom(float fovH) const { float num = tan(hsDegreesToRadians(fovH / 2)) * tan(hsDegreesToRadians(fCamera->GetFOVw() / 2)); float denom = tan(hsDegreesToRadians(fCamera->GetFOVh() / 2)); - return 2 * hsABS(hsRadiansToDegrees(atan(num / denom))); + return 2 * fabs(hsRadiansToDegrees(atan(num / denom))); } bool plCameraBrain1::MsgReceive(plMessage* msg) @@ -1689,7 +1689,7 @@ hsPoint3 plCameraBrain1_Circle::MoveTowardsFromGoal(const hsPoint3* fromGoal, do if (fCurRad != fGoalRad) { - float dist = hsABS(fGoalRad-fCurRad); + float dist = fabs(fGoalRad-fCurRad); hsAssert(dist>=0 && dist<=kTwoPI, "illegal radian diff"); bool mustWrap = (dist > M_PI); // go opposite direction for shortcut and wrap diff --git a/Sources/Plasma/FeatureLib/pfCamera/plCameraModifier.cpp b/Sources/Plasma/FeatureLib/pfCamera/plCameraModifier.cpp index 6723f0bf..a6f2a0e4 100644 --- a/Sources/Plasma/FeatureLib/pfCamera/plCameraModifier.cpp +++ b/Sources/Plasma/FeatureLib/pfCamera/plCameraModifier.cpp @@ -198,7 +198,7 @@ bool plCameraModifier1::MsgReceive(plMessage* msg) { double time = (double)fFOVInstructions[pEventMsg->fIndex]->GetConfig()->fAccel; double time2 = (double)pEventMsg->fEventTime; - time = hsABS(time - time2); + time = fabs(time - time2); float h = fFOVInstructions[pEventMsg->fIndex]->GetConfig()->fFOVh; float w = fFOVInstructions[pEventMsg->fIndex]->GetConfig()->fFOVw; if (GetBrain()) diff --git a/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp b/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp index 2e1237d3..5a92a0f8 100644 --- a/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp +++ b/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp @@ -1949,7 +1949,7 @@ void plVirtualCam1::StartTransition(CamTrans* transition) pBrain->SetCamera(fTransitionCamera); // deal with FOV - - float diffH = hsABS(pCam->GetFOVh() - fPrevCam->GetFOVh()); + float diffH = fabs(pCam->GetFOVh() - fPrevCam->GetFOVh()); if ( diffH ) { double time = 0; diff --git a/Sources/Plasma/NucleusLib/pnNetCommon/plSynchedObject.cpp b/Sources/Plasma/NucleusLib/pnNetCommon/plSynchedObject.cpp index e11123a5..e1483f8c 100644 --- a/Sources/Plasma/NucleusLib/pnNetCommon/plSynchedObject.cpp +++ b/Sources/Plasma/NucleusLib/pnNetCommon/plSynchedObject.cpp @@ -134,7 +134,7 @@ void plSynchedObject::IAppendSynchedValueFriend(plSynchedValueBase* v) uint8_t plSynchedObject::RegisterSynchedValue(plSynchedValueBase* v) { int32_t addrOff = ((int32_t)v - (int32_t)this)>>2; - hsAssert(hsABS(addrOff) < (uint32_t)(1<<(sizeof(AddrOffsetType)<<3)), "address offset overflow"); + hsAssert(abs(addrOff) < (uint32_t)(1<<(sizeof(AddrOffsetType)<<3)), "address offset overflow"); IAppendSynchedValueAddrOffset((AddrOffsetType)addrOff); int32_t idx = fNumSynchedValues-1; hsAssert(idx<256, "index too big"); diff --git a/Sources/Plasma/NucleusLib/pnNetCommon/plSynchedValue.h b/Sources/Plasma/NucleusLib/pnNetCommon/plSynchedValue.h index 079c5800..77a0b60e 100644 --- a/Sources/Plasma/NucleusLib/pnNetCommon/plSynchedValue.h +++ b/Sources/Plasma/NucleusLib/pnNetCommon/plSynchedValue.h @@ -87,7 +87,7 @@ protected: // is set to his address so we can automatically get at it during construction. fFlags=0; int32_t off = (int32_t)plSynchedObject::GetStaticSynchedObject() - (int32_t)this; - if ( hsABS(off) < (1<<(sizeof(fSynchedObjectAddrOffset)<<3)) ) + if ( abs(off) < (1<<(sizeof(fSynchedObjectAddrOffset)<<3)) ) fSynchedObjectAddrOffset = (int16_t)off; else fSynchedObjectAddrOffset=-1; diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp index 3f80b997..57501f05 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp @@ -622,7 +622,7 @@ float QuatAngleDiff(const hsQuat &a, const hsQuat &b) // Calling acos on 1.0 is returning an undefined value. Need to check for it. float epsilon = 0.00001; - if (hsABS(cos_t - 1.f) < epsilon) + if (fabs(cos_t - 1.f) < epsilon) return 0; theta = acos(cos_t); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp index 8a4a5903..b6c5451a 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp @@ -284,7 +284,7 @@ void plAnimatedMovementStrategy::RecalcVelocity(double timeNow, float elapsed, b // Update controller rotation float zRot = fAnimAngularVel + fTurnStr; - if (hsABS(zRot) > 0.0001f) + if (fabs(zRot) > 0.0001f) fController->IncrementAngle(zRot * elapsed); // Update controller velocity @@ -396,7 +396,7 @@ void plWalkingStrategy::Apply(float delSecs) hsVector3 achievedVelocity = fController->GetAchievedLinearVelocity(); // Add in gravity if the avatar's z velocity isn't being set explicitly - if (hsABS(velocity.fZ) < 0.001f) + if (fabs(velocity.fZ) < 0.001f) { // Get our previous z velocity. If we're on the ground, clamp it to zero at // the largest, so we won't launch into the air if we're running uphill. @@ -625,7 +625,7 @@ void plSwimStrategy::Apply(float delSecs) hsVector3 linCurrent(0.0f, 0.0f, 0.0f); fCurrentRegion->GetCurrent(fController, linCurrent, angCurrent, delSecs); - if (hsABS(angCurrent) > 0.0001f) + if (fabs(angCurrent) > 0.0001f) fController->IncrementAngle(angCurrent * delSecs); velocity += linCurrent; @@ -710,7 +710,7 @@ void plDynamicWalkingStrategy::Apply(float delSecs) hsVector3 achievedVelocity = fController->GetAchievedLinearVelocity(); // Add in gravity if the avatar's z velocity isn't being set explicitly - if (hsABS(velocity.fZ) < 0.001f) + if (fabs(velocity.fZ) < 0.001f) { // Get our previous z velocity. If we're on the ground, clamp it to zero at // the largest, so we won't launch into the air if we're running uphill. diff --git a/Sources/Plasma/PubUtilLib/plInputCore/plAvatarInputInterface.cpp b/Sources/Plasma/PubUtilLib/plInputCore/plAvatarInputInterface.cpp index ca7ef87e..a6a1744e 100644 --- a/Sources/Plasma/PubUtilLib/plInputCore/plAvatarInputInterface.cpp +++ b/Sources/Plasma/PubUtilLib/plInputCore/plAvatarInputInterface.cpp @@ -849,17 +849,17 @@ bool plAvatarInputInterface::InterpretInputEvent( plInputEventMsg *pMsg ) if (mouseMap->fMap[i]->fControlFlags & kControlFlagRangePos) { if (mouseMap->fMap[i]->fControlFlags & kControlFlagXAxisEvent) - pct = hsABS((mouseMap->fMap[i]->fBox.fX - pMouseMsg->GetXPos()) / (mouseMap->fMap[i]->fBox.fY - mouseMap->fMap[i]->fBox.fX)); + pct = fabs((mouseMap->fMap[i]->fBox.fX - pMouseMsg->GetXPos()) / (mouseMap->fMap[i]->fBox.fY - mouseMap->fMap[i]->fBox.fX)); else - pct = hsABS((mouseMap->fMap[i]->fBox.fZ - pMouseMsg->GetYPos()) / (mouseMap->fMap[i]->fBox.fW - mouseMap->fMap[i]->fBox.fZ)); + pct = fabs((mouseMap->fMap[i]->fBox.fZ - pMouseMsg->GetYPos()) / (mouseMap->fMap[i]->fBox.fW - mouseMap->fMap[i]->fBox.fZ)); } else if (mouseMap->fMap[i]->fControlFlags & kControlFlagRangeNeg) { if (mouseMap->fMap[i]->fControlFlags & kControlFlagXAxisEvent) - pct = hsABS((mouseMap->fMap[i]->fBox.fY - pMouseMsg->GetXPos()) / (mouseMap->fMap[i]->fBox.fY - mouseMap->fMap[i]->fBox.fX)); + pct = fabs((mouseMap->fMap[i]->fBox.fY - pMouseMsg->GetXPos()) / (mouseMap->fMap[i]->fBox.fY - mouseMap->fMap[i]->fBox.fX)); else - pct = hsABS((mouseMap->fMap[i]->fBox.fW - pMouseMsg->GetYPos()) / (mouseMap->fMap[i]->fBox.fW - mouseMap->fMap[i]->fBox.fZ)); + pct = fabs((mouseMap->fMap[i]->fBox.fW - pMouseMsg->GetYPos()) / (mouseMap->fMap[i]->fBox.fW - mouseMap->fMap[i]->fBox.fZ)); } pCmd->fPct = pct; if (pct == 1.0f || pct == -1.0f) @@ -960,17 +960,17 @@ bool plAvatarInputInterface::InterpretInputEvent( plInputEventMsg *pMsg ) if (mouseMap->fMap[i]->fControlFlags & kControlFlagRangePos) { if (mouseMap->fMap[i]->fControlFlags & kControlFlagXAxisEvent) - pct = hsABS((mouseMap->fMap[i]->fBox.fX - pMouseMsg->GetXPos()) / (mouseMap->fMap[i]->fBox.fY - mouseMap->fMap[i]->fBox.fX)); + pct = fabs((mouseMap->fMap[i]->fBox.fX - pMouseMsg->GetXPos()) / (mouseMap->fMap[i]->fBox.fY - mouseMap->fMap[i]->fBox.fX)); else - pct = hsABS((mouseMap->fMap[i]->fBox.fZ - pMouseMsg->GetYPos()) / (mouseMap->fMap[i]->fBox.fW - mouseMap->fMap[i]->fBox.fZ)); + pct = fabs((mouseMap->fMap[i]->fBox.fZ - pMouseMsg->GetYPos()) / (mouseMap->fMap[i]->fBox.fW - mouseMap->fMap[i]->fBox.fZ)); } else if (mouseMap->fMap[i]->fControlFlags & kControlFlagRangeNeg) { if (mouseMap->fMap[i]->fControlFlags & kControlFlagXAxisEvent) - pct = hsABS((mouseMap->fMap[i]->fBox.fY - pMouseMsg->GetXPos()) / (mouseMap->fMap[i]->fBox.fY - mouseMap->fMap[i]->fBox.fX)); + pct = fabs((mouseMap->fMap[i]->fBox.fY - pMouseMsg->GetXPos()) / (mouseMap->fMap[i]->fBox.fY - mouseMap->fMap[i]->fBox.fX)); else - pct = hsABS((mouseMap->fMap[i]->fBox.fW - pMouseMsg->GetYPos()) / (mouseMap->fMap[i]->fBox.fW - mouseMap->fMap[i]->fBox.fZ)); + pct = fabs((mouseMap->fMap[i]->fBox.fW - pMouseMsg->GetYPos()) / (mouseMap->fMap[i]->fBox.fW - mouseMap->fMap[i]->fBox.fZ)); } pCmd->fPct = pct; if (pct == 1.0f || pct == -1.0f) diff --git a/Sources/Plasma/PubUtilLib/plInputCore/plDebugInputInterface.cpp b/Sources/Plasma/PubUtilLib/plInputCore/plDebugInputInterface.cpp index ddec7617..86104386 100644 --- a/Sources/Plasma/PubUtilLib/plInputCore/plDebugInputInterface.cpp +++ b/Sources/Plasma/PubUtilLib/plInputCore/plDebugInputInterface.cpp @@ -245,17 +245,17 @@ bool plDebugInputInterface::InterpretInputEvent( plInputEventMsg *pMsg ) if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRangePos) { if (fMouseMap.fMap[i]->fControlFlags & kControlFlagXAxisEvent) - pct = hsABS((fMouseMap.fMap[i]->fBox.fX - pMouseMsg->GetXPos()) / (fMouseMap.fMap[i]->fBox.fY - fMouseMap.fMap[i]->fBox.fX)); + pct = fabs((fMouseMap.fMap[i]->fBox.fX - pMouseMsg->GetXPos()) / (fMouseMap.fMap[i]->fBox.fY - fMouseMap.fMap[i]->fBox.fX)); else - pct = hsABS((fMouseMap.fMap[i]->fBox.fZ - pMouseMsg->GetYPos()) / (fMouseMap.fMap[i]->fBox.fW - fMouseMap.fMap[i]->fBox.fZ)); + pct = fabs((fMouseMap.fMap[i]->fBox.fZ - pMouseMsg->GetYPos()) / (fMouseMap.fMap[i]->fBox.fW - fMouseMap.fMap[i]->fBox.fZ)); } else if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRangeNeg) { if (fMouseMap.fMap[i]->fControlFlags & kControlFlagXAxisEvent) - pct = hsABS((fMouseMap.fMap[i]->fBox.fY - pMouseMsg->GetXPos()) / (fMouseMap.fMap[i]->fBox.fY - fMouseMap.fMap[i]->fBox.fX)); + pct = fabs((fMouseMap.fMap[i]->fBox.fY - pMouseMsg->GetXPos()) / (fMouseMap.fMap[i]->fBox.fY - fMouseMap.fMap[i]->fBox.fX)); else - pct = hsABS((fMouseMap.fMap[i]->fBox.fW - pMouseMsg->GetYPos()) / (fMouseMap.fMap[i]->fBox.fW - fMouseMap.fMap[i]->fBox.fZ)); + pct = fabs((fMouseMap.fMap[i]->fBox.fW - pMouseMsg->GetYPos()) / (fMouseMap.fMap[i]->fBox.fW - fMouseMap.fMap[i]->fBox.fZ)); } pCmd->fPct = pct; if (pct == 1.0f || pct == -1.0f) @@ -320,17 +320,17 @@ bool plDebugInputInterface::InterpretInputEvent( plInputEventMsg *pMsg ) if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRangePos) { if (fMouseMap.fMap[i]->fControlFlags & kControlFlagXAxisEvent) - pct = hsABS((fMouseMap.fMap[i]->fBox.fX - pMouseMsg->GetXPos()) / (fMouseMap.fMap[i]->fBox.fY - fMouseMap.fMap[i]->fBox.fX)); + pct = fabs((fMouseMap.fMap[i]->fBox.fX - pMouseMsg->GetXPos()) / (fMouseMap.fMap[i]->fBox.fY - fMouseMap.fMap[i]->fBox.fX)); else - pct = hsABS((fMouseMap.fMap[i]->fBox.fZ - pMouseMsg->GetYPos()) / (fMouseMap.fMap[i]->fBox.fW - fMouseMap.fMap[i]->fBox.fZ)); + pct = fabs((fMouseMap.fMap[i]->fBox.fZ - pMouseMsg->GetYPos()) / (fMouseMap.fMap[i]->fBox.fW - fMouseMap.fMap[i]->fBox.fZ)); } else if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRangeNeg) { if (fMouseMap.fMap[i]->fControlFlags & kControlFlagXAxisEvent) - pct = hsABS((fMouseMap.fMap[i]->fBox.fY - pMouseMsg->GetXPos()) / (fMouseMap.fMap[i]->fBox.fY - fMouseMap.fMap[i]->fBox.fX)); + pct = fabs((fMouseMap.fMap[i]->fBox.fY - pMouseMsg->GetXPos()) / (fMouseMap.fMap[i]->fBox.fY - fMouseMap.fMap[i]->fBox.fX)); else - pct = hsABS((fMouseMap.fMap[i]->fBox.fW - pMouseMsg->GetYPos()) / (fMouseMap.fMap[i]->fBox.fW - fMouseMap.fMap[i]->fBox.fZ)); + pct = fabs((fMouseMap.fMap[i]->fBox.fW - pMouseMsg->GetYPos()) / (fMouseMap.fMap[i]->fBox.fW - fMouseMap.fMap[i]->fBox.fZ)); } pCmd->fPct = pct; if (pct == 1.0f || pct == -1.0f) diff --git a/Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp b/Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp index 8ae64159..efc773c6 100644 --- a/Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp +++ b/Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp @@ -413,7 +413,7 @@ bool plSceneInputInterface::MsgReceive( plMessage *msg ) return true; } - if (hsABS(avPt.fZ - objPt.fZ) > 1.0f) // you need to also be in the same plane (some books are on top of rocks you need to jump onto) + if (fabs(avPt.fZ - objPt.fZ) > 1.0f) // you need to also be in the same plane (some books are on top of rocks you need to jump onto) { ResetClickableState(); return true; diff --git a/Sources/Plasma/PubUtilLib/plInterp/hsKeys.cpp b/Sources/Plasma/PubUtilLib/plInterp/hsKeys.cpp index 054b48fa..1f722233 100644 --- a/Sources/Plasma/PubUtilLib/plInterp/hsKeys.cpp +++ b/Sources/Plasma/PubUtilLib/plInterp/hsKeys.cpp @@ -61,9 +61,9 @@ void hsPoint3Key::Write(hsStream *stream) bool hsPoint3Key::CompareValue(hsPoint3Key *key) { - return hsABS(fValue.fX - key->fValue.fX) < .01 && - hsABS(fValue.fY - key->fValue.fY) < .01 && - hsABS(fValue.fZ - key->fValue.fZ) < .01; + return fabs(fValue.fX - key->fValue.fX) < .01 && + fabs(fValue.fY - key->fValue.fY) < .01 && + fabs(fValue.fZ - key->fValue.fZ) < .01; } void hsBezPoint3Key::Read(hsStream *stream) @@ -84,9 +84,9 @@ void hsBezPoint3Key::Write(hsStream *stream) bool hsBezPoint3Key::CompareValue(hsBezPoint3Key *key) { - return hsABS(fValue.fX - key->fValue.fX) < .01 && - hsABS(fValue.fY - key->fValue.fY) < .01 && - hsABS(fValue.fZ - key->fValue.fZ) < .01; + return fabs(fValue.fX - key->fValue.fX) < .01 && + fabs(fValue.fY - key->fValue.fY) < .01 && + fabs(fValue.fZ - key->fValue.fZ) < .01; } ///////////////////////////////////////// @@ -179,21 +179,21 @@ void hsCompressedQuatKey32::SetQuat(hsQuat &q) { q.Normalize(); uint32_t maxElement = kCompQuatNukeX; - float maxVal = hsABS(q.fX); - if (hsABS(q.fY) > maxVal) + float maxVal = fabs(q.fX); + if (fabs(q.fY) > maxVal) { maxElement = kCompQuatNukeY; - maxVal = hsABS(q.fY); + maxVal = fabs(q.fY); } - if (hsABS(q.fZ) > maxVal) + if (fabs(q.fZ) > maxVal) { maxElement = kCompQuatNukeZ; - maxVal = hsABS(q.fZ); + maxVal = fabs(q.fZ); } - if (hsABS(q.fW) > maxVal) + if (fabs(q.fW) > maxVal) { maxElement = kCompQuatNukeW; - maxVal = hsABS(q.fW); + maxVal = fabs(q.fW); } switch (maxElement) { @@ -322,21 +322,21 @@ void hsCompressedQuatKey64::SetQuat(hsQuat &q) { q.Normalize(); uint32_t maxElement = kCompQuatNukeX; - float maxVal = hsABS(q.fX); - if (hsABS(q.fY) > maxVal) + float maxVal = fabs(q.fX); + if (fabs(q.fY) > maxVal) { maxElement = kCompQuatNukeY; - maxVal = hsABS(q.fY); + maxVal = fabs(q.fY); } - if (hsABS(q.fZ) > maxVal) + if (fabs(q.fZ) > maxVal) { maxElement = kCompQuatNukeZ; - maxVal = hsABS(q.fZ); + maxVal = fabs(q.fZ); } - if (hsABS(q.fW) > maxVal) + if (fabs(q.fW) > maxVal) { maxElement = kCompQuatNukeW; - maxVal = hsABS(q.fW); + maxVal = fabs(q.fW); } switch (maxElement) { diff --git a/Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp b/Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp index ef01995f..c514555a 100644 --- a/Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp +++ b/Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp @@ -40,6 +40,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com *==LICENSE==*/ #include +#include #include "hsStream.h" #include "hsTimer.h" #include "plSDL.h" @@ -2110,10 +2111,24 @@ void plSimpleStateVariable::CopyData(const plSimpleStateVariable* other, uint32_ // send notification msg if necessary, called internally // +template +typename std::enable_if::value, _T>::type +_generic_abs(_T value) +{ + return fabs(value); +} + +template +typename std::enable_if::value, _T>::type +_generic_abs(_T value) +{ + return abs(value); +} + #define NOTIFY_CHECK(type, var) \ case type: \ for(i=0;ivar[i])>d) \ + if (_generic_abs(var[i] - other->var[i]) > d) \ { \ notify=true; \ break; \ From 827ea85af021b8d351dea798f3558c5a648f457f Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Tue, 22 Jul 2014 23:43:45 -0700 Subject: [PATCH 7/9] Remove some additional usless / unused junk --- Sources/Plasma/CoreLib/HeadSpin.h | 18 - Sources/Plasma/CoreLib/hsColorRGBA.h | 1 - .../FeatureLib/pfCharacter/CMakeLists.txt | 2 - .../pfCharacter/plPlayerModifier.cpp | 626 ------------------ .../FeatureLib/pfCharacter/plPlayerModifier.h | 149 ----- .../pfConsole/pfConsoleCommands.cpp | 1 - .../pfConsole/pfConsoleCommandsNet.cpp | 1 - Sources/Tools/MaxMain/plMaxNode.cpp | 1 - 8 files changed, 799 deletions(-) delete mode 100644 Sources/Plasma/FeatureLib/pfCharacter/plPlayerModifier.cpp delete mode 100644 Sources/Plasma/FeatureLib/pfCharacter/plPlayerModifier.h diff --git a/Sources/Plasma/CoreLib/HeadSpin.h b/Sources/Plasma/CoreLib/HeadSpin.h index ab9c72af..c2875a8f 100644 --- a/Sources/Plasma/CoreLib/HeadSpin.h +++ b/Sources/Plasma/CoreLib/HeadSpin.h @@ -95,12 +95,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com //====================================== // Basic macros //====================================== -#ifdef __cplusplus - #define hsCTypeDefStruct(foo) -#else - #define hsCTypeDefStruct(foo) typedef struct foo foo; -#endif - #ifdef HS_BUILD_FOR_WIN32 # ifndef CDECL # define CDECL __cdecl @@ -109,9 +103,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com # define CDECL #endif -#define kPosInfinity16 (32767) -#define kNegInfinity16 (-32768) - #define kPosInfinity32 (0x7fffffff) #define kNegInfinity32 (0x80000000) @@ -124,21 +115,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #endif typedef int32_t hsError; -typedef uint32_t hsGSeedValue; #define hsOK 0 #define hsFail -1 #define hsFailed(r) ((hsError)(r)=hsOK) -#define hsLongAlign(n) (((n) + 3) & ~3L) - -#define hsSGN(x) (((x) < 0) ? -1 : ( ((x) > 0) ? 1 : 0 )) - -#define hsBitTst2Bool(value, mask) (((value) & (mask)) != 0) - -#define hsFourByteTag(a, b, c, d) (((uint32_t)(a) << 24) | ((uint32_t)(b) << 16) | ((uint32_t)(c) << 8) | (d)) - #if defined(HAVE_CXX14_DEPRECATED_ATTR) # define hsDeprecated(message) [[deprecated(message)]] #elif defined(HAVE_GCC_DEPRECATED_ATTR) diff --git a/Sources/Plasma/CoreLib/hsColorRGBA.h b/Sources/Plasma/CoreLib/hsColorRGBA.h index 398acaf2..8567111a 100644 --- a/Sources/Plasma/CoreLib/hsColorRGBA.h +++ b/Sources/Plasma/CoreLib/hsColorRGBA.h @@ -75,7 +75,6 @@ struct hsColor32 { } int operator!=(const hsColor32& aa) { return !(aa == *this); } }; -hsCTypeDefStruct(hsColor32) typedef hsColor32 hsRGBAColor32; struct hsColorRGBA { diff --git a/Sources/Plasma/FeatureLib/pfCharacter/CMakeLists.txt b/Sources/Plasma/FeatureLib/pfCharacter/CMakeLists.txt index 3f6fd895..7b94bca7 100644 --- a/Sources/Plasma/FeatureLib/pfCharacter/CMakeLists.txt +++ b/Sources/Plasma/FeatureLib/pfCharacter/CMakeLists.txt @@ -7,14 +7,12 @@ include_directories(../../PubUtilLib) set(pfCharacter_SOURCES pfMarkerInfo.cpp pfMarkerMgr.cpp - plPlayerModifier.cpp ) set(pfCharacter_HEADERS pfCharacterCreatable.h pfMarkerInfo.h pfMarkerMgr.h - plPlayerModifier.h ) add_library(pfCharacter STATIC ${pfCharacter_SOURCES} ${pfCharacter_HEADERS}) diff --git a/Sources/Plasma/FeatureLib/pfCharacter/plPlayerModifier.cpp b/Sources/Plasma/FeatureLib/pfCharacter/plPlayerModifier.cpp deleted file mode 100644 index 1c26c315..00000000 --- a/Sources/Plasma/FeatureLib/pfCharacter/plPlayerModifier.cpp +++ /dev/null @@ -1,626 +0,0 @@ -/*==LICENSE==* - -CyanWorlds.com Engine - MMOG client, server and tools -Copyright (C) 2011 Cyan Worlds, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Additional permissions under GNU GPL version 3 section 7 - -If you modify this Program, or any covered work, by linking or -combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, -NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent -JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK -(or a modified version of those libraries), -containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, -PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG -JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the -licensors of this Program grant you additional -permission to convey the resulting work. Corresponding Source for a -non-source form of such a combination shall include the source code for -the parts of OpenSSL and IJG JPEG Library used as well as that of the covered -work. - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - -*==LICENSE==*/ -//#pragma warning(disable: 4503 4786) -//#define HK_HARDCORE -// -//#include // for havok Vector3 -////#include <.//gpi/math/quaternion.h> // for havok Vector3 -//#include // for havok Vertex -// -// -//#include "HeadSpin.h" -//#include "../plInterp/plController.h" -//#include "plPlayerModifier.h" -//#include "hsTimer.h" -//#include "../pnSceneObject/plSceneObject.h" -//#include "../pnSceneObject/plSimulationInterface.h" -//#include "../pnInputCore/plControlEventCodes.h" -//#include "../pnMessage/plTimeMsg.h" -//#include "../pnMessage/plWarpMsg.h" -//#include "../pnMessage/plCameraMsg.h" -//#include "../pnSceneObject/plCoordinateInterface.h" -//#include "plgDispatch.h" -//#include "../pfCamera/plCameraModifier.h" -//#include "hsResMgr.h" -//#include "../pnKeyedObject/plKey.h" -//#include "../plNetClient/plNetClientMgr.h" -//#include "../plModifier/plSpawnModifier.h" -//#include "../plMessage/plMatrixUpdateMsg.h" -// -//#include "../pnTimer/plTimerCallbackManager.h" -//#include "../plAudio/plAudioSystem.h" -//#include "../plMessage/plInputEventMsg.h" -//#include "../plMessage/plSpawnRequestMsg.h" -//#include "../plMessage/plSpawnModMsg.h" -//#include "../plMessage/plPlayerMsg.h" -//#include "../pnMessage/plAudioSysMsg.h" -//#include "../pfCamera/plCameraBrain.h" -// -//#include "../plHavok1/plHKPhysical.h" -// -//float plPlayerModifier::fTurnRate = 1.0f; -//float plPlayerModifier::fAcceleration = 80.0f; -//float plPlayerModifier::fDeceleration = 80.0f; -//float plPlayerModifier::fMaxVelocity = 200.0f; -// -//plPlayerModifier::plPlayerModifier() : -//bUseDesiredFacing(false), -//bUseDesiredMatrix(false) -//{ -// fCurSpeed = 0.0f; -// fLastTime = 0.0; -// bMoving = false; -// fRotationScalar = 1.0f; -// bIgnoreDesiredMatrix = false; -// SetFlag( kWantsToSpawn ); -//} -// -//plPlayerModifier::~plPlayerModifier() -//{ -// for (int i = 0; i < fSpawnPoints.Count(); i++) -// delete fSpawnPoints[i]; -// fSpawnPoints.SetCount(0); -//} -// -//// Adding RemoveTarget override of plSingleModifier to tell everyone we -//// told in AddTarget about our subject that he's gone now. -//void plPlayerModifier::RemoveTarget(plSceneObject* so) -//{ -// if( fTarget && fTarget->IsLocallyOwned()==plSynchedObject::kYes ) -// { -// plCameraMsg* pMsg = new plCameraMsg; -// pMsg->SetCmd(plCameraMsg::kSetSubject); -// pMsg->SetSubject(nil); -// pMsg->SetBCastFlag( plMessage::kBCastByExactType ); -// plgDispatch::MsgSend(pMsg); -// -// plAudioSysMsg* pAudMsg1 = new plAudioSysMsg(plAudioSysMsg::kSetListenerCoordinateRefCamera); -// plAudioSysMsg* pAudMsg2 = new plAudioSysMsg(plAudioSysMsg::kSetListenerVelocityRefCamera); -// plAudioSysMsg* pAudMsg3 = new plAudioSysMsg(plAudioSysMsg::kSetListenerFacingRefCamera); -// plgDispatch::MsgSend(pAudMsg1); -// plgDispatch::MsgSend(pAudMsg2); -// plgDispatch::MsgSend(pAudMsg3); -// } -// plSingleModifier::RemoveTarget(so); -//} -// -//void plPlayerModifier::AddTarget(plSceneObject* so) -//{ -// fTarget = so; -// plSimulationInterface * pSI = IGetTargetSimulationInterface(0); // so->GetSimulationInterface(); // -// -// plgDispatch::Dispatch()->RegisterForExactType(plEvalMsg::Index(), GetKey()); -// -// // set the desired rotation vector... -//// hsAssert(fTarget->GetCoordinateInterface(), "Player modifier target has no coordinate interface"); -// -// // These are now set in the component -//// if(pSI) -//// { -//// pSI->SetProperty(plSimulationInterface::kAffectLOS, false); -//// pSI->SetProperty(kUpright, true); -//// } -// -// // -// // setup for local player if necessary -// // -// int locallyOwned=so->IsLocallyOwned(); -// if (locallyOwned==plSynchedObject::kMaybe) // don't know since we're still loading, defer -// SetFlag(kNeedsLocalSetup); -// else if (locallyOwned==plSynchedObject::kYes) -// IDoLocalSetup(so); -//} -// -//void plPlayerModifier::IDoLocalSetup(plSceneObject* so) -//{ -// plCameraMsg* pMsg = new plCameraMsg; -// pMsg->SetCmd(plCameraMsg::kSetSubject); -// pMsg->SetSubject(so); -// pMsg->SetBCastFlag( plMessage::kBCastByExactType ); -// plgDispatch::MsgSend(pMsg); -// -// // this is to solve the problem of physical vs nonphysical players... -//// plCameraMsg* pMsg2 = new plCameraMsg; -//// pMsg2->SetBCastFlag(plMessage::kBCastByExactType); -//// pMsg2->SetCmd(plCameraMsg::kSetOffset); -//// pMsg2->SetCmd(plCameraMsg::kEntering); -//// pMsg2->SetTriggerer(so->GetKey()); -//// pMsg2->SetOffsetY(50); -//// pMsg2->SetOffsetZ(10); -//// plgDispatch::MsgSend(pMsg2); -//} -// -//void plPlayerModifier::IMakeUsListener( plSceneObject *so ) -//{ -// // set the listener to use us... -// plAudioSysMsg* pAudMsg1 = new plAudioSysMsg(plAudioSysMsg::kSetListenerFacingRef); -// pAudMsg1->SetSceneObject(so->GetKey()); -// plAudioSysMsg* pAudMsg2 = new plAudioSysMsg(plAudioSysMsg::kSetListenerCoordinateRef); -// pAudMsg2->SetSceneObject(so->GetKey()); -// plAudioSysMsg* pAudMsg3 = new plAudioSysMsg(plAudioSysMsg::kSetListenerVelocityRef); -// pAudMsg3->SetSceneObject(so->GetKey()); -// plgDispatch::MsgSend(pAudMsg1); -// plgDispatch::MsgSend(pAudMsg2); -// plgDispatch::MsgSend(pAudMsg3); -// -// // Now that we have a valid listener, unmute the audio system -// plgAudioSys::SetMuted( false ); -//} -// -//bool plPlayerModifier::MsgReceive(plMessage* msg) -//{ -// plControlEventMsg* pCommandMsg = plControlEventMsg::ConvertNoRef(msg); -// if (pCommandMsg) -// return(HandleControlInput(pCommandMsg)); -// -// plMatrixUpdateMsg* pMMsg = plMatrixUpdateMsg::ConvertNoRef( msg ); -// if (pMMsg && HasFlag(kHasSpawned)) -// { -// hsAssert(GetTarget()->IsLocallyOwned()==plSynchedObject::kNo, "master objects should not get correction msgs"); -// fDesiredMatrix = pMMsg->fMatrix; -// if (bIgnoreDesiredMatrix) -// bIgnoreDesiredMatrix = false; -// else -// { -// bUseDesiredMatrix = true; -// } -// return true; -// } -// -// plSpawnModMsg* pSpawn = plSpawnModMsg::ConvertNoRef(msg); -// if (pSpawn && HasFlag(kWantsToSpawn)) -// { -// spawnPt* pt = new spawnPt; -// pt->pt = pSpawn->fPos; -// -// hsVector3 temp(fTarget->GetCoordinateInterface()->GetLocalToWorld().GetTranslate() - pt->pt); -// pt->dist = temp.MagnitudeSquared(); -// fSpawnPoints.Append(pt); -// } -// plPlayerMsg* pPMsg = plPlayerMsg::ConvertNoRef(msg); -// if (pPMsg) -// { -// if (pPMsg->Cmd(plPlayerMsg::kWarpToSpawnPoint)) -// { -// WarpToSpawnPoint(); -// return true; -// } -// } -// return plSingleModifier::MsgReceive(msg); -//} -// -//bool plPlayerModifier::HandleControlInput(plControlEventMsg* pMsg) -//{ -// bool ret=false; -// -// if (pMsg->ControlActivated() && (pMsg->GetControlCode() == B_CONTROL_ROTATE_RIGHT || pMsg->GetControlCode() == B_CONTROL_ROTATE_LEFT || pMsg->GetControlCode() == A_CONTROL_TURN)) -// { -// fRotationScalar = pMsg->GetPct(); -// if ( HasMovementFlag( pMsg->GetControlCode() ) ) -// bIgnoreDesiredMatrix = true; -// } -// if (pMsg->ControlActivated() && !HasMovementFlag( pMsg->GetControlCode() ) ) -// { -// SetMovementFlag( pMsg->GetControlCode() ); -// if ( pMsg->GetControlCode() == B_CONTROL_TURN_TO ) -// { -// //fFacingTarget = pMsg->GetTurnToPt(); -// } -// } -// else -// if ( !pMsg->ControlActivated() && HasMovementFlag( pMsg->GetControlCode() ) ) -// { -// ClearMovementFlag( pMsg->GetControlCode() ); -// } -// -// ret = true; -// return ret; -//} -// -//void plPlayerModifier::SetMoving(bool b) -//{ -// if (b != bMoving) -// { -// plPlayerMsg* pMsg = new plPlayerMsg; -// -// if (b) -// pMsg->SetCmd( plPlayerMsg::kMovementStarted ); -// else -// pMsg->SetCmd( plPlayerMsg::kMovementStopped ); -// -// plgDispatch::MsgSend( pMsg ); -// bMoving = b; -// } -//} -// -// -//hsPoint3 forceForward(0,-200,0); -//hsPoint3 forceRight(-200,0,0); -//hsPoint3 forceUp(0,0,15); -// -//bool plPlayerModifier::IEval(double secs, float del, uint32_t dirty) -//{ -// // setup for local player if necessary -// if (HasFlag(kNeedsLocalSetup)) -// { -// int locallyOwned=fTarget->IsLocallyOwned(); -// if (locallyOwned==plSynchedObject::kYes) -// IDoLocalSetup(fTarget); -// else -// if (locallyOwned==plSynchedObject::kNo) -// ClearFlag(kNeedsLocalSetup); -// } -// -// if (HasFlag(kWantsToSpawn)) -// { -// if (fTarget->IsLocallyOwned()==plSynchedObject::kNo) -// { -// // if our target is a proxy player, don't warp him to a spawn point; -// // we will receive his location as a state update. -// ClearFlag(kWantsToSpawn); -// } -// else -// if (fSpawnPoints.Count() -// // if MP game, make sure we're connected before spawning -// && (!plNetClientMgr::GetInstance()->IsEnabled() || -// plNetClientMgr::GetInstance()->HasJoined()) -// ) -// { -// int i; -//#if 0 -// for (i = 0; i < fSpawnPoints.Count(); i++) -// { -// for (int j = i + 1; j < fSpawnPoints.Count(); j++) -// { -// if (fSpawnPoints[j]->dist < fSpawnPoints[i]->dist) -// { -// spawnPt* pt; -// pt = fSpawnPoints[j]; -// fSpawnPoints[j] = fSpawnPoints[i]; -// fSpawnPoints[i] = pt; -// } -// } -// } -// hsPoint3 warpPoint = fSpawnPoints[0]->pt; -//#else -// // choose spawnPoint based on netID, not distance -// int netID = plNetClientMgr::GetInstance()->GetClientNum(); -// if (netID==-1) -// netID=0; -// hsPoint3 warpPoint = netID>=fSpawnPoints.Count() ? -// fSpawnPoints[fSpawnPoints.Count()-1]->pt : fSpawnPoints[netID]->pt; -//#endif -// // Send msg for net synchronization -// plWarpMsg* warpMsg = new plWarpMsg; -// warpMsg->fPos = warpPoint; -// warpMsg->AddReceiver( fTarget->GetKey() ); -// warpMsg->SetWarpFlags(warpMsg->GetWarpFlags() | plWarpMsg::kFlushTransform | plWarpMsg::kZeroVelocity ); -// plgDispatch::MsgSend( warpMsg ); -//#ifdef HS_DEBUGGING -// char str[256]; -// sprintf(str, "%s has %d spawnPoints. Using pt %f %f %f\n", -// GetKeyName(), fSpawnPoints.GetCount(), -// fSpawnPoints[0]->pt.fX,fSpawnPoints[0]->pt.fY,fSpawnPoints[0]->pt.fZ); -// hsStatusMessage(str); -//#endif -// for (i = 0; i < fSpawnPoints.Count(); i++) -// delete fSpawnPoints[i]; -// -// fSpawnPoints.SetCount(0); -// ClearFlag(kWantsToSpawn); -// } -// else -// { -// plSpawnRequestMsg* pMsg = new plSpawnRequestMsg; -// pMsg->SetSender(GetKey()); -// plgDispatch::MsgSend( pMsg ); -// } -// bIgnoreDesiredMatrix = true; -// return true; -// } -// else -// { -// if( !HasFlag( kHasSpawned ) ) -// { -// // Don't make us listener until we have actually spawned -// IMakeUsListener( fTarget ); -// SetFlag(kHasSpawned); -// } -// } -// -// if (!fTarget->GetCoordinateInterface()) -// return true; -// -// // update our desired position: -//// float eTime = secs - fLastTime; -// float eTime = hsTimer::GetDelSysSeconds(); -// -// hsPoint3 newLinearForce(0,0,0); -// -// hsMatrix44 targetMatrix; -// if (bUseDesiredMatrix) -// targetMatrix = fDesiredMatrix; -// else -// targetMatrix = fTarget->GetCoordinateInterface()->GetLocalToWorld(); -// hsPoint3 playerPos = targetMatrix.GetTranslate(); -// hsVector3 view, up, right; -// targetMatrix.GetAxis(&view, &up, &right); -// -// float speed = fMaxVelocity; -// float turn = fTurnRate; -// -// if (HasMovementFlag(B_CONTROL_MODIFIER_FAST)) -// { -// turn *= 0.25; -// speed *= 3.5; -// } -// if (HasMovementFlag(B_CONTROL_MOVE_FORWARD)) -// { -// playerPos += view * speed * eTime; -// newLinearForce = newLinearForce + forceForward * speed * eTime; // calc force for physics -// } -// if (HasMovementFlag(B_CONTROL_MOVE_BACKWARD)) -// { -// playerPos += view * speed * eTime * -1; -// newLinearForce = newLinearForce + forceForward * speed * eTime * -1; // calc force for physics -// } -// if (HasMovementFlag(B_CONTROL_STRAFE_LEFT)) -// { -// playerPos += right * speed * eTime * -1; -// -// newLinearForce = newLinearForce + forceRight * speed * eTime * -1; -// } -// if (HasMovementFlag(B_CONTROL_STRAFE_RIGHT)) -// { -// playerPos += right * speed * eTime; -// -// newLinearForce = newLinearForce + forceRight * speed * eTime; -// } -// if (HasMovementFlag(B_CONTROL_MOVE_DOWN)) -// { -// playerPos += up * speed * eTime * -1; -// -// newLinearForce = newLinearForce + forceUp * speed * eTime * -1; -// } -// if (HasMovementFlag(B_CONTROL_MOVE_UP)) -// { -// playerPos += up * speed * eTime; -// -// newLinearForce = newLinearForce + forceUp * speed * eTime; -// } -// -// -// fDesiredPosition = playerPos; -// -// // move toward our desired position... -// -// hsPoint3 curPos = targetMatrix.GetTranslate(); -// hsPoint3 newPos; -// -// hsVector3 dir(fDesiredPosition - curPos); -// float distToGoal=dir.Magnitude(); -// -// if (dir.MagnitudeSquared() > 0.0f) -// dir.Normalize(); -// -// hsVector3 vel( view * fCurSpeed ); -// -// IAdjustVelocity(fAcceleration, fDeceleration, &dir, &vel, fMaxVelocity, distToGoal, eTime); -// fCurSpeed = vel.Magnitude(); -// -// float distMoved = IClampVelocity(&vel, fMaxVelocity, eTime); -// -// // compute final pos -// if (distMoved > distToGoal) -// newPos = fDesiredPosition; -// else -// newPos = curPos + vel; -// -// // calculate rotation matrix -// -// hsVector3 rotUp(0,0,1); -// hsVector3 rotRight(1,0,0); -// hsMatrix44 rot; -// -// if ( HasMovementFlag( B_CONTROL_TURN_TO ) ) -// { -// // compute view goal -// -// hsVector3 fPlayerViewGoal(&fFacingTarget,&curPos); -// fPlayerViewGoal.fZ = 0; -// fPlayerViewGoal.Normalize(); -// -// // compute degrees needed to turn left/right -// hsVector3 cross = fPlayerViewGoal % view; -// float dot = fPlayerViewGoal * view; -// float rad = acos(dot); -// fRotationScalar = 1.0f; -// -// if (cross.fZ<0) -// { -// SetMovementFlag( B_CONTROL_ROTATE_LEFT ); -// } -// else -// { -// SetMovementFlag( B_CONTROL_ROTATE_RIGHT ); -// } -// if (dot >= 0.999f) -// { -// ClearMovementFlag( B_CONTROL_TURN_TO ); -// ClearMovementFlag( B_CONTROL_ROTATE_RIGHT ); -// ClearMovementFlag( B_CONTROL_ROTATE_LEFT ); -// } -// } -// -// float angle = 0; -// -// if ( HasMovementFlag( B_CONTROL_ROTATE_RIGHT ) ) -// { -// angle = fTurnRate * eTime * -1 * fRotationScalar; -// } -// -// if ( HasMovementFlag( B_CONTROL_ROTATE_LEFT ) || HasMovementFlag( A_CONTROL_TURN ) ) -// { -// angle = fTurnRate * eTime * fRotationScalar; -// } -// -// hsMatrix44 justRot(targetMatrix); -// hsPoint3 zero(0,0,0); -// justRot.SetTranslate(&zero); -// -// if(angle) { -// hsQuat q(angle, &rotUp); -// q.NormalizeIfNeeded(); -// q.MakeMatrix(&rot); -// -// justRot = rot * justRot; -// -// targetMatrix = rot * targetMatrix; -// } -// -// // use the desired rotation matrix to set position and rotation: -// -// -// plSimulationInterface * SI = IGetTargetSimulationInterface(0); -// -// if(SI) -// { -// Havok::Vector3 hkLocalForce(newLinearForce.fX, newLinearForce.fY, newLinearForce.fZ); -// if (bUseDesiredMatrix) -// { -// hsMatrix44 inv; -// -// fDesiredMatrix.GetInverse(&inv); -// -// // we're just going to set the position on the simulation interface directly -// // because it will then be further modified by the simulation and its final position -// // will *then* be sent to the coordinate interface -// SI->SetTransform(fDesiredMatrix, inv); -// } -// -// SI->SetRotation(justRot);//rot); -// SI->ApplyForce(plSimulationInterface::kForce, hkLocalForce); -// } else { -// hsMatrix44 inv; -// targetMatrix.SetTranslate(&newPos); -// targetMatrix.GetInverse(&inv); -// -// plCoordinateInterface* pCI = pCI = IGetTargetCoordinateInterface(0); -// pCI->SetTransform(targetMatrix, inv); -// -// -// } -// -// fLastTime = secs; -// SetMoving(fCurSpeed); -// -// if (bUseDesiredMatrix) -// bUseDesiredMatrix = false; -// return true; -//} -// -//// -//// vector version. dir vector should be normalized -//// -//void plPlayerModifier::IAdjustVelocity(float adjAccelRate, float adjDecelRate, -// hsVector3* dir, hsVector3* vel, float maxSpeed, -// float distToGoal, double elapsedTime) -//{ -// float speed = vel->Magnitude(); // save current speed -// *vel = *dir * speed; // change vel to correct dir -// -// // compute accel/decel -// float finalAccelRate; -// if (IShouldDecelerate(adjDecelRate, speed, distToGoal)) -// { -// finalAccelRate = -adjDecelRate; -// } -// else -// { -// finalAccelRate = adjAccelRate; -// } -// -// if (finalAccelRate != 0) -// { -// // compute accel vector in the direction of the goal -// hsVector3 accelVec = *dir * finalAccelRate; -// accelVec = accelVec * elapsedTime; -// -// // add acceleration to velocity -// *vel = *vel + accelVec; -// } -// else -// { -// *vel = *dir * maxSpeed; -// } -//} -// -//float plPlayerModifier::IClampVelocity(hsVector3* vel, float maxSpeed, double elapsedTime) -//{ -// *vel = *vel * elapsedTime; -// maxSpeed *= elapsedTime; -// -// // clamp speed (clamp if going negative?) -// float distMoved = vel->Magnitude(); -// if (distMoved > maxSpeed) -// { -// vel->Normalize(); -// *vel = *vel * maxSpeed; -// return maxSpeed; -// } -// return distMoved; -//} -// -//bool32 plPlayerModifier::IShouldDecelerate(float decelSpeed, float curSpeed, float distToGoal) -//{ -// if (decelSpeed == 0) -// // no deceleration -// return false; -// -// // compute distance required to stop, given decel speed (in units/sec sq) -// float stopTime = curSpeed / decelSpeed; -// float avgSpeed = curSpeed * .5f; -// float stopDist = avgSpeed * stopTime; -// -// return (hsABS(distToGoal) <= hsABS(stopDist)); // stopDist+avgSpeed? -//} -// diff --git a/Sources/Plasma/FeatureLib/pfCharacter/plPlayerModifier.h b/Sources/Plasma/FeatureLib/pfCharacter/plPlayerModifier.h deleted file mode 100644 index 92d4c694..00000000 --- a/Sources/Plasma/FeatureLib/pfCharacter/plPlayerModifier.h +++ /dev/null @@ -1,149 +0,0 @@ -/*==LICENSE==* - -CyanWorlds.com Engine - MMOG client, server and tools -Copyright (C) 2011 Cyan Worlds, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Additional permissions under GNU GPL version 3 section 7 - -If you modify this Program, or any covered work, by linking or -combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, -NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent -JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK -(or a modified version of those libraries), -containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, -PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG -JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the -licensors of this Program grant you additional -permission to convey the resulting work. Corresponding Source for a -non-source form of such a combination shall include the source code for -the parts of OpenSSL and IJG JPEG Library used as well as that of the covered -work. - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - -*==LICENSE==*/ -// -//#ifndef plPlayerModifier_inc -//#define plPlayerModifier_inc -// -//#include "../pnModifier/plSingleModifier.h" -//#include "../pnSceneObject/plSimulationInterface.h" -//#include "hsMatrix44.h" -// -//class plControlEventMsg; -// -//namespace Havok { -// class Vector3; -//} -// -//class plPlayerModifier : public plSingleModifier -//{ -//protected: -// -// enum -// { -// kWantsToSpawn = 0, -// kTimerSet, -// kHasSpawned, -// kNeedsLocalSetup -// }; -// -// struct spawnPt -// { -// hsPoint3 pt; -// float dist; -// }; -// -// static float fTurnRate; -// -// static float fAcceleration; -// static float fDeceleration; -// static float fMaxVelocity; -// float fCurSpeed; -// -// -// double fLastTime; -// hsMatrix44 fDesiredMatrix; -// -// hsPoint3 fDesiredPosition; -// hsPoint3 fFacingTarget; -// bool bUseDesiredFacing; -// bool bUseDesiredMatrix; -// bool bIgnoreDesiredMatrix; -// -// float fRotationScalar; -// hsTArray fSpawnPoints; -// -// void IAdjustVelocity(float adjAccelRate, -// float adjDecelRate, -// hsVector3* dir, -// hsVector3* vel, -// float maxSpeed, -// float distToGoal, -// double elapsedTime); -// -// float IClampVelocity(hsVector3* vel, float maxSpeed, double elapsedTime); -// bool32 IShouldDecelerate(float decelSpeed, float curSpeed, float distToGoal); -// -// bool HasMovementFlag(int f) const { return fMoveFlags.IsBitSet(f); } -// void SetMovementFlag(int f) { fMoveFlags.SetBit(f); } -// void ClearMovementFlag(int which) { fMoveFlags.ClearBit( which ); } -// -// hsBitVector fMoveFlags; -// hsBitVector fFlags; -// -// void WarpToSpawnPoint() { SetFlag( kWantsToSpawn ); } -// -// bool bMoving; -// -// void IApplyForce(plSimulationInterface::plSimpleForce type, const Havok::Vector3 &vec); -// void IDoLocalSetup(plSceneObject*); -// void IMakeUsListener( plSceneObject *so ); -// -//public: -// plPlayerModifier(); -// virtual ~plPlayerModifier(); -// -// CLASSNAME_REGISTER( plPlayerModifier ); -// GETINTERFACE_ANY( plPlayerModifier, plSingleModifier ); -// -// virtual bool MsgReceive(plMessage* msg); -// virtual void AddTarget(plSceneObject* so); -// virtual void RemoveTarget(plSceneObject* so); -// -// bool HandleControlInput(plControlEventMsg* pMsg); -// virtual bool IEval(double secs, float del, uint32_t dirty); -// -// void SetMoving(bool b); -// bool IsMoving() { return bMoving; } -// -// bool HasFlag(int f) const { return fFlags.IsBitSet(f); } -// void SetFlag(int f) { fFlags.SetBit(f); } -// void ClearFlag(int which) { fFlags.ClearBit( which ); } -// -// static void SetTurnRate(float f) {fTurnRate = f;} -// static void SetAcceleration(float f) {fAcceleration = f;} -// static void SetDeceleration(float f) {fDeceleration = f;} -// static void SetVelocity(float f) {fMaxVelocity = f;} -// -// -//}; -// -//#endif plPlayerModifier_inc diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp index c59f127b..985fdcba 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp @@ -72,7 +72,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnModifier/plLogicModBase.h" #include "plModifier/plSDLModifier.h" #include "plSDL/plSDL.h" -#include "pfCharacter/plPlayerModifier.h" #include "plSurface/plLayerDepth.h" #include "plSurface/plLayerOr.h" #include "plSurface/plLayerOr.h" diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp index 99784a84..7f9ec74d 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp @@ -64,7 +64,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnKeyedObject/plKey.h" #include "pnKeyedObject/plKeyImp.h" #include "pnModifier/plLogicModBase.h" -#include "pfCharacter/plPlayerModifier.h" #include "hsTimer.h" #include "pnMessage/plClientMsg.h" #include "pnMessage/plEnableMsg.h" diff --git a/Sources/Tools/MaxMain/plMaxNode.cpp b/Sources/Tools/MaxMain/plMaxNode.cpp index 97b6d400..f3a0bb51 100644 --- a/Sources/Tools/MaxMain/plMaxNode.cpp +++ b/Sources/Tools/MaxMain/plMaxNode.cpp @@ -91,7 +91,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plModifier/plResponderModifier.h" #include "plModifier/plInterfaceInfoModifier.h" #include "pfAnimation/plLightModifier.h" -#include "pfCharacter/plPlayerModifier.h" #include "plAvatar/plAGModifier.h" #include "plAvatar/plAGAnim.h" #include "plAvatar/plPointChannel.h" From 094b0fe557ba8cbbeddb7dad1cf48ff01dc46116 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Sat, 26 Jul 2014 12:04:01 -0700 Subject: [PATCH 8/9] Move header out of HeadSpin.h --- Sources/Plasma/Apps/plFileSecure/main.cpp | 1 + Sources/Plasma/CoreLib/HeadSpin.h | 1 - Sources/Plasma/CoreLib/hsBounds.h | 1 + Sources/Plasma/CoreLib/hsStream.cpp | 1 + Sources/Plasma/NucleusLib/inc/plProfileManager.cpp | 2 +- Sources/Plasma/NucleusLib/pnEncryption/plChallengeHash.cpp | 2 ++ Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp | 1 + Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp | 1 + Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp | 1 + Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp | 1 + Sources/Plasma/PubUtilLib/plInterp/plAnimPath.cpp | 1 + Sources/Plasma/PubUtilLib/plInterp/plController.cpp | 2 ++ Sources/Plasma/PubUtilLib/plMath/plAvg.cpp | 1 + Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp | 2 ++ Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp | 2 ++ Sources/Plasma/PubUtilLib/plPipeline/plStatusLogDrawer.cpp | 2 ++ Sources/Tools/MaxMain/plPhysXCooking.cpp | 2 ++ 17 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Sources/Plasma/Apps/plFileSecure/main.cpp b/Sources/Plasma/Apps/plFileSecure/main.cpp index e3fecce6..a186110b 100644 --- a/Sources/Plasma/Apps/plFileSecure/main.cpp +++ b/Sources/Plasma/Apps/plFileSecure/main.cpp @@ -45,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include +#include void print_version() { puts(plProduct::ProductString().c_str()); diff --git a/Sources/Plasma/CoreLib/HeadSpin.h b/Sources/Plasma/CoreLib/HeadSpin.h index c2875a8f..69c6d7f7 100644 --- a/Sources/Plasma/CoreLib/HeadSpin.h +++ b/Sources/Plasma/CoreLib/HeadSpin.h @@ -59,7 +59,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include #include -#include //====================================== // Winblows Hacks diff --git a/Sources/Plasma/CoreLib/hsBounds.h b/Sources/Plasma/CoreLib/hsBounds.h index 3fc56837..f5b368c8 100644 --- a/Sources/Plasma/CoreLib/hsBounds.h +++ b/Sources/Plasma/CoreLib/hsBounds.h @@ -46,6 +46,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "hsGeometry3.h" #include "hsPoint2.h" #include "hsMatrix44.h" +#include /////////////////////////////////////////////////////////////////////////////// // BOUNDS diff --git a/Sources/Plasma/CoreLib/hsStream.cpp b/Sources/Plasma/CoreLib/hsStream.cpp index 72f4f65f..33656ee4 100644 --- a/Sources/Plasma/CoreLib/hsStream.cpp +++ b/Sources/Plasma/CoreLib/hsStream.cpp @@ -44,6 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #if HS_BUILD_FOR_WIN32 # include #endif +#include #pragma hdrstop #include "hsStream.h" diff --git a/Sources/Plasma/NucleusLib/inc/plProfileManager.cpp b/Sources/Plasma/NucleusLib/inc/plProfileManager.cpp index d8a380bd..b9bc668e 100644 --- a/Sources/Plasma/NucleusLib/inc/plProfileManager.cpp +++ b/Sources/Plasma/NucleusLib/inc/plProfileManager.cpp @@ -42,7 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plProfileManager.h" #include "plProfile.h" #include "hsTimer.h" - +#include plProfileManager::plProfileManager() : fLastAvgTime(0), fProcessorSpeed(0) { diff --git a/Sources/Plasma/NucleusLib/pnEncryption/plChallengeHash.cpp b/Sources/Plasma/NucleusLib/pnEncryption/plChallengeHash.cpp index 300f7bcd..c7dd3d3a 100644 --- a/Sources/Plasma/NucleusLib/pnEncryption/plChallengeHash.cpp +++ b/Sources/Plasma/NucleusLib/pnEncryption/plChallengeHash.cpp @@ -42,6 +42,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plChallengeHash.h" +#include + ShaDigest fSeed; void CryptCreateRandomSeed(size_t length, uint8_t* data) diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp index 63594843..82d19d30 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp @@ -40,6 +40,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com *==LICENSE==*/ #include +#include #include "plAvBehaviors.h" #include "plAvBrainHuman.h" diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp index b6c5451a..4ec91a85 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp @@ -40,6 +40,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com *==LICENSE==*/ #include +#include #include "plPhysicalControllerCore.h" diff --git a/Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp b/Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp index e6b96279..b3ba4a99 100644 --- a/Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp +++ b/Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp @@ -45,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include +#include static const uint32_t kDefaultKey[4] = { 0x6c0a5452, 0x3827d0f, 0x3a170b92, 0x16db7fc2 }; static const int kEncryptChunkSize = 8; diff --git a/Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp b/Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp index 5cdf684c..10c6a442 100644 --- a/Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp +++ b/Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp @@ -61,6 +61,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plProfile.h" #include "plJPEG.h" #include +#include plProfile_CreateMemCounter("Mipmaps", "Memory", MemMipmaps); diff --git a/Sources/Plasma/PubUtilLib/plInterp/plAnimPath.cpp b/Sources/Plasma/PubUtilLib/plInterp/plAnimPath.cpp index e25ba89c..bee6ebdd 100644 --- a/Sources/Plasma/PubUtilLib/plInterp/plAnimPath.cpp +++ b/Sources/Plasma/PubUtilLib/plInterp/plAnimPath.cpp @@ -46,6 +46,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "hsFastMath.h" #include "hsResMgr.h" #include +#include const float kSmallDelTime = 1.e-2f; const float kInvSmallDelTime = 1.f / kSmallDelTime; diff --git a/Sources/Plasma/PubUtilLib/plInterp/plController.cpp b/Sources/Plasma/PubUtilLib/plInterp/plController.cpp index 79baf8a9..9b0a5f06 100644 --- a/Sources/Plasma/PubUtilLib/plInterp/plController.cpp +++ b/Sources/Plasma/PubUtilLib/plInterp/plController.cpp @@ -46,6 +46,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plTransform/hsEuler.h" #include "plAnimTimeConvert.h" +#include + ///////////////////////////////////////////// // Controller interp caching ///////////////////////////////////////////// diff --git a/Sources/Plasma/PubUtilLib/plMath/plAvg.cpp b/Sources/Plasma/PubUtilLib/plMath/plAvg.cpp index 9e7be7cf..579a5812 100644 --- a/Sources/Plasma/PubUtilLib/plMath/plAvg.cpp +++ b/Sources/Plasma/PubUtilLib/plMath/plAvg.cpp @@ -43,6 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "HeadSpin.h" #include "plAvg.h" #include +#include template class TimeBasedAvgRing; template class TimeBasedAvgRing; diff --git a/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp b/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp index 78a662ab..edc969ed 100644 --- a/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp +++ b/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp @@ -53,6 +53,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plParticleSystem.h" #include "plMessage/plParticleUpdateMsg.h" +#include + /////////////////////////////////////////////////////////////////////////////////////////// plParticleCollisionEffect::plParticleCollisionEffect() { diff --git a/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp b/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp index 23531fb0..1f49610e 100644 --- a/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp @@ -43,6 +43,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include +#include + #include "plgDispatch.h" #include "hsTimer.h" #include "plProfile.h" diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plStatusLogDrawer.cpp b/Sources/Plasma/PubUtilLib/plPipeline/plStatusLogDrawer.cpp index 72ab227c..1d2e5585 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plStatusLogDrawer.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/plStatusLogDrawer.cpp @@ -51,6 +51,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plDebugText.h" #include "plStatusLog/plStatusLog.h" +#include + //// Draw //////////////////////////////////////////////////////////////////// void plStatusLogDrawer::IDrawLogNames(plStatusLog* curLog, plStatusLog* firstLog) diff --git a/Sources/Tools/MaxMain/plPhysXCooking.cpp b/Sources/Tools/MaxMain/plPhysXCooking.cpp index 62990dc8..58a45b83 100644 --- a/Sources/Tools/MaxMain/plPhysXCooking.cpp +++ b/Sources/Tools/MaxMain/plPhysXCooking.cpp @@ -54,6 +54,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include +#include + #include "plMaxMeshExtractor.h" #include "plPhysXCooking.h" From 085c00706cc63b7ded8f6c6cd16f79a91fd9480e Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Sat, 9 Aug 2014 12:44:57 -0700 Subject: [PATCH 9/9] Some fixes for Clang --- Sources/Plasma/CoreLib/hsTemplates.h | 1 + Sources/Plasma/NucleusLib/pnUtils/pnUtArray.h | 8 ++++---- Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Sources/Plasma/CoreLib/hsTemplates.h b/Sources/Plasma/CoreLib/hsTemplates.h index f5f0ffe4..7d975eea 100644 --- a/Sources/Plasma/CoreLib/hsTemplates.h +++ b/Sources/Plasma/CoreLib/hsTemplates.h @@ -47,6 +47,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "hsRefCnt.h" #include +#include #ifdef HS_DEBUGGING diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtArray.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtArray.h index 0d4537b4..6d7fea92 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtArray.h +++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtArray.h @@ -740,25 +740,25 @@ public: //=========================================================================== template TArray::TArray () : TFArray() { - m_chunkSize = std::max(1u, 256 / sizeof(T)); + m_chunkSize = std::max(size_t(1), 256 / sizeof(T)); } //=========================================================================== template TArray::TArray (const char file[], int line) : TFArray(file, line) { - m_chunkSize = std::max(1u, 256 / sizeof(T)); + m_chunkSize = std::max(size_t(1), 256 / sizeof(T)); } //=========================================================================== template TArray::TArray (unsigned count) : TFArray(count) { - m_chunkSize = std::max(1u, 256 / sizeof(T)); + m_chunkSize = std::max(size_t(1), 256 / sizeof(T)); } //=========================================================================== template TArray::TArray (const T * source, unsigned count) : TFArray(source, count) { - m_chunkSize = std::max(1u, 256 / sizeof(T)); + m_chunkSize = std::max(size_t(1), 256 / sizeof(T)); } //=========================================================================== diff --git a/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp b/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp index b3dc5622..3aa975c4 100644 --- a/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp +++ b/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp @@ -721,7 +721,7 @@ bool plSecureStream::GetSecureEncryptionKey(const plFileName& filename, uint32_t } // file doesn't exist, use default key - unsigned memSize = std::min(length, arrsize(plSecureStream::kDefaultKey)); + unsigned memSize = std::min(size_t(length), arrsize(plSecureStream::kDefaultKey)); memSize *= sizeof(uint32_t); memcpy(key, plSecureStream::kDefaultKey, memSize);