diff options
author | rubidium <rubidium@openttd.org> | 2008-04-21 11:29:01 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-04-21 11:29:01 +0000 |
commit | a40bba8bace426b961d31f5b0362629044c0766e (patch) | |
tree | 05dfb2564e3487afc402523c5fbe4b764fc97d54 /src/newgrf_industrytiles.cpp | |
parent | 2a779a5e100be9133e21b5645d90d0d390af9ecd (diff) | |
download | openttd-a40bba8bace426b961d31f5b0362629044c0766e.tar.xz |
(svn r12817) -Feature: the ability to play NewGRF sounds for industries and stations.
Diffstat (limited to 'src/newgrf_industrytiles.cpp')
-rw-r--r-- | src/newgrf_industrytiles.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp index 418539e8f..79bbf72eb 100644 --- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -15,6 +15,7 @@ #include "newgrf_callbacks.h" #include "newgrf_industries.h" #include "newgrf_industrytiles.h" +#include "newgrf_sound.h" #include "newgrf_text.h" #include "industry_map.h" #include "clear_map.h" @@ -337,6 +338,10 @@ void AnimateNewIndustryTile(TileIndex tile) frame = callback_res & 0xFF; break; } + + /* If the lower 7 bits of the upper byte of the callback + * result are not empty, it is a sound effect. */ + if (GB(callback_res, 8, 7) != 0) PlayTileSound(itspec->grf_prop.grffile, GB(callback_res, 8, 7), tile); } } @@ -356,7 +361,7 @@ void AnimateNewIndustryTile(TileIndex tile) MarkTileDirtyByTile(tile); } -static void ChangeIndustryTileAnimationFrame(TileIndex tile, IndustryAnimationTrigger iat, uint32 random_bits, IndustryGfx gfx, Industry *ind) +static void ChangeIndustryTileAnimationFrame(const IndustryTileSpec *itspec, TileIndex tile, IndustryAnimationTrigger iat, uint32 random_bits, IndustryGfx gfx, Industry *ind) { uint16 callback_res = GetIndustryTileCallback(CBID_INDTILE_ANIM_START_STOP, random_bits, iat, gfx, ind, tile); if (callback_res == CALLBACK_FAILED) return; @@ -370,6 +375,10 @@ static void ChangeIndustryTileAnimationFrame(TileIndex tile, IndustryAnimationTr AddAnimatedTile(tile); break; } + + /* If the lower 7 bits of the upper byte of the callback + * result are not empty, it is a sound effect. */ + if (GB(callback_res, 8, 7) != 0) PlayTileSound(itspec->grf_prop.grffile, GB(callback_res, 8, 7), tile); } bool StartStopIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat, uint32 random) @@ -380,7 +389,7 @@ bool StartStopIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat if (!HasBit(itspec->animation_triggers, iat)) return false; Industry *ind = GetIndustryByTile(tile); - ChangeIndustryTileAnimationFrame(tile, iat, random, gfx, ind); + ChangeIndustryTileAnimationFrame(itspec, tile, iat, random, gfx, ind); return true; } |