mirror of https://github.com/OpenTTD/OpenTTD
Codechange: split large function into smaller functions with self-explanatory names
parent
a409e4b026
commit
8cbf1be9d6
|
@ -554,19 +554,8 @@ static bool TransportIndustryGoods(TileIndex tile)
|
|||
return moved_cargo;
|
||||
}
|
||||
|
||||
|
||||
static void AnimateTile_Industry(TileIndex tile)
|
||||
static void AnimateSugarSieve(TileIndex tile)
|
||||
{
|
||||
IndustryGfx gfx = GetIndustryGfx(tile);
|
||||
|
||||
if (GetIndustryTileSpec(gfx)->animation.status != ANIM_STATUS_NO_ANIMATION) {
|
||||
AnimateNewIndustryTile(tile);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (gfx) {
|
||||
case GFX_SUGAR_MINE_SIEVE:
|
||||
if ((_tick_counter & 1) == 0) {
|
||||
byte m = GetAnimationFrame(tile) + 1;
|
||||
|
||||
if (_settings_client.sound.ambient) {
|
||||
|
@ -583,11 +572,10 @@ static void AnimateTile_Industry(TileIndex tile)
|
|||
SetAnimationFrame(tile, m);
|
||||
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case GFX_TOFFEE_QUARY:
|
||||
if ((_tick_counter & 3) == 0) {
|
||||
static void AnimateToffeeQuarry(TileIndex tile)
|
||||
{
|
||||
byte m = GetAnimationFrame(tile);
|
||||
|
||||
if (_industry_anim_offs_toffee[m] == 0xFF && _settings_client.sound.ambient) {
|
||||
|
@ -601,11 +589,10 @@ static void AnimateTile_Industry(TileIndex tile)
|
|||
SetAnimationFrame(tile, m);
|
||||
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case GFX_BUBBLE_CATCHER:
|
||||
if ((_tick_counter & 1) == 0) {
|
||||
static void AnimateBubbleCatcher(TileIndex tile)
|
||||
{
|
||||
byte m = GetAnimationFrame(tile);
|
||||
|
||||
if (++m >= 40) {
|
||||
|
@ -615,12 +602,10 @@ static void AnimateTile_Industry(TileIndex tile)
|
|||
SetAnimationFrame(tile, m);
|
||||
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Sparks on a coal plant */
|
||||
case GFX_POWERPLANT_SPARKS:
|
||||
if ((_tick_counter & 3) == 0) {
|
||||
static void AnimatePowerPlantSparks(TileIndex tile)
|
||||
{
|
||||
byte m = GetAnimationFrame(tile);
|
||||
if (m == 6) {
|
||||
SetAnimationFrame(tile, 0);
|
||||
|
@ -629,11 +614,10 @@ static void AnimateTile_Industry(TileIndex tile)
|
|||
SetAnimationFrame(tile, m + 1);
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case GFX_TOY_FACTORY:
|
||||
if ((_tick_counter & 1) == 0) {
|
||||
static void AnimateToyFactory(TileIndex tile)
|
||||
{
|
||||
byte m = GetAnimationFrame(tile) + 1;
|
||||
|
||||
switch (m) {
|
||||
|
@ -654,24 +638,17 @@ static void AnimateTile_Industry(TileIndex tile)
|
|||
|
||||
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:
|
||||
case GFX_PLASTIC_FOUNTAIN_ANIMATED_5: case GFX_PLASTIC_FOUNTAIN_ANIMATED_6:
|
||||
case GFX_PLASTIC_FOUNTAIN_ANIMATED_7: case GFX_PLASTIC_FOUNTAIN_ANIMATED_8:
|
||||
if ((_tick_counter & 3) == 0) {
|
||||
gfx = (gfx < 155) ? gfx + 1 : 148;
|
||||
static void AnimatePlasticFountain(TileIndex tile, IndustryGfx gfx)
|
||||
{
|
||||
gfx = (gfx < GFX_PLASTIC_FOUNTAIN_ANIMATED_8) ? gfx + 1 : GFX_PLASTIC_FOUNTAIN_ANIMATED_1;
|
||||
SetIndustryGfx(tile, gfx);
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case GFX_OILWELL_ANIMATED_1:
|
||||
case GFX_OILWELL_ANIMATED_2:
|
||||
case GFX_OILWELL_ANIMATED_3:
|
||||
if ((_tick_counter & 7) == 0) {
|
||||
static void AnimateOilWell(TileIndex tile, IndustryGfx gfx)
|
||||
{
|
||||
bool b = Chance16(1, 7);
|
||||
byte m = GetAnimationFrame(tile) + 1;
|
||||
if (m == 4 && (m = 0, ++gfx) == GFX_OILWELL_ANIMATED_3 + 1 && (gfx = GFX_OILWELL_ANIMATED_1, b)) {
|
||||
|
@ -683,12 +660,10 @@ static void AnimateTile_Industry(TileIndex tile)
|
|||
SetIndustryGfx(tile, gfx);
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case GFX_COAL_MINE_TOWER_ANIMATED:
|
||||
case GFX_COPPER_MINE_TOWER_ANIMATED:
|
||||
case GFX_GOLD_MINE_TOWER_ANIMATED: {
|
||||
static void AnimateMineTower(TileIndex tile)
|
||||
{
|
||||
int state = _tick_counter & 0x7FF;
|
||||
|
||||
if ((state -= 0x400) < 0) return;
|
||||
|
@ -717,8 +692,56 @@ static void AnimateTile_Industry(TileIndex tile)
|
|||
SetAnimationFrame(tile, m);
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
static void AnimateTile_Industry(TileIndex tile)
|
||||
{
|
||||
IndustryGfx gfx = GetIndustryGfx(tile);
|
||||
|
||||
if (GetIndustryTileSpec(gfx)->animation.status != ANIM_STATUS_NO_ANIMATION) {
|
||||
AnimateNewIndustryTile(tile);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (gfx) {
|
||||
case GFX_SUGAR_MINE_SIEVE:
|
||||
if ((_tick_counter & 1) == 0) AnimateSugarSieve(tile);
|
||||
break;
|
||||
|
||||
case GFX_TOFFEE_QUARY:
|
||||
if ((_tick_counter & 3) == 0) AnimateToffeeQuarry(tile);
|
||||
break;
|
||||
|
||||
case GFX_BUBBLE_CATCHER:
|
||||
if ((_tick_counter & 1) == 0) AnimateBubbleCatcher(tile);
|
||||
break;
|
||||
|
||||
case GFX_POWERPLANT_SPARKS:
|
||||
if ((_tick_counter & 3) == 0) AnimatePowerPlantSparks(tile);
|
||||
break;
|
||||
|
||||
case GFX_TOY_FACTORY:
|
||||
if ((_tick_counter & 1) == 0) AnimateToyFactory(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:
|
||||
case GFX_PLASTIC_FOUNTAIN_ANIMATED_5: case GFX_PLASTIC_FOUNTAIN_ANIMATED_6:
|
||||
case GFX_PLASTIC_FOUNTAIN_ANIMATED_7: case GFX_PLASTIC_FOUNTAIN_ANIMATED_8:
|
||||
if ((_tick_counter & 3) == 0) AnimatePlasticFountain(tile, gfx);
|
||||
break;
|
||||
|
||||
case GFX_OILWELL_ANIMATED_1:
|
||||
case GFX_OILWELL_ANIMATED_2:
|
||||
case GFX_OILWELL_ANIMATED_3:
|
||||
if ((_tick_counter & 7) == 0) AnimateOilWell(tile, gfx);
|
||||
break;
|
||||
|
||||
case GFX_COAL_MINE_TOWER_ANIMATED:
|
||||
case GFX_COPPER_MINE_TOWER_ANIMATED:
|
||||
case GFX_GOLD_MINE_TOWER_ANIMATED:
|
||||
AnimateMineTower(tile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3091,11 +3091,8 @@ static Foundation GetFoundation_Station(TileIndex tile, Slope tileh)
|
|||
return FlatteningFoundation(tileh);
|
||||
}
|
||||
|
||||
static void GetTileDesc_Station(TileIndex tile, TileDesc *td)
|
||||
static void FillTileDescRoadStop(TileIndex tile, TileDesc *td)
|
||||
{
|
||||
td->owner[0] = GetTileOwner(tile);
|
||||
|
||||
if (IsRoadStopTile(tile)) {
|
||||
RoadType road_rt = GetRoadTypeRoad(tile);
|
||||
RoadType tram_rt = GetRoadTypeTram(tile);
|
||||
Owner road_owner = INVALID_OWNER;
|
||||
|
@ -3130,11 +3127,10 @@ static void GetTileDesc_Station(TileIndex tile, TileDesc *td)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
td->build_date = BaseStation::GetByTile(tile)->build_date;
|
||||
|
||||
if (HasStationTileRail(tile)) {
|
||||
void FillTileDescRailStation(TileIndex tile, TileDesc *td)
|
||||
{
|
||||
const StationSpec *spec = GetStationSpec(tile);
|
||||
|
||||
if (spec != nullptr) {
|
||||
|
@ -3150,9 +3146,10 @@ static void GetTileDesc_Station(TileIndex tile, TileDesc *td)
|
|||
const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(tile));
|
||||
td->rail_speed = rti->max_speed;
|
||||
td->railtype = rti->strings.name;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsAirport(tile)) {
|
||||
void FillTileDescAirport(TileIndex tile, TileDesc *td)
|
||||
{
|
||||
const AirportSpec *as = Station::GetByTile(tile)->airport.GetSpec();
|
||||
td->airport_class = AirportClass::Get(as->cls_id)->name;
|
||||
td->airport_name = as->name;
|
||||
|
@ -3167,7 +3164,16 @@ static void GetTileDesc_Station(TileIndex tile, TileDesc *td)
|
|||
const GRFConfig *gc = GetGRFConfig(ats->grf_prop.grffile->grfid);
|
||||
td->grf = gc->GetName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void GetTileDesc_Station(TileIndex tile, TileDesc *td)
|
||||
{
|
||||
td->owner[0] = GetTileOwner(tile);
|
||||
td->build_date = BaseStation::GetByTile(tile)->build_date;
|
||||
|
||||
if (IsRoadStop(tile)) FillTileDescRoadStop(tile, td);
|
||||
if (HasStationRail(tile)) FillTileDescRailStation(tile, td);
|
||||
if (IsAirport(tile)) FillTileDescAirport(tile, td);
|
||||
|
||||
StringID str;
|
||||
switch (GetStationType(tile)) {
|
||||
|
|
Loading…
Reference in New Issue