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;
|
return moved_cargo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void AnimateSugarSieve(TileIndex tile)
|
||||||
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) {
|
|
||||||
byte m = GetAnimationFrame(tile) + 1;
|
byte m = GetAnimationFrame(tile) + 1;
|
||||||
|
|
||||||
if (_settings_client.sound.ambient) {
|
if (_settings_client.sound.ambient) {
|
||||||
|
@ -583,11 +572,10 @@ static void AnimateTile_Industry(TileIndex tile)
|
||||||
SetAnimationFrame(tile, m);
|
SetAnimationFrame(tile, m);
|
||||||
|
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case GFX_TOFFEE_QUARY:
|
static void AnimateToffeeQuarry(TileIndex tile)
|
||||||
if ((_tick_counter & 3) == 0) {
|
{
|
||||||
byte m = GetAnimationFrame(tile);
|
byte m = GetAnimationFrame(tile);
|
||||||
|
|
||||||
if (_industry_anim_offs_toffee[m] == 0xFF && _settings_client.sound.ambient) {
|
if (_industry_anim_offs_toffee[m] == 0xFF && _settings_client.sound.ambient) {
|
||||||
|
@ -601,11 +589,10 @@ static void AnimateTile_Industry(TileIndex tile)
|
||||||
SetAnimationFrame(tile, m);
|
SetAnimationFrame(tile, m);
|
||||||
|
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case GFX_BUBBLE_CATCHER:
|
static void AnimateBubbleCatcher(TileIndex tile)
|
||||||
if ((_tick_counter & 1) == 0) {
|
{
|
||||||
byte m = GetAnimationFrame(tile);
|
byte m = GetAnimationFrame(tile);
|
||||||
|
|
||||||
if (++m >= 40) {
|
if (++m >= 40) {
|
||||||
|
@ -615,12 +602,10 @@ static void AnimateTile_Industry(TileIndex tile)
|
||||||
SetAnimationFrame(tile, m);
|
SetAnimationFrame(tile, m);
|
||||||
|
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
/* Sparks on a coal plant */
|
static void AnimatePowerPlantSparks(TileIndex tile)
|
||||||
case GFX_POWERPLANT_SPARKS:
|
{
|
||||||
if ((_tick_counter & 3) == 0) {
|
|
||||||
byte m = GetAnimationFrame(tile);
|
byte m = GetAnimationFrame(tile);
|
||||||
if (m == 6) {
|
if (m == 6) {
|
||||||
SetAnimationFrame(tile, 0);
|
SetAnimationFrame(tile, 0);
|
||||||
|
@ -629,11 +614,10 @@ static void AnimateTile_Industry(TileIndex tile)
|
||||||
SetAnimationFrame(tile, m + 1);
|
SetAnimationFrame(tile, m + 1);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case GFX_TOY_FACTORY:
|
static void AnimateToyFactory(TileIndex tile)
|
||||||
if ((_tick_counter & 1) == 0) {
|
{
|
||||||
byte m = GetAnimationFrame(tile) + 1;
|
byte m = GetAnimationFrame(tile) + 1;
|
||||||
|
|
||||||
switch (m) {
|
switch (m) {
|
||||||
|
@ -654,24 +638,17 @@ static void AnimateTile_Industry(TileIndex tile)
|
||||||
|
|
||||||
SetAnimationFrame(tile, m);
|
SetAnimationFrame(tile, m);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case GFX_PLASTIC_FOUNTAIN_ANIMATED_1: case GFX_PLASTIC_FOUNTAIN_ANIMATED_2:
|
static void AnimatePlasticFountain(TileIndex tile, IndustryGfx gfx)
|
||||||
case GFX_PLASTIC_FOUNTAIN_ANIMATED_3: case GFX_PLASTIC_FOUNTAIN_ANIMATED_4:
|
{
|
||||||
case GFX_PLASTIC_FOUNTAIN_ANIMATED_5: case GFX_PLASTIC_FOUNTAIN_ANIMATED_6:
|
gfx = (gfx < GFX_PLASTIC_FOUNTAIN_ANIMATED_8) ? gfx + 1 : GFX_PLASTIC_FOUNTAIN_ANIMATED_1;
|
||||||
case GFX_PLASTIC_FOUNTAIN_ANIMATED_7: case GFX_PLASTIC_FOUNTAIN_ANIMATED_8:
|
|
||||||
if ((_tick_counter & 3) == 0) {
|
|
||||||
gfx = (gfx < 155) ? gfx + 1 : 148;
|
|
||||||
SetIndustryGfx(tile, gfx);
|
SetIndustryGfx(tile, gfx);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case GFX_OILWELL_ANIMATED_1:
|
static void AnimateOilWell(TileIndex tile, IndustryGfx gfx)
|
||||||
case GFX_OILWELL_ANIMATED_2:
|
{
|
||||||
case GFX_OILWELL_ANIMATED_3:
|
|
||||||
if ((_tick_counter & 7) == 0) {
|
|
||||||
bool b = Chance16(1, 7);
|
bool b = Chance16(1, 7);
|
||||||
byte m = GetAnimationFrame(tile) + 1;
|
byte m = GetAnimationFrame(tile) + 1;
|
||||||
if (m == 4 && (m = 0, ++gfx) == GFX_OILWELL_ANIMATED_3 + 1 && (gfx = GFX_OILWELL_ANIMATED_1, b)) {
|
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);
|
SetIndustryGfx(tile, gfx);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case GFX_COAL_MINE_TOWER_ANIMATED:
|
static void AnimateMineTower(TileIndex tile)
|
||||||
case GFX_COPPER_MINE_TOWER_ANIMATED:
|
{
|
||||||
case GFX_GOLD_MINE_TOWER_ANIMATED: {
|
|
||||||
int state = _tick_counter & 0x7FF;
|
int state = _tick_counter & 0x7FF;
|
||||||
|
|
||||||
if ((state -= 0x400) < 0) return;
|
if ((state -= 0x400) < 0) return;
|
||||||
|
@ -717,8 +692,56 @@ static void AnimateTile_Industry(TileIndex tile)
|
||||||
SetAnimationFrame(tile, m);
|
SetAnimationFrame(tile, m);
|
||||||
MarkTileDirtyByTile(tile);
|
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);
|
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 road_rt = GetRoadTypeRoad(tile);
|
||||||
RoadType tram_rt = GetRoadTypeTram(tile);
|
RoadType tram_rt = GetRoadTypeTram(tile);
|
||||||
Owner road_owner = INVALID_OWNER;
|
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;
|
void FillTileDescRailStation(TileIndex tile, TileDesc *td)
|
||||||
|
{
|
||||||
if (HasStationTileRail(tile)) {
|
|
||||||
const StationSpec *spec = GetStationSpec(tile);
|
const StationSpec *spec = GetStationSpec(tile);
|
||||||
|
|
||||||
if (spec != nullptr) {
|
if (spec != nullptr) {
|
||||||
|
@ -3150,9 +3146,10 @@ static void GetTileDesc_Station(TileIndex tile, TileDesc *td)
|
||||||
const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(tile));
|
const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(tile));
|
||||||
td->rail_speed = rti->max_speed;
|
td->rail_speed = rti->max_speed;
|
||||||
td->railtype = rti->strings.name;
|
td->railtype = rti->strings.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsAirport(tile)) {
|
void FillTileDescAirport(TileIndex tile, TileDesc *td)
|
||||||
|
{
|
||||||
const AirportSpec *as = Station::GetByTile(tile)->airport.GetSpec();
|
const AirportSpec *as = Station::GetByTile(tile)->airport.GetSpec();
|
||||||
td->airport_class = AirportClass::Get(as->cls_id)->name;
|
td->airport_class = AirportClass::Get(as->cls_id)->name;
|
||||||
td->airport_name = as->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);
|
const GRFConfig *gc = GetGRFConfig(ats->grf_prop.grffile->grfid);
|
||||||
td->grf = gc->GetName();
|
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;
|
StringID str;
|
||||||
switch (GetStationType(tile)) {
|
switch (GetStationType(tile)) {
|
||||||
|
|
Loading…
Reference in New Issue