summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2012-01-03 00:45:22 +0000
committeryexo <yexo@openttd.org>2012-01-03 00:45:22 +0000
commit5f79b4c5d1eb364e5e8ba6291bb522d45af4c115 (patch)
tree246ee542b805e02c6d2ee1aaa7cb5d5f9a45ed4b /src
parentb9e19cc6c15df0e66152d46df767b6370b89a9db (diff)
downloadopenttd-5f79b4c5d1eb364e5e8ba6291bb522d45af4c115.tar.xz
(svn r23724) -Codechange: split of the check to see if ambient sounds are enabled to a header file allowing compilers to inline that check
Diffstat (limited to 'src')
-rw-r--r--src/clear_cmd.cpp2
-rw-r--r--src/newgrf_generic.cpp2
-rw-r--r--src/newgrf_generic.h11
-rw-r--r--src/tree_cmd.cpp2
-rw-r--r--src/water_cmd.cpp2
5 files changed, 13 insertions, 6 deletions
diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp
index 7d89c311d..53b878939 100644
--- a/src/clear_cmd.cpp
+++ b/src/clear_cmd.cpp
@@ -259,7 +259,7 @@ static void TileLoop_Clear(TileIndex tile)
return;
}
}
- AmbientSoundEffectCallback(tile);
+ AmbientSoundEffect(tile);
switch (_settings_game.game_creation.landscape) {
case LT_TROPIC: TileLoopClearDesert(tile); break;
diff --git a/src/newgrf_generic.cpp b/src/newgrf_generic.cpp
index 7f85992c9..0b098a934 100644
--- a/src/newgrf_generic.cpp
+++ b/src/newgrf_generic.cpp
@@ -235,8 +235,6 @@ void AmbientSoundEffectCallback(TileIndex tile)
{
assert(IsTileType(tile, MP_CLEAR) || IsTileType(tile, MP_TREES) || IsTileType(tile, MP_WATER));
- /* Only run callback if enabled. */
- if (!HasGrfMiscBit(GMB_AMBIENT_SOUND_CALLBACK)) return;
/* Only run every 1/200-th time. */
uint32 r; // Save for later
if (!Chance16R(1, 200, r)) return;
diff --git a/src/newgrf_generic.h b/src/newgrf_generic.h
index ca245193e..c047a7b8b 100644
--- a/src/newgrf_generic.h
+++ b/src/newgrf_generic.h
@@ -51,6 +51,15 @@ void ResetGenericCallbacks();
void AddGenericCallback(uint8 feature, const GRFFile *file, const SpriteGroup *group);
uint16 GetAiPurchaseCallbackResult(uint8 feature, CargoID cargo_type, uint8 default_selection, IndustryType src_industry, IndustryType dst_industry, uint8 distance, AIConstructionEvent event, uint8 count, uint8 station_size, const GRFFile **file);
-void AmbientSoundEffectCallback(TileIndex tile);
+
+/** Play an ambient sound effect for an empty tile. */
+static inline void AmbientSoundEffect(TileIndex tile)
+{
+ /* Only run callback if enabled. */
+ if (!HasGrfMiscBit(GMB_AMBIENT_SOUND_CALLBACK)) return;
+
+ extern void AmbientSoundEffectCallback(TileIndex tile);
+ AmbientSoundEffectCallback(tile);
+}
#endif /* NEWGRF_GENERIC_H */
diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp
index 37886a944..81e590f41 100644
--- a/src/tree_cmd.cpp
+++ b/src/tree_cmd.cpp
@@ -627,7 +627,7 @@ static void TileLoop_Trees(TileIndex tile)
}
}
- AmbientSoundEffectCallback(tile);
+ AmbientSoundEffect(tile);
uint treeCounter = GetTreeCounter(tile);
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index bf1ec56c3..77a8129d1 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -1143,7 +1143,7 @@ static void DoDryUp(TileIndex tile)
*/
void TileLoop_Water(TileIndex tile)
{
- if (IsTileType(tile, MP_WATER)) AmbientSoundEffectCallback(tile);
+ if (IsTileType(tile, MP_WATER)) AmbientSoundEffect(tile);
switch (GetFloodingBehaviour(tile)) {
case FLOOD_ACTIVE: