summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/effectvehicle.cpp78
-rw-r--r--src/effectvehicle_base.h3
-rw-r--r--src/effectvehicle_func.h8
-rw-r--r--src/industry_cmd.cpp8
-rw-r--r--src/roadveh_cmd.cpp4
-rw-r--r--src/saveload/oldloader_sl.cpp6
-rw-r--r--src/saveload/vehicle_sl.cpp4
-rw-r--r--src/ship_cmd.cpp4
-rw-r--r--src/train_cmd.cpp4
-rw-r--r--src/vehicle_base.h6
10 files changed, 60 insertions, 65 deletions
diff --git a/src/effectvehicle.cpp b/src/effectvehicle.cpp
index 767c31702..6a7ba73d4 100644
--- a/src/effectvehicle.cpp
+++ b/src/effectvehicle.cpp
@@ -13,14 +13,14 @@
#include "table/sprites.h"
-static void ChimneySmokeInit(Vehicle *v)
+static void ChimneySmokeInit(EffectVehicle *v)
{
uint32 r = Random();
v->cur_image = SPR_CHIMNEY_SMOKE_0 + GB(r, 0, 3);
v->progress = GB(r, 16, 3);
}
-static bool ChimneySmokeTick(Vehicle *v)
+static bool ChimneySmokeTick(EffectVehicle *v)
{
if (v->progress > 0) {
v->progress--;
@@ -43,13 +43,13 @@ static bool ChimneySmokeTick(Vehicle *v)
return true;
}
-static void SteamSmokeInit(Vehicle *v)
+static void SteamSmokeInit(EffectVehicle *v)
{
v->cur_image = SPR_STEAM_SMOKE_0;
v->progress = 12;
}
-static bool SteamSmokeTick(Vehicle *v)
+static bool SteamSmokeTick(EffectVehicle *v)
{
bool moved = false;
@@ -75,13 +75,13 @@ static bool SteamSmokeTick(Vehicle *v)
return true;
}
-static void DieselSmokeInit(Vehicle *v)
+static void DieselSmokeInit(EffectVehicle *v)
{
v->cur_image = SPR_DIESEL_SMOKE_0;
v->progress = 0;
}
-static bool DieselSmokeTick(Vehicle *v)
+static bool DieselSmokeTick(EffectVehicle *v)
{
v->progress++;
@@ -101,13 +101,13 @@ static bool DieselSmokeTick(Vehicle *v)
return true;
}
-static void ElectricSparkInit(Vehicle *v)
+static void ElectricSparkInit(EffectVehicle *v)
{
v->cur_image = SPR_ELECTRIC_SPARK_0;
v->progress = 1;
}
-static bool ElectricSparkTick(Vehicle *v)
+static bool ElectricSparkTick(EffectVehicle *v)
{
if (v->progress < 2) {
v->progress++;
@@ -125,13 +125,13 @@ static bool ElectricSparkTick(Vehicle *v)
return true;
}
-static void SmokeInit(Vehicle *v)
+static void SmokeInit(EffectVehicle *v)
{
v->cur_image = SPR_SMOKE_0;
v->progress = 12;
}
-static bool SmokeTick(Vehicle *v)
+static bool SmokeTick(EffectVehicle *v)
{
bool moved = false;
@@ -157,13 +157,13 @@ static bool SmokeTick(Vehicle *v)
return true;
}
-static void ExplosionLargeInit(Vehicle *v)
+static void ExplosionLargeInit(EffectVehicle *v)
{
v->cur_image = SPR_EXPLOSION_LARGE_0;
v->progress = 0;
}
-static bool ExplosionLargeTick(Vehicle *v)
+static bool ExplosionLargeTick(EffectVehicle *v)
{
v->progress++;
if ((v->progress & 3) == 0) {
@@ -179,13 +179,13 @@ static bool ExplosionLargeTick(Vehicle *v)
return true;
}
-static void BreakdownSmokeInit(Vehicle *v)
+static void BreakdownSmokeInit(EffectVehicle *v)
{
v->cur_image = SPR_BREAKDOWN_SMOKE_0;
v->progress = 0;
}
-static bool BreakdownSmokeTick(Vehicle *v)
+static bool BreakdownSmokeTick(EffectVehicle *v)
{
v->progress++;
if ((v->progress & 7) == 0) {
@@ -197,8 +197,8 @@ static bool BreakdownSmokeTick(Vehicle *v)
VehicleMove(v, true);
}
- v->u.effect.animation_state--;
- if (v->u.effect.animation_state == 0) {
+ v->animation_state--;
+ if (v->animation_state == 0) {
delete v;
return false;
}
@@ -206,13 +206,13 @@ static bool BreakdownSmokeTick(Vehicle *v)
return true;
}
-static void ExplosionSmallInit(Vehicle *v)
+static void ExplosionSmallInit(EffectVehicle *v)
{
v->cur_image = SPR_EXPLOSION_SMALL_0;
v->progress = 0;
}
-static bool ExplosionSmallTick(Vehicle *v)
+static bool ExplosionSmallTick(EffectVehicle *v)
{
v->progress++;
if ((v->progress & 3) == 0) {
@@ -228,12 +228,12 @@ static bool ExplosionSmallTick(Vehicle *v)
return true;
}
-static void BulldozerInit(Vehicle *v)
+static void BulldozerInit(EffectVehicle *v)
{
v->cur_image = SPR_BULLDOZER_NE;
v->progress = 0;
- v->u.effect.animation_state = 0;
- v->u.effect.animation_substate = 0;
+ v->animation_state = 0;
+ v->animation_substate = 0;
}
struct BulldozerMovement {
@@ -275,22 +275,22 @@ static const struct {
{ 0, -1 }
};
-static bool BulldozerTick(Vehicle *v)
+static bool BulldozerTick(EffectVehicle *v)
{
v->progress++;
if ((v->progress & 7) == 0) {
- const BulldozerMovement *b = &_bulldozer_movement[v->u.effect.animation_state];
+ const BulldozerMovement *b = &_bulldozer_movement[v->animation_state];
v->cur_image = SPR_BULLDOZER_NE + b->image;
v->x_pos += _inc_by_dir[b->direction].x;
v->y_pos += _inc_by_dir[b->direction].y;
- v->u.effect.animation_substate++;
- if (v->u.effect.animation_substate >= b->duration) {
- v->u.effect.animation_substate = 0;
- v->u.effect.animation_state++;
- if (v->u.effect.animation_state == lengthof(_bulldozer_movement)) {
+ v->animation_substate++;
+ if (v->animation_substate >= b->duration) {
+ v->animation_substate = 0;
+ v->animation_state++;
+ if (v->animation_state == lengthof(_bulldozer_movement)) {
delete v;
return false;
}
@@ -301,7 +301,7 @@ static bool BulldozerTick(Vehicle *v)
return true;
}
-static void BubbleInit(Vehicle *v)
+static void BubbleInit(EffectVehicle *v)
{
v->cur_image = SPR_BUBBLE_GENERATE_0;
v->spritenum = 0;
@@ -458,7 +458,7 @@ static const BubbleMovement * const _bubble_movement[] = {
_bubble_absorb,
};
-static bool BubbleTick(Vehicle *v)
+static bool BubbleTick(EffectVehicle *v)
{
uint anim_state;
@@ -471,14 +471,14 @@ static bool BubbleTick(Vehicle *v)
VehicleMove(v, true);
return true;
}
- if (v->u.effect.animation_substate != 0) {
+ if (v->animation_substate != 0) {
v->spritenum = GB(Random(), 0, 2) + 1;
} else {
v->spritenum = 6;
}
anim_state = 0;
} else {
- anim_state = v->u.effect.animation_state + 1;
+ anim_state = v->animation_state + 1;
}
const BubbleMovement *b = &_bubble_movement[v->spritenum - 1][anim_state];
@@ -506,7 +506,7 @@ static bool BubbleTick(Vehicle *v)
if (IsTileType(tile, MP_INDUSTRY) && GetIndustryGfx(tile) == GFX_BUBBLE_CATCHER) AddAnimatedTile(tile);
}
- v->u.effect.animation_state = anim_state;
+ v->animation_state = anim_state;
b = &_bubble_movement[v->spritenum - 1][anim_state];
v->x_pos += b->x;
@@ -520,8 +520,8 @@ static bool BubbleTick(Vehicle *v)
}
-typedef void EffectInitProc(Vehicle *v);
-typedef bool EffectTickProc(Vehicle *v);
+typedef void EffectInitProc(EffectVehicle *v);
+typedef bool EffectTickProc(EffectVehicle *v);
static EffectInitProc * const _effect_init_procs[] = {
ChimneySmokeInit,
@@ -550,11 +550,11 @@ static EffectTickProc * const _effect_tick_procs[] = {
};
-Vehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicleType type)
+EffectVehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicleType type)
{
if (!Vehicle::CanAllocateItem()) return NULL;
- Vehicle *v = new EffectVehicle();
+ EffectVehicle *v = new EffectVehicle();
v->subtype = type;
v->x_pos = x;
v->y_pos = y;
@@ -571,14 +571,14 @@ Vehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicleType type)
return v;
}
-Vehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicleType type)
+EffectVehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicleType type)
{
int safe_x = Clamp(x, 0, MapMaxX() * TILE_SIZE);
int safe_y = Clamp(y, 0, MapMaxY() * TILE_SIZE);
return CreateEffectVehicle(x, y, GetSlopeZ(safe_x, safe_y) + z, type);
}
-Vehicle *CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVehicleType type)
+EffectVehicle *CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVehicleType type)
{
return CreateEffectVehicle(v->x_pos + x, v->y_pos + y, v->z_pos + z, type);
}
diff --git a/src/effectvehicle_base.h b/src/effectvehicle_base.h
index 789dd1f36..1c4c3f339 100644
--- a/src/effectvehicle_base.h
+++ b/src/effectvehicle_base.h
@@ -23,6 +23,9 @@
* - bubbles (industry)
*/
struct EffectVehicle : public Vehicle {
+ uint16 animation_state;
+ byte animation_substate;
+
/** Initializes the Vehicle to a special vehicle */
EffectVehicle() { this->type = VEH_EFFECT; }
diff --git a/src/effectvehicle_func.h b/src/effectvehicle_func.h
index 46b8c1460..b3b21ff2e 100644
--- a/src/effectvehicle_func.h
+++ b/src/effectvehicle_func.h
@@ -5,7 +5,7 @@
#ifndef EFFECTVEHICLE_FUNC_H
#define EFFECTVEHICLE_FUNC_H
-#include "vehicle_type.h"
+#include "effectvehicle_base.h"
/** Effect vehicle types */
enum EffectVehicleType {
@@ -21,8 +21,8 @@ enum EffectVehicleType {
EV_BUBBLE = 9
};
-Vehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicleType type);
-Vehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicleType type);
-Vehicle *CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVehicleType type);
+EffectVehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicleType type);
+EffectVehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicleType type);
+EffectVehicle *CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVehicleType type);
#endif /* EFFECTVEHICLE_FUNC_H */
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 754cee0fe..902bc9097 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -702,8 +702,6 @@ static void MakeIndustryTileBigger(TileIndex tile)
static void TileLoopIndustry_BubbleGenerator(TileIndex tile)
{
- int dir;
- Vehicle *v;
static const int8 _bubble_spawn_location[3][4] = {
{ 11, 0, -4, -14 },
{ -4, -10, -4, 1 },
@@ -712,16 +710,16 @@ static void TileLoopIndustry_BubbleGenerator(TileIndex tile)
SndPlayTileFx(SND_2E_EXTRACT_AND_POP, tile);
- dir = Random() & 3;
+ int dir = Random() & 3;
- v = CreateEffectVehicleAbove(
+ EffectVehicle *v = CreateEffectVehicleAbove(
TileX(tile) * TILE_SIZE + _bubble_spawn_location[0][dir],
TileY(tile) * TILE_SIZE + _bubble_spawn_location[1][dir],
_bubble_spawn_location[2][dir],
EV_BUBBLE
);
- if (v != NULL) v->u.effect.animation_substate = dir;
+ if (v != NULL) v->animation_substate = dir;
}
static void TileLoop_Industry(TileIndex tile)
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 1a87bcb9c..ce74d39db 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -637,8 +637,8 @@ static void HandleBrokenRoadVeh(Vehicle *v)
}
if (!(v->vehstatus & VS_HIDDEN)) {
- Vehicle *u = CreateEffectVehicleRel(v, 4, 4, 5, EV_BREAKDOWN_SMOKE);
- if (u != NULL) u->u.effect.animation_state = v->breakdown_delay * 2;
+ EffectVehicle *u = CreateEffectVehicleRel(v, 4, 4, 5, EV_BREAKDOWN_SMOKE);
+ if (u != NULL) u->animation_state = v->breakdown_delay * 2;
}
}
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp
index d692be42b..3a7eebd29 100644
--- a/src/saveload/oldloader_sl.cpp
+++ b/src/saveload/oldloader_sl.cpp
@@ -1122,8 +1122,8 @@ static const OldChunks vehicle_air_chunk[] = {
};
static const OldChunks vehicle_effect_chunk[] = {
- OCL_SVAR( OC_UINT16, VehicleEffect, animation_state ),
- OCL_SVAR( OC_UINT8, VehicleEffect, animation_substate ),
+ OCL_SVAR( OC_UINT16, EffectVehicle, animation_state ),
+ OCL_SVAR( OC_UINT8, EffectVehicle, animation_substate ),
OCL_NULL( 7 ), // Junk
@@ -1160,7 +1160,7 @@ static bool LoadOldVehicleUnion(LoadgameState *ls, int num)
case VEH_ROAD : res = LoadChunk(ls, &v->u.road, vehicle_road_chunk); break;
case VEH_SHIP : res = LoadChunk(ls, v, vehicle_ship_chunk); break;
case VEH_AIRCRAFT: res = LoadChunk(ls, &v->u.air, vehicle_air_chunk); break;
- case VEH_EFFECT : res = LoadChunk(ls, &v->u.effect, vehicle_effect_chunk); break;
+ case VEH_EFFECT : res = LoadChunk(ls, v, vehicle_effect_chunk); break;
case VEH_DISASTER: res = LoadChunk(ls, &v->u.disaster, vehicle_disaster_chunk); break;
}
}
diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp
index c749a27e3..9a4c2503d 100644
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -606,8 +606,8 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
SLE_VAR(Vehicle, progress, SLE_UINT8),
SLE_VAR(Vehicle, vehstatus, SLE_UINT8),
- SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleEffect, animation_state), SLE_UINT16),
- SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleEffect, animation_substate), SLE_UINT8),
+ SLE_VAR(EffectVehicle, animation_state, SLE_UINT16),
+ SLE_VAR(EffectVehicle, animation_substate, SLE_UINT8),
SLE_CONDVAR(Vehicle, spritenum, SLE_UINT8, 2, SL_MAX_VERSION),
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index fb0e2e07b..a7c49e88d 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -213,8 +213,8 @@ static void HandleBrokenShip(Vehicle *v)
}
if (!(v->vehstatus & VS_HIDDEN)) {
- Vehicle *u = CreateEffectVehicleRel(v, 4, 4, 5, EV_BREAKDOWN_SMOKE);
- if (u != NULL) u->u.effect.animation_state = v->breakdown_delay * 2;
+ EffectVehicle *u = CreateEffectVehicleRel(v, 4, 4, 5, EV_BREAKDOWN_SMOKE);
+ if (u != NULL) u->animation_state = v->breakdown_delay * 2;
}
}
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 61c2e547d..49754a070 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -4079,8 +4079,8 @@ static void HandleBrokenTrain(Vehicle *v)
}
if (!(v->vehstatus & VS_HIDDEN)) {
- Vehicle *u = CreateEffectVehicleRel(v, 4, 4, 5, EV_BREAKDOWN_SMOKE);
- if (u != NULL) u->u.effect.animation_state = v->breakdown_delay * 2;
+ EffectVehicle *u = CreateEffectVehicleRel(v, 4, 4, 5, EV_BREAKDOWN_SMOKE);
+ if (u != NULL) u->animation_state = v->breakdown_delay * 2;
}
}
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index 91b5b69b8..03c9dcb4e 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -175,11 +175,6 @@ struct VehicleRoad {
RoadTypes compatible_roadtypes;
};
-struct VehicleEffect {
- uint16 animation_state;
- byte animation_substate;
-};
-
struct VehicleDisaster {
uint16 image_override;
VehicleID big_ufo_destroyer_target;
@@ -316,7 +311,6 @@ public:
VehicleRail rail;
VehicleAir air;
VehicleRoad road;
- VehicleEffect effect;
VehicleDisaster disaster;
} u;