OpenTTD
Data Structures | Macros | Typedefs | Functions | Variables
effectvehicle.cpp File Reference

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
 

Macros

#define MK(x, y, z, i)   { x, y, z, i }
 
#define ME(i)   { i, 4, 0, 0 }
 

Typedefs

typedef void EffectInitProc(EffectVehicle *v)
 
typedef bool EffectTickProc(EffectVehicle *v)
 

Functions

static bool IncrementSprite (EffectVehicle *v, SpriteID last)
 Increment the sprite unless it has reached the end of the animation. More...
 
static void ChimneySmokeInit (EffectVehicle *v)
 
static bool ChimneySmokeTick (EffectVehicle *v)
 
static void SteamSmokeInit (EffectVehicle *v)
 
static bool SteamSmokeTick (EffectVehicle *v)
 
static void DieselSmokeInit (EffectVehicle *v)
 
static bool DieselSmokeTick (EffectVehicle *v)
 
static void ElectricSparkInit (EffectVehicle *v)
 
static bool ElectricSparkTick (EffectVehicle *v)
 
static void SmokeInit (EffectVehicle *v)
 
static bool SmokeTick (EffectVehicle *v)
 
static void ExplosionLargeInit (EffectVehicle *v)
 
static bool ExplosionLargeTick (EffectVehicle *v)
 
static void BreakdownSmokeInit (EffectVehicle *v)
 
static bool BreakdownSmokeTick (EffectVehicle *v)
 
static void ExplosionSmallInit (EffectVehicle *v)
 
static bool ExplosionSmallTick (EffectVehicle *v)
 
static void BulldozerInit (EffectVehicle *v)
 
static bool BulldozerTick (EffectVehicle *v)
 
static void BubbleInit (EffectVehicle *v)
 
static bool BubbleTick (EffectVehicle *v)
 
 assert_compile (lengthof(_effect_init_procs)==EV_END)
 
 assert_compile (lengthof(_effect_tick_procs)==EV_END)
 
 assert_compile (lengthof(_effect_transparency_options)==EV_END)
 
EffectVehicleCreateEffectVehicle (int x, int y, int z, EffectVehicleType type)
 Create an effect vehicle at a particular location. More...
 
EffectVehicleCreateEffectVehicleAbove (int x, int y, int z, EffectVehicleType type)
 Create an effect vehicle above a particular location. More...
 
EffectVehicleCreateEffectVehicleRel (const Vehicle *v, int x, int y, int z, EffectVehicleType type)
 Create an effect vehicle above a particular vehicle. More...
 

Variables

static const BulldozerMovement _bulldozer_movement []
 
struct {
   int8   x
 
   int8   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 EffectInitProc *const _effect_init_procs []
 Functions to initialise an effect vehicle after construction. More...
 
static EffectTickProc *const _effect_tick_procs []
 Functions for controlling effect vehicles at each tick. More...
 
static const TransparencyOption _effect_transparency_options []
 Transparency options affecting the effects. More...
 

Detailed Description

Implementation of everything generic to vehicles.

Definition in file effectvehicle.cpp.

Function Documentation

◆ CreateEffectVehicle()

EffectVehicle* CreateEffectVehicle ( int  x,
int  y,
int  z,
EffectVehicleType  type 
)

Create an effect vehicle at a particular location.

Parameters
xThe x location on the map.
yThe y location on the map.
zThe z location on the map.
typeThe type of effect vehicle.
Returns
The effect vehicle.

Definition at line 596 of file effectvehicle.cpp.

◆ CreateEffectVehicleAbove()

EffectVehicle* CreateEffectVehicleAbove ( int  x,
int  y,
int  z,
EffectVehicleType  type 
)

Create an effect vehicle above a particular location.

Parameters
xThe x location on the map.
yThe y location on the map.
zThe offset from the ground.
typeThe type of effect vehicle.
Returns
The effect vehicle.

Definition at line 624 of file effectvehicle.cpp.

◆ CreateEffectVehicleRel()

EffectVehicle* CreateEffectVehicleRel ( const Vehicle v,
int  x,
int  y,
int  z,
EffectVehicleType  type 
)

Create an effect vehicle above a particular vehicle.

Parameters
vThe vehicle to base the position on.
xThe x offset to the vehicle.
yThe y offset to the vehicle.
zThe z offset to the vehicle.
typeThe type of effect vehicle.
Returns
The effect vehicle.

Definition at line 640 of file effectvehicle.cpp.

Referenced by CrashAirplane(), FloodVehicle(), HandleCrashedTrain(), and RoadVehIsCrashed().

◆ IncrementSprite()

static bool IncrementSprite ( EffectVehicle v,
SpriteID  last 
)
static

Increment the sprite unless it has reached the end of the animation.

Parameters
vVehicle to increment sprite of.
lastLast sprite of animation.
Returns
true if the sprite was incremented, false if the end was reached.

Definition at line 31 of file effectvehicle.cpp.

References PalSpriteID::sprite, and Vehicle::sprite_seq.

Variable Documentation

◆ _bubble_burst

const BubbleMovement _bubble_burst[]
static
Initial value:
= {
MK(0, 0, 1, 2),
MK(0, 0, 1, 7),
MK(0, 0, 1, 8),
MK(0, 0, 1, 9),
}

Definition at line 364 of file effectvehicle.cpp.

◆ _bubble_float_ne

const BubbleMovement _bubble_float_ne[]
static
Initial value:
= {
MK( 0, 0, 1, 0),
MK(-1, 0, 1, 1),
MK( 0, 0, 1, 0),
MK(-1, 0, 1, 2),
}

Definition at line 340 of file effectvehicle.cpp.

◆ _bubble_float_nw

const BubbleMovement _bubble_float_nw[]
static
Initial value:
= {
MK(0, 0, 1, 0),
MK(0, -1, 1, 1),
MK(0, 0, 1, 0),
MK(0, -1, 1, 2),
}

Definition at line 356 of file effectvehicle.cpp.

◆ _bubble_float_se

const BubbleMovement _bubble_float_se[]
static
Initial value:
= {
MK(0, 0, 1, 0),
MK(0, 1, 1, 1),
MK(0, 0, 1, 0),
MK(0, 1, 1, 2),
}

Definition at line 348 of file effectvehicle.cpp.

◆ _bubble_float_sw

const BubbleMovement _bubble_float_sw[]
static
Initial value:
= {
MK(0, 0, 1, 0),
MK(1, 0, 1, 1),
MK(0, 0, 1, 0),
MK(1, 0, 1, 2),
}

Definition at line 331 of file effectvehicle.cpp.

◆ _bubble_movement

const BubbleMovement* const _bubble_movement[]
static
Initial value:
= {
_bubble_float_sw,
_bubble_float_ne,
_bubble_float_se,
_bubble_float_nw,
_bubble_burst,
_bubble_absorb,
}

Definition at line 462 of file effectvehicle.cpp.

◆ _bulldozer_movement

const BulldozerMovement _bulldozer_movement[]
static
Initial value:
= {
{ 0, 0, 4 },
{ 3, 3, 4 },
{ 2, 2, 7 },
{ 0, 2, 7 },
{ 1, 1, 3 },
{ 2, 2, 7 },
{ 0, 2, 7 },
{ 1, 1, 3 },
{ 2, 2, 7 },
{ 0, 2, 7 },
{ 3, 3, 6 },
{ 2, 2, 6 },
{ 1, 1, 7 },
{ 3, 1, 7 },
{ 0, 0, 3 },
{ 1, 1, 7 },
{ 3, 1, 7 },
{ 0, 0, 3 },
{ 1, 1, 7 },
{ 3, 1, 7 }
}

Definition at line 255 of file effectvehicle.cpp.

◆ _effect_init_procs

EffectInitProc* const _effect_init_procs[]
static
Initial value:
= {
ChimneySmokeInit,
SteamSmokeInit,
DieselSmokeInit,
ElectricSparkInit,
SmokeInit,
ExplosionLargeInit,
BreakdownSmokeInit,
ExplosionSmallInit,
BulldozerInit,
BubbleInit,
SmokeInit,
SmokeInit,
}

Functions to initialise an effect vehicle after construction.

Definition at line 537 of file effectvehicle.cpp.

◆ _effect_tick_procs

EffectTickProc* const _effect_tick_procs[]
static
Initial value:
= {
ChimneySmokeTick,
SteamSmokeTick,
DieselSmokeTick,
ElectricSparkTick,
SmokeTick,
ExplosionLargeTick,
BreakdownSmokeTick,
ExplosionSmallTick,
BulldozerTick,
BubbleTick,
SmokeTick,
SmokeTick,
}

Functions for controlling effect vehicles at each tick.

Definition at line 554 of file effectvehicle.cpp.

Referenced by EffectVehicle::Tick().

◆ _effect_transparency_options

const TransparencyOption _effect_transparency_options[]
static
Initial value:

Transparency options affecting the effects.

Definition at line 571 of file effectvehicle.cpp.

Referenced by EffectVehicle::GetTransparencyOption().

◆ _inc_by_dir

const { ... } _inc_by_dir[]
Initial value:
= {
{ -1, 0 },
{ 0, 1 },
{ 1, 0 },
{ 0, -1 }
}