|
OpenTTD Source 20260218-master-g2123fca5ea
|
Implementation of everything generic to vehicles. More...
#include "stdafx.h"#include "landscape.h"#include "core/random_func.hpp"#include "industry_map.h"#include "vehicle_func.h"#include "sound_func.h"#include "animated_tile_func.h"#include "effectvehicle_func.h"#include "effectvehicle_base.h"#include "safeguards.h"Go to the source code of this file.
Data Structures | |
| struct | BulldozerMovement |
| struct | BubbleMovement |
| struct | EffectProcs |
| Container holding functions to call for a specific effect vehicle type. More... | |
Macros | |
| #define | MK(x, y, z, i) |
| #define | ME(i) |
Functions | |
| static bool | IncrementSprite (EffectVehicle *v, SpriteID last) |
| Increment the sprite unless it has reached the end of the animation. | |
| static void | ChimneySmokeInit (EffectVehicle *v) |
| Initialise the smoke of a chimney. | |
| static bool | ChimneySmokeTick (EffectVehicle *v) |
| Run a single tick of the smoke of a chimney. | |
| static void | SteamSmokeInit (EffectVehicle *v) |
| Initialise the smoke of a steam engine. | |
| static bool | SteamSmokeTick (EffectVehicle *v) |
| Run a single tick of the smoke of a steam engine. | |
| static void | DieselSmokeInit (EffectVehicle *v) |
| Initialise the smoke of a diesel engine. | |
| static bool | DieselSmokeTick (EffectVehicle *v) |
| Run a single tick of the smoke of a diesel engine. | |
| static void | ElectricSparkInit (EffectVehicle *v) |
| Initialise the sparks of a train. | |
| static bool | ElectricSparkTick (EffectVehicle *v) |
| Run a single tick of the sparks of a train. | |
| static void | SmokeInit (EffectVehicle *v) |
| Initialise some smoke. | |
| static bool | SmokeTick (EffectVehicle *v) |
| Run a single tick of some smoke. | |
| static void | ExplosionLargeInit (EffectVehicle *v) |
| Initialise a large explosion. | |
| static bool | ExplosionLargeTick (EffectVehicle *v) |
| Run a single tick of a large explosion. | |
| static void | BreakdownSmokeInit (EffectVehicle *v) |
| Initialise the smoke of a broken down vehicle. | |
| static bool | BreakdownSmokeTick (EffectVehicle *v) |
| Run a single tick of the smoke of a broken down vehicle. | |
| static void | ExplosionSmallInit (EffectVehicle *v) |
| Initialise a small explosion. | |
| static bool | ExplosionSmallTick (EffectVehicle *v) |
| Run a single tick of a small explosion. | |
| static void | BulldozerInit (EffectVehicle *v) |
| Initialise the bulldozer (road works). | |
| static bool | BulldozerTick (EffectVehicle *v) |
| Run a single tick of a bulldozer (road works). | |
| static void | BubbleInit (EffectVehicle *v) |
| Initialise the bubbles of the bubble generator industry. | |
| static bool | BubbleTick (EffectVehicle *v) |
| Run a single tick of bubbles of the bubble generator industry. | |
| EffectVehicle * | CreateEffectVehicle (int x, int y, int z, EffectVehicleType type) |
| Create an effect vehicle at a particular location. | |
| EffectVehicle * | CreateEffectVehicleAbove (int x, int y, int z, EffectVehicleType type) |
| Create an effect vehicle above a particular location. | |
| EffectVehicle * | CreateEffectVehicleRel (const Vehicle *v, int x, int y, int z, EffectVehicleType type) |
| Create an effect vehicle above a particular vehicle. | |
Variables | |
| static const BulldozerMovement | _bulldozer_movement [] |
| struct { | |
| int8_t x | |
| int8_t y | |
| } | _inc_by_dir [] |
| static const BubbleMovement | _bubble_float_sw [] |
| static const BubbleMovement | _bubble_float_ne [] |
| static const BubbleMovement | _bubble_float_se [] |
| static const BubbleMovement | _bubble_float_nw [] |
| static const BubbleMovement | _bubble_burst [] |
| static const BubbleMovement | _bubble_absorb [] |
| static const BubbleMovement *const | _bubble_movement [] |
| static const std::array< EffectProcs, EV_END > | _effect_procs |
| Per-EffectVehicleType handling. | |
Implementation of everything generic to vehicles.
Definition in file effectvehicle.cpp.
| #define ME | ( | i | ) |
Definition at line 346 of file effectvehicle.cpp.
| #define MK | ( | x, | |
| y, | |||
| z, | |||
| i ) |
Definition at line 345 of file effectvehicle.cpp.
|
static |
Initialise the smoke of a broken down vehicle.
Initialises effect vehicle for a specific type.
| v | The vehicle to initialise. |
Definition at line 207 of file effectvehicle.cpp.
References Vehicle::progress, VehicleSpriteSeq::Set(), Vehicle::sprite_cache, and MutableSpriteCache::sprite_seq.
|
static |
Run a single tick of the smoke of a broken down vehicle.
Run the actions/perform the behaviour of an effect vehicle for a tick.
| v | The vehicle to work with. |
true iff the vehicle is still valid, i.e. has not been removed yet. Definition at line 214 of file effectvehicle.cpp.
References EffectVehicle::animation_state, IncrementSprite(), Vehicle::progress, VehicleSpriteSeq::Set(), Vehicle::sprite_cache, MutableSpriteCache::sprite_seq, and Vehicle::UpdatePositionAndViewport().
|
static |
Initialise the bubbles of the bubble generator industry.
Initialises effect vehicle for a specific type.
| v | The vehicle to initialise. |
Definition at line 331 of file effectvehicle.cpp.
References Vehicle::progress, VehicleSpriteSeq::Set(), Vehicle::sprite_cache, MutableSpriteCache::sprite_seq, and Vehicle::spritenum.
|
static |
Run a single tick of bubbles of the bubble generator industry.
Run the actions/perform the behaviour of an effect vehicle for a tick.
| v | The vehicle to work with. |
true iff the vehicle is still valid, i.e. has not been removed yet. Definition at line 489 of file effectvehicle.cpp.
References _settings_client, AddAnimatedTile(), EffectVehicle::animation_state, EffectVehicle::animation_substate, Chance16I(), GB(), GetIndustryGfx(), Industry, IsTileType(), Vehicle::progress, VehicleSpriteSeq::Set(), SND_2F_BUBBLE_GENERATOR_FAIL, SND_31_BUBBLE_GENERATOR_SUCCESS, Vehicle::sprite_cache, MutableSpriteCache::sprite_seq, Vehicle::spritenum, TileVirtXY(), Vehicle::UpdatePositionAndViewport(), Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.
|
static |
Initialise the bulldozer (road works).
Initialises effect vehicle for a specific type.
| v | The vehicle to initialise. |
Definition at line 256 of file effectvehicle.cpp.
References EffectVehicle::animation_state, EffectVehicle::animation_substate, Vehicle::progress, VehicleSpriteSeq::Set(), Vehicle::sprite_cache, and MutableSpriteCache::sprite_seq.
|
static |
Run a single tick of a bulldozer (road works).
Run the actions/perform the behaviour of an effect vehicle for a tick.
| v | The vehicle to work with. |
true iff the vehicle is still valid, i.e. has not been removed yet. Definition at line 304 of file effectvehicle.cpp.
References EffectVehicle::animation_state, EffectVehicle::animation_substate, lengthof, Vehicle::progress, VehicleSpriteSeq::Set(), Vehicle::sprite_cache, MutableSpriteCache::sprite_seq, Vehicle::UpdatePositionAndViewport(), Vehicle::x_pos, and Vehicle::y_pos.
|
static |
Initialise the smoke of a chimney.
Initialises effect vehicle for a specific type.
| v | The vehicle to initialise. |
Definition at line 40 of file effectvehicle.cpp.
References GB(), Vehicle::progress, VehicleSpriteSeq::Set(), Vehicle::sprite_cache, and MutableSpriteCache::sprite_seq.
|
static |
Run a single tick of the smoke of a chimney.
Run the actions/perform the behaviour of an effect vehicle for a tick.
| v | The vehicle to work with. |
true iff the vehicle is still valid, i.e. has not been removed yet. Definition at line 48 of file effectvehicle.cpp.
References IncrementSprite(), Industry, IsTileType(), Vehicle::progress, VehicleSpriteSeq::Set(), Vehicle::sprite_cache, MutableSpriteCache::sprite_seq, TileVirtXY(), Vehicle::UpdatePositionAndViewport(), Vehicle::x_pos, and Vehicle::y_pos.
| EffectVehicle * CreateEffectVehicle | ( | int | x, |
| int | y, | ||
| int | z, | ||
| EffectVehicleType | type ) |
Create an effect vehicle at a particular location.
| x | The x location on the map. |
| y | The y location on the map. |
| z | The z location on the map. |
| type | The type of effect vehicle. |
Definition at line 597 of file effectvehicle.cpp.
References _effect_procs, Vehicle::subtype, Vehicle::tile, Unclickable, EffectVehicle::UpdateDeltaXY(), Vehicle::UpdatePositionAndViewport(), Vehicle::vehstatus, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.
Referenced by CreateEffectVehicleAbove(), and CreateEffectVehicleRel().
| EffectVehicle * CreateEffectVehicleAbove | ( | int | x, |
| int | y, | ||
| int | z, | ||
| EffectVehicleType | type ) |
Create an effect vehicle above a particular location.
| x | The x location on the map. |
| y | The y location on the map. |
| z | The offset from the ground. |
| type | The type of effect vehicle. |
Definition at line 625 of file effectvehicle.cpp.
References Clamp(), CreateEffectVehicle(), GetSlopePixelZ(), Map::MaxX(), Map::MaxY(), and TILE_SIZE.
Referenced by CmdClearArea(), DisasterTick_Aircraft(), and DisasterTick_Big_Ufo_Destroyer().
| EffectVehicle * CreateEffectVehicleRel | ( | const Vehicle * | v, |
| int | x, | ||
| int | y, | ||
| int | z, | ||
| EffectVehicleType | type ) |
Create an effect vehicle above a particular vehicle.
| v | The vehicle to base the position on. |
| x | The x offset to the vehicle. |
| y | The y offset to the vehicle. |
| z | The z offset to the vehicle. |
| type | The type of effect vehicle. |
Definition at line 641 of file effectvehicle.cpp.
References CreateEffectVehicle(), Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.
Referenced by CrashAirplane(), DisasterTick_Big_Ufo_Destroyer(), DisasterTick_Ufo(), DisasterTick_Zeppeliner(), FloodVehicle(), HandleAircraftSmoke(), Vehicle::HandleBreakdown(), HandleCrashedAircraft(), HandleCrashedTrain(), RoadVehIsCrashed(), Vehicle::ShowVisualEffect(), and SpawnAdvancedVisualEffect().
|
static |
Initialise the smoke of a diesel engine.
Initialises effect vehicle for a specific type.
| v | The vehicle to initialise. |
Definition at line 102 of file effectvehicle.cpp.
References Vehicle::progress, VehicleSpriteSeq::Set(), Vehicle::sprite_cache, and MutableSpriteCache::sprite_seq.
|
static |
Run a single tick of the smoke of a diesel engine.
Run the actions/perform the behaviour of an effect vehicle for a tick.
| v | The vehicle to work with. |
true iff the vehicle is still valid, i.e. has not been removed yet. Definition at line 109 of file effectvehicle.cpp.
References IncrementSprite(), Vehicle::progress, Vehicle::UpdatePositionAndViewport(), and Vehicle::z_pos.
|
static |
Initialise the sparks of a train.
Initialises effect vehicle for a specific type.
| v | The vehicle to initialise. |
Definition at line 128 of file effectvehicle.cpp.
References Vehicle::progress, VehicleSpriteSeq::Set(), Vehicle::sprite_cache, and MutableSpriteCache::sprite_seq.
|
static |
Run a single tick of the sparks of a train.
Run the actions/perform the behaviour of an effect vehicle for a tick.
| v | The vehicle to work with. |
true iff the vehicle is still valid, i.e. has not been removed yet. Definition at line 135 of file effectvehicle.cpp.
References IncrementSprite(), Vehicle::progress, and Vehicle::UpdatePositionAndViewport().
|
static |
Initialise a large explosion.
Initialises effect vehicle for a specific type.
| v | The vehicle to initialise. |
Definition at line 185 of file effectvehicle.cpp.
References Vehicle::progress, VehicleSpriteSeq::Set(), Vehicle::sprite_cache, and MutableSpriteCache::sprite_seq.
|
static |
Run a single tick of a large explosion.
Run the actions/perform the behaviour of an effect vehicle for a tick.
| v | The vehicle to work with. |
true iff the vehicle is still valid, i.e. has not been removed yet. Definition at line 192 of file effectvehicle.cpp.
References IncrementSprite(), Vehicle::progress, and Vehicle::UpdatePositionAndViewport().
|
static |
Initialise a small explosion.
Initialises effect vehicle for a specific type.
| v | The vehicle to initialise. |
Definition at line 234 of file effectvehicle.cpp.
References Vehicle::progress, VehicleSpriteSeq::Set(), Vehicle::sprite_cache, and MutableSpriteCache::sprite_seq.
|
static |
Run a single tick of a small explosion.
Run the actions/perform the behaviour of an effect vehicle for a tick.
| v | The vehicle to work with. |
true iff the vehicle is still valid, i.e. has not been removed yet. Definition at line 241 of file effectvehicle.cpp.
References IncrementSprite(), Vehicle::progress, and Vehicle::UpdatePositionAndViewport().
|
static |
Increment the sprite unless it has reached the end of the animation.
| v | Vehicle to increment sprite of. |
| last | Last sprite of animation. |
Definition at line 29 of file effectvehicle.cpp.
References Vehicle::sprite_cache, and MutableSpriteCache::sprite_seq.
Referenced by BreakdownSmokeTick(), ChimneySmokeTick(), DieselSmokeTick(), ElectricSparkTick(), ExplosionLargeTick(), ExplosionSmallTick(), SmokeTick(), and SteamSmokeTick().
|
static |
Initialise some smoke.
Initialises effect vehicle for a specific type.
| v | The vehicle to initialise. |
Definition at line 153 of file effectvehicle.cpp.
References Vehicle::progress, VehicleSpriteSeq::Set(), Vehicle::sprite_cache, and MutableSpriteCache::sprite_seq.
|
static |
Run a single tick of some smoke.
Run the actions/perform the behaviour of an effect vehicle for a tick.
| v | The vehicle to work with. |
true iff the vehicle is still valid, i.e. has not been removed yet. Definition at line 160 of file effectvehicle.cpp.
References IncrementSprite(), Vehicle::progress, Vehicle::UpdatePositionAndViewport(), and Vehicle::z_pos.
|
static |
Initialise the smoke of a steam engine.
Initialises effect vehicle for a specific type.
| v | The vehicle to initialise. |
Definition at line 70 of file effectvehicle.cpp.
References Vehicle::progress, VehicleSpriteSeq::Set(), Vehicle::sprite_cache, and MutableSpriteCache::sprite_seq.
|
static |
Run a single tick of the smoke of a steam engine.
Run the actions/perform the behaviour of an effect vehicle for a tick.
| v | The vehicle to work with. |
true iff the vehicle is still valid, i.e. has not been removed yet. Definition at line 77 of file effectvehicle.cpp.
References IncrementSprite(), Vehicle::progress, Vehicle::UpdatePositionAndViewport(), and Vehicle::z_pos.
|
static |
Definition at line 389 of file effectvehicle.cpp.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 479 of file effectvehicle.cpp.
|
static |
Definition at line 270 of file effectvehicle.cpp.
|
static |
Per-EffectVehicleType handling.
Definition at line 574 of file effectvehicle.cpp.
Referenced by CreateEffectVehicle(), EffectVehicle::GetTransparencyOption(), and EffectVehicle::Tick().
| const struct { ... } _inc_by_dir[] |
| int8_t x |
Definition at line 294 of file effectvehicle.cpp.
| int8_t y |
Definition at line 295 of file effectvehicle.cpp.