File diff r15923:6550af31238a → r15924:f5bba173626e
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: