Skip to content

Commit

Permalink
[vphysics] Fix some issues found by MSVC static analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
dimhotepus committed Oct 3, 2023
1 parent ab6b3d5 commit f1f87ce
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion public/filesystem_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static void InitializeCharacterSets()
}


const char* ParseFileInternal( const char* pFileBytes, char* pTokenOut, bool* pWasQuoted, characterset_t *pCharSet, size_t nMaxTokenLen )
const char* ParseFileInternal( const char* pFileBytes, OUT_Z_CAP(nMaxTokenLen) char* pTokenOut, bool* pWasQuoted, characterset_t *pCharSet, size_t nMaxTokenLen )
{
pTokenOut[0] = 0;

Expand Down
2 changes: 2 additions & 0 deletions public/vphysics_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,8 @@ struct fluidparams_t
damping = src.damping;
torqueFactor = src.torqueFactor;
viscosityFactor = src.viscosityFactor;
pGameData = src.pGameData;
useAerodynamics = src.useAerodynamics;
contents = src.contents;
}
};
Expand Down
4 changes: 3 additions & 1 deletion public/vphysics_interfaceV30.h
Original file line number Diff line number Diff line change
Expand Up @@ -930,14 +930,16 @@ struct fluidparams_t
bool useAerodynamics;// true if this controller should calculate surface pressure
int contents;

fluidparams_t() {}
fluidparams_t() : pGameData(nullptr) {}
fluidparams_t( fluidparams_t const& src )
{
Vector4DCopy( src.surfacePlane, surfacePlane );
VectorCopy( src.currentVelocity, currentVelocity );
damping = src.damping;
torqueFactor = src.torqueFactor;
viscosityFactor = src.viscosityFactor;
pGameData = src.pGameData;
useAerodynamics = src.useAerodynamics;
contents = src.contents;
}
};
Expand Down
2 changes: 1 addition & 1 deletion vphysics/ledgewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void CVPhysicsVirtualMeshWriter::UnpackCompactLedgeFromHull( IVP_Compact_Ledge *
//pLedge->ledgetree_node_offset = -((int)pLedge);

// keep track of which triangle edge referenced this edge (so the next one can swap the order and point to the first one)
int forwardEdgeIndex[255];
int forwardEdgeIndex[255] = {};
for ( int i = 0; i < pHull->edgeCount; i++ )
{
forwardEdgeIndex[i] = -1;
Expand Down
1 change: 1 addition & 0 deletions vphysics/physics_collide.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class CPhysicsCollision : public IPhysicsCollision
public:
CPhysicsCollision()
{
memset(m_bboxVertMap, 0, sizeof(m_bboxVertMap));
}
CPhysConvex *ConvexFromVerts( Vector **pVerts, int vertCount );
CPhysConvex *ConvexFromVertsFast( Vector **pVerts, int vertCount );
Expand Down
2 changes: 1 addition & 1 deletion vphysics/physics_constraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ void CPhysicsConstraint::InitHinge( IVP_Environment *pEnvironment, CPhysicsConst

hk_Hinge_BP_Builder builder;

IVP_U_Point axisIVP_ws, axisPerpIVP_os, axisStartIVP_ws, axisStartIVP_os;
IVP_U_Point axisIVP_ws, axisPerpIVP_os;

ConvertDirectionToIVP( hinge.worldAxisDirection, axisIVP_ws );
builder.set_axis_ws( (hk_Rigid_Body*)m_pObjReference->GetObject(), (hk_Rigid_Body*)m_pObjAttached->GetObject(), vec(axisIVP_ws) );
Expand Down
8 changes: 4 additions & 4 deletions vphysics/vcollide_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

static void ReadVector( const char *pString, Vector& out )
{
float x, y, z;
float x = 0, y = 0, z = 0;
sscanf( pString, "%f %f %f", &x, &y, &z );
out[0] = x;
out[1] = y;
Expand All @@ -29,7 +29,7 @@ static void ReadVector( const char *pString, Vector& out )

static void ReadAngles( const char *pString, QAngle& out )
{
float x, y, z;
float x = 0, y = 0, z = 0;
sscanf( pString, "%f %f %f", &x, &y, &z );
out[0] = x;
out[1] = y;
Expand All @@ -38,7 +38,7 @@ static void ReadAngles( const char *pString, QAngle& out )

static void ReadVector4D( const char *pString, Vector4D& out )
{
float x, y, z, w;
float x = 0, y = 0, z = 0, w = 0;
sscanf( pString, "%f %f %f %f", &x, &y, &z, &w );
out[0] = x;
out[1] = y;
Expand Down Expand Up @@ -916,7 +916,7 @@ void DestroyVPhysicsKeyParser( IVPhysicsKeyParser *pParser )
// Helper functions for parsing script file
//-----------------------------------------------------------------------------

const char *ParseKeyvalue( const char *pBuffer, char (&key)[MAX_KEYVALUE], char (&value)[MAX_KEYVALUE] )
const char *ParseKeyvalue( const char *pBuffer, OUT_Z_ARRAY char (&key)[MAX_KEYVALUE], OUT_Z_ARRAY char (&value)[MAX_KEYVALUE] )
{
// Make sure value is always null-terminated.
value[0] = 0;
Expand Down

0 comments on commit f1f87ce

Please sign in to comment.