mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
This commit is contained in:
parent
7f86dcca90
commit
4efa2efdbb
|
@ -224,7 +224,7 @@ static void IndustryDrawSugarMine(const TileInfo *ti)
|
||||||
{
|
{
|
||||||
if (!IsIndustryCompleted(ti->tile)) return;
|
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);
|
AddChildSpriteScreen(SPR_IT_SUGAR_MINE_SIEVE + d->image_1, PAL_NONE, d->x, 0);
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ static void IndustryDrawToffeeQuarry(const TileInfo *ti)
|
||||||
uint8 x = 0;
|
uint8 x = 0;
|
||||||
|
|
||||||
if (IsIndustryCompleted(ti->tile)) {
|
if (IsIndustryCompleted(ti->tile)) {
|
||||||
x = _industry_anim_offs_toffee[GetIndustryAnimationState(ti->tile)];
|
x = _industry_anim_offs_toffee[GetAnimationFrame(ti->tile)];
|
||||||
if (x == 0xFF) {
|
if (x == 0xFF) {
|
||||||
x = 0;
|
x = 0;
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ static void IndustryDrawToffeeQuarry(const TileInfo *ti)
|
||||||
static void IndustryDrawBubbleGenerator( const TileInfo *ti)
|
static void IndustryDrawBubbleGenerator( const TileInfo *ti)
|
||||||
{
|
{
|
||||||
if (IsIndustryCompleted(ti->tile)) {
|
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 {
|
} else {
|
||||||
AddChildSpriteScreen(SPR_IT_BUBBLE_GENERATOR_SPRING, PAL_NONE, 3, 67);
|
AddChildSpriteScreen(SPR_IT_BUBBLE_GENERATOR_SPRING, PAL_NONE, 3, 67);
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ static void IndustryDrawBubbleGenerator( const TileInfo *ti)
|
||||||
|
|
||||||
static void IndustryDrawToyFactory(const TileInfo *ti)
|
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) {
|
if (d->image_1 != 0xFF) {
|
||||||
AddChildSpriteScreen(SPR_IT_TOY_FACTORY_CLAY, PAL_NONE, d->x, 96 + d->image_1);
|
AddChildSpriteScreen(SPR_IT_TOY_FACTORY_CLAY, PAL_NONE, d->x, 96 + d->image_1);
|
||||||
|
@ -281,7 +281,7 @@ static void IndustryDrawToyFactory(const TileInfo *ti)
|
||||||
static void IndustryDrawCoalPlantSparks(const TileInfo *ti)
|
static void IndustryDrawCoalPlantSparks(const TileInfo *ti)
|
||||||
{
|
{
|
||||||
if (IsIndustryCompleted(ti->tile)) {
|
if (IsIndustryCompleted(ti->tile)) {
|
||||||
uint8 image = GetIndustryAnimationState(ti->tile);
|
uint8 image = GetAnimationFrame(ti->tile);
|
||||||
|
|
||||||
if (image != 0 && image < 7) {
|
if (image != 0 && image < 7) {
|
||||||
AddChildSpriteScreen(image + SPR_IT_POWER_PLANT_TRANSFORMERS,
|
AddChildSpriteScreen(image + SPR_IT_POWER_PLANT_TRANSFORMERS,
|
||||||
|
@ -328,7 +328,7 @@ static void DrawTile_Industry(TileInfo *ti)
|
||||||
}
|
}
|
||||||
|
|
||||||
const DrawBuildingsTileStruct *dits = &_industry_draw_tile_data[gfx << 2 | (indts->anim_state ?
|
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))];
|
GetIndustryConstructionStage(ti->tile))];
|
||||||
|
|
||||||
SpriteID image = dits->ground.sprite;
|
SpriteID image = dits->ground.sprite;
|
||||||
|
@ -541,7 +541,7 @@ static void AnimateTile_Industry(TileIndex tile)
|
||||||
switch (gfx) {
|
switch (gfx) {
|
||||||
case GFX_SUGAR_MINE_SIEVE:
|
case GFX_SUGAR_MINE_SIEVE:
|
||||||
if ((_tick_counter & 1) == 0) {
|
if ((_tick_counter & 1) == 0) {
|
||||||
byte m = GetIndustryAnimationState(tile) + 1;
|
byte m = GetAnimationFrame(tile) + 1;
|
||||||
|
|
||||||
switch (m & 7) {
|
switch (m & 7) {
|
||||||
case 2: SndPlayTileFx(SND_2D_RIP_2, tile); break;
|
case 2: SndPlayTileFx(SND_2D_RIP_2, tile); break;
|
||||||
|
@ -552,7 +552,7 @@ static void AnimateTile_Industry(TileIndex tile)
|
||||||
m = 0;
|
m = 0;
|
||||||
DeleteAnimatedTile(tile);
|
DeleteAnimatedTile(tile);
|
||||||
}
|
}
|
||||||
SetIndustryAnimationState(tile, m);
|
SetAnimationFrame(tile, m);
|
||||||
|
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
|
@ -560,7 +560,7 @@ static void AnimateTile_Industry(TileIndex tile)
|
||||||
|
|
||||||
case GFX_TOFFEE_QUARY:
|
case GFX_TOFFEE_QUARY:
|
||||||
if ((_tick_counter & 3) == 0) {
|
if ((_tick_counter & 3) == 0) {
|
||||||
byte m = GetIndustryAnimationState(tile);
|
byte m = GetAnimationFrame(tile);
|
||||||
|
|
||||||
if (_industry_anim_offs_toffee[m] == 0xFF) {
|
if (_industry_anim_offs_toffee[m] == 0xFF) {
|
||||||
SndPlayTileFx(SND_30_CARTOON_SOUND, tile);
|
SndPlayTileFx(SND_30_CARTOON_SOUND, tile);
|
||||||
|
@ -570,7 +570,7 @@ static void AnimateTile_Industry(TileIndex tile)
|
||||||
m = 0;
|
m = 0;
|
||||||
DeleteAnimatedTile(tile);
|
DeleteAnimatedTile(tile);
|
||||||
}
|
}
|
||||||
SetIndustryAnimationState(tile, m);
|
SetAnimationFrame(tile, m);
|
||||||
|
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
|
@ -578,13 +578,13 @@ static void AnimateTile_Industry(TileIndex tile)
|
||||||
|
|
||||||
case GFX_BUBBLE_CATCHER:
|
case GFX_BUBBLE_CATCHER:
|
||||||
if ((_tick_counter & 1) == 0) {
|
if ((_tick_counter & 1) == 0) {
|
||||||
byte m = GetIndustryAnimationState(tile);
|
byte m = GetAnimationFrame(tile);
|
||||||
|
|
||||||
if (++m >= 40) {
|
if (++m >= 40) {
|
||||||
m = 0;
|
m = 0;
|
||||||
DeleteAnimatedTile(tile);
|
DeleteAnimatedTile(tile);
|
||||||
}
|
}
|
||||||
SetIndustryAnimationState(tile, m);
|
SetAnimationFrame(tile, m);
|
||||||
|
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
|
@ -593,12 +593,12 @@ static void AnimateTile_Industry(TileIndex tile)
|
||||||
/* Sparks on a coal plant */
|
/* Sparks on a coal plant */
|
||||||
case GFX_POWERPLANT_SPARKS:
|
case GFX_POWERPLANT_SPARKS:
|
||||||
if ((_tick_counter & 3) == 0) {
|
if ((_tick_counter & 3) == 0) {
|
||||||
byte m = GetIndustryAnimationState(tile);
|
byte m = GetAnimationFrame(tile);
|
||||||
if (m == 6) {
|
if (m == 6) {
|
||||||
SetIndustryAnimationState(tile, 0);
|
SetAnimationFrame(tile, 0);
|
||||||
DeleteAnimatedTile(tile);
|
DeleteAnimatedTile(tile);
|
||||||
} else {
|
} else {
|
||||||
SetIndustryAnimationState(tile, m + 1);
|
SetAnimationFrame(tile, m + 1);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -606,7 +606,7 @@ static void AnimateTile_Industry(TileIndex tile)
|
||||||
|
|
||||||
case GFX_TOY_FACTORY:
|
case GFX_TOY_FACTORY:
|
||||||
if ((_tick_counter & 1) == 0) {
|
if ((_tick_counter & 1) == 0) {
|
||||||
byte m = GetIndustryAnimationState(tile) + 1;
|
byte m = GetAnimationFrame(tile) + 1;
|
||||||
|
|
||||||
switch (m) {
|
switch (m) {
|
||||||
case 1: SndPlayTileFx(SND_2C_MACHINERY, tile); break;
|
case 1: SndPlayTileFx(SND_2C_MACHINERY, tile); break;
|
||||||
|
@ -624,7 +624,7 @@ static void AnimateTile_Industry(TileIndex tile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetIndustryAnimationState(tile, m);
|
SetAnimationFrame(tile, m);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -649,13 +649,13 @@ static void AnimateTile_Industry(TileIndex tile)
|
||||||
bool b = Chance16(1, 7);
|
bool b = Chance16(1, 7);
|
||||||
IndustryGfx gfx = GetIndustryGfx(tile);
|
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)) {
|
if (m == 4 && (m = 0, ++gfx) == GFX_OILWELL_ANIMATED_3 + 1 && (gfx = GFX_OILWELL_ANIMATED_1, b)) {
|
||||||
SetIndustryGfx(tile, GFX_OILWELL_NOT_ANIMATED);
|
SetIndustryGfx(tile, GFX_OILWELL_NOT_ANIMATED);
|
||||||
SetIndustryConstructionStage(tile, 3);
|
SetIndustryConstructionStage(tile, 3);
|
||||||
DeleteAnimatedTile(tile);
|
DeleteAnimatedTile(tile);
|
||||||
} else {
|
} else {
|
||||||
SetIndustryAnimationState(tile, m);
|
SetAnimationFrame(tile, m);
|
||||||
SetIndustryGfx(tile, gfx);
|
SetIndustryGfx(tile, gfx);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
|
@ -671,26 +671,26 @@ static void AnimateTile_Industry(TileIndex tile)
|
||||||
|
|
||||||
if (state < 0x1A0) {
|
if (state < 0x1A0) {
|
||||||
if (state < 0x20 || state >= 0x180) {
|
if (state < 0x20 || state >= 0x180) {
|
||||||
byte m = GetIndustryAnimationState(tile);
|
byte m = GetAnimationFrame(tile);
|
||||||
if (!(m & 0x40)) {
|
if (!(m & 0x40)) {
|
||||||
SetIndustryAnimationState(tile, m | 0x40);
|
SetAnimationFrame(tile, m | 0x40);
|
||||||
SndPlayTileFx(SND_0B_MINING_MACHINERY, tile);
|
SndPlayTileFx(SND_0B_MINING_MACHINERY, tile);
|
||||||
}
|
}
|
||||||
if (state & 7) return;
|
if (state & 7) return;
|
||||||
} else {
|
} else {
|
||||||
if (state & 3) return;
|
if (state & 3) return;
|
||||||
}
|
}
|
||||||
byte m = (GetIndustryAnimationState(tile) + 1) | 0x40;
|
byte m = (GetAnimationFrame(tile) + 1) | 0x40;
|
||||||
if (m > 0xC2) m = 0xC0;
|
if (m > 0xC2) m = 0xC0;
|
||||||
SetIndustryAnimationState(tile, m);
|
SetAnimationFrame(tile, m);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
} else if (state >= 0x200 && state < 0x3A0) {
|
} else if (state >= 0x200 && state < 0x3A0) {
|
||||||
int i = (state < 0x220 || state >= 0x380) ? 7 : 3;
|
int i = (state < 0x220 || state >= 0x380) ? 7 : 3;
|
||||||
if (state & i) return;
|
if (state & i) return;
|
||||||
|
|
||||||
byte m = (GetIndustryAnimationState(tile) & 0xBF) - 1;
|
byte m = (GetAnimationFrame(tile) & 0xBF) - 1;
|
||||||
if (m < 0x80) m = 0x82;
|
if (m < 0x80) m = 0x82;
|
||||||
SetIndustryAnimationState(tile, m);
|
SetAnimationFrame(tile, m);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -754,7 +754,7 @@ static void MakeIndustryTileBigger(TileIndex tile)
|
||||||
case GFX_TOY_FACTORY:
|
case GFX_TOY_FACTORY:
|
||||||
case GFX_BUBBLE_CATCHER:
|
case GFX_BUBBLE_CATCHER:
|
||||||
case GFX_TOFFEE_QUARY:
|
case GFX_TOFFEE_QUARY:
|
||||||
SetIndustryAnimationState(tile, 0);
|
SetAnimationFrame(tile, 0);
|
||||||
SetIndustryAnimationLoop(tile, 0);
|
SetIndustryAnimationLoop(tile, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -826,7 +826,7 @@ static void TileLoop_Industry(TileIndex tile)
|
||||||
case GFX_GOLD_MINE_TOWER_NOT_ANIMATED: gfx = GFX_GOLD_MINE_TOWER_ANIMATED; break;
|
case GFX_GOLD_MINE_TOWER_NOT_ANIMATED: gfx = GFX_GOLD_MINE_TOWER_ANIMATED; break;
|
||||||
}
|
}
|
||||||
SetIndustryGfx(tile, gfx);
|
SetIndustryGfx(tile, gfx);
|
||||||
SetIndustryAnimationState(tile, 0x80);
|
SetAnimationFrame(tile, 0x80);
|
||||||
AddAnimatedTile(tile);
|
AddAnimatedTile(tile);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -834,7 +834,7 @@ static void TileLoop_Industry(TileIndex tile)
|
||||||
case GFX_OILWELL_NOT_ANIMATED:
|
case GFX_OILWELL_NOT_ANIMATED:
|
||||||
if (Chance16(1, 6)) {
|
if (Chance16(1, 6)) {
|
||||||
SetIndustryGfx(tile, GFX_OILWELL_ANIMATED_1);
|
SetIndustryGfx(tile, GFX_OILWELL_ANIMATED_1);
|
||||||
SetIndustryAnimationState(tile, 0);
|
SetAnimationFrame(tile, 0);
|
||||||
AddAnimatedTile(tile);
|
AddAnimatedTile(tile);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -228,29 +228,6 @@ static inline void SetIndustryAnimationLoop(TileIndex tile, byte count)
|
||||||
_m[tile].m4 = count;
|
_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.
|
* Get the random bits for this tile.
|
||||||
* Used for grf callbacks
|
* Used for grf callbacks
|
||||||
|
|
|
@ -185,7 +185,7 @@ static uint32 AirportTileGetVariable(const ResolverObject *object, byte variable
|
||||||
case 0x43: return GetRelativePosition(tile, st->airport.tile);
|
case 0x43: return GetRelativePosition(tile, st->airport.tile);
|
||||||
|
|
||||||
/* Animation frame of tile */
|
/* Animation frame of tile */
|
||||||
case 0x44: return GetStationAnimationFrame(tile);
|
case 0x44: return GetAnimationFrame(tile);
|
||||||
|
|
||||||
/* Land info of nearby tiles */
|
/* Land info of nearby tiles */
|
||||||
case 0x60: return GetNearbyAirportTileInformation(parameter, tile, st->index);
|
case 0x60: return GetNearbyAirportTileInformation(parameter, tile, st->index);
|
||||||
|
@ -194,7 +194,7 @@ static uint32 AirportTileGetVariable(const ResolverObject *object, byte variable
|
||||||
case 0x61:
|
case 0x61:
|
||||||
tile = GetNearbyTile(parameter, tile);
|
tile = GetNearbyTile(parameter, tile);
|
||||||
if (st->TileBelongsToAirport(tile)) {
|
if (st->TileBelongsToAirport(tile)) {
|
||||||
return GetStationAnimationFrame(tile);
|
return GetAnimationFrame(tile);
|
||||||
}
|
}
|
||||||
return UINT_MAX;
|
return UINT_MAX;
|
||||||
|
|
||||||
|
@ -322,7 +322,7 @@ void AnimateAirportTile(TileIndex tile)
|
||||||
if ((_tick_counter % (1 << animation_speed)) != 0) return;
|
if ((_tick_counter % (1 << animation_speed)) != 0) return;
|
||||||
|
|
||||||
bool frame_set_by_callback = false;
|
bool frame_set_by_callback = false;
|
||||||
uint8 frame = GetStationAnimationFrame(tile);
|
uint8 frame = GetAnimationFrame(tile);
|
||||||
uint16 num_frames = GB(ats->animation_info, 0, 8);
|
uint16 num_frames = GB(ats->animation_info, 0, 8);
|
||||||
|
|
||||||
if (HasBit(ats->callback_mask, CBM_AIRT_ANIM_NEXT_FRAME)) {
|
if (HasBit(ats->callback_mask, CBM_AIRT_ANIM_NEXT_FRAME)) {
|
||||||
|
@ -362,7 +362,7 @@ void AnimateAirportTile(TileIndex tile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetStationAnimationFrame(tile, frame);
|
SetAnimationFrame(tile, frame);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,7 +376,7 @@ static void ChangeAirportTileAnimationFrame(const AirportTileSpec *ats, TileInde
|
||||||
case 0xFE: AddAnimatedTile(tile); break;
|
case 0xFE: AddAnimatedTile(tile); break;
|
||||||
case 0xFF: DeleteAnimatedTile(tile); break;
|
case 0xFF: DeleteAnimatedTile(tile); break;
|
||||||
default:
|
default:
|
||||||
SetStationAnimationFrame(tile, callback_res & 0xFF);
|
SetAnimationFrame(tile, callback_res & 0xFF);
|
||||||
AddAnimatedTile(tile);
|
AddAnimatedTile(tile);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -286,7 +286,7 @@ static uint32 HouseGetVariable(const ResolverObject *object, byte variable, byte
|
||||||
case 0x45: return _generating_world ? 1 : 0;
|
case 0x45: return _generating_world ? 1 : 0;
|
||||||
|
|
||||||
/* Current animation frame. */
|
/* 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 */
|
/* Position of the house */
|
||||||
case 0x47: return TileY(tile) << 16 | TileX(tile);
|
case 0x47: return TileY(tile) << 16 | TileX(tile);
|
||||||
|
@ -309,7 +309,7 @@ static uint32 HouseGetVariable(const ResolverObject *object, byte variable, byte
|
||||||
/* Current animation frame of nearby house tiles */
|
/* Current animation frame of nearby house tiles */
|
||||||
case 0x63: {
|
case 0x63: {
|
||||||
TileIndex testtile = GetNearbyTile(parameter, tile);
|
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 */
|
/* Cargo acceptance history of nearby stations */
|
||||||
|
@ -488,7 +488,7 @@ void AnimateNewHouseTile(TileIndex tile)
|
||||||
* maximum, corresponding to around 33 minutes. */
|
* maximum, corresponding to around 33 minutes. */
|
||||||
if (_tick_counter % (1 << animation_speed) != 0) return;
|
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);
|
byte num_frames = GB(hs->animation_frames, 0, 7);
|
||||||
|
|
||||||
if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_NEXT_FRAME)) {
|
if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_NEXT_FRAME)) {
|
||||||
|
@ -529,7 +529,7 @@ void AnimateNewHouseTile(TileIndex tile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetHouseAnimationFrame(tile, frame);
|
SetAnimationFrame(tile, frame);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,7 +540,7 @@ void ChangeHouseAnimationFrame(const GRFFile *file, TileIndex tile, uint16 callb
|
||||||
case 0xFE: AddAnimatedTile(tile); break;
|
case 0xFE: AddAnimatedTile(tile); break;
|
||||||
case 0xFF: DeleteAnimatedTile(tile); break;
|
case 0xFF: DeleteAnimatedTile(tile); break;
|
||||||
default:
|
default:
|
||||||
SetHouseAnimationFrame(tile, callback_result & 0xFF);
|
SetAnimationFrame(tile, callback_result & 0xFF);
|
||||||
AddAnimatedTile(tile);
|
AddAnimatedTile(tile);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,7 +251,7 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte par
|
||||||
case 0x63:
|
case 0x63:
|
||||||
tile = GetNearbyTile(parameter, tile);
|
tile = GetNearbyTile(parameter, tile);
|
||||||
if (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == industry) {
|
if (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == industry) {
|
||||||
return GetIndustryAnimationState(tile);
|
return GetAnimationFrame(tile);
|
||||||
}
|
}
|
||||||
return 0xFFFFFFFF;
|
return 0xFFFFFFFF;
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ static uint32 IndustryTileGetVariable(const ResolverObject *object, byte variabl
|
||||||
case 0x43: return GetRelativePosition(tile, inds->location.tile);
|
case 0x43: return GetRelativePosition(tile, inds->location.tile);
|
||||||
|
|
||||||
/* Animation frame. Like house variable 46 but can contain anything 0..FF. */
|
/* 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 */
|
/* Land info of nearby tiles */
|
||||||
case 0x60: return GetNearbyIndustryTileInformation(parameter, tile, inds == NULL ? (IndustryID)INVALID_INDUSTRY : inds->index);
|
case 0x60: return GetNearbyIndustryTileInformation(parameter, tile, inds == NULL ? (IndustryID)INVALID_INDUSTRY : inds->index);
|
||||||
|
@ -96,7 +96,7 @@ static uint32 IndustryTileGetVariable(const ResolverObject *object, byte variabl
|
||||||
case 0x61:
|
case 0x61:
|
||||||
tile = GetNearbyTile(parameter, tile);
|
tile = GetNearbyTile(parameter, tile);
|
||||||
if (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == inds) {
|
if (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == inds) {
|
||||||
return GetIndustryAnimationState(tile);
|
return GetAnimationFrame(tile);
|
||||||
}
|
}
|
||||||
return UINT_MAX;
|
return UINT_MAX;
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ void AnimateNewIndustryTile(TileIndex tile)
|
||||||
if ((_tick_counter % (1 << animation_speed)) != 0) return;
|
if ((_tick_counter % (1 << animation_speed)) != 0) return;
|
||||||
|
|
||||||
bool frame_set_by_callback = false;
|
bool frame_set_by_callback = false;
|
||||||
byte frame = GetIndustryAnimationState(tile);
|
byte frame = GetAnimationFrame(tile);
|
||||||
uint16 num_frames = GB(itspec->animation_info, 0, 8);
|
uint16 num_frames = GB(itspec->animation_info, 0, 8);
|
||||||
|
|
||||||
if (HasBit(itspec->callback_mask, CBM_INDT_ANIM_NEXT_FRAME)) {
|
if (HasBit(itspec->callback_mask, CBM_INDT_ANIM_NEXT_FRAME)) {
|
||||||
|
@ -357,7 +357,7 @@ void AnimateNewIndustryTile(TileIndex tile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetIndustryAnimationState(tile, frame);
|
SetAnimationFrame(tile, frame);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,7 +371,7 @@ static void ChangeIndustryTileAnimationFrame(const IndustryTileSpec *itspec, Til
|
||||||
case 0xFE: AddAnimatedTile(tile); break;
|
case 0xFE: AddAnimatedTile(tile); break;
|
||||||
case 0xFF: DeleteAnimatedTile(tile); break;
|
case 0xFF: DeleteAnimatedTile(tile); break;
|
||||||
default:
|
default:
|
||||||
SetIndustryAnimationState(tile, callback_res & 0xFF);
|
SetAnimationFrame(tile, callback_res & 0xFF);
|
||||||
AddAnimatedTile(tile);
|
AddAnimatedTile(tile);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -325,13 +325,13 @@ static uint32 StationGetVariable(const ResolverObject *object, byte variable, by
|
||||||
return _svc.v49;
|
return _svc.v49;
|
||||||
|
|
||||||
case 0x4A: // Animation frame of tile
|
case 0x4A: // Animation frame of tile
|
||||||
return GetStationAnimationFrame(tile);
|
return GetAnimationFrame(tile);
|
||||||
|
|
||||||
/* Variables which use the parameter */
|
/* Variables which use the parameter */
|
||||||
/* Variables 0x60 to 0x65 are handled separately below */
|
/* Variables 0x60 to 0x65 are handled separately below */
|
||||||
case 0x66: // Animation frame of nearby tile
|
case 0x66: // Animation frame of nearby tile
|
||||||
if (parameter != 0) tile = GetNearbyTile(parameter, 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
|
case 0x67: { // Land info of nearby tile
|
||||||
Axis axis = GetRailStationAxis(tile);
|
Axis axis = GetRailStationAxis(tile);
|
||||||
|
@ -827,7 +827,7 @@ void AnimateStationTile(TileIndex tile)
|
||||||
|
|
||||||
if (_tick_counter % (1 << animation_speed) != 0) return;
|
if (_tick_counter % (1 << animation_speed) != 0) return;
|
||||||
|
|
||||||
uint8 frame = GetStationAnimationFrame(tile);
|
uint8 frame = GetAnimationFrame(tile);
|
||||||
uint8 num_frames = ss->anim_frames;
|
uint8 num_frames = ss->anim_frames;
|
||||||
|
|
||||||
bool frame_set_by_callback = false;
|
bool frame_set_by_callback = false;
|
||||||
|
@ -871,7 +871,7 @@ void AnimateStationTile(TileIndex tile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetStationAnimationFrame(tile, frame);
|
SetAnimationFrame(tile, frame);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -886,7 +886,7 @@ static void ChangeStationAnimationFrame(const StationSpec *ss, const BaseStation
|
||||||
case 0xFE: AddAnimatedTile(tile); break;
|
case 0xFE: AddAnimatedTile(tile); break;
|
||||||
case 0xFF: DeleteAnimatedTile(tile); break;
|
case 0xFF: DeleteAnimatedTile(tile); break;
|
||||||
default:
|
default:
|
||||||
SetStationAnimationFrame(tile, callback);
|
SetAnimationFrame(tile, callback);
|
||||||
AddAnimatedTile(tile);
|
AddAnimatedTile(tile);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,13 +89,13 @@ static void IncreaseAnimationStage(TileIndex tile)
|
||||||
{
|
{
|
||||||
TileArea ta = Object::GetByTile(tile)->location;
|
TileArea ta = Object::GetByTile(tile)->location;
|
||||||
TILE_AREA_LOOP(t, ta) {
|
TILE_AREA_LOOP(t, ta) {
|
||||||
SetObjectAnimationStage(t, GetObjectAnimationStage(t) + 1);
|
SetAnimationFrame(t, GetAnimationFrame(t) + 1);
|
||||||
MarkTileDirtyByTile(t);
|
MarkTileDirtyByTile(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** We encode the company HQ size in the animation stage. */
|
/** 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. */
|
/** We encode the company HQ size in the animation stage. */
|
||||||
#define IncreaseCompanyHQSize IncreaseAnimationStage
|
#define IncreaseCompanyHQSize IncreaseAnimationStage
|
||||||
|
|
||||||
|
|
|
@ -106,30 +106,6 @@ static inline bool IsStatueTile(TileIndex t)
|
||||||
return IsTileType(t, MP_OBJECT) && IsStatue(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.
|
* Make an Object tile.
|
||||||
|
|
|
@ -2176,7 +2176,7 @@ bool AfterLoadGame()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (old_gfx < atc[i].old_start + atc[i].num_frames) {
|
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);
|
SetStationGfx(t, atc[i].old_start - offset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1277,7 +1277,7 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32
|
||||||
|
|
||||||
SetCustomStationSpecIndex(tile, specindex);
|
SetCustomStationSpecIndex(tile, specindex);
|
||||||
SetStationTileRandomBits(tile, GB(Random(), 0, 4));
|
SetStationTileRandomBits(tile, GB(Random(), 0, 4));
|
||||||
SetStationAnimationFrame(tile, 0);
|
SetAnimationFrame(tile, 0);
|
||||||
|
|
||||||
if (statspec != NULL) {
|
if (statspec != NULL) {
|
||||||
/* Use a fixed axis for GetPlatformInfo as our platforms / numtracks are always the right way around */
|
/* Use a fixed axis for GetPlatformInfo as our platforms / numtracks are always the right way around */
|
||||||
|
@ -2578,19 +2578,19 @@ static void DrawTile_Station(TileInfo *ti)
|
||||||
}
|
}
|
||||||
switch (gfx) {
|
switch (gfx) {
|
||||||
case APT_RADAR_GRASS_FENCE_SW:
|
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;
|
break;
|
||||||
case APT_GRASS_FENCE_NE_FLAG:
|
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;
|
break;
|
||||||
case APT_RADAR_FENCE_SW:
|
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;
|
break;
|
||||||
case APT_RADAR_FENCE_NE:
|
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;
|
break;
|
||||||
case APT_GRASS_FENCE_NE_FLAG_2:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,30 +84,6 @@ static inline void SetStationGfx(TileIndex t, StationGfx gfx)
|
||||||
_m[t].m5 = gfx;
|
_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?
|
* Is this station tile a rail station?
|
||||||
* @param t the tile to get the information from
|
* @param t the tile to get the information from
|
||||||
|
|
|
@ -202,6 +202,30 @@ static inline TropicZone GetTropicZone(TileIndex tile)
|
||||||
return (TropicZone)GB(_m[tile].m6, 0, 2);
|
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);
|
Slope GetTileSlope(TileIndex tile, uint *h);
|
||||||
uint GetTileZ(TileIndex tile);
|
uint GetTileZ(TileIndex tile);
|
||||||
uint GetTileMaxZ(TileIndex tile);
|
uint GetTileMaxZ(TileIndex tile);
|
||||||
|
|
|
@ -139,30 +139,6 @@ static inline void SetLiftPosition(TileIndex t, byte pos)
|
||||||
SB(_m[t].m6, 2, 6, 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
|
* Get the completion of this house
|
||||||
* @param t the tile
|
* @param t the tile
|
||||||
|
@ -386,7 +362,7 @@ static inline void MakeHouseTile(TileIndex t, TownID tid, byte counter, byte sta
|
||||||
SetHouseType(t, type);
|
SetHouseType(t, type);
|
||||||
SetHouseCompleted(t, stage == TOWN_HOUSE_COMPLETED);
|
SetHouseCompleted(t, stage == TOWN_HOUSE_COMPLETED);
|
||||||
_m[t].m5 = IsHouseCompleted(t) ? 0 : (stage << 3 | counter);
|
_m[t].m5 = IsHouseCompleted(t) ? 0 : (stage << 3 | counter);
|
||||||
SetHouseAnimationFrame(t, 0);
|
SetAnimationFrame(t, 0);
|
||||||
SetHouseProcessingTime(t, HouseSpec::Get(type)->processing_time);
|
SetHouseProcessingTime(t, HouseSpec::Get(type)->processing_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue