newgrf_spritegroup.c
changeset 3788 069d945ed860
parent 3753 aa15896bc569
child 3861 1bc622ec64e8
equal deleted inserted replaced
3787:a71d1c53e679 3788:069d945ed860
    97 
    97 
    98 
    98 
    99 /* Evaluate an adjustment for a variable of the given size. This is a bit of
    99 /* Evaluate an adjustment for a variable of the given size. This is a bit of
   100  * an unwieldy macro, but it saves triplicating the code. */
   100  * an unwieldy macro, but it saves triplicating the code. */
   101 #define BUILD_EVAL_ADJUST(size, usize) \
   101 #define BUILD_EVAL_ADJUST(size, usize) \
   102 static inline size EvalAdjust_ ## size(const DeterministicSpriteGroupAdjust *adjust, size last_value, uint value) \
   102 static inline usize EvalAdjust_ ## size(const DeterministicSpriteGroupAdjust *adjust, usize last_value, int32 value) \
   103 { \
   103 { \
   104 	value >>= adjust->shift_num; \
   104 	value >>= adjust->shift_num; \
   105 	value  &= adjust->and_mask; \
   105 	value  &= adjust->and_mask; \
   106 \
   106 \
   107 	if (adjust->type != DSGA_TYPE_NONE) value += (size)adjust->add_val; \
   107 	if (adjust->type != DSGA_TYPE_NONE) value += (size)adjust->add_val; \
   108 \
   108 \
   109 	switch (adjust->type) { \
   109 	switch (adjust->type) { \
   110 		case DSGA_TYPE_DIV:  value /= (size)adjust->divmod_val; break; \
   110 		case DSGA_TYPE_DIV:  value /= (size)adjust->divmod_val; break; \
   111 		case DSGA_TYPE_MOD:  value %= (size)adjust->divmod_val; break; \
   111 		case DSGA_TYPE_MOD:  value %= (usize)adjust->divmod_val; break; \
   112 		case DSGA_TYPE_NONE: break; \
   112 		case DSGA_TYPE_NONE: break; \
   113 	} \
   113 	} \
   114 \
   114 \
   115 	/* Get our value to the correct range */ \
   115 	/* Get our value to the correct range */ \
   116 	value = (size)value; \
   116 	value = (usize)value; \
   117 \
   117 \
   118 	switch (adjust->operation) { \
   118 	switch (adjust->operation) { \
   119 		case DSGA_OP_ADD:  return last_value + value; \
   119 		case DSGA_OP_ADD:  return last_value + value; \
   120 		case DSGA_OP_SUB:  return last_value - value; \
   120 		case DSGA_OP_SUB:  return last_value - value; \
   121 		case DSGA_OP_SMIN: return min(last_value, value); \
   121 		case DSGA_OP_SMIN: return min(last_value, value); \