[iortcw] 09/89: All: Fix Coverity warning that endVelocity is uninitialized

Simon McVittie smcv at debian.org
Fri Sep 8 10:44:14 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to tag 1.51b
in repository iortcw.

commit 61dfb290d66443cfe7d12b1bf0ea01e01cbdc10d
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date:   Tue Jun 13 09:24:30 2017 -0400

    All: Fix Coverity warning that endVelocity is uninitialized
---
 MP/code/game/bg_slidemove.c | 27 +++++++++++++++++++--------
 SP/code/game/bg_slidemove.c | 27 +++++++++++++++++++--------
 2 files changed, 38 insertions(+), 16 deletions(-)

diff --git a/MP/code/game/bg_slidemove.c b/MP/code/game/bg_slidemove.c
index cac17be..c54e842 100644
--- a/MP/code/game/bg_slidemove.c
+++ b/MP/code/game/bg_slidemove.c
@@ -164,8 +164,10 @@ qboolean    PM_SlideMove( qboolean gravity ) {
 			// slide along the plane
 			PM_ClipVelocity( pm->ps->velocity, planes[i], clipVelocity, OVERCLIP );
 
-			// slide along the plane
-			PM_ClipVelocity( endVelocity, planes[i], endClipVelocity, OVERCLIP );
+			if ( gravity ) {
+				// slide along the plane
+				PM_ClipVelocity( endVelocity, planes[i], endClipVelocity, OVERCLIP );
+			}
 
 			// see if there is a second plane that the new move enters
 			for ( j = 0 ; j < numplanes ; j++ ) {
@@ -178,7 +180,10 @@ qboolean    PM_SlideMove( qboolean gravity ) {
 
 				// try clipping the move to the plane
 				PM_ClipVelocity( clipVelocity, planes[j], clipVelocity, OVERCLIP );
-				PM_ClipVelocity( endClipVelocity, planes[j], endClipVelocity, OVERCLIP );
+
+				if ( gravity ) {
+					PM_ClipVelocity( endClipVelocity, planes[j], endClipVelocity, OVERCLIP );
+				}
 
 				// see if it goes back into the first clip plane
 				if ( DotProduct( clipVelocity, planes[i] ) >= 0 ) {
@@ -191,10 +196,12 @@ qboolean    PM_SlideMove( qboolean gravity ) {
 				d = DotProduct( dir, pm->ps->velocity );
 				VectorScale( dir, d, clipVelocity );
 
-				CrossProduct( planes[i], planes[j], dir );
-				VectorNormalize( dir );
-				d = DotProduct( dir, endVelocity );
-				VectorScale( dir, d, endClipVelocity );
+				if ( gravity ) {
+					CrossProduct( planes[i], planes[j], dir );
+					VectorNormalize( dir );
+					d = DotProduct( dir, endVelocity );
+					VectorScale( dir, d, endClipVelocity );
+				}
 
 				// see if there is a third plane the the new move enters
 				for ( k = 0 ; k < numplanes ; k++ ) {
@@ -213,7 +220,11 @@ qboolean    PM_SlideMove( qboolean gravity ) {
 
 			// if we have fixed all interactions, try another move
 			VectorCopy( clipVelocity, pm->ps->velocity );
-			VectorCopy( endClipVelocity, endVelocity );
+
+			if ( gravity ) {
+				VectorCopy( endClipVelocity, endVelocity );
+			}
+
 			break;
 		}
 	}
diff --git a/SP/code/game/bg_slidemove.c b/SP/code/game/bg_slidemove.c
index 175d82c..a62c348 100644
--- a/SP/code/game/bg_slidemove.c
+++ b/SP/code/game/bg_slidemove.c
@@ -164,8 +164,10 @@ qboolean    PM_SlideMove( qboolean gravity ) {
 			// slide along the plane
 			PM_ClipVelocity( pm->ps->velocity, planes[i], clipVelocity, OVERCLIP );
 
-			// slide along the plane
-			PM_ClipVelocity( endVelocity, planes[i], endClipVelocity, OVERCLIP );
+			if ( gravity ) {
+				// slide along the plane
+				PM_ClipVelocity( endVelocity, planes[i], endClipVelocity, OVERCLIP );
+			}
 
 			// see if there is a second plane that the new move enters
 			for ( j = 0 ; j < numplanes ; j++ ) {
@@ -178,7 +180,10 @@ qboolean    PM_SlideMove( qboolean gravity ) {
 
 				// try clipping the move to the plane
 				PM_ClipVelocity( clipVelocity, planes[j], clipVelocity, OVERCLIP );
-				PM_ClipVelocity( endClipVelocity, planes[j], endClipVelocity, OVERCLIP );
+
+				if ( gravity ) {
+					PM_ClipVelocity( endClipVelocity, planes[j], endClipVelocity, OVERCLIP );
+				}
 
 				// see if it goes back into the first clip plane
 				if ( DotProduct( clipVelocity, planes[i] ) >= 0 ) {
@@ -191,10 +196,12 @@ qboolean    PM_SlideMove( qboolean gravity ) {
 				d = DotProduct( dir, pm->ps->velocity );
 				VectorScale( dir, d, clipVelocity );
 
-				CrossProduct( planes[i], planes[j], dir );
-				VectorNormalize( dir );
-				d = DotProduct( dir, endVelocity );
-				VectorScale( dir, d, endClipVelocity );
+				if ( gravity ) {
+					CrossProduct( planes[i], planes[j], dir );
+					VectorNormalize( dir );
+					d = DotProduct( dir, endVelocity );
+					VectorScale( dir, d, endClipVelocity );
+				}
 
 				// see if there is a third plane the the new move enters
 				for ( k = 0 ; k < numplanes ; k++ ) {
@@ -213,7 +220,11 @@ qboolean    PM_SlideMove( qboolean gravity ) {
 
 			// if we have fixed all interactions, try another move
 			VectorCopy( clipVelocity, pm->ps->velocity );
-			VectorCopy( endClipVelocity, endVelocity );
+
+			if ( gravity ) {
+				VectorCopy( endClipVelocity, endVelocity );
+			}
+
 			break;
 		}
 	}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git



More information about the Pkg-games-commits mailing list