[ioquake3] 36/59: Fix undefined behavior when shifting left by 32.
Simon McVittie
smcv at debian.org
Wed Sep 21 19:57:07 UTC 2016
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch debian/master
in repository ioquake3.
commit 497a74f22a39cbf8694e5d8567f3113f03ba3620
Author: SmileTheory <SmileTheory at gmail.com>
Date: Wed Sep 7 16:56:23 2016 -0700
Fix undefined behavior when shifting left by 32.
https://bugzilla.icculus.org/show_bug.cgi?id=6432
---
code/renderergl1/tr_world.c | 10 +++++-----
code/renderergl2/tr_world.c | 22 +++++++++++-----------
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/code/renderergl1/tr_world.c b/code/renderergl1/tr_world.c
index 0a2743f..88eca6d 100644
--- a/code/renderergl1/tr_world.c
+++ b/code/renderergl1/tr_world.c
@@ -353,10 +353,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) {
@@ -661,8 +661,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/code/renderergl2/tr_world.c b/code/renderergl2/tr_world.c
index 98b1c81..c4b1533 100644
--- a/code/renderergl2/tr_world.c
+++ b/code/renderergl2/tr_world.c
@@ -401,11 +401,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
@@ -761,7 +761,7 @@ R_AddWorldSurfaces
=============
*/
void R_AddWorldSurfaces (void) {
- int planeBits, dlightBits, pshadowBits;
+ uint32_t planeBits, dlightBits, pshadowBits;
if ( !r_drawworld->integer ) {
return;
@@ -782,12 +782,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;
@@ -799,12 +799,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;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/ioquake3.git
More information about the Pkg-games-commits
mailing list