(svn r1863) Give the effect vehicle type enums more descriptive names and use the enum as parameter type for CreateEffectVehicle*()

-Fix: [1116619] Generate the correct smoke type for diesel trains
This commit is contained in:
tron 2005-02-12 15:53:32 +00:00
parent ac758b6875
commit 6b83a05ada
10 changed files with 41 additions and 44 deletions

View File

@ -1057,7 +1057,7 @@ static void HandleCrashedAircraft(Vehicle *v)
4 + (r&0xF), 4 + (r&0xF),
4 + ((r>>4)&0xF), 4 + ((r>>4)&0xF),
((r>>8)&0xF), ((r>>8)&0xF),
EV_DEMOLISH); EV_EXPLOSION_SMALL);
} }
} else if (v->u.air.crashed_counter >= 10000) { } else if (v->u.air.crashed_counter >= 10000) {
// remove rubble of crashed airplane // remove rubble of crashed airplane
@ -1108,7 +1108,7 @@ static void HandleAircraftSmoke(Vehicle *v)
_aircraft_smoke_xy[v->direction], _aircraft_smoke_xy[v->direction],
_aircraft_smoke_xy[v->direction + 8], _aircraft_smoke_xy[v->direction + 8],
2, 2,
EV_SMOKE_3 EV_SMOKE
); );
} }
} }
@ -1206,7 +1206,7 @@ static void CrashAirplane(Vehicle *v)
v->vehstatus |= VS_CRASHED; v->vehstatus |= VS_CRASHED;
v->u.air.crashed_counter = 0; v->u.air.crashed_counter = 0;
CreateEffectVehicleRel(v, 4, 4, 8, EV_CRASHED_SMOKE); CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
InvalidateWindow(WC_VEHICLE_VIEW, v->index); InvalidateWindow(WC_VEHICLE_VIEW, v->index);

View File

@ -166,7 +166,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
} }
if ((v->tick_counter&7)==0) { if ((v->tick_counter&7)==0) {
CreateEffectVehicleRel(v, 0, -17, 2, EV_SMOKE_3); CreateEffectVehicleRel(v, 0, -17, 2, EV_SMOKE);
} }
} else if (v->current_order.station == 0) { } else if (v->current_order.station == 0) {
tile = v->tile; /**/ tile = v->tile; /**/
@ -219,7 +219,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
SetDisasterVehiclePos(v, x, y, z); SetDisasterVehiclePos(v, x, y, z);
if (++v->age == 1) { if (++v->age == 1) {
CreateEffectVehicleRel(v, 0, 7, 8, EV_CRASHED_SMOKE); CreateEffectVehicleRel(v, 0, 7, 8, EV_EXPLOSION_LARGE);
SndPlayVehicleFx(SND_12_EXPLOSION, v); SndPlayVehicleFx(SND_12_EXPLOSION, v);
v->u.disaster.image_override = 0xF42; v->u.disaster.image_override = 0xF42;
} else if (v->age == 70) { } else if (v->age == 70) {
@ -232,7 +232,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
-7 + (r&0xF), -7 + (r&0xF),
-7 + (r>>4&0xF), -7 + (r>>4&0xF),
5 + (r>>8&0x7), 5 + (r>>8&0x7),
EV_DEMOLISH); EV_EXPLOSION_SMALL);
} }
} else if (v->age == 350) { } else if (v->age == 350) {
v->current_order.station = 3; v->current_order.station = 3;
@ -323,7 +323,7 @@ static void DisasterTick_UFO(Vehicle *v)
// destroy? // destroy?
if (v->age > 50) { if (v->age > 50) {
CreateEffectVehicleRel(v, 0, 7, 8, EV_CRASHED_SMOKE); CreateEffectVehicleRel(v, 0, 7, 8, EV_EXPLOSION_LARGE);
SndPlayVehicleFx(SND_12_EXPLOSION, v); SndPlayVehicleFx(SND_12_EXPLOSION, v);
DeleteDisasterVeh(v); DeleteDisasterVeh(v);
} }
@ -370,7 +370,7 @@ static void DisasterTick_2(Vehicle *v)
x + (r & 0x3F), x + (r & 0x3F),
y + (r >> 6 & 0x3F), y + (r >> 6 & 0x3F),
(r >> 12 & 0xF), (r >> 12 & 0xF),
EV_DEMOLISH); EV_EXPLOSION_SMALL);
if (++v->age >= 55) if (++v->age >= 55)
v->current_order.station = 3; v->current_order.station = 3;
@ -441,7 +441,7 @@ static void DisasterTick_3(Vehicle *v)
x + (r & 0x3F), x + (r & 0x3F),
y + (r >> 6 & 0x3F), y + (r >> 6 & 0x3F),
(r >> 12 & 0xF), (r >> 12 & 0xF),
EV_DEMOLISH); EV_EXPLOSION_SMALL);
if (++v->age >= 55) if (++v->age >= 55)
v->current_order.station = 3; v->current_order.station = 3;
@ -614,7 +614,7 @@ static void DisasterTick_4b(Vehicle *v)
return; return;
v->current_order.station = 1; v->current_order.station = 1;
CreateEffectVehicleRel(u, 0, 7, 8, EV_CRASHED_SMOKE); CreateEffectVehicleRel(u, 0, 7, 8, EV_EXPLOSION_LARGE);
SndPlayVehicleFx(SND_12_EXPLOSION, u); SndPlayVehicleFx(SND_12_EXPLOSION, u);
DeleteDisasterVeh(u); DeleteDisasterVeh(u);
@ -625,7 +625,7 @@ static void DisasterTick_4b(Vehicle *v)
v->x_pos-32+(r&0x3F), v->x_pos-32+(r&0x3F),
v->y_pos-32+(r>>5&0x3F), v->y_pos-32+(r>>5&0x3F),
0, 0,
EV_DEMOLISH); EV_EXPLOSION_SMALL);
} }
BEGIN_TILE_LOOP(tile,6,6,v->tile - TILE_XY(3,3)) BEGIN_TILE_LOOP(tile,6,6,v->tile - TILE_XY(3,3))

View File

@ -669,7 +669,7 @@ static void MakeIndustryTileBiggerCase8(uint tile)
{ {
TileInfo ti; TileInfo ti;
FindLandscapeHeight(&ti, TileX(tile) * 16, TileY(tile) * 16); FindLandscapeHeight(&ti, TileX(tile) * 16, TileY(tile) * 16);
CreateEffectVehicle(ti.x + 15, ti.y + 14, ti.z + 59 + (ti.tileh != 0 ? 8 : 0), EV_INDUSTRYSMOKE); CreateEffectVehicle(ti.x + 15, ti.y + 14, ti.z + 59 + (ti.tileh != 0 ? 8 : 0), EV_CHIMNEY_SMOKE);
} }
static void MakeIndustryTileBigger(uint tile, byte size) static void MakeIndustryTileBigger(uint tile, byte size)
@ -735,7 +735,7 @@ static void TileLoopIndustryCase161(uint tile)
TileX(tile) * 16 + _tileloop_ind_case_161[dir + 0], TileX(tile) * 16 + _tileloop_ind_case_161[dir + 0],
TileY(tile) * 16 + _tileloop_ind_case_161[dir + 4], TileY(tile) * 16 + _tileloop_ind_case_161[dir + 4],
_tileloop_ind_case_161[dir + 8], _tileloop_ind_case_161[dir + 8],
EV_INDUSTRY_SMOKE EV_BUBBLE
); );
if (v != NULL) if (v != NULL)
@ -819,7 +819,7 @@ static void TileLoop_Industry(uint tile)
break; break;
case 49: { case 49: {
CreateEffectVehicleAbove(TileX(tile) * 16 + 6, TileY(tile) * 16 + 6, 43, EV_SMOKE_3); CreateEffectVehicleAbove(TileX(tile) * 16 + 6, TileY(tile) * 16 + 6, 43, EV_SMOKE);
} break; } break;

View File

@ -334,7 +334,9 @@ int32 CmdClearArea(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
// draw explosion animation... // draw explosion animation...
if ((x==sx || x==ex) && (y==sy || y==ey)) { if ((x==sx || x==ex) && (y==sy || y==ey)) {
// big explosion in each corner, or small explosion for single tiles // big explosion in each corner, or small explosion for single tiles
CreateEffectVehicleAbove(x + 8,y + 8, 2, sy==ey && sx==ex ? EV_DEMOLISH : EV_CRASHED_SMOKE); CreateEffectVehicleAbove(x + 8, y + 8, 2,
sy == ey && sx == ex ? EV_EXPLOSION_SMALL : EV_EXPLOSION_LARGE
);
} }
} }
} }

View File

@ -980,7 +980,7 @@ static void TileLoop_Road(uint tile)
TileX(tile) * 16 + 7, TileX(tile) * 16 + 7,
TileY(tile) * 16 + 7, TileY(tile) * 16 + 7,
0, 0,
EV_ROADWORK); EV_BULLDOZER);
MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile);
return; return;
} }

View File

@ -509,7 +509,7 @@ static void RoadVehIsCrashed(Vehicle *v)
{ {
v->u.road.crashed_ctr++; v->u.road.crashed_ctr++;
if (v->u.road.crashed_ctr == 2) { if (v->u.road.crashed_ctr == 2) {
CreateEffectVehicleRel(v,4,4,8,EV_CRASHED_SMOKE); CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
} else if (v->u.road.crashed_ctr <= 45) { } else if (v->u.road.crashed_ctr <= 45) {
if ((v->tick_counter&7)==0) if ((v->tick_counter&7)==0)
RoadVehSetRandomDirection(v); RoadVehSetRandomDirection(v);

View File

@ -1454,14 +1454,14 @@ static void HandleLocomotiveSmokeCloud(Vehicle *v)
case 1: case 1:
// diesel smoke // diesel smoke
if (u->cur_speed <= 40 && !IsTileDepotType(v->tile, TRANSPORT_RAIL) && !IsTunnelTile(v->tile) && (uint16)Random() <= 0x1E00) { if (u->cur_speed <= 40 && !IsTileDepotType(v->tile, TRANSPORT_RAIL) && !IsTunnelTile(v->tile) && (uint16)Random() <= 0x1E00) {
CreateEffectVehicleRel(v, 0,0,10, EV_SMOKE_3); CreateEffectVehicleRel(v, 0, 0, 10, EV_DIESEL_SMOKE);
} }
break; break;
case 2: case 2:
// blue spark // blue spark
if ( (v->tick_counter&0x3) == 0 && !IsTileDepotType(v->tile, TRANSPORT_RAIL) && !IsTunnelTile(v->tile) && (uint16)Random() <= 0x5B0) { if ( (v->tick_counter&0x3) == 0 && !IsTileDepotType(v->tile, TRANSPORT_RAIL) && !IsTunnelTile(v->tile) && (uint16)Random() <= 0x5B0) {
CreateEffectVehicleRel(v, 0,0,10, EV_SMOKE_2); CreateEffectVehicleRel(v, 0, 0, 10, EV_ELECTRIC_SPARK);
} }
break; break;
} }
@ -2658,7 +2658,7 @@ static void HandleCrashedTrain(Vehicle *v)
Vehicle *u; Vehicle *u;
if ( (state == 4) && (v->u.rail.track != 0x40) ) { if ( (state == 4) && (v->u.rail.track != 0x40) ) {
CreateEffectVehicleRel(v, 4, 4, 8, EV_CRASHED_SMOKE); CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
} }
if (state <= 200 && (uint16)(r=Random()) <= 0x2492) { if (state <= 200 && (uint16)(r=Random()) <= 0x2492) {
@ -2673,7 +2673,7 @@ static void HandleCrashedTrain(Vehicle *v)
2 + ((r>>8)&7), 2 + ((r>>8)&7),
2 + ((r>>16)&7), 2 + ((r>>16)&7),
5 + (r&7), 5 + (r&7),
EV_DEMOLISH); EV_EXPLOSION_SMALL);
break; break;
} }
} while ( (u=u->next) != NULL); } while ( (u=u->next) != NULL);

View File

@ -1104,7 +1104,7 @@ static EffectTickProc * const _effect_tick_procs[] = {
}; };
Vehicle *CreateEffectVehicle(int x, int y, int z, int type) Vehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicle type)
{ {
Vehicle *v; Vehicle *v;
@ -1129,12 +1129,12 @@ Vehicle *CreateEffectVehicle(int x, int y, int z, int type)
return v; return v;
} }
Vehicle *CreateEffectVehicleAbove(int x, int y, int z, int type) Vehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicle type)
{ {
return CreateEffectVehicle(x, y, GetSlopeZ(x, y) + z, type); return CreateEffectVehicle(x, y, GetSlopeZ(x, y) + z, type);
} }
Vehicle *CreateEffectVehicleRel(Vehicle *v, int x, int y, int z, int type) Vehicle *CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVehicle type)
{ {
return CreateEffectVehicle(v->x_pos + x, v->y_pos + y, v->z_pos + z, type); return CreateEffectVehicle(v->x_pos + x, v->y_pos + y, v->z_pos + z, type);
} }

View File

@ -238,23 +238,18 @@ enum TrainSubtype {
}; };
/* Effect vehicle types */ /* Effect vehicle types */
enum { typedef enum EffectVehicle {
EV_INDUSTRYSMOKE = 0, EV_CHIMNEY_SMOKE = 0,
EV_STEAM_SMOKE = 1, EV_STEAM_SMOKE = 1,
EV_DIESEL_SMOKE = 2,
EV_SMOKE_1 = 2, EV_ELECTRIC_SPARK = 3,
EV_SMOKE_2 = 3, EV_SMOKE = 4,
EV_SMOKE_3 = 4, EV_EXPLOSION_LARGE = 5,
EV_CRASHED_SMOKE = 5,
EV_BREAKDOWN_SMOKE = 6, EV_BREAKDOWN_SMOKE = 6,
EV_EXPLOSION_SMALL = 7,
EV_DEMOLISH = 7, EV_BULLDOZER = 8,
EV_ROADWORK = 8, EV_BUBBLE = 9
} EffectVehicle;
EV_INDUSTRY_SMOKE = 9,
};
typedef void VehicleTickProc(Vehicle *v); typedef void VehicleTickProc(Vehicle *v);
typedef void *VehicleFromPosProc(Vehicle *v, void *data); typedef void *VehicleFromPosProc(Vehicle *v, void *data);
@ -295,9 +290,9 @@ int GetAircraftImage(Vehicle *v, byte direction);
int GetRoadVehImage(Vehicle *v, byte direction); int GetRoadVehImage(Vehicle *v, byte direction);
int GetShipImage(Vehicle *v, byte direction); int GetShipImage(Vehicle *v, byte direction);
Vehicle *CreateEffectVehicle(int x, int y, int z, int type); Vehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicle type);
Vehicle *CreateEffectVehicleAbove(int x, int y, int z, int type); Vehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicle type);
Vehicle *CreateEffectVehicleRel(Vehicle *v, int x, int y, int z, int type); Vehicle *CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVehicle type);
uint32 VehicleEnterTile(Vehicle *v, uint tile, int x, int y); uint32 VehicleEnterTile(Vehicle *v, uint tile, int x, int y);

View File

@ -601,7 +601,7 @@ static void FloodVehicle(Vehicle *v)
NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ACCIDENT, 0), NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ACCIDENT, 0),
v->index, v->index,
0); 0);
CreateEffectVehicleRel(v,4,4,8,EV_CRASHED_SMOKE); // show cool destruction effects CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE); // show cool destruction effects
SndPlayVehicleFx(SND_12_EXPLOSION, v); // create sound SndPlayVehicleFx(SND_12_EXPLOSION, v); // create sound
} }
} }