Changeset - r18865:94e7c2925733
[Not reviewed]
master
0 5 0
yexo - 12 years ago 2012-01-03 00:45:22
yexo@openttd.org
(svn r23724) -Codechange: split of the check to see if ambient sounds are enabled to a header file allowing compilers to inline that check
5 files changed with 13 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/clear_cmd.cpp
Show inline comments
 
@@ -256,13 +256,13 @@ static void TileLoop_Clear(TileIndex til
 
		if (z == 0 && slope == SLOPE_FLAT) {
 
			DoFloodTile(tile);
 
			MarkTileDirtyByTile(tile);
 
			return;
 
		}
 
	}
 
	AmbientSoundEffectCallback(tile);
 
	AmbientSoundEffect(tile);
 

	
 
	switch (_settings_game.game_creation.landscape) {
 
		case LT_TROPIC: TileLoopClearDesert(tile); break;
 
		case LT_ARCTIC: TileLoopClearAlps(tile);   break;
 
	}
 

	
src/newgrf_generic.cpp
Show inline comments
 
@@ -232,14 +232,12 @@ uint16 GetAiPurchaseCallbackResult(uint8
 
 * @param tile Tile the sound effect should be generated for.
 
 */
 
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;
 

	
 
	ResolverObject object;
 

	
src/newgrf_generic.h
Show inline comments
 
@@ -48,9 +48,18 @@ static const IndustryType IT_AI_UNKNOWN 
 
static const IndustryType IT_AI_TOWN    = 0xFF; ///< The AI actually wants to transport to/from a town, not an industry.
 

	
 
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 */
src/tree_cmd.cpp
Show inline comments
 
@@ -624,13 +624,13 @@ static void TileLoop_Trees(TileIndex til
 
		switch (_settings_game.game_creation.landscape) {
 
			case LT_TROPIC: TileLoopTreesDesert(tile); break;
 
			case LT_ARCTIC: TileLoopTreesAlps(tile);   break;
 
		}
 
	}
 

	
 
	AmbientSoundEffectCallback(tile);
 
	AmbientSoundEffect(tile);
 

	
 
	uint treeCounter = GetTreeCounter(tile);
 

	
 
	/* Handle growth of grass (under trees/on MP_TREES tiles) at every 8th processings, like it's done for grass on MP_CLEAR tiles. */
 
	if ((treeCounter & 7) == 7 && GetTreeGround(tile) == TREE_GROUND_GRASS) {
 
		uint density = GetTreeDensity(tile);
src/water_cmd.cpp
Show inline comments
 
@@ -1140,13 +1140,13 @@ static void DoDryUp(TileIndex tile)
 
 * called from tunnelbridge_cmd, and by TileLoop_Industry() and TileLoop_Track()
 
 *
 
 * @param tile the water/shore tile that floods
 
 */
 
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:
 
			for (Direction dir = DIR_BEGIN; dir < DIR_END; dir++) {
 
				TileIndex dest = tile + TileOffsByDir(dir);
 
				if (!IsValidTile(dest)) continue;
0 comments (0 inline, 0 general)