Changeset - r15924:f5bba173626e
[Not reviewed]
master
0 14 0
rubidium - 14 years ago 2010-08-26 14:45:45
rubidium@openttd.org
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
14 files changed with 83 insertions and 154 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -221,13 +221,13 @@ void Industry::PostDestructor(size_t ind
 

	
 

	
 
static void IndustryDrawSugarMine(const TileInfo *ti)
 
{
 
	if (!IsIndustryCompleted(ti->tile)) return;
 

	
 
	const DrawIndustryAnimationStruct *d = &_draw_industry_spec1[GetIndustryAnimationState(ti->tile)];
 
	const DrawIndustryAnimationStruct *d = &_draw_industry_spec1[GetAnimationFrame(ti->tile)];
 

	
 
	AddChildSpriteScreen(SPR_IT_SUGAR_MINE_SIEVE + d->image_1, PAL_NONE, d->x, 0);
 

	
 
	if (d->image_2 != 0) {
 
		AddChildSpriteScreen(SPR_IT_SUGAR_MINE_CLOUDS + d->image_2 - 1, PAL_NONE, 8, 41);
 
	}
 
@@ -240,34 +240,34 @@ static void IndustryDrawSugarMine(const 
 

	
 
static void IndustryDrawToffeeQuarry(const TileInfo *ti)
 
{
 
	uint8 x = 0;
 

	
 
	if (IsIndustryCompleted(ti->tile)) {
 
		x = _industry_anim_offs_toffee[GetIndustryAnimationState(ti->tile)];
 
		x = _industry_anim_offs_toffee[GetAnimationFrame(ti->tile)];
 
		if (x == 0xFF) {
 
			x = 0;
 
		}
 
	}
 

	
 
	AddChildSpriteScreen(SPR_IT_TOFFEE_QUARRY_SHOVEL, PAL_NONE, 22 - x, 24 + x);
 
	AddChildSpriteScreen(SPR_IT_TOFFEE_QUARRY_TOFFEE, PAL_NONE, 6, 14);
 
}
 

	
 
static void IndustryDrawBubbleGenerator( const TileInfo *ti)
 
{
 
	if (IsIndustryCompleted(ti->tile)) {
 
		AddChildSpriteScreen(SPR_IT_BUBBLE_GENERATOR_BUBBLE, PAL_NONE, 5, _industry_anim_offs_bubbles[GetIndustryAnimationState(ti->tile)]);
 
		AddChildSpriteScreen(SPR_IT_BUBBLE_GENERATOR_BUBBLE, PAL_NONE, 5, _industry_anim_offs_bubbles[GetAnimationFrame(ti->tile)]);
 
	} else {
 
		AddChildSpriteScreen(SPR_IT_BUBBLE_GENERATOR_SPRING, PAL_NONE, 3, 67);
 
	}
 
}
 

	
 
static void IndustryDrawToyFactory(const TileInfo *ti)
 
{
 
	const DrawIndustryAnimationStruct *d = &_industry_anim_offs_toys[GetIndustryAnimationState(ti->tile)];
 
	const DrawIndustryAnimationStruct *d = &_industry_anim_offs_toys[GetAnimationFrame(ti->tile)];
 

	
 
	if (d->image_1 != 0xFF) {
 
		AddChildSpriteScreen(SPR_IT_TOY_FACTORY_CLAY, PAL_NONE, d->x, 96 + d->image_1);
 
	}
 

	
 
	if (d->image_2 != 0xFF) {
 
@@ -278,13 +278,13 @@ static void IndustryDrawToyFactory(const
 
	AddChildSpriteScreen(SPR_IT_TOY_FACTORY_STAMP_HOLDER, PAL_NONE, 0, 42);
 
}
 

	
 
static void IndustryDrawCoalPlantSparks(const TileInfo *ti)
 
{
 
	if (IsIndustryCompleted(ti->tile)) {
 
		uint8 image = GetIndustryAnimationState(ti->tile);
 
		uint8 image = GetAnimationFrame(ti->tile);
 

	
 
		if (image != 0 && image < 7) {
 
			AddChildSpriteScreen(image + SPR_IT_POWER_PLANT_TRANSFORMERS,
 
				PAL_NONE,
 
				_coal_plant_sparks[image - 1].x,
 
				_coal_plant_sparks[image - 1].y
 
@@ -325,13 +325,13 @@ static void DrawTile_Industry(TileInfo *
 
				indts = GetIndustryTileSpec(gfx);
 
			}
 
		}
 
	}
 

	
 
	const DrawBuildingsTileStruct *dits = &_industry_draw_tile_data[gfx << 2 | (indts->anim_state ?
 
			GetIndustryAnimationState(ti->tile) & INDUSTRY_COMPLETED :
 
			GetAnimationFrame(ti->tile) & INDUSTRY_COMPLETED :
 
			GetIndustryConstructionStage(ti->tile))];
 

	
 
	SpriteID image = dits->ground.sprite;
 

	
 
	/* DrawFoundation() modifes ti->z and ti->tileh */
 
	if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED);
 
@@ -538,78 +538,78 @@ static void AnimateTile_Industry(TileInd
 
		return;
 
	}
 

	
 
	switch (gfx) {
 
	case GFX_SUGAR_MINE_SIEVE:
 
		if ((_tick_counter & 1) == 0) {
 
			byte m = GetIndustryAnimationState(tile) + 1;
 
			byte m = GetAnimationFrame(tile) + 1;
 

	
 
			switch (m & 7) {
 
			case 2: SndPlayTileFx(SND_2D_RIP_2, tile); break;
 
			case 6: SndPlayTileFx(SND_29_RIP, tile); break;
 
			}
 

	
 
			if (m >= 96) {
 
				m = 0;
 
				DeleteAnimatedTile(tile);
 
			}
 
			SetIndustryAnimationState(tile, m);
 
			SetAnimationFrame(tile, m);
 

	
 
			MarkTileDirtyByTile(tile);
 
		}
 
		break;
 

	
 
	case GFX_TOFFEE_QUARY:
 
		if ((_tick_counter & 3) == 0) {
 
			byte m = GetIndustryAnimationState(tile);
 
			byte m = GetAnimationFrame(tile);
 

	
 
			if (_industry_anim_offs_toffee[m] == 0xFF) {
 
				SndPlayTileFx(SND_30_CARTOON_SOUND, tile);
 
			}
 

	
 
			if (++m >= 70) {
 
				m = 0;
 
				DeleteAnimatedTile(tile);
 
			}
 
			SetIndustryAnimationState(tile, m);
 
			SetAnimationFrame(tile, m);
 

	
 
			MarkTileDirtyByTile(tile);
 
		}
 
		break;
 

	
 
	case GFX_BUBBLE_CATCHER:
 
		if ((_tick_counter & 1) == 0) {
 
			byte m = GetIndustryAnimationState(tile);
 
			byte m = GetAnimationFrame(tile);
 

	
 
			if (++m >= 40) {
 
				m = 0;
 
				DeleteAnimatedTile(tile);
 
			}
 
			SetIndustryAnimationState(tile, m);
 
			SetAnimationFrame(tile, m);
 

	
 
			MarkTileDirtyByTile(tile);
 
		}
 
		break;
 

	
 
	/* Sparks on a coal plant */
 
	case GFX_POWERPLANT_SPARKS:
 
		if ((_tick_counter & 3) == 0) {
 
			byte m = GetIndustryAnimationState(tile);
 
			byte m = GetAnimationFrame(tile);
 
			if (m == 6) {
 
				SetIndustryAnimationState(tile, 0);
 
				SetAnimationFrame(tile, 0);
 
				DeleteAnimatedTile(tile);
 
			} else {
 
				SetIndustryAnimationState(tile, m + 1);
 
				SetAnimationFrame(tile, m + 1);
 
				MarkTileDirtyByTile(tile);
 
			}
 
		}
 
		break;
 

	
 
	case GFX_TOY_FACTORY:
 
		if ((_tick_counter & 1) == 0) {
 
			byte m = GetIndustryAnimationState(tile) + 1;
 
			byte m = GetAnimationFrame(tile) + 1;
 

	
 
			switch (m) {
 
				case  1: SndPlayTileFx(SND_2C_MACHINERY, tile); break;
 
				case 23: SndPlayTileFx(SND_2B_COMEDY_HIT, tile); break;
 
				case 28: SndPlayTileFx(SND_2A_EXTRACT_AND_POP, tile); break;
 
				default:
 
@@ -621,13 +621,13 @@ static void AnimateTile_Industry(TileInd
 
							DeleteAnimatedTile(tile);
 
						}
 
						SetIndustryAnimationLoop(tile, n);
 
					}
 
			}
 

	
 
			SetIndustryAnimationState(tile, m);
 
			SetAnimationFrame(tile, m);
 
			MarkTileDirtyByTile(tile);
 
		}
 
		break;
 

	
 
	case GFX_PLASTIC_FOUNTAIN_ANIMATED_1: case GFX_PLASTIC_FOUNTAIN_ANIMATED_2:
 
	case GFX_PLASTIC_FOUNTAIN_ANIMATED_3: case GFX_PLASTIC_FOUNTAIN_ANIMATED_4:
 
@@ -646,19 +646,19 @@ static void AnimateTile_Industry(TileInd
 
	case GFX_OILWELL_ANIMATED_2:
 
	case GFX_OILWELL_ANIMATED_3:
 
		if ((_tick_counter & 7) == 0) {
 
			bool b = Chance16(1, 7);
 
			IndustryGfx gfx = GetIndustryGfx(tile);
 

	
 
			byte m = GetIndustryAnimationState(tile) + 1;
 
			byte m = GetAnimationFrame(tile) + 1;
 
			if (m == 4 && (m = 0, ++gfx) == GFX_OILWELL_ANIMATED_3 + 1 && (gfx = GFX_OILWELL_ANIMATED_1, b)) {
 
				SetIndustryGfx(tile, GFX_OILWELL_NOT_ANIMATED);
 
				SetIndustryConstructionStage(tile, 3);
 
				DeleteAnimatedTile(tile);
 
			} else {
 
				SetIndustryAnimationState(tile, m);
 
				SetAnimationFrame(tile, m);
 
				SetIndustryGfx(tile, gfx);
 
				MarkTileDirtyByTile(tile);
 
			}
 
		}
 
		break;
 

	
 
@@ -668,32 +668,32 @@ static void AnimateTile_Industry(TileInd
 
			int state = _tick_counter & 0x7FF;
 

	
 
			if ((state -= 0x400) < 0) return;
 

	
 
			if (state < 0x1A0) {
 
				if (state < 0x20 || state >= 0x180) {
 
					byte m = GetIndustryAnimationState(tile);
 
					byte m = GetAnimationFrame(tile);
 
					if (!(m & 0x40)) {
 
						SetIndustryAnimationState(tile, m | 0x40);
 
						SetAnimationFrame(tile, m | 0x40);
 
						SndPlayTileFx(SND_0B_MINING_MACHINERY, tile);
 
					}
 
					if (state & 7) return;
 
				} else {
 
					if (state & 3) return;
 
				}
 
				byte m = (GetIndustryAnimationState(tile) + 1) | 0x40;
 
				byte m = (GetAnimationFrame(tile) + 1) | 0x40;
 
				if (m > 0xC2) m = 0xC0;
 
				SetIndustryAnimationState(tile, m);
 
				SetAnimationFrame(tile, m);
 
				MarkTileDirtyByTile(tile);
 
			} else if (state >= 0x200 && state < 0x3A0) {
 
				int i = (state < 0x220 || state >= 0x380) ? 7 : 3;
 
				if (state & i) return;
 

	
 
				byte m = (GetIndustryAnimationState(tile) & 0xBF) - 1;
 
				byte m = (GetAnimationFrame(tile) & 0xBF) - 1;
 
				if (m < 0x80) m = 0x82;
 
				SetIndustryAnimationState(tile, m);
 
				SetAnimationFrame(tile, m);
 
				MarkTileDirtyByTile(tile);
 
			}
 
			break;
 
		}
 
	}
 
}
 
@@ -751,13 +751,13 @@ static void MakeIndustryTileBigger(TileI
 
		break;
 
	}
 

	
 
	case GFX_TOY_FACTORY:
 
	case GFX_BUBBLE_CATCHER:
 
	case GFX_TOFFEE_QUARY:
 
		SetIndustryAnimationState(tile, 0);
 
		SetAnimationFrame(tile, 0);
 
		SetIndustryAnimationLoop(tile, 0);
 
		break;
 

	
 
	case GFX_PLASTIC_FOUNTAIN_ANIMATED_1: case GFX_PLASTIC_FOUNTAIN_ANIMATED_2:
 
	case GFX_PLASTIC_FOUNTAIN_ANIMATED_3: case GFX_PLASTIC_FOUNTAIN_ANIMATED_4:
 
	case GFX_PLASTIC_FOUNTAIN_ANIMATED_5: case GFX_PLASTIC_FOUNTAIN_ANIMATED_6:
 
@@ -823,21 +823,21 @@ static void TileLoop_Industry(TileIndex 
 
			switch (gfx) {
 
				case GFX_COAL_MINE_TOWER_NOT_ANIMATED:   gfx = GFX_COAL_MINE_TOWER_ANIMATED;   break;
 
				case GFX_COPPER_MINE_TOWER_NOT_ANIMATED: gfx = GFX_COPPER_MINE_TOWER_ANIMATED; break;
 
				case GFX_GOLD_MINE_TOWER_NOT_ANIMATED:   gfx = GFX_GOLD_MINE_TOWER_ANIMATED;   break;
 
			}
 
			SetIndustryGfx(tile, gfx);
 
			SetIndustryAnimationState(tile, 0x80);
 
			SetAnimationFrame(tile, 0x80);
 
			AddAnimatedTile(tile);
 
		}
 
		break;
 

	
 
	case GFX_OILWELL_NOT_ANIMATED:
 
		if (Chance16(1, 6)) {
 
			SetIndustryGfx(tile, GFX_OILWELL_ANIMATED_1);
 
			SetIndustryAnimationState(tile, 0);
 
			SetAnimationFrame(tile, 0);
 
			AddAnimatedTile(tile);
 
		}
 
		break;
 

	
 
	case GFX_COAL_MINE_TOWER_ANIMATED:
 
	case GFX_COPPER_MINE_TOWER_ANIMATED:
src/industry_map.h
Show inline comments
 
@@ -226,35 +226,12 @@ static inline void SetIndustryAnimationL
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	_m[tile].m4 = count;
 
}
 

	
 
/**
 
 * Get the animation state
 
 * @param tile the tile to get the animation state of
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 */
 
static inline byte GetIndustryAnimationState(TileIndex tile)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	return _me[tile].m7;
 
}
 

	
 
/**
 
 * Set the animation state
 
 * @param tile the tile to set the animation state of
 
 * @param state the new animation state
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 */
 
static inline void SetIndustryAnimationState(TileIndex tile, byte state)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	_me[tile].m7 = state;
 
}
 

	
 
/**
 
 * Get the random bits for this tile.
 
 * Used for grf callbacks
 
 * @param tile TileIndex of the tile to query
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 * @return requested bits
 
 */
src/newgrf_airporttiles.cpp
Show inline comments
 
@@ -182,22 +182,22 @@ static uint32 AirportTileGetVariable(con
 
		case 0x42: return GetTownRadiusGroup(ClosestTownFromTile(tile, UINT_MAX), tile);
 

	
 
		/* Position relative to most northern airport tile. */
 
		case 0x43: return GetRelativePosition(tile, st->airport.tile);
 

	
 
		/* Animation frame of tile */
 
		case 0x44: return GetStationAnimationFrame(tile);
 
		case 0x44: return GetAnimationFrame(tile);
 

	
 
		/* Land info of nearby tiles */
 
		case 0x60: return GetNearbyAirportTileInformation(parameter, tile, st->index);
 

	
 
		/* Animation stage of nearby tiles */
 
		case 0x61:
 
			tile = GetNearbyTile(parameter, tile);
 
			if (st->TileBelongsToAirport(tile)) {
 
				return GetStationAnimationFrame(tile);
 
				return GetAnimationFrame(tile);
 
			}
 
			return UINT_MAX;
 

	
 
		/* Get airport tile ID at offset */
 
		case 0x62: return GetAirportTileIDAtOffset(GetNearbyTile(parameter, tile), st, object->grffile->grfid);
 
	}
 
@@ -319,13 +319,13 @@ void AnimateAirportTile(TileIndex tile)
 
	 * increasing this value by one doubles the wait. 0 is the minimum value
 
	 * allowed for animation_speed, which corresponds to 30ms, and 16 is the
 
	 * maximum, corresponding to around 33 minutes. */
 
	if ((_tick_counter % (1 << animation_speed)) != 0) return;
 

	
 
	bool frame_set_by_callback = false;
 
	uint8 frame      = GetStationAnimationFrame(tile);
 
	uint8 frame      = GetAnimationFrame(tile);
 
	uint16 num_frames = GB(ats->animation_info, 0, 8);
 

	
 
	if (HasBit(ats->callback_mask, CBM_AIRT_ANIM_NEXT_FRAME)) {
 
		uint16 callback_res = GetAirportTileCallback(CBID_AIRPTILE_ANIM_NEXT_FRAME, HasBit(ats->animation_special_flags, 0) ? Random() : 0, 0, gfx, st, tile);
 

	
 
		if (callback_res != CALLBACK_FAILED) {
 
@@ -359,13 +359,13 @@ void AnimateAirportTile(TileIndex tile)
 
		} else {
 
			/* This animation doesn't loop, so stay here */
 
			DeleteAnimatedTile(tile);
 
		}
 
	}
 

	
 
	SetStationAnimationFrame(tile, frame);
 
	SetAnimationFrame(tile, frame);
 
	MarkTileDirtyByTile(tile);
 
}
 

	
 
static void ChangeAirportTileAnimationFrame(const AirportTileSpec *ats, TileIndex tile, AirpAnimationTrigger trigger, StationGfx gfx, Station *st)
 
{
 
	uint16 callback_res = GetAirportTileCallback(CBID_AIRPTILE_ANIM_START_STOP, Random(), trigger, gfx, st, tile);
 
@@ -373,13 +373,13 @@ static void ChangeAirportTileAnimationFr
 

	
 
	switch (callback_res & 0xFF) {
 
		case 0xFD: /* Do nothing. */         break;
 
		case 0xFE: AddAnimatedTile(tile);    break;
 
		case 0xFF: DeleteAnimatedTile(tile); break;
 
		default:
 
			SetStationAnimationFrame(tile, callback_res & 0xFF);
 
			SetAnimationFrame(tile, callback_res & 0xFF);
 
			AddAnimatedTile(tile);
 
			break;
 
	}
 

	
 
	/* If the lower 7 bits of the upper byte of the callback
 
	 * result are not empty, it is a sound effect. */
src/newgrf_house.cpp
Show inline comments
 
@@ -283,13 +283,13 @@ static uint32 HouseGetVariable(const Res
 
		case 0x44: return GetNumHouses(house_id, town);
 

	
 
		/* Whether the town is being created or just expanded. */
 
		case 0x45: return _generating_world ? 1 : 0;
 

	
 
		/* Current animation frame. */
 
		case 0x46: return IsTileType(tile, MP_HOUSE) ? GetHouseAnimationFrame(tile) : 0;
 
		case 0x46: return IsTileType(tile, MP_HOUSE) ? GetAnimationFrame(tile) : 0;
 

	
 
		/* Position of the house */
 
		case 0x47: return TileY(tile) << 16 | TileX(tile);
 

	
 
		/* Building counts for old houses with id = parameter. */
 
		case 0x60: return GetNumHouses(parameter, town);
 
@@ -306,13 +306,13 @@ static uint32 HouseGetVariable(const Res
 
		/* Land info for nearby tiles. */
 
		case 0x62: return GetNearbyTileInformation(parameter, tile);
 

	
 
		/* Current animation frame of nearby house tiles */
 
		case 0x63: {
 
			TileIndex testtile = GetNearbyTile(parameter, tile);
 
			return IsTileType(testtile, MP_HOUSE) ? GetHouseAnimationFrame(testtile) : 0;
 
			return IsTileType(testtile, MP_HOUSE) ? GetAnimationFrame(testtile) : 0;
 
		}
 

	
 
		/* Cargo acceptance history of nearby stations */
 
		/*case 0x64: not implemented yet */
 

	
 
		/* Distance test for some house types */
 
@@ -485,13 +485,13 @@ void AnimateNewHouseTile(TileIndex tile)
 
	/* An animation speed of 2 means the animation frame changes 4 ticks, and
 
	 * increasing this value by one doubles the wait. 2 is the minimum value
 
	 * allowed for animation_speed, which corresponds to 120ms, and 16 is the
 
	 * maximum, corresponding to around 33 minutes. */
 
	if (_tick_counter % (1 << animation_speed) != 0) return;
 

	
 
	byte frame      = GetHouseAnimationFrame(tile);
 
	byte frame      = GetAnimationFrame(tile);
 
	byte num_frames = GB(hs->animation_frames, 0, 7);
 

	
 
	if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_NEXT_FRAME)) {
 
		uint32 param = (hs->extra_flags & CALLBACK_1A_RANDOM_BITS) ? Random() : 0;
 
		uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_NEXT_FRAME, param, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
 

	
 
@@ -526,24 +526,24 @@ void AnimateNewHouseTile(TileIndex tile)
 
		} else {
 
			/* This animation doesn't loop, so stay here */
 
			DeleteAnimatedTile(tile);
 
		}
 
	}
 

	
 
	SetHouseAnimationFrame(tile, frame);
 
	SetAnimationFrame(tile, frame);
 
	MarkTileDirtyByTile(tile);
 
}
 

	
 
void ChangeHouseAnimationFrame(const GRFFile *file, TileIndex tile, uint16 callback_result)
 
{
 
	switch (callback_result & 0xFF) {
 
		case 0xFD: /* Do nothing. */         break;
 
		case 0xFE: AddAnimatedTile(tile);    break;
 
		case 0xFF: DeleteAnimatedTile(tile); break;
 
		default:
 
			SetHouseAnimationFrame(tile, callback_result & 0xFF);
 
			SetAnimationFrame(tile, callback_result & 0xFF);
 
			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_result, 8, 7) != 0) PlayTileSound(file, GB(callback_result, 8, 7), tile);
src/newgrf_industries.cpp
Show inline comments
 
@@ -248,13 +248,13 @@ uint32 IndustryGetVariable(const Resolve
 
		case 0x62: return GetNearbyIndustryTileInformation(parameter, tile, INVALID_INDUSTRY);
 

	
 
		/* Animation stage of nearby tiles */
 
		case 0x63:
 
			tile = GetNearbyTile(parameter, tile);
 
			if (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == industry) {
 
				return GetIndustryAnimationState(tile);
 
				return GetAnimationFrame(tile);
 
			}
 
			return 0xFFFFFFFF;
 

	
 
		/* Distance of nearest industry of given type */
 
		case 0x64: return GetClosestIndustry(tile, MapNewGRFIndustryType(parameter, indspec->grf_prop.grffile->grfid), industry);
 
		/* Get town zone and Manhattan distance of closest town */
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -84,22 +84,22 @@ static uint32 IndustryTileGetVariable(co
 
		case 0x42: return GetTownRadiusGroup(ClosestTownFromTile(tile, UINT_MAX), tile);
 

	
 
		/* Relative position */
 
		case 0x43: return GetRelativePosition(tile, inds->location.tile);
 

	
 
		/* Animation frame. Like house variable 46 but can contain anything 0..FF. */
 
		case 0x44: return (IsTileType(tile, MP_INDUSTRY)) ? GetIndustryAnimationState(tile) : 0;
 
		case 0x44: return (IsTileType(tile, MP_INDUSTRY)) ? GetAnimationFrame(tile) : 0;
 

	
 
		/* Land info of nearby tiles */
 
		case 0x60: return GetNearbyIndustryTileInformation(parameter, tile, inds == NULL ? (IndustryID)INVALID_INDUSTRY : inds->index);
 

	
 
		/* Animation stage of nearby tiles */
 
		case 0x61:
 
			tile = GetNearbyTile(parameter, tile);
 
			if (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == inds) {
 
				return GetIndustryAnimationState(tile);
 
				return GetAnimationFrame(tile);
 
			}
 
			return UINT_MAX;
 

	
 
		/* Get industry tile ID at offset */
 
		case 0x62: return GetIndustryIDAtOffset(GetNearbyTile(parameter, tile), inds, object->grffile->grfid);
 
	}
 
@@ -313,13 +313,13 @@ void AnimateNewIndustryTile(TileIndex ti
 
	 * increasing this value by one doubles the wait. 0 is the minimum value
 
	 * allowed for animation_speed, which corresponds to 30ms, and 16 is the
 
	 * maximum, corresponding to around 33 minutes. */
 
	if ((_tick_counter % (1 << animation_speed)) != 0) return;
 

	
 
	bool frame_set_by_callback = false;
 
	byte frame = GetIndustryAnimationState(tile);
 
	byte frame = GetAnimationFrame(tile);
 
	uint16 num_frames = GB(itspec->animation_info, 0, 8);
 

	
 
	if (HasBit(itspec->callback_mask, CBM_INDT_ANIM_NEXT_FRAME)) {
 
		uint16 callback_res = GetIndustryTileCallback(CBID_INDTILE_ANIM_NEXT_FRAME,
 
				(itspec->special_flags & INDTILE_SPECIAL_NEXTFRAME_RANDOMBITS) ? Random() : 0, 0, gfx, ind, tile);
 

	
 
@@ -354,13 +354,13 @@ void AnimateNewIndustryTile(TileIndex ti
 
		} else {
 
			/* This animation doesn't loop, so stay here */
 
			DeleteAnimatedTile(tile);
 
		}
 
	}
 

	
 
	SetIndustryAnimationState(tile, frame);
 
	SetAnimationFrame(tile, frame);
 
	MarkTileDirtyByTile(tile);
 
}
 

	
 
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);
 
@@ -368,13 +368,13 @@ static void ChangeIndustryTileAnimationF
 

	
 
	switch (callback_res & 0xFF) {
 
		case 0xFD: /* Do nothing. */         break;
 
		case 0xFE: AddAnimatedTile(tile);    break;
 
		case 0xFF: DeleteAnimatedTile(tile); break;
 
		default:
 
			SetIndustryAnimationState(tile, callback_res & 0xFF);
 
			SetAnimationFrame(tile, callback_res & 0xFF);
 
			AddAnimatedTile(tile);
 
			break;
 
	}
 

	
 
	/* If the lower 7 bits of the upper byte of the callback
 
	 * result are not empty, it is a sound effect. */
src/newgrf_station.cpp
Show inline comments
 
@@ -322,19 +322,19 @@ static uint32 StationGetVariable(const R
 

	
 
		case 0x49:
 
			if (!HasBit(_svc.valid, 5)) { _svc.v49 = GetPlatformInfoHelper(tile, false, true, false); SetBit(_svc.valid, 5); }
 
			return _svc.v49;
 

	
 
		case 0x4A: // Animation frame of tile
 
			return GetStationAnimationFrame(tile);
 
			return GetAnimationFrame(tile);
 

	
 
		/* Variables which use the parameter */
 
		/* Variables 0x60 to 0x65 are handled separately below */
 
		case 0x66: // Animation frame of nearby tile
 
			if (parameter != 0) tile = GetNearbyTile(parameter, tile);
 
			return st->TileBelongsToRailStation(tile) ? GetStationAnimationFrame(tile) : UINT_MAX;
 
			return st->TileBelongsToRailStation(tile) ? GetAnimationFrame(tile) : UINT_MAX;
 

	
 
		case 0x67: { // Land info of nearby tile
 
			Axis axis = GetRailStationAxis(tile);
 

	
 
			if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required
 

	
 
@@ -824,13 +824,13 @@ void AnimateStationTile(TileIndex tile)
 
		uint16 callback = GetStationCallback(CBID_STATION_ANIMATION_SPEED, 0, 0, ss, st, tile);
 
		if (callback != CALLBACK_FAILED) animation_speed = Clamp(callback & 0xFF, 0, 16);
 
	}
 

	
 
	if (_tick_counter % (1 << animation_speed) != 0) return;
 

	
 
	uint8 frame      = GetStationAnimationFrame(tile);
 
	uint8 frame      = GetAnimationFrame(tile);
 
	uint8 num_frames = ss->anim_frames;
 

	
 
	bool frame_set_by_callback = false;
 

	
 
	if (HasBit(ss->callback_mask, CBM_STATION_ANIMATION_NEXT_FRAME)) {
 
		uint32 param = HasBit(ss->flags, SSF_CB141_RANDOM_BITS) ? Random() : 0;
 
@@ -868,13 +868,13 @@ void AnimateStationTile(TileIndex tile)
 
		} else {
 
			/* This animation doesn't loop, so stay here */
 
			DeleteAnimatedTile(tile);
 
		}
 
	}
 

	
 
	SetStationAnimationFrame(tile, frame);
 
	SetAnimationFrame(tile, frame);
 
	MarkTileDirtyByTile(tile);
 
}
 

	
 

	
 
static void ChangeStationAnimationFrame(const StationSpec *ss, const BaseStation *st, TileIndex tile, uint16 random_bits, StatAnimTrigger trigger, CargoID cargo_type)
 
{
 
@@ -883,13 +883,13 @@ static void ChangeStationAnimationFrame(
 

	
 
	switch (callback & 0xFF) {
 
		case 0xFD: /* Do nothing. */         break;
 
		case 0xFE: AddAnimatedTile(tile);    break;
 
		case 0xFF: DeleteAnimatedTile(tile); break;
 
		default:
 
			SetStationAnimationFrame(tile, callback);
 
			SetAnimationFrame(tile, callback);
 
			AddAnimatedTile(tile);
 
			break;
 
	}
 

	
 
	/* If the lower 7 bits of the upper byte of the callback
 
	 * result are not empty, it is a sound effect. */
src/object_cmd.cpp
Show inline comments
 
@@ -86,19 +86,19 @@ void BuildObject(ObjectType type, TileIn
 
 * @param tile The tile of the structure.
 
 */
 
static void IncreaseAnimationStage(TileIndex tile)
 
{
 
	TileArea ta = Object::GetByTile(tile)->location;
 
	TILE_AREA_LOOP(t, ta) {
 
		SetObjectAnimationStage(t, GetObjectAnimationStage(t) + 1);
 
		SetAnimationFrame(t, GetAnimationFrame(t) + 1);
 
		MarkTileDirtyByTile(t);
 
	}
 
}
 

	
 
/** We encode the company HQ size in the animation stage. */
 
#define GetCompanyHQSize GetObjectAnimationStage
 
#define GetCompanyHQSize GetAnimationFrame
 
/** We encode the company HQ size in the animation stage. */
 
#define IncreaseCompanyHQSize IncreaseAnimationStage
 

	
 
void UpdateCompanyHQ(TileIndex tile, uint score)
 
{
 
	if (tile == INVALID_TILE) return;
src/object_map.h
Show inline comments
 
@@ -103,36 +103,12 @@ static inline bool IsStatue(TileIndex t)
 
 */
 
static inline bool IsStatueTile(TileIndex t)
 
{
 
	return IsTileType(t, MP_OBJECT) && IsStatue(t);
 
}
 

	
 
/**
 
 * Get animation stage/counter of this tile.
 
 * @param t The tile to query.
 
 * @pre IsTileType(t, MP_OBJECT)
 
 * @return The animation 'stage' of the tile.
 
 */
 
static inline byte GetObjectAnimationStage(TileIndex t)
 
{
 
	assert(IsTileType(t, MP_OBJECT));
 
	return _me[t].m7;
 
}
 

	
 
/**
 
 * Set animation stage/counter of this tile.
 
 * @param t     The tile to query.
 
 * @param stage The stage of this tile.
 
 * @pre IsTileType(t, MP_OBJECT)
 
 */
 
static inline void SetObjectAnimationStage(TileIndex t, uint8 stage)
 
{
 
	assert(IsTileType(t, MP_OBJECT));
 
	_me[t].m7 = stage;
 
}
 

	
 

	
 
/**
 
 * Make an Object tile.
 
 * @note do not use this function directly. Use one of the other Make* functions.
 
 * @param t      The tile to make and object tile.
 
 * @param u      The object type of the tile.
src/saveload/afterload.cpp
Show inline comments
 
@@ -2173,13 +2173,13 @@ bool AfterLoadGame()
 
				for (uint i = 0; i < lengthof(atc); i++) {
 
					if (old_gfx < atc[i].old_start) {
 
						SetStationGfx(t, old_gfx - offset);
 
						break;
 
					}
 
					if (old_gfx < atc[i].old_start + atc[i].num_frames) {
 
						SetStationAnimationFrame(t, old_gfx - atc[i].old_start);
 
						SetAnimationFrame(t, old_gfx - atc[i].old_start);
 
						SetStationGfx(t, atc[i].old_start - offset);
 
						break;
 
					}
 
					offset += atc[i].num_frames - 1;
 
				}
 
			}
src/station_cmd.cpp
Show inline comments
 
@@ -1274,13 +1274,13 @@ CommandCost CmdBuildRailStation(TileInde
 
				MakeRailStation(tile, st->owner, st->index, axis, layout & ~1, rt);
 
				/* Free the spec if we overbuild something */
 
				DeallocateSpecFromStation(st, old_specindex);
 

	
 
				SetCustomStationSpecIndex(tile, specindex);
 
				SetStationTileRandomBits(tile, GB(Random(), 0, 4));
 
				SetStationAnimationFrame(tile, 0);
 
				SetAnimationFrame(tile, 0);
 

	
 
				if (statspec != NULL) {
 
					/* Use a fixed axis for GetPlatformInfo as our platforms / numtracks are always the right way around */
 
					uint32 platinfo = GetPlatformInfo(AXIS_X, 0, plat_len, numtracks_orig, plat_len - w, numtracks_orig - numtracks, false);
 

	
 
					/* As the station is not yet completely finished, the station does not yet exist. */
 
@@ -2575,25 +2575,25 @@ static void DrawTile_Station(TileInfo *t
 
			 * Use the substitute one instead */
 
			assert(ats->grf_prop.subst_id != INVALID_AIRPORTTILE);
 
			gfx = ats->grf_prop.subst_id;
 
		}
 
		switch (gfx) {
 
			case APT_RADAR_GRASS_FENCE_SW:
 
				t = &_station_display_datas_airport_radar_grass_fence_sw[GetStationAnimationFrame(ti->tile)];
 
				t = &_station_display_datas_airport_radar_grass_fence_sw[GetAnimationFrame(ti->tile)];
 
				break;
 
			case APT_GRASS_FENCE_NE_FLAG:
 
				t = &_station_display_datas_airport_flag_grass_fence_ne[GetStationAnimationFrame(ti->tile)];
 
				t = &_station_display_datas_airport_flag_grass_fence_ne[GetAnimationFrame(ti->tile)];
 
				break;
 
			case APT_RADAR_FENCE_SW:
 
				t = &_station_display_datas_airport_radar_fence_sw[GetStationAnimationFrame(ti->tile)];
 
				t = &_station_display_datas_airport_radar_fence_sw[GetAnimationFrame(ti->tile)];
 
				break;
 
			case APT_RADAR_FENCE_NE:
 
				t = &_station_display_datas_airport_radar_fence_ne[GetStationAnimationFrame(ti->tile)];
 
				t = &_station_display_datas_airport_radar_fence_ne[GetAnimationFrame(ti->tile)];
 
				break;
 
			case APT_GRASS_FENCE_NE_FLAG_2:
 
				t = &_station_display_datas_airport_flag_grass_fence_ne_2[GetStationAnimationFrame(ti->tile)];
 
				t = &_station_display_datas_airport_flag_grass_fence_ne_2[GetAnimationFrame(ti->tile)];
 
				break;
 
		}
 
	}
 

	
 
	Owner owner = GetTileOwner(ti->tile);
 

	
src/station_map.h
Show inline comments
 
@@ -82,36 +82,12 @@ static inline void SetStationGfx(TileInd
 
{
 
	assert(IsTileType(t, MP_STATION));
 
	_m[t].m5 = gfx;
 
}
 

	
 
/**
 
 * Get the station's animation frame of this tile
 
 * @param t the tile to query
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return the station's animation frame
 
 */
 
static inline uint8 GetStationAnimationFrame(TileIndex t)
 
{
 
	assert(IsTileType(t, MP_STATION));
 
	return _me[t].m7;
 
}
 

	
 
/**
 
 * Set the station's animation frame of this tile
 
 * @param t the tile to update
 
 * @param frame the new frame
 
 * @pre IsTileType(t, MP_STATION)
 
 */
 
static inline void SetStationAnimationFrame(TileIndex t, uint8 frame)
 
{
 
	assert(IsTileType(t, MP_STATION));
 
	_me[t].m7 = frame;
 
}
 

	
 
/**
 
 * Is this station tile a rail station?
 
 * @param t the tile to get the information from
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return true if and only if the tile is a rail station
 
 */
 
static inline bool IsRailStation(TileIndex t)
src/tile_map.h
Show inline comments
 
@@ -199,12 +199,36 @@ static inline void SetTropicZone(TileInd
 
static inline TropicZone GetTropicZone(TileIndex tile)
 
{
 
	assert(tile < MapSize());
 
	return (TropicZone)GB(_m[tile].m6, 0, 2);
 
}
 

	
 
/**
 
 * Get the current animation frame
 
 * @param t the tile
 
 * @pre IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION)
 
 * @return frame number
 
 */
 
static inline byte GetAnimationFrame(TileIndex t)
 
{
 
	assert(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION));
 
	return _me[t].m7;
 
}
 

	
 
/**
 
 * Set a new animation frame
 
 * @param t the tile
 
 * @param frame the new frame number
 
 * @pre IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION)
 
 */
 
static inline void SetAnimationFrame(TileIndex t, byte frame)
 
{
 
	assert(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION));
 
	_me[t].m7 = frame;
 
}
 

	
 
Slope GetTileSlope(TileIndex tile, uint *h);
 
uint GetTileZ(TileIndex tile);
 
uint GetTileMaxZ(TileIndex tile);
 

	
 

	
 
/**
src/town_map.h
Show inline comments
 
@@ -137,36 +137,12 @@ static inline byte GetLiftPosition(TileI
 
static inline void SetLiftPosition(TileIndex t, byte pos)
 
{
 
	SB(_m[t].m6, 2, 6, pos);
 
}
 

	
 
/**
 
 * Get the current animation frame for this house
 
 * @param t the tile
 
 * @pre IsTileType(t, MP_HOUSE)
 
 * @return frame number
 
 */
 
static inline byte GetHouseAnimationFrame(TileIndex t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	return _me[t].m7;
 
}
 

	
 
/**
 
 * Set a new animation frame for this house
 
 * @param t the tile
 
 * @param frame the new frame number
 
 * @pre IsTileType(t, MP_HOUSE)
 
 */
 
static inline void SetHouseAnimationFrame(TileIndex t, byte frame)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	_me[t].m7 = frame;
 
}
 

	
 
/**
 
 * Get the completion of this house
 
 * @param t the tile
 
 * @return true if it is, false if it is not
 
 */
 
static inline bool IsHouseCompleted(TileIndex t)
 
{
 
@@ -383,11 +359,11 @@ static inline void MakeHouseTile(TileInd
 
	_m[t].m1 = random_bits;
 
	_m[t].m2 = tid;
 
	_m[t].m3 = 0;
 
	SetHouseType(t, type);
 
	SetHouseCompleted(t, stage == TOWN_HOUSE_COMPLETED);
 
	_m[t].m5 = IsHouseCompleted(t) ? 0 : (stage << 3 | counter);
 
	SetHouseAnimationFrame(t, 0);
 
	SetAnimationFrame(t, 0);
 
	SetHouseProcessingTime(t, HouseSpec::Get(type)->processing_time);
 
}
 

	
 
#endif /* TOWN_MAP_H */
0 comments (0 inline, 0 general)