mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Turn AnimationStatus into an enum class.
parent
47f0f4dd9e
commit
03ed59a004
|
@ -696,7 +696,7 @@ static void AnimateTile_Industry(TileIndex tile)
|
||||||
{
|
{
|
||||||
IndustryGfx gfx = GetIndustryGfx(tile);
|
IndustryGfx gfx = GetIndustryGfx(tile);
|
||||||
|
|
||||||
if (GetIndustryTileSpec(gfx)->animation.status != ANIM_STATUS_NO_ANIMATION) {
|
if (GetIndustryTileSpec(gfx)->animation.status != AnimationStatus::NoAnimation) {
|
||||||
AnimateNewIndustryTile(tile);
|
AnimateNewIndustryTile(tile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1955,7 +1955,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
|
||||||
/* it->gfx is stored in the map. But the translated ID cur_gfx is the interesting one */
|
/* it->gfx is stored in the map. But the translated ID cur_gfx is the interesting one */
|
||||||
IndustryGfx cur_gfx = GetTranslatedIndustryTileID(it.gfx);
|
IndustryGfx cur_gfx = GetTranslatedIndustryTileID(it.gfx);
|
||||||
const IndustryTileSpec *its = GetIndustryTileSpec(cur_gfx);
|
const IndustryTileSpec *its = GetIndustryTileSpec(cur_gfx);
|
||||||
if (its->animation.status != ANIM_STATUS_NO_ANIMATION) AddAnimatedTile(cur_tile);
|
if (its->animation.status != AnimationStatus::NoAnimation) AddAnimatedTile(cur_tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,7 +210,7 @@ static ChangeInfoResult AirportTilesChangeInfo(uint first, uint last, int prop,
|
||||||
|
|
||||||
tsp->enabled = true;
|
tsp->enabled = true;
|
||||||
|
|
||||||
tsp->animation.status = ANIM_STATUS_NO_ANIMATION;
|
tsp->animation = AnimationInfo{};
|
||||||
|
|
||||||
tsp->grf_prop.local_id = id;
|
tsp->grf_prop.local_id = id;
|
||||||
tsp->grf_prop.subst_id = subs_id;
|
tsp->grf_prop.subst_id = subs_id;
|
||||||
|
@ -239,7 +239,7 @@ static ChangeInfoResult AirportTilesChangeInfo(uint first, uint last, int prop,
|
||||||
|
|
||||||
case 0x0F: // Animation information
|
case 0x0F: // Animation information
|
||||||
tsp->animation.frames = buf.ReadByte();
|
tsp->animation.frames = buf.ReadByte();
|
||||||
tsp->animation.status = buf.ReadByte();
|
tsp->animation.status = static_cast<AnimationStatus>(buf.ReadByte());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x10: // Animation speed
|
case 0x10: // Animation speed
|
||||||
|
|
|
@ -253,11 +253,12 @@ static ChangeInfoResult TownHouseChangeInfo(uint first, uint last, int prop, Byt
|
||||||
housespec->extra_flags = static_cast<HouseExtraFlags>(buf.ReadByte());
|
housespec->extra_flags = static_cast<HouseExtraFlags>(buf.ReadByte());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x1A: // Animation frames
|
case 0x1A: { // Animation frames
|
||||||
housespec->animation.frames = buf.ReadByte();
|
uint8_t info = buf.ReadByte();
|
||||||
housespec->animation.status = GB(housespec->animation.frames, 7, 1);
|
housespec->animation.frames = GB(info, 0, 7);
|
||||||
SB(housespec->animation.frames, 7, 1, 0);
|
housespec->animation.status = HasBit(info, 7) ? AnimationStatus::Looping : AnimationStatus::NonLooping;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 0x1B: // Animation speed
|
case 0x1B: // Animation speed
|
||||||
housespec->animation.speed = Clamp(buf.ReadByte(), 2, 16);
|
housespec->animation.speed = Clamp(buf.ReadByte(), 2, 16);
|
||||||
|
|
|
@ -152,7 +152,7 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint first, uint last, int prop,
|
||||||
|
|
||||||
case 0x0F: // Animation information
|
case 0x0F: // Animation information
|
||||||
tsp->animation.frames = buf.ReadByte();
|
tsp->animation.frames = buf.ReadByte();
|
||||||
tsp->animation.status = buf.ReadByte();
|
tsp->animation.status = static_cast<AnimationStatus>(buf.ReadByte());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x10: // Animation speed
|
case 0x10: // Animation speed
|
||||||
|
|
|
@ -151,7 +151,7 @@ static ChangeInfoResult ObjectChangeInfo(uint first, uint last, int prop, ByteRe
|
||||||
|
|
||||||
case 0x11: // Animation info
|
case 0x11: // Animation info
|
||||||
spec->animation.frames = buf.ReadByte();
|
spec->animation.frames = buf.ReadByte();
|
||||||
spec->animation.status = buf.ReadByte();
|
spec->animation.status = static_cast<AnimationStatus>(buf.ReadByte());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x12: // Animation speed
|
case 0x12: // Animation speed
|
||||||
|
|
|
@ -115,7 +115,7 @@ static ChangeInfoResult RoadStopChangeInfo(uint first, uint last, int prop, Byte
|
||||||
|
|
||||||
case 0x0E: // Animation info
|
case 0x0E: // Animation info
|
||||||
rs->animation.frames = buf.ReadByte();
|
rs->animation.frames = buf.ReadByte();
|
||||||
rs->animation.status = buf.ReadByte();
|
rs->animation.status = static_cast<AnimationStatus>(buf.ReadByte());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x0F: // Animation speed
|
case 0x0F: // Animation speed
|
||||||
|
|
|
@ -235,7 +235,7 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR
|
||||||
|
|
||||||
case 0x16: // Animation info
|
case 0x16: // Animation info
|
||||||
statspec->animation.frames = buf.ReadByte();
|
statspec->animation.frames = buf.ReadByte();
|
||||||
statspec->animation.status = buf.ReadByte();
|
statspec->animation.status = static_cast<AnimationStatus>(buf.ReadByte());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x17: // Animation speed
|
case 0x17: // Animation speed
|
||||||
|
|
|
@ -103,7 +103,7 @@ struct AnimationBase {
|
||||||
if (!frame_set_by_callback) {
|
if (!frame_set_by_callback) {
|
||||||
if (frame < num_frames) {
|
if (frame < num_frames) {
|
||||||
frame++;
|
frame++;
|
||||||
} else if (frame == num_frames && spec->animation.status == ANIM_STATUS_LOOPING) {
|
} else if (frame == num_frames && spec->animation.status == AnimationStatus::Looping) {
|
||||||
/* This animation loops, so start again from the beginning */
|
/* This animation loops, so start again from the beginning */
|
||||||
frame = 0;
|
frame = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -10,16 +10,18 @@
|
||||||
#ifndef NEWGRF_ANIMATION_TYPE_H
|
#ifndef NEWGRF_ANIMATION_TYPE_H
|
||||||
#define NEWGRF_ANIMATION_TYPE_H
|
#define NEWGRF_ANIMATION_TYPE_H
|
||||||
|
|
||||||
static const uint8_t ANIM_STATUS_NON_LOOPING = 0x00; ///< Animation is not looping.
|
enum class AnimationStatus : uint8_t {
|
||||||
static const uint8_t ANIM_STATUS_LOOPING = 0x01; ///< Animation is looping.
|
NonLooping = 0x00, ///< Animation is not looping.
|
||||||
static const uint8_t ANIM_STATUS_NO_ANIMATION = 0xFF; ///< There is no animation.
|
Looping = 0x01, ///< Animation is looping.
|
||||||
|
NoAnimation = 0xFF, ///< There is no animation.
|
||||||
|
};
|
||||||
|
|
||||||
/** Information about animation. */
|
/** Information about animation. */
|
||||||
struct AnimationInfo {
|
struct AnimationInfo {
|
||||||
uint8_t frames; ///< The number of frames.
|
uint8_t frames = 0; ///< The number of frames.
|
||||||
uint8_t status; ///< Status; 0: no looping, 1: looping, 0xFF: no animation.
|
AnimationStatus status = AnimationStatus::NoAnimation; ///< Status.
|
||||||
uint8_t speed; ///< The speed, i.e. the amount of time between frames.
|
uint8_t speed = 2; ///< The speed: time between frames = 2^speed ticks.
|
||||||
uint16_t triggers; ///< The triggers that trigger animation.
|
uint16_t triggers = 0; ///< The triggers that trigger animation.
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Animation triggers for station. */
|
/** Animation triggers for station. */
|
||||||
|
|
|
@ -60,7 +60,8 @@ DECLARE_INCREMENT_DECREMENT_OPERATORS(ObjectClassID)
|
||||||
struct ObjectSpec : NewGRFSpecBase<ObjectClassID> {
|
struct ObjectSpec : NewGRFSpecBase<ObjectClassID> {
|
||||||
/* 2 because of the "normal" and "buy" sprite stacks. */
|
/* 2 because of the "normal" and "buy" sprite stacks. */
|
||||||
FixedGRFFileProps<2> grf_prop; ///< Properties related the the grf file
|
FixedGRFFileProps<2> grf_prop; ///< Properties related the the grf file
|
||||||
AnimationInfo animation; ///< Information about the animation.
|
/* Animation speed default differs from other features */
|
||||||
|
AnimationInfo animation{0, AnimationStatus::NoAnimation, 0, 0}; ///< Information about the animation.
|
||||||
StringID name; ///< The name for this object.
|
StringID name; ///< The name for this object.
|
||||||
|
|
||||||
LandscapeTypes climate; ///< In which climates is this object available?
|
LandscapeTypes climate; ///< In which climates is this object available?
|
||||||
|
|
|
@ -118,8 +118,8 @@ struct StationSpec : NewGRFSpecBase<StationClassID> {
|
||||||
StationSpec() : name(0),
|
StationSpec() : name(0),
|
||||||
disallowed_platforms(0), disallowed_lengths(0),
|
disallowed_platforms(0), disallowed_lengths(0),
|
||||||
cargo_threshold(0), cargo_triggers(0),
|
cargo_threshold(0), cargo_triggers(0),
|
||||||
callback_mask(0), flags(0),
|
callback_mask(0), flags(0)
|
||||||
animation({0, 0, 2, 0}) {}
|
{}
|
||||||
/**
|
/**
|
||||||
* Properties related the the grf file.
|
* Properties related the the grf file.
|
||||||
* NUM_CARGO real cargo plus three pseudo cargo sprite groups.
|
* NUM_CARGO real cargo plus three pseudo cargo sprite groups.
|
||||||
|
|
|
@ -2617,7 +2617,7 @@ CommandCost CmdBuildAirport(DoCommandFlags flags, TileIndex tile, uint8_t airpor
|
||||||
SetStationTileRandomBits(t, GB(Random(), 0, 4));
|
SetStationTileRandomBits(t, GB(Random(), 0, 4));
|
||||||
st->airport.Add(iter);
|
st->airport.Add(iter);
|
||||||
|
|
||||||
if (AirportTileSpec::Get(GetTranslatedAirportTileID(iter.GetStationGfx()))->animation.status != ANIM_STATUS_NO_ANIMATION) AddAnimatedTile(t);
|
if (AirportTileSpec::Get(GetTranslatedAirportTileID(iter.GetStationGfx()))->animation.status != AnimationStatus::NoAnimation) AddAnimatedTile(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only call the animation trigger after all tiles have been built */
|
/* Only call the animation trigger after all tiles have been built */
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
#define AIRPORTTILES_H
|
#define AIRPORTTILES_H
|
||||||
|
|
||||||
/** Writes all airport tile properties in the AirportTile struct */
|
/** Writes all airport tile properties in the AirportTile struct */
|
||||||
#define AT(num_frames, anim_speed) {{num_frames, ANIM_STATUS_LOOPING, anim_speed, 0}, STR_NULL, AirportTileCallbackMasks{}, 0, true, GRFFileProps(INVALID_AIRPORTTILE), {}}
|
#define AT(num_frames, anim_speed) {{num_frames, AnimationStatus::Looping, anim_speed, 0}, STR_NULL, AirportTileCallbackMasks{}, 0, true, GRFFileProps(INVALID_AIRPORTTILE), {}}
|
||||||
/** Writes an airport tile without animation in the AirportTile struct */
|
/** Writes an airport tile without animation in the AirportTile struct */
|
||||||
#define AT_NOANIM {{0, ANIM_STATUS_NO_ANIMATION, 2, 0}, STR_NULL, AirportTileCallbackMasks{}, 0, true, GRFFileProps(INVALID_AIRPORTTILE), {}}
|
#define AT_NOANIM {AnimationInfo{}, STR_NULL, AirportTileCallbackMasks{}, 0, true, GRFFileProps(INVALID_AIRPORTTILE), {}}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All default airport tiles.
|
* All default airport tiles.
|
||||||
|
|
|
@ -1533,7 +1533,7 @@ static const IndustrySpec _origin_industry_specs[NEW_INDUSTRYOFFSET] = {
|
||||||
*/
|
*/
|
||||||
#define MT(ca1, c1, ca2, c2, ca3, c3, sl, a1, a2, a3) { \
|
#define MT(ca1, c1, ca2, c2, ca3, c3, sl, a1, a2, a3) { \
|
||||||
{INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO}, \
|
{INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO}, \
|
||||||
{ca1, ca2, ca3}, sl, a1, a2, a3, IndustryTileCallbackMasks{}, {0, ANIM_STATUS_NO_ANIMATION, 2, 0}, IndustryTileSpecialFlags{}, true, GRFFileProps(INVALID_INDUSTRYTILE), {}, {c1, c2, c3} \
|
{ca1, ca2, ca3}, sl, a1, a2, a3, IndustryTileCallbackMasks{}, AnimationInfo{}, IndustryTileSpecialFlags{}, true, GRFFileProps(INVALID_INDUSTRYTILE), {}, {c1, c2, c3} \
|
||||||
}
|
}
|
||||||
static const IndustryTileSpec _origin_industry_tile_specs[NEW_INDUSTRYTILEOFFSET] = {
|
static const IndustryTileSpec _origin_industry_tile_specs[NEW_INDUSTRYTILEOFFSET] = {
|
||||||
/* Coal Mine */
|
/* Coal Mine */
|
||||||
|
|
|
@ -104,7 +104,7 @@ static const DrawTileSpriteSpan _object_hq[] = {
|
||||||
#undef TILE_SPRITE_LINE
|
#undef TILE_SPRITE_LINE
|
||||||
#undef TILE_SPRITE_LINE_NOTHING
|
#undef TILE_SPRITE_LINE_NOTHING
|
||||||
|
|
||||||
#define M(name, size, build_cost_multiplier, clear_cost_multiplier, height, climate, gen_amount, flags) {{INVALID_OBJECT_CLASS, 0}, FixedGRFFileProps<2>{}, {0, 0, 0, 0}, name, climate, size, build_cost_multiplier, clear_cost_multiplier, TimerGameCalendar::Date{}, CalendarTime::MAX_DATE + 1, flags, ObjectCallbackMasks{}, height, 1, gen_amount, {}}
|
#define M(name, size, build_cost_multiplier, clear_cost_multiplier, height, climate, gen_amount, flags) {{INVALID_OBJECT_CLASS, 0}, FixedGRFFileProps<2>{}, AnimationInfo{}, name, climate, size, build_cost_multiplier, clear_cost_multiplier, TimerGameCalendar::Date{}, CalendarTime::MAX_DATE + 1, flags, ObjectCallbackMasks{}, height, 1, gen_amount, {}}
|
||||||
|
|
||||||
/* Climates
|
/* Climates
|
||||||
* T = Temperate
|
* T = Temperate
|
||||||
|
|
|
@ -1814,7 +1814,7 @@ static_assert(lengthof(_town_draw_tile_data) == (NEW_HOUSE_OFFSET) * 4 * 4);
|
||||||
{ca1, ca2, ca3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
|
{ca1, ca2, ca3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
|
||||||
{INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO}, \
|
{INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO}, \
|
||||||
bf, ba, true, GRFFileProps(INVALID_HOUSE_ID), HouseCallbackMasks{}, {COLOUR_BEGIN, COLOUR_BEGIN, COLOUR_BEGIN, COLOUR_BEGIN}, \
|
bf, ba, true, GRFFileProps(INVALID_HOUSE_ID), HouseCallbackMasks{}, {COLOUR_BEGIN, COLOUR_BEGIN, COLOUR_BEGIN, COLOUR_BEGIN}, \
|
||||||
16, HouseExtraFlags{}, HOUSE_NO_CLASS, {0, 0, 2, 0}, 0, 0, 0, {}, {cg1, cg2, cg3}, }
|
16, HouseExtraFlags{}, HOUSE_NO_CLASS, AnimationInfo{}, 0, 0, 0, {}, {cg1, cg2, cg3}, }
|
||||||
/** House specifications from original data */
|
/** House specifications from original data */
|
||||||
extern const HouseSpec _original_house_specs[] = {
|
extern const HouseSpec _original_house_specs[] = {
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue