From 03fccc622065a48dfe9de2f7dc4d3fa7bc442a6a Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Tue, 28 Mar 2023 19:18:55 +0200 Subject: [PATCH] R_IssueEntityDefCallback() fix bounds check in the "Work around false positive GCC -W(maybe-)uninitialized warnings" commit I changed that code.. but my change made it nonsensical, of course we must get oldBounds before calling the callback which changes the bounds, otherwise comparing the "oldbounds" with the current bounds just compares them with themselves.. --- neo/renderer/tr_light.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/neo/renderer/tr_light.cpp b/neo/renderer/tr_light.cpp index 24cb9da2..59e4dfb3 100644 --- a/neo/renderer/tr_light.cpp +++ b/neo/renderer/tr_light.cpp @@ -1062,6 +1062,12 @@ 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++; @@ -1076,10 +1082,7 @@ bool R_IssueEntityDefCallback( idRenderEntityLocal *def ) { return false; } - // 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 ( checkBounds ) { 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 ||