--- a/src/newgrf_spritegroup.cpp Wed Jun 13 11:17:30 2007 +0000
+++ b/src/newgrf_spritegroup.cpp Wed Jun 13 11:45:14 2007 +0000
@@ -76,6 +76,8 @@
_spritegroup_count = 0;
}
+static uint32 _temp_store[0x110];
+
static inline uint32 GetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
{
@@ -96,6 +98,8 @@
case 0x1C: return object->last_value;
case 0x20: return _opt.landscape == LT_ARCTIC ? GetSnowLine() : 0xFF;
+ case 0x7D: return _temp_store[parameter];
+
/* Not a common variable, so evalute the feature specific variables */
default: return object->GetVariable(object, variable, parameter, available);
}
@@ -125,14 +129,18 @@
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;
case DSGA_OP_XOR: return last_value ^ value;
+ case DSGA_OP_STO:
+ if (value < lengthof(_temp_store)) _temp_store[value] = last_value;
+ return last_value;
+ case DSGA_OP_RST: return value;
default: return value;
}
}