[iortcw] 107/152: All: Fix undefined behavior when shifting left by 32
Simon McVittie
smcv at debian.org
Fri Sep 8 10:40:19 UTC 2017
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to annotated tag 1.5a
in repository iortcw.
commit bd6dd64d905c20c1aae4833fed3183dcc1f0125d
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date: Sun Sep 11 17:24:57 2016 -0400
All: Fix undefined behavior when shifting left by 32
---
MP/code/rend2/tr_world.c | 22 +++++++++++-----------
MP/code/renderer/tr_world.c | 10 +++++-----
SP/code/rend2/tr_world.c | 22 +++++++++++-----------
SP/code/renderer/tr_world.c | 10 +++++-----
4 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/MP/code/rend2/tr_world.c b/MP/code/rend2/tr_world.c
index dbe3183..3153f02 100644
--- a/MP/code/rend2/tr_world.c
+++ b/MP/code/rend2/tr_world.c
@@ -464,11 +464,11 @@ void R_AddBrushModelSurfaces ( trRefEntity_t *ent ) {
R_RecursiveWorldNode
================
*/
-static void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits, int pshadowBits ) {
+static void R_RecursiveWorldNode( mnode_t *node, uint32_t planeBits, uint32_t dlightBits, uint32_t pshadowBits ) {
do {
- int newDlights[2];
- unsigned int newPShadows[2];
+ uint32_t newDlights[2];
+ uint32_t newPShadows[2];
// if the node wasn't marked as potentially visible, exit
// pvs is skipped for depth shadows
@@ -810,7 +810,7 @@ R_AddWorldSurfaces
=============
*/
void R_AddWorldSurfaces( void ) {
- int planeBits, dlightBits, pshadowBits;
+ uint32_t planeBits, dlightBits, pshadowBits;
if ( !r_drawworld->integer ) {
return;
@@ -831,12 +831,12 @@ void R_AddWorldSurfaces( void ) {
ClearBounds( tr.viewParms.visBounds[0], tr.viewParms.visBounds[1] );
// perform frustum culling and flag all the potentially visible surfaces
- if ( tr.refdef.num_dlights > 32 ) {
- tr.refdef.num_dlights = 32 ;
+ if ( tr.refdef.num_dlights > MAX_DLIGHTS ) {
+ tr.refdef.num_dlights = MAX_DLIGHTS ;
}
- if ( tr.refdef.num_pshadows > 32 ) {
- tr.refdef.num_pshadows = 32 ;
+ if ( tr.refdef.num_pshadows > MAX_DRAWN_PSHADOWS ) {
+ tr.refdef.num_pshadows = MAX_DRAWN_PSHADOWS;
}
planeBits = (tr.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 31 : 15;
@@ -848,12 +848,12 @@ void R_AddWorldSurfaces( void ) {
}
else if ( !(tr.viewParms.flags & VPF_SHADOWMAP) )
{
- dlightBits = ( 1 << tr.refdef.num_dlights ) - 1;
- pshadowBits = ( 1 << tr.refdef.num_pshadows ) - 1;
+ dlightBits = ( 1ULL << tr.refdef.num_dlights ) - 1;
+ pshadowBits = ( 1ULL << tr.refdef.num_pshadows ) - 1;
}
else
{
- dlightBits = ( 1 << tr.refdef.num_dlights ) - 1;
+ dlightBits = ( 1ULL << tr.refdef.num_dlights ) - 1;
pshadowBits = 0;
}
diff --git a/MP/code/renderer/tr_world.c b/MP/code/renderer/tr_world.c
index 4ab764d..2a7d729 100644
--- a/MP/code/renderer/tr_world.c
+++ b/MP/code/renderer/tr_world.c
@@ -411,10 +411,10 @@ void R_AddBrushModelSurfaces( trRefEntity_t *ent ) {
R_RecursiveWorldNode
================
*/
-static void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits ) {
+static void R_RecursiveWorldNode( mnode_t *node, unsigned int planeBits, unsigned int dlightBits ) {
do {
- int newDlights[2];
+ unsigned int newDlights[2];
// if the node wasn't marked as potentially visible, exit
if ( node->visframe != tr.visCount ) {
@@ -707,8 +707,8 @@ void R_AddWorldSurfaces( void ) {
ClearBounds( tr.viewParms.visBounds[0], tr.viewParms.visBounds[1] );
// perform frustum culling and add all the potentially visible surfaces
- if ( tr.refdef.num_dlights > 32 ) {
- tr.refdef.num_dlights = 32 ;
+ if ( tr.refdef.num_dlights > MAX_DLIGHTS ) {
+ tr.refdef.num_dlights = MAX_DLIGHTS ;
}
- R_RecursiveWorldNode( tr.world->nodes, 15, ( 1 << tr.refdef.num_dlights ) - 1 );
+ R_RecursiveWorldNode( tr.world->nodes, 15, ( 1ULL << tr.refdef.num_dlights ) - 1 );
}
diff --git a/SP/code/rend2/tr_world.c b/SP/code/rend2/tr_world.c
index 6b65bcc..cb60ff1 100644
--- a/SP/code/rend2/tr_world.c
+++ b/SP/code/rend2/tr_world.c
@@ -500,11 +500,11 @@ void R_AddBrushModelSurfaces ( trRefEntity_t *ent ) {
R_RecursiveWorldNode
================
*/
-static void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits, int pshadowBits ) {
+static void R_RecursiveWorldNode( mnode_t *node, uint32_t planeBits, uint32_t dlightBits, uint32_t pshadowBits ) {
do {
- int newDlights[2];
- unsigned int newPShadows[2];
+ uint32_t newDlights[2];
+ uint32_t newPShadows[2];
// if the node wasn't marked as potentially visible, exit
// pvs is skipped for depth shadows
@@ -846,7 +846,7 @@ R_AddWorldSurfaces
=============
*/
void R_AddWorldSurfaces( void ) {
- int planeBits, dlightBits, pshadowBits;
+ uint32_t planeBits, dlightBits, pshadowBits;
if ( !r_drawworld->integer ) {
return;
@@ -867,12 +867,12 @@ void R_AddWorldSurfaces( void ) {
ClearBounds( tr.viewParms.visBounds[0], tr.viewParms.visBounds[1] );
// perform frustum culling and flag all the potentially visible surfaces
- if ( tr.refdef.num_dlights > 32 ) {
- tr.refdef.num_dlights = 32 ;
+ if ( tr.refdef.num_dlights > MAX_DLIGHTS ) {
+ tr.refdef.num_dlights = MAX_DLIGHTS ;
}
- if ( tr.refdef.num_pshadows > 32 ) {
- tr.refdef.num_pshadows = 32 ;
+ if ( tr.refdef.num_pshadows > MAX_DRAWN_PSHADOWS ) {
+ tr.refdef.num_pshadows = MAX_DRAWN_PSHADOWS;
}
planeBits = (tr.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 31 : 15;
@@ -884,12 +884,12 @@ void R_AddWorldSurfaces( void ) {
}
else if ( !(tr.viewParms.flags & VPF_SHADOWMAP) )
{
- dlightBits = ( 1 << tr.refdef.num_dlights ) - 1;
- pshadowBits = ( 1 << tr.refdef.num_pshadows ) - 1;
+ dlightBits = ( 1ULL << tr.refdef.num_dlights ) - 1;
+ pshadowBits = ( 1ULL << tr.refdef.num_pshadows ) - 1;
}
else
{
- dlightBits = ( 1 << tr.refdef.num_dlights ) - 1;
+ dlightBits = ( 1ULL << tr.refdef.num_dlights ) - 1;
pshadowBits = 0;
}
diff --git a/SP/code/renderer/tr_world.c b/SP/code/renderer/tr_world.c
index 5e87506..d312767 100644
--- a/SP/code/renderer/tr_world.c
+++ b/SP/code/renderer/tr_world.c
@@ -407,10 +407,10 @@ void R_AddBrushModelSurfaces( trRefEntity_t *ent ) {
R_RecursiveWorldNode
================
*/
-static void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits ) {
+static void R_RecursiveWorldNode( mnode_t *node, unsigned int planeBits, unsigned int dlightBits ) {
do {
- int newDlights[2];
+ unsigned int newDlights[2];
// if the node wasn't marked as potentially visible, exit
if ( node->visframe != tr.visCount ) {
@@ -703,8 +703,8 @@ void R_AddWorldSurfaces( void ) {
ClearBounds( tr.viewParms.visBounds[0], tr.viewParms.visBounds[1] );
// perform frustum culling and add all the potentially visible surfaces
- if ( tr.refdef.num_dlights > 32 ) {
- tr.refdef.num_dlights = 32 ;
+ if ( tr.refdef.num_dlights > MAX_DLIGHTS ) {
+ tr.refdef.num_dlights = MAX_DLIGHTS ;
}
- R_RecursiveWorldNode( tr.world->nodes, 15, ( 1 << tr.refdef.num_dlights ) - 1 );
+ R_RecursiveWorldNode( tr.world->nodes, 15, ( 1ULL << tr.refdef.num_dlights ) - 1 );
}
--
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