Browse Source

Merge pull request #441 from zrax/headspin_cleanup

HeadSpin.h cleanup
Darryl Pogue 10 years ago
parent
commit
ba1d7c3ae1
  1. 3
      Sources/Plasma/Apps/plFileSecure/main.cpp
  2. 126
      Sources/Plasma/CoreLib/HeadSpin.h
  3. 4
      Sources/Plasma/CoreLib/hsBounds.cpp
  4. 5
      Sources/Plasma/CoreLib/hsBounds.h
  5. 1
      Sources/Plasma/CoreLib/hsColorRGBA.h
  6. 2
      Sources/Plasma/CoreLib/hsQuat.cpp
  7. 15
      Sources/Plasma/CoreLib/hsStream.cpp
  8. 3
      Sources/Plasma/CoreLib/hsTemplates.h
  9. 8
      Sources/Plasma/CoreLib/hsWindows.h
  10. 8
      Sources/Plasma/CoreLib/plViewTransform.cpp
  11. 10
      Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.cpp
  12. 2
      Sources/Plasma/FeatureLib/pfCamera/plCameraModifier.cpp
  13. 2
      Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp
  14. 2
      Sources/Plasma/FeatureLib/pfCharacter/CMakeLists.txt
  15. 626
      Sources/Plasma/FeatureLib/pfCharacter/plPlayerModifier.cpp
  16. 149
      Sources/Plasma/FeatureLib/pfCharacter/plPlayerModifier.h
  17. 1
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp
  18. 1
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp
  19. 2
      Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp
  20. 29
      Sources/Plasma/FeatureLib/pfSurface/plLayerAVI.cpp
  21. 2
      Sources/Plasma/NucleusLib/inc/plProfile.h
  22. 4
      Sources/Plasma/NucleusLib/inc/plProfileManager.cpp
  23. 8
      Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp
  24. 6
      Sources/Plasma/NucleusLib/pnEncryption/plChallengeHash.cpp
  25. 4
      Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp
  26. 8
      Sources/Plasma/NucleusLib/pnNetCli/pnNcCli.cpp
  27. 2
      Sources/Plasma/NucleusLib/pnNetCommon/plSynchedObject.cpp
  28. 2
      Sources/Plasma/NucleusLib/pnNetCommon/plSynchedValue.h
  29. 4
      Sources/Plasma/NucleusLib/pnUtils/pnUtArray.cpp
  30. 16
      Sources/Plasma/NucleusLib/pnUtils/pnUtArray.h
  31. 4
      Sources/Plasma/NucleusLib/pnUtils/pnUtCmd.cpp
  32. 4
      Sources/Plasma/NucleusLib/pnUtils/pnUtHash.h
  33. 6
      Sources/Plasma/NucleusLib/pnUtils/pnUtSort.h
  34. 4
      Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp
  35. 3
      Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp
  36. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp
  37. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp
  38. 15
      Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp
  39. 2
      Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgr.cpp
  40. 2
      Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgrVS.cpp
  41. 2
      Sources/Plasma/PubUtilLib/plDrawable/plSpaceTreeMaker.cpp
  42. 3
      Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp
  43. 6
      Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp
  44. 5
      Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp
  45. 2
      Sources/Plasma/PubUtilLib/plGLight/plLightInfo.cpp
  46. 2
      Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp
  47. 16
      Sources/Plasma/PubUtilLib/plInputCore/plAvatarInputInterface.cpp
  48. 16
      Sources/Plasma/PubUtilLib/plInputCore/plDebugInputInterface.cpp
  49. 3
      Sources/Plasma/PubUtilLib/plInputCore/plInputInterfaceMgr.cpp
  50. 2
      Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp
  51. 40
      Sources/Plasma/PubUtilLib/plInterp/hsKeys.cpp
  52. 3
      Sources/Plasma/PubUtilLib/plInterp/plAnimPath.cpp
  53. 4
      Sources/Plasma/PubUtilLib/plInterp/plController.cpp
  54. 3
      Sources/Plasma/PubUtilLib/plMath/plAvg.cpp
  55. 4
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrShow.cpp
  56. 6
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp
  57. 6
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp
  58. 2
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp
  59. 4
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp
  60. 16
      Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp
  61. 2
      Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEmitter.cpp
  62. 4
      Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp
  63. 2
      Sources/Plasma/PubUtilLib/plPipeline/DX/plDXPipeline.cpp
  64. 3
      Sources/Plasma/PubUtilLib/plPipeline/DX/plDXShader.cpp
  65. 4
      Sources/Plasma/PubUtilLib/plPipeline/plStatusLogDrawer.cpp
  66. 17
      Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp
  67. 2
      Sources/Plasma/PubUtilLib/plSockets/plBufferedSocketWriter.cpp
  68. 10
      Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp
  69. 8
      Sources/Tools/MaxConvert/plDistributor.cpp
  70. 4
      Sources/Tools/MaxExport/plExportLogErrorMsg.cpp
  71. 12
      Sources/Tools/MaxMain/plMaxMeshExtractor.cpp
  72. 27
      Sources/Tools/MaxMain/plMaxNode.cpp
  73. 26
      Sources/Tools/MaxMain/plPhysXCooking.cpp
  74. 2
      Sources/Tools/MaxPlasmaLights/plRealTimeLights.cpp

3
Sources/Plasma/Apps/plFileSecure/main.cpp

@ -45,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <ctime>
#include <string>
#include <algorithm>
void print_version() {
puts(plProduct::ProductString().c_str());
@ -75,7 +76,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);
}

126
Sources/Plasma/CoreLib/HeadSpin.h

@ -94,12 +94,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
@ -108,9 +102,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)
@ -123,24 +114,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 hsSucceeded(r) ((hsError)(r)>=hsOK)
#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 ))
#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)
@ -178,15 +157,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
@ -213,27 +202,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
//===========================================================================
@ -243,66 +211,6 @@ inline void hsSwap(float& a, float& b)
# define NULL_STMT ((void)0)
#endif
//===========================================================================
template<class T>
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<class T>
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
* Swaps the values of two variables
*
***/
//===========================================================================
template<class T>
void SWAP (T & a, T & b) {
T temp = a;
a = b;
b = temp;
}
/****************************************************************************
*
@ -448,8 +356,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[]);

4
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;

5
Sources/Plasma/CoreLib/hsBounds.h

@ -42,10 +42,11 @@ 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"
#include <algorithm>
///////////////////////////////////////////////////////////////////////////////
// BOUNDS
@ -186,7 +187,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 });
}
//

1
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 {

2
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);
}

15
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 <io.h>
#endif
#include <algorithm>
#pragma hdrstop
#include "hsStream.h"
@ -1054,7 +1055,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 +1064,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<int32_t>(byteCount)-length);
HSMemory::BlockMove(fQueue,static_cast<char*>(buffer)+total,length);
fReadCursor = length;
total += length;
@ -1079,7 +1080,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 +1088,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 +1107,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<int32_t>(deltaByteCount)-length);
fReadCursor = length;
}
else
{
fReadCursor %= fSize;
}
}
}
void hsQueueStream::Rewind()

3
Sources/Plasma/CoreLib/hsTemplates.h

@ -47,6 +47,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsRefCnt.h"
#include <cstdarg>
#include <algorithm>
#ifdef HS_DEBUGGING
@ -238,7 +239,7 @@ void hsDynamicArray<T>::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];

8
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 <algorithm>
using std::min;
using std::max;
# endif
# define WIN32_LEAN_AND_MEAN

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

10
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

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

2
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;

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

626
Sources/Plasma/FeatureLib/pfCharacter/plPlayerModifier.cpp

@ -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 <http://www.gnu.org/licenses/>.
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 <hkmath/vector3.h> // for havok Vector3
////#include <.//gpi/math/quaternion.h> // for havok Vector3
//#include <hkgeometry/geomdef.h> // 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?
//}
//

149
Sources/Plasma/FeatureLib/pfCharacter/plPlayerModifier.h

@ -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 <http://www.gnu.org/licenses/>.
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<spawnPt*> 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

1
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"

1
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"

2
Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp

@ -133,7 +133,7 @@ void plDispatchLog::DumpMsg(plMessage* msg, int numReceivers, int sendTimeMs, in
float sendTime = hsTimer::GetMilliSeconds<float>(hsTimer::GetTicks() - fStartTicks);
char indentStr[50];
indent = hsMinimum(indent, sizeof(indentStr)-1);
indent = std::min(indent, static_cast<int32_t>(sizeof(indentStr)-1));
memset(indentStr, ' ', indent);
indentStr[indent] = '\0';

29
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++;

2
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;

4
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 <algorithm>
plProfileManager::plProfileManager() : fLastAvgTime(0), fProcessorSpeed(0)
{
@ -161,7 +161,7 @@ void plProfileBase::EndFrame()
{
fAvgCount++;
fAvgTotal += fValue;
fMax = hsMaximum(fMax, fValue);
fMax = std::max(fMax, fValue);
}
void plProfileBase::UpdateAvg()

8
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);
}

6
Sources/Plasma/NucleusLib/pnEncryption/plChallengeHash.cpp

@ -42,14 +42,16 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plChallengeHash.h"
#include <algorithm>
ShaDigest fSeed;
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++) {

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

8
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);
}

2
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");

2
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;

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

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

@ -740,25 +740,25 @@ public:
//===========================================================================
template<class T, class C>
TArray<T,C>::TArray () : TFArray<T,C>() {
m_chunkSize = max(1, 256 / sizeof(T));
m_chunkSize = std::max(size_t(1), 256 / sizeof(T));
}
//===========================================================================
template<class T, class C>
TArray<T,C>::TArray (const char file[], int line) : TFArray<T,C>(file, line) {
m_chunkSize = max(1, 256 / sizeof(T));
m_chunkSize = std::max(size_t(1), 256 / sizeof(T));
}
//===========================================================================
template<class T, class C>
TArray<T,C>::TArray (unsigned count) : TFArray<T,C>(count) {
m_chunkSize = max(1, 256 / sizeof(T));
m_chunkSize = std::max(size_t(1), 256 / sizeof(T));
}
//===========================================================================
template<class T, class C>
TArray<T,C>::TArray (const T * source, unsigned count) : TFArray<T,C>(source, count) {
m_chunkSize = max(1, 256 / sizeof(T));
m_chunkSize = std::max(size_t(1), 256 / sizeof(T));
}
//===========================================================================
@ -890,8 +890,8 @@ void TArray<T,C>::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<T,C>::Pop () {
//===========================================================================
template<class T, class C>
void TArray<T,C>::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<T,C>::SetChunkSize (unsigned chunkSize) {
//===========================================================================
template<class T, class C>
void TArray<T,C>::SetCount (unsigned count) {
AdjustSizeChunked(max(this->m_alloc, count), count);
AdjustSizeChunked(std::max(this->m_alloc, count), count);
}
//===========================================================================

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

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

@ -432,7 +432,7 @@ void TBaseHashTable<T>::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<unsigned>(kSlotMinCount), v));
}
}
@ -459,7 +459,7 @@ void TBaseHashTable<T>::SetSlotCount (unsigned count) {
template<class T>
void TBaseHashTable<T>::SetSlotMaxCount (unsigned count) {
if (count)
m_slotMaxCount = max(kSlotMinCount, count);
m_slotMaxCount = std::max(static_cast<unsigned>(kSlotMinCount), count);
}
//===========================================================================

6
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 */ \

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

3
Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp

@ -40,6 +40,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include <cmath>
#include <algorithm>
#include "plAvBehaviors.h"
#include "plAvBrainHuman.h"
@ -106,7 +107,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<int>(10 * strength), 10);
blendBar[bars] = '\0';
plString details;

2
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
}

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

15
Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp

@ -40,6 +40,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include <cmath>
#include <algorithm>
#include "plPhysicalControllerCore.h"
@ -284,7 +285,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,13 +397,13 @@ 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.
float prevZVel = achievedVelocity.fZ;
if (IsOnGround())
prevZVel = hsMinimum(prevZVel, 0.0f);
prevZVel = std::min(prevZVel, 0.0f);
velocity.fZ = prevZVel + (kGravity * delSecs);
}
@ -577,7 +578,7 @@ bool plWalkingStrategy::EnableControlledFlight(bool status)
++fControlledFlight;
}
else
fControlledFlight = max(--fControlledFlight, 0);
fControlledFlight = std::max(--fControlledFlight, 0);
return status;
}
@ -625,7 +626,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,13 +711,13 @@ 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.
float prevZVel = achievedVelocity.fZ;
if (IsOnGround())
prevZVel = hsMinimum(prevZVel, 0.f);
prevZVel = std::min(prevZVel, 0.f);
velocity.fZ = prevZVel + (kGravity * delSecs);
}

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

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

2
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;
}

3
Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp

@ -45,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <ctime>
#include <wchar.h>
#include <algorithm>
static const uint32_t kDefaultKey[4] = { 0x6c0a5452, 0x3827d0f, 0x3a170b92, 0x16db7fc2 };
static const int kEncryptChunkSize = 8;
@ -301,7 +302,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);

6
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);
@ -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(size_t(length), arrsize(plSecureStream::kDefaultKey));
memSize *= sizeof(uint32_t);
memcpy(key, plSecureStream::kDefaultKey, memSize);

5
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 <cmath>
#include <algorithm>
plProfile_CreateMemCounter("Mipmaps", "Memory", MemMipmaps);
@ -994,9 +995,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;
}

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

2
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;

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

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

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

2
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;

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

3
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 <cmath>
#include <algorithm>
const float kSmallDelTime = 1.e-2f;
const float kInvSmallDelTime = 1.f / kSmallDelTime;
@ -271,7 +272,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);
}
}
}

4
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 <algorithm>
/////////////////////////////////////////////
// Controller interp caching
/////////////////////////////////////////////
@ -816,7 +818,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;
}

3
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 <cmath>
#include <algorithm>
template class TimeBasedAvgRing<float>;
template class TimeBasedAvgRing<double>;
@ -153,7 +154,7 @@ void TimeBasedAvgRing<T>::AddItem(T value, double time)
}
// update the max avg
fMaxAvg = hsMaximum( fMaxAvg, fAvg );
fMaxAvg = std::max(fMaxAvg, fAvg);
}

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

6
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);
}

6
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)
@ -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;

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

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

16
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 <algorithm>
///////////////////////////////////////////////////////////////////////////////////////////
plParticleCollisionEffect::plParticleCollisionEffect()
{
@ -681,12 +683,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<uint32_t>(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 +697,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<uint32_t>(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;

2
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<uint16_t>(victim ? victim->fNumValidParticles : 0));
if (spaceAvail < numToCopy)
numToCopy = spaceAvail;

4
Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp

@ -43,6 +43,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <NxPhysics.h>
#include <algorithm>
#include "plgDispatch.h"
#include "hsTimer.h"
#include "plProfile.h"
@ -701,7 +703,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;

2
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<int>(fSettings.fMaxPiggyBacks), fPiggyBackStack.GetCount());
}
// IPushProjPiggyBack //////////////////////////////////////////////////

3
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 <d3d9.h>
#include <d3dx9core.h>
#include "HeadSpin.h"
#include "plDXShader.h"
#include "plSurface/plShader.h"

4
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 <algorithm>
//// Draw ////////////////////////////////////////////////////////////////////
void plStatusLogDrawer::IDrawLogNames(plStatusLog* curLog, plStatusLog* firstLog)
@ -62,7 +64,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++;
}

17
Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp

@ -40,6 +40,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include <cfloat>
#include <type_traits>
#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 _T>
typename std::enable_if<std::is_floating_point<_T>::value, _T>::type
_generic_abs(_T value)
{
return fabs(value);
}
template <typename _T>
typename std::enable_if<std::is_integral<_T>::value, _T>::type
_generic_abs(_T value)
{
return abs(value);
}
#define NOTIFY_CHECK(type, var) \
case type: \
for(i=0;i<cnt;i++) \
if (hsABS(var[i] - other->var[i])>d) \
if (_generic_abs(var[i] - other->var[i]) > d) \
{ \
notify=true; \
break; \

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

10
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<int>(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<int>(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<int>(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<int>(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;
}

8
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;
}

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

12
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);
}
}

27
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"
@ -699,12 +698,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 +769,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);
}

26
Sources/Tools/MaxMain/plPhysXCooking.cpp

@ -54,6 +54,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <NxUtilLib.h>
#include <NxMat33.h>
#include <algorithm>
#include "plMaxMeshExtractor.h"
#include "plPhysXCooking.h"
@ -304,12 +306,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 +455,12 @@ hsVectorStream* plPhysXCooking::IMakePolytope(const plMaxMeshExtractor::NeutralM
}
for(int i=0;i<inMesh.fNumVerts;i++)
{
AABBMin.fX = hsMinimum(nxLocs2[i].x, AABBMin.fX);
AABBMin.fY = hsMinimum(nxLocs2[i].y, AABBMin.fY);
AABBMin.fZ = hsMinimum(nxLocs2[i].z, AABBMin.fZ);
AABBMax.fX = hsMaximum(nxLocs2[i].x, AABBMax.fX);
AABBMax.fY = hsMaximum(nxLocs2[i].y, AABBMax.fY);
AABBMax.fZ = hsMaximum(nxLocs2[i].z, AABBMax.fZ);
AABBMin.fX = std::min(nxLocs2[i].x, AABBMin.fX);
AABBMin.fY = std::min(nxLocs2[i].y, AABBMin.fY);
AABBMin.fZ = std::min(nxLocs2[i].z, AABBMin.fZ);
AABBMax.fX = std::max(nxLocs2[i].x, AABBMax.fX);
AABBMax.fY = std::max(nxLocs2[i].y, AABBMax.fY);
AABBMax.fZ = std::max(nxLocs2[i].z, AABBMax.fZ);
}
int resultingPoints=0;

2
Sources/Tools/MaxPlasmaLights/plRealTimeLights.cpp

@ -315,7 +315,7 @@ int SpotLight::Update(TimeValue t, const RendContext &rc, RenderGlobalContext *r
decayRadius = gl->GetDecayRadius(t);
projector = gl->GetProjector();
fov = hsMaximum(fs,hs);
fov = std::max(fs, hs);
float aspect = 1.0f;

Loading…
Cancel
Save