summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2007-05-14 17:37:34 +0000
committerpeter1138 <peter1138@openttd.org>2007-05-14 17:37:34 +0000
commitb80e11c44cf80aaed516b193e58622361d9a3e96 (patch)
treee594842b1ff0c265dd1d3e674e6b325eb81e63c1
parentc7d57379fbdda52590cddb83240934da6b5e8b21 (diff)
downloadopenttd-b80e11c44cf80aaed516b193e58622361d9a3e96.tar.xz
(svn r9837) -Fix: [NewGRF] Catch occurance of division-by-zero in varaction handling.
-rw-r--r--src/newgrf_spritegroup.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp
index 2d12ce0c5..3258fa03d 100644
--- a/src/newgrf_spritegroup.cpp
+++ b/src/newgrf_spritegroup.cpp
@@ -129,10 +129,10 @@ static U EvalAdjustT(const DeterministicSpriteGroupAdjust *adjust, U last_value,
case DSGA_OP_SMAX: return max((S)last_value, (S)value);
case DSGA_OP_UMIN: return min((U)last_value, (U)value);
case DSGA_OP_UMAX: return max((U)last_value, (U)value);
- case DSGA_OP_SDIV: return (S)last_value / (S)value;
- case DSGA_OP_SMOD: return (S)last_value % (S)value;
- case DSGA_OP_UDIV: return (U)last_value / (U)value;
- case DSGA_OP_UMOD: return (U)last_value % (U)value;
+ case DSGA_OP_SDIV: return value == 0 ? (S)last_value : (S)last_value / (S)value;
+ case DSGA_OP_SMOD: return value == 0 ? (S)last_value : (S)last_value % (S)value;
+ case DSGA_OP_UDIV: return value == 0 ? (U)last_value : (U)last_value / (U)value;
+ case DSGA_OP_UMOD: return value == 0 ? (U)last_value : (U)last_value % (U)value;
case DSGA_OP_MUL: return last_value * value;
case DSGA_OP_AND: return last_value & value;
case DSGA_OP_OR: return last_value | value;