From c2bad6d22c9889bfb673055c2e9af424b0d157fe Mon Sep 17 00:00:00 2001 From: frosch Date: Tue, 12 Feb 2008 15:43:10 +0000 Subject: (svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function. -Fix: Add some variables that were missing in one or both cases. --- src/newgrf_spritegroup.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'src/newgrf_spritegroup.cpp') diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp index 6b77fbda8..a5e7077e8 100644 --- a/src/newgrf_spritegroup.cpp +++ b/src/newgrf_spritegroup.cpp @@ -7,6 +7,7 @@ #include "variables.h" #include "landscape.h" #include "oldpool.h" +#include "newgrf.h" #include "newgrf_callbacks.h" #include "newgrf_spritegroup.h" #include "sprite.h" @@ -81,23 +82,16 @@ TemporaryStorageArray _temp_store; static inline uint32 GetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) { - /* Return common variables */ + /* First handle variables common with Action7/9/D */ + uint32 value; + if (GetGlobalVariable(variable, &value)) return variable; + + /* Non-common variable */ switch (variable) { - case 0x00: return max(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0); - case 0x01: return Clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR; - case 0x02: return _cur_month; - case 0x03: return _opt.landscape; - case 0x09: return _date_fract; - case 0x0A: return _tick_counter; case 0x0C: return object->callback; case 0x10: return object->callback_param1; - case 0x11: return 0; - case 0x12: return _game_mode; case 0x18: return object->callback_param2; - case 0x1A: return UINT_MAX; - case 0x1B: return GB(_display_opt, 0, 6); case 0x1C: return object->last_value; - case 0x20: return _opt.landscape == LT_ARCTIC ? GetSnowLine() : 0xFF; case 0x7D: return _temp_store.Get(parameter); -- cgit v1.2.3-54-g00ecf