From 930d0c97021d9ec9d3acf37d916b236de0c1ca3a Mon Sep 17 00:00:00 2001 From: frosch Date: Sat, 14 May 2011 12:36:31 +0000 Subject: [PATCH] (svn r22452) -Fix (r18708): Zero register 0x100 as specified before resolving custom station foundations. --- src/newgrf_spritegroup.h | 11 +++++++++++ src/newgrf_station.cpp | 1 + 2 files changed, 12 insertions(+) diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h index da4d5e5df8..2541195d90 100644 --- a/src/newgrf_spritegroup.h +++ b/src/newgrf_spritegroup.h @@ -35,6 +35,17 @@ static inline uint32 GetRegister(uint i) return _temp_store.Get(i); } +/** + * Clears the value of a so-called newgrf "register". + * @param i index of the register + * @pre i < 0x110 + */ +static inline void ClearRegister(uint i) +{ + extern TemporaryStorageArray _temp_store; + _temp_store.Store(i, 0); +} + /* List of different sprite group types */ enum SpriteGroupType { SGT_REAL, diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index fd7a730ddf..4cc68e2a43 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -613,6 +613,7 @@ SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, const NewStationResolver(&object, statspec, st, tile); object.callback_param1 = 2; // Indicate we are resolving the foundation sprites + ClearRegister(0x100); group = ResolveStation(&object); if (group == NULL || group->type != SGT_RESULT) return 0; return group->GetResult() + GetRegister(0x100);