summaryrefslogtreecommitdiff
path: root/src/newgrf_spritegroup.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2008-02-12 15:43:10 +0000
committerfrosch <frosch@openttd.org>2008-02-12 15:43:10 +0000
commitc2bad6d22c9889bfb673055c2e9af424b0d157fe (patch)
treee54564a2e5c648444ed5f9c745207db195ed32dd /src/newgrf_spritegroup.cpp
parent23bae896c9584b864fc9f90f0e537f2483aaed76 (diff)
downloadopenttd-c2bad6d22c9889bfb673055c2e9af424b0d157fe.tar.xz
(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.
Diffstat (limited to 'src/newgrf_spritegroup.cpp')
-rw-r--r--src/newgrf_spritegroup.cpp18
1 files changed, 6 insertions, 12 deletions
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<uint32, 0x110> _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);