summaryrefslogtreecommitdiff
path: root/src/industry_map.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-09-23 19:55:42 +0000
committerrubidium <rubidium@openttd.org>2007-09-23 19:55:42 +0000
commitfc371ad994ce4b060be355a2b3bd635852bc80fb (patch)
treea2298d4c636cb8b7a33e9425bdf01b9f5896e668 /src/industry_map.h
parent4dca543135cac8034a5391e797711207ecf446b5 (diff)
downloadopenttd-fc371ad994ce4b060be355a2b3bd635852bc80fb.tar.xz
(svn r11152) -Fix: GetIndustryIDAtOffset crashed when translation of the GFX ID would be needed. Fix by Belugas.
-Fix: GetIndustryIDAtOffset crashed when the industry->xy tile was not an industry tile.
Diffstat (limited to 'src/industry_map.h')
-rw-r--r--src/industry_map.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/industry_map.h b/src/industry_map.h
index 7cf93af5a..80c05cc09 100644
--- a/src/industry_map.h
+++ b/src/industry_map.h
@@ -124,6 +124,12 @@ static inline void SetIndustryConstructionStage(TileIndex tile, byte value)
SB(_m[tile].m1, 0, 2, value);
}
+static inline IndustryGfx GetCleanIndustryGfx(TileIndex t)
+{
+ assert(IsTileType(t, MP_INDUSTRY));
+ return _m[t].m5 | (GB(_m[t].m6, 2, 1) << 8);
+}
+
/**
* Get the industry graphics ID for the given industry tile
* @param t the tile to get the gfx for
@@ -133,7 +139,7 @@ static inline void SetIndustryConstructionStage(TileIndex tile, byte value)
static inline IndustryGfx GetIndustryGfx(TileIndex t)
{
assert(IsTileType(t, MP_INDUSTRY));
- return GetTranslatedIndustryTileID(_m[t].m5 | (GB(_m[t].m6, 2, 1) << 8));
+ return GetTranslatedIndustryTileID(GetCleanIndustryGfx(t));
}
/**
@@ -145,7 +151,8 @@ static inline IndustryGfx GetIndustryGfx(TileIndex t)
static inline void SetIndustryGfx(TileIndex t, IndustryGfx gfx)
{
assert(IsTileType(t, MP_INDUSTRY));
- _m[t].m5 = gfx;
+ _m[t].m5 = GB(gfx, 0, 8);
+ SB(_m[t].m6, 2, 1, GB(gfx, 8, 1));
}
/**