changeset 15668:433a5dc96551 draft

(svn r20333) -Fix (r20332): Mask second operand to 5 bits to avoid differences between platforms.
author frosch <frosch@openttd.org>
date Mon, 02 Aug 2010 23:35:47 +0000
parents 960ec264266c
children 1cb744e35ef3
files src/newgrf_spritegroup.cpp
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/newgrf_spritegroup.cpp
+++ b/src/newgrf_spritegroup.cpp
@@ -124,9 +124,9 @@
 		case DSGA_OP_ROR:  return RotateRight(last_value, value);
 		case DSGA_OP_SCMP: return ((S)last_value == (S)value) ? 1 : ((S)last_value < (S)value ? 0 : 2);
 		case DSGA_OP_UCMP: return ((U)last_value == (U)value) ? 1 : ((U)last_value < (U)value ? 0 : 2);
-		case DSGA_OP_SHL:  return (U)last_value << (U)value;
-		case DSGA_OP_SHR:  return (U)last_value >> (U)value;
-		case DSGA_OP_SAR:  return (S)last_value >> (U)value;
+		case DSGA_OP_SHL:  return (U)last_value << ((U)value & 0x1F); // mask 'value' to 5 bits, which should behave the same on all architectures.
+		case DSGA_OP_SHR:  return (U)last_value >> ((U)value & 0x1F);
+		case DSGA_OP_SAR:  return (S)last_value >> ((U)value & 0x1F);
 		default:           return value;
 	}
 }