|
@@ -37,25 +37,25 @@ static bool ChimneySmokeTick(EffectVehic
|
|
|
TileIndex tile = TileVirtXY(v->x_pos, v->y_pos);
|
|
|
if (!IsTileType(tile, MP_INDUSTRY)) {
|
|
|
delete v;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (v->cur_image != SPR_CHIMNEY_SMOKE_7) {
|
|
|
v->cur_image++;
|
|
|
} else {
|
|
|
v->cur_image = SPR_CHIMNEY_SMOKE_0;
|
|
|
}
|
|
|
v->progress = 7;
|
|
|
VehicleUpdatePositionAndViewport(v);
|
|
|
v->UpdatePositionAndViewport();
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static void SteamSmokeInit(EffectVehicle *v)
|
|
|
{
|
|
|
v->cur_image = SPR_STEAM_SMOKE_0;
|
|
|
v->progress = 12;
|
|
|
}
|
|
|
|
|
|
static bool SteamSmokeTick(EffectVehicle *v)
|
|
@@ -70,70 +70,70 @@ static bool SteamSmokeTick(EffectVehicle
|
|
|
}
|
|
|
|
|
|
if ((v->progress & 0xF) == 4) {
|
|
|
if (v->cur_image != SPR_STEAM_SMOKE_4) {
|
|
|
v->cur_image++;
|
|
|
} else {
|
|
|
delete v;
|
|
|
return false;
|
|
|
}
|
|
|
moved = true;
|
|
|
}
|
|
|
|
|
|
if (moved) VehicleUpdatePositionAndViewport(v);
|
|
|
if (moved) v->UpdatePositionAndViewport();
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static void DieselSmokeInit(EffectVehicle *v)
|
|
|
{
|
|
|
v->cur_image = SPR_DIESEL_SMOKE_0;
|
|
|
v->progress = 0;
|
|
|
}
|
|
|
|
|
|
static bool DieselSmokeTick(EffectVehicle *v)
|
|
|
{
|
|
|
v->progress++;
|
|
|
|
|
|
if ((v->progress & 3) == 0) {
|
|
|
v->z_pos++;
|
|
|
VehicleUpdatePositionAndViewport(v);
|
|
|
v->UpdatePositionAndViewport();
|
|
|
} else if ((v->progress & 7) == 1) {
|
|
|
if (v->cur_image != SPR_DIESEL_SMOKE_5) {
|
|
|
v->cur_image++;
|
|
|
VehicleUpdatePositionAndViewport(v);
|
|
|
v->UpdatePositionAndViewport();
|
|
|
} else {
|
|
|
delete v;
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static void ElectricSparkInit(EffectVehicle *v)
|
|
|
{
|
|
|
v->cur_image = SPR_ELECTRIC_SPARK_0;
|
|
|
v->progress = 1;
|
|
|
}
|
|
|
|
|
|
static bool ElectricSparkTick(EffectVehicle *v)
|
|
|
{
|
|
|
if (v->progress < 2) {
|
|
|
v->progress++;
|
|
|
} else {
|
|
|
v->progress = 0;
|
|
|
if (v->cur_image != SPR_ELECTRIC_SPARK_5) {
|
|
|
v->cur_image++;
|
|
|
VehicleUpdatePositionAndViewport(v);
|
|
|
v->UpdatePositionAndViewport();
|
|
|
} else {
|
|
|
delete v;
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static void SmokeInit(EffectVehicle *v)
|
|
|
{
|
|
|
v->cur_image = SPR_SMOKE_0;
|
|
@@ -152,91 +152,91 @@ static bool SmokeTick(EffectVehicle *v)
|
|
|
}
|
|
|
|
|
|
if ((v->progress & 0xF) == 4) {
|
|
|
if (v->cur_image != SPR_SMOKE_4) {
|
|
|
v->cur_image++;
|
|
|
} else {
|
|
|
delete v;
|
|
|
return false;
|
|
|
}
|
|
|
moved = true;
|
|
|
}
|
|
|
|
|
|
if (moved) VehicleUpdatePositionAndViewport(v);
|
|
|
if (moved) v->UpdatePositionAndViewport();
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static void ExplosionLargeInit(EffectVehicle *v)
|
|
|
{
|
|
|
v->cur_image = SPR_EXPLOSION_LARGE_0;
|
|
|
v->progress = 0;
|
|
|
}
|
|
|
|
|
|
static bool ExplosionLargeTick(EffectVehicle *v)
|
|
|
{
|
|
|
v->progress++;
|
|
|
if ((v->progress & 3) == 0) {
|
|
|
if (v->cur_image != SPR_EXPLOSION_LARGE_F) {
|
|
|
v->cur_image++;
|
|
|
VehicleUpdatePositionAndViewport(v);
|
|
|
v->UpdatePositionAndViewport();
|
|
|
} else {
|
|
|
delete v;
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static void BreakdownSmokeInit(EffectVehicle *v)
|
|
|
{
|
|
|
v->cur_image = SPR_BREAKDOWN_SMOKE_0;
|
|
|
v->progress = 0;
|
|
|
}
|
|
|
|
|
|
static bool BreakdownSmokeTick(EffectVehicle *v)
|
|
|
{
|
|
|
v->progress++;
|
|
|
if ((v->progress & 7) == 0) {
|
|
|
if (v->cur_image != SPR_BREAKDOWN_SMOKE_3) {
|
|
|
v->cur_image++;
|
|
|
} else {
|
|
|
v->cur_image = SPR_BREAKDOWN_SMOKE_0;
|
|
|
}
|
|
|
VehicleUpdatePositionAndViewport(v);
|
|
|
v->UpdatePositionAndViewport();
|
|
|
}
|
|
|
|
|
|
v->animation_state--;
|
|
|
if (v->animation_state == 0) {
|
|
|
delete v;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static void ExplosionSmallInit(EffectVehicle *v)
|
|
|
{
|
|
|
v->cur_image = SPR_EXPLOSION_SMALL_0;
|
|
|
v->progress = 0;
|
|
|
}
|
|
|
|
|
|
static bool ExplosionSmallTick(EffectVehicle *v)
|
|
|
{
|
|
|
v->progress++;
|
|
|
if ((v->progress & 3) == 0) {
|
|
|
if (v->cur_image != SPR_EXPLOSION_SMALL_B) {
|
|
|
v->cur_image++;
|
|
|
VehicleUpdatePositionAndViewport(v);
|
|
|
v->UpdatePositionAndViewport();
|
|
|
} else {
|
|
|
delete v;
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static void BulldozerInit(EffectVehicle *v)
|
|
|
{
|
|
|
v->cur_image = SPR_BULLDOZER_NE;
|
|
@@ -295,25 +295,25 @@ static bool BulldozerTick(EffectVehicle
|
|
|
v->x_pos += _inc_by_dir[b->direction].x;
|
|
|
v->y_pos += _inc_by_dir[b->direction].y;
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
}
|
|
|
VehicleUpdatePositionAndViewport(v);
|
|
|
v->UpdatePositionAndViewport();
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static void BubbleInit(EffectVehicle *v)
|
|
|
{
|
|
|
v->cur_image = SPR_BUBBLE_GENERATE_0;
|
|
|
v->spritenum = 0;
|
|
|
v->progress = 0;
|
|
|
}
|
|
|
|
|
@@ -468,25 +468,25 @@ static const BubbleMovement * const _bub
|
|
|
};
|
|
|
|
|
|
static bool BubbleTick(EffectVehicle *v)
|
|
|
{
|
|
|
uint anim_state;
|
|
|
|
|
|
v->progress++;
|
|
|
if ((v->progress & 3) != 0) return true;
|
|
|
|
|
|
if (v->spritenum == 0) {
|
|
|
v->cur_image++;
|
|
|
if (v->cur_image < SPR_BUBBLE_GENERATE_3) {
|
|
|
VehicleUpdatePositionAndViewport(v);
|
|
|
v->UpdatePositionAndViewport();
|
|
|
return true;
|
|
|
}
|
|
|
if (v->animation_substate != 0) {
|
|
|
v->spritenum = GB(Random(), 0, 2) + 1;
|
|
|
} else {
|
|
|
v->spritenum = 6;
|
|
|
}
|
|
|
anim_state = 0;
|
|
|
} else {
|
|
|
anim_state = v->animation_state + 1;
|
|
|
}
|
|
|
|
|
@@ -514,25 +514,25 @@ static bool BubbleTick(EffectVehicle *v)
|
|
|
tile = TileVirtXY(v->x_pos, v->y_pos);
|
|
|
if (IsTileType(tile, MP_INDUSTRY) && GetIndustryGfx(tile) == GFX_BUBBLE_CATCHER) AddAnimatedTile(tile);
|
|
|
}
|
|
|
|
|
|
v->animation_state = anim_state;
|
|
|
b = &_bubble_movement[v->spritenum - 1][anim_state];
|
|
|
|
|
|
v->x_pos += b->x;
|
|
|
v->y_pos += b->y;
|
|
|
v->z_pos += b->z;
|
|
|
v->cur_image = SPR_BUBBLE_0 + b->image;
|
|
|
|
|
|
VehicleUpdatePositionAndViewport(v);
|
|
|
v->UpdatePositionAndViewport();
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
|
|
|
typedef void EffectInitProc(EffectVehicle *v);
|
|
|
typedef bool EffectTickProc(EffectVehicle *v);
|
|
|
|
|
|
/** Functions to initialise an effect vehicle after construction. */
|
|
|
static EffectInitProc * const _effect_init_procs[] = {
|
|
|
ChimneySmokeInit, // EV_CHIMNEY_SMOKE
|
|
|
SteamSmokeInit, // EV_STEAM_SMOKE
|
|
@@ -598,25 +598,25 @@ EffectVehicle *CreateEffectVehicle(int x
|
|
|
|
|
|
EffectVehicle *v = new EffectVehicle();
|
|
|
v->subtype = type;
|
|
|
v->x_pos = x;
|
|
|
v->y_pos = y;
|
|
|
v->z_pos = z;
|
|
|
v->tile = 0;
|
|
|
v->UpdateDeltaXY(INVALID_DIR);
|
|
|
v->vehstatus = VS_UNCLICKABLE;
|
|
|
|
|
|
_effect_init_procs[type](v);
|
|
|
|
|
|
VehicleUpdatePositionAndViewport(v);
|
|
|
v->UpdatePositionAndViewport();
|
|
|
|
|
|
return v;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Create an effect vehicle above a particular location.
|
|
|
* @param x The x location on the map.
|
|
|
* @param y The y location on the map.
|
|
|
* @param z The offset from the ground.
|
|
|
* @param type The type of effect vehicle.
|
|
|
* @return The effect vehicle.
|
|
|
*/
|