42 uint32_t r = Random();
116 }
else if ((v->
progress & 7) == 1) {
312 v->
x_pos += _inc_by_dir[b->direction].x;
313 v->
y_pos += _inc_by_dir[b->direction].y;
345#define MK(x, y, z, i) { x, y, z, i }
346#define ME(i) { i, 4, 0, 0 }
494 if ((v->
progress & 3) != 0)
return true;
514 if (b->y == 4 && b->x == 0) {
519 if (b->y == 4 && b->x == 1) {
527 if (b->y == 4 && b->x == 2) {
538 b = &_bubble_movement[v->
spritenum - 1][anim_state];
653 this->
bounds = {{}, {1, 1, 1}, {}};
void AddAnimatedTile(TileIndex tile, bool mark_dirty)
Add the given tile to the animated tile table (if it does not exist yet).
static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
static void ElectricSparkInit(EffectVehicle *v)
Initialise the sparks of a train.
static void ExplosionLargeInit(EffectVehicle *v)
Initialise a large explosion.
static void BubbleInit(EffectVehicle *v)
Initialise the bubbles of the bubble generator industry.
static void DieselSmokeInit(EffectVehicle *v)
Initialise the smoke of a diesel engine.
static void ChimneySmokeInit(EffectVehicle *v)
Initialise the smoke of a chimney.
static bool BulldozerTick(EffectVehicle *v)
Run a single tick of a bulldozer (road works).
EffectVehicle * CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVehicleType type)
Create an effect vehicle above a particular vehicle.
static bool DieselSmokeTick(EffectVehicle *v)
Run a single tick of the smoke of a diesel engine.
EffectVehicle * CreateEffectVehicle(int x, int y, int z, EffectVehicleType type)
Create an effect vehicle at a particular location.
static bool IncrementSprite(EffectVehicle *v, SpriteID last)
Increment the sprite unless it has reached the end of the animation.
static bool BreakdownSmokeTick(EffectVehicle *v)
Run a single tick of the smoke of a broken down vehicle.
static const std::array< EffectProcs, EV_END > _effect_procs
Per-EffectVehicleType handling.
EffectVehicle * CreateEffectVehicleAbove(int x, int y, int z, EffectVehicleType type)
Create an effect vehicle above a particular location.
static void SteamSmokeInit(EffectVehicle *v)
Initialise the smoke of a steam engine.
static bool ElectricSparkTick(EffectVehicle *v)
Run a single tick of the sparks of a train.
static void BreakdownSmokeInit(EffectVehicle *v)
Initialise the smoke of a broken down vehicle.
static bool SteamSmokeTick(EffectVehicle *v)
Run a single tick of the smoke of a steam engine.
static void ExplosionSmallInit(EffectVehicle *v)
Initialise a small explosion.
static void BulldozerInit(EffectVehicle *v)
Initialise the bulldozer (road works).
static bool ChimneySmokeTick(EffectVehicle *v)
Run a single tick of the smoke of a chimney.
static bool SmokeTick(EffectVehicle *v)
Run a single tick of some smoke.
static bool BubbleTick(EffectVehicle *v)
Run a single tick of bubbles of the bubble generator industry.
static void SmokeInit(EffectVehicle *v)
Initialise some smoke.
static bool ExplosionSmallTick(EffectVehicle *v)
Run a single tick of a small explosion.
static bool ExplosionLargeTick(EffectVehicle *v)
Run a single tick of a large explosion.
Base class for all effect vehicles.
Functions related to effect vehicles.
EffectVehicleType
Effect vehicle types.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Accessors to map for industries.
IndustryGfx GetIndustryGfx(Tile t)
Get the industry graphics ID for the given industry tile.
int GetSlopePixelZ(int x, int y, bool ground_vehicle)
Return world Z coordinate of a given point of a tile.
Functions related to OTTD's landscape.
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Pseudo random number generator.
bool Chance16I(const uint32_t a, const uint32_t b, const uint32_t r)
Checks if a given randomize-number is below a given probability.
A number of safeguards to prevent using unsafe methods.
ClientSettings _settings_client
The current settings for this game.
#define MK(a, b)
Macro for ordinary entry of LegendAndColour.
Functions related to sound.
@ SND_31_BUBBLE_GENERATOR_SUCCESS
49 == 0x31 Industry animation: bubble generator (2b): bubble slurped
@ SND_2F_BUBBLE_GENERATOR_FAIL
47 == 0x2F Industry animation: bubble generator (2a): bubble pop
Definition of base types and functions in a cross-platform compatible way.
#define lengthof(array)
Return the length of an fixed size array.
bool(EffectVehicle *v) TickProc
Run the actions/perform the behaviour of an effect vehicle for a tick.
void(EffectVehicle *v) InitProc
Initialises effect vehicle for a specific type.
InitProc * init_proc
Function to initialise an effect vehicle after construction.
TickProc * tick_proc
Functions for controlling effect vehicles at each tick.
TransparencyOption transparency
Transparency option affecting the effect.
A special vehicle is one of the following:
void UpdateDeltaXY() override
Updates the x and y offsets and the size of the sprite used for this vehicle.
TransparencyOption GetTransparencyOption() const
Determines the transparency option affecting the effect.
uint8_t animation_substate
Sub state to time the change of the graphics/behaviour.
bool Tick() override
Calls the tick handler of the vehicle.
uint16_t animation_state
State primarily used to change the graphics/behaviour.
static uint MaxY()
Gets the maximum Y coordinate within the map, including TileType::Void.
static uint MaxX()
Gets the maximum X coordinate within the map, including TileType::Void.
VehicleSpriteSeq sprite_seq
Vehicle appearance.
static bool CanAllocateItem(size_t n=1)
static T * Create(Targs &&... args)
void Set(SpriteID sprite)
Assign a single sprite to the sequence.
int32_t z_pos
z coordinate.
uint8_t subtype
subtype (Filled with values from AircraftSubType/DisasterSubType/EffectVehicleType/GroundVehicleSubty...
VehStates vehstatus
Status.
int32_t y_pos
y coordinate.
int32_t x_pos
x coordinate.
SpriteBounds bounds
Bounding box of vehicle.
uint8_t spritenum
currently displayed sprite index 0xfd == custom sprite, 0xfe == custom second head sprite 0xff == res...
MutableSpriteCache sprite_cache
Cache of sprites and values related to recalculating them, see MutableSpriteCache.
uint8_t progress
The percentage (if divided by 256) this vehicle already crossed the tile unit.
void UpdatePositionAndViewport()
Update the position of the vehicle, and update the viewport.
TileIndex tile
Current tile index.
static bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
static constexpr uint TILE_SIZE
Tile size in world coordinates.
@ Industry
Part of an industry.
TransparencyOption
Transparency option bits: which position in _transparency_opt stands for which transparency.
@ TO_INVALID
Invalid transparency option.
@ TO_INDUSTRIES
industries
@ Unclickable
Vehicle is not clickable by the user (shadow vehicles).
Functions related to vehicles.