src/newgrf_spritegroup.cpp
branchnoai
changeset 9624 b71483f2330f
parent 9601 b499fdd106d5
child 9631 8a2d1c2ceb88
--- a/src/newgrf_spritegroup.cpp	Fri May 11 15:13:08 2007 +0000
+++ b/src/newgrf_spritegroup.cpp	Fri May 25 00:25:08 2007 +0000
@@ -129,10 +129,10 @@
 		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;