Work around false positive GCC -W(maybe-)uninitialized warnings

shouldn't hurt too much, and the R_IssueEntityDefCallback() code
even is a bit better now
This commit is contained in:
Daniel Gibson 2023-01-05 07:54:41 +01:00
parent 957176d659
commit 6730ddcb29
3 changed files with 11 additions and 12 deletions

View file

@ -155,7 +155,7 @@ GetPointOutsideObstacles
void GetPointOutsideObstacles( const obstacle_t *obstacles, const int numObstacles, idVec2 &point, int *obstacle, int *edgeNum ) {
int i, j, k, n, bestObstacle, bestEdgeNum, queueStart, queueEnd, edgeNums[2];
float d, bestd, scale[2];
idVec3 plane, bestPlane;
idVec3 plane, bestPlane(0.0f, 0.0f, 0.0f); // DG: init it to shut up compiler
idVec2 newPoint, dir, bestPoint;
int *queue;
bool *obstacleVisited;
@ -1128,7 +1128,8 @@ idAI::PredictPath
*/
bool idAI::PredictPath( const idEntity *ent, const idAAS *aas, const idVec3 &start, const idVec3 &velocity, int totalTime, int frameTime, int stopEvent, predictedPath_t &path ) {
int i, j, step, numFrames, curFrameTime;
idVec3 delta, curStart, curEnd, curVelocity, lastEnd, stepUp, tmpStart;
idVec3 delta, curStart, curEnd, curVelocity, lastEnd, tmpStart;
idVec3 stepUp(0,0,0); // DG: init this to get rid of compiler warning
idVec3 gravity, gravityDir, invGravityDir;
float maxStepHeight, minFloorCos;
pathTrace_t trace;
@ -1183,7 +1184,7 @@ bool idAI::PredictPath( const idEntity *ent, const idAAS *aas, const idVec3 &sta
return true;
}
if ( step ) {
if ( step != 0 ) {
// step down at end point
tmpStart = trace.endPos;

View file

@ -157,7 +157,7 @@ GetPointOutsideObstacles
void GetPointOutsideObstacles( const obstacle_t *obstacles, const int numObstacles, idVec2 &point, int *obstacle, int *edgeNum ) {
int i, j, k, n, bestObstacle, bestEdgeNum, queueStart, queueEnd, edgeNums[2];
float d, bestd, scale[2];
idVec3 plane, bestPlane;
idVec3 plane, bestPlane(0.0f, 0.0f, 0.0f); // DG: init it to shut up compiler
idVec2 newPoint, dir, bestPoint;
int *queue;
bool *obstacleVisited;
@ -1131,7 +1131,8 @@ idAI::PredictPath
*/
bool idAI::PredictPath( const idEntity *ent, const idAAS *aas, const idVec3 &start, const idVec3 &velocity, int totalTime, int frameTime, int stopEvent, predictedPath_t &path ) {
int i, j, step, numFrames, curFrameTime;
idVec3 delta, curStart, curEnd, curVelocity, lastEnd, stepUp, tmpStart;
idVec3 delta, curStart, curEnd, curVelocity, lastEnd, tmpStart;
idVec3 stepUp(0,0,0); // DG: init this to get rid of compiler warning
idVec3 gravity, gravityDir, invGravityDir;
float maxStepHeight, minFloorCos;
pathTrace_t trace;

View file

@ -1062,12 +1062,6 @@ R_IssueEntityDefCallback
*/
bool R_IssueEntityDefCallback( idRenderEntityLocal *def ) {
bool update;
idBounds oldBounds;
const bool checkBounds = r_checkBounds.GetBool();
if ( checkBounds ) {
oldBounds = def->referenceBounds;
}
def->archived = false; // will need to be written to the demo file
tr.pc.c_entityDefCallbacks++;
@ -1082,7 +1076,10 @@ bool R_IssueEntityDefCallback( idRenderEntityLocal *def ) {
return false;
}
if ( checkBounds ) {
// DG: moved some code down here so all the boundchecking stuff is in the same if (because why not)
// (also works around yet another GCC maybe-uninitialized false positive)
if ( r_checkBounds.GetBool() ) {
idBounds oldBounds = def->referenceBounds;
if ( oldBounds[0][0] > def->referenceBounds[0][0] + CHECK_BOUNDS_EPSILON ||
oldBounds[0][1] > def->referenceBounds[0][1] + CHECK_BOUNDS_EPSILON ||
oldBounds[0][2] > def->referenceBounds[0][2] + CHECK_BOUNDS_EPSILON ||