Changeset - r9008:e9055c9e2c9e
[Not reviewed]
master
0 10 0
rubidium - 16 years ago 2008-04-20 10:13:54
rubidium@openttd.org
(svn r12803) -Cleanup: rename SpecialVehicle to EffectVehicle to have a uniform naming of the thing instead of using both names for the same thing.
10 files changed with 43 insertions and 43 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -699,13 +699,13 @@ static void TileLoopIndustry_BubbleGener
 
		TileX(tile) * TILE_SIZE + _tileloop_ind_case_161[dir + 0],
 
		TileY(tile) * TILE_SIZE + _tileloop_ind_case_161[dir + 4],
 
		_tileloop_ind_case_161[dir + 8],
 
		EV_BUBBLE
 
	);
 

	
 
	if (v != NULL) v->u.special.animation_substate = dir;
 
	if (v != NULL) v->u.effect.animation_substate = dir;
 
}
 

	
 
static void TileLoop_Industry(TileIndex tile)
 
{
 
	IndustryGfx newgfx;
 
	IndustryGfx gfx;
src/oldloader.cpp
Show inline comments
 
@@ -1083,15 +1083,15 @@ static const OldChunks vehicle_air_chunk
 

	
 
	OCL_NULL( 5 ), ///< Junk
 

	
 
	OCL_END()
 
};
 

	
 
static const OldChunks vehicle_special_chunk[] = {
 
	OCL_SVAR( OC_UINT16, VehicleSpecial, animation_state ),
 
	OCL_SVAR(  OC_UINT8, VehicleSpecial, animation_substate ),
 
static const OldChunks vehicle_effect_chunk[] = {
 
	OCL_SVAR( OC_UINT16, VehicleEffect, animation_state ),
 
	OCL_SVAR(  OC_UINT8, VehicleEffect, animation_substate ),
 

	
 
	OCL_NULL( 7 ), // Junk
 

	
 
	OCL_END()
 
};
 

	
 
@@ -1120,13 +1120,13 @@ static bool LoadOldVehicleUnion(Loadgame
 
		default: NOT_REACHED();
 
		case VEH_INVALID : res = LoadChunk(ls, NULL,           vehicle_empty_chunk);    break;
 
		case VEH_TRAIN   : res = LoadChunk(ls, &v->u.rail,     vehicle_train_chunk);    break;
 
		case VEH_ROAD    : res = LoadChunk(ls, &v->u.road,     vehicle_road_chunk);     break;
 
		case VEH_SHIP    : res = LoadChunk(ls, &v->u.ship,     vehicle_ship_chunk);     break;
 
		case VEH_AIRCRAFT: res = LoadChunk(ls, &v->u.air,      vehicle_air_chunk);      break;
 
		case VEH_SPECIAL : res = LoadChunk(ls, &v->u.special,  vehicle_special_chunk);  break;
 
		case VEH_EFFECT  : res = LoadChunk(ls, &v->u.effect,   vehicle_effect_chunk);   break;
 
		case VEH_DISASTER: res = LoadChunk(ls, &v->u.disaster, vehicle_disaster_chunk); break;
 
	}
 

	
 
	/* This chunk size should always be 10 bytes */
 
	if (ls->total_read - temp != 10) {
 
		DEBUG(oldloader, 0, "Assert failed in VehicleUnion: invalid chunk size");
 
@@ -1233,13 +1233,13 @@ bool LoadOldVehicle(LoadgameState *ls, i
 
			default: NOT_REACHED();
 
			case 0x00 /*VEH_INVALID */: v = new (_current_vehicle_id) InvalidVehicle();  break;
 
			case 0x10 /*VEH_TRAIN   */: v = new (_current_vehicle_id) Train();           break;
 
			case 0x11 /*VEH_ROAD    */: v = new (_current_vehicle_id) RoadVehicle();     break;
 
			case 0x12 /*VEH_SHIP    */: v = new (_current_vehicle_id) Ship();            break;
 
			case 0x13 /*VEH_AIRCRAFT*/: v = new (_current_vehicle_id) Aircraft();        break;
 
			case 0x14 /*VEH_SPECIAL */: v = new (_current_vehicle_id) SpecialVehicle();  break;
 
			case 0x14 /*VEH_EFFECT  */: v = new (_current_vehicle_id) EffectVehicle();   break;
 
			case 0x15 /*VEH_DISASTER*/: v = new (_current_vehicle_id) DisasterVehicle(); break;
 
		}
 
		if (!LoadChunk(ls, v, vehicle_chunk)) return false;
 

	
 
		/* This should be consistent, else we have a big problem... */
 
		if (v->index != _current_vehicle_id) {
 
@@ -1267,13 +1267,13 @@ bool LoadOldVehicle(LoadgameState *ls, i
 
		if (_old_next_ptr != 0xFFFF) v->next = GetVehiclePoolSize() <= _old_next_ptr ? new (_old_next_ptr) InvalidVehicle() : GetVehicle(_old_next_ptr);
 

	
 
		_old_string_id = RemapOldStringID(_old_string_id);
 
		v->name = CopyFromOldName(_old_string_id);
 

	
 
		/* Vehicle-subtype is different in TTD(Patch) */
 
		if (v->type == VEH_SPECIAL) v->subtype = v->subtype >> 1;
 
		if (v->type == VEH_EFFECT) v->subtype = v->subtype >> 1;
 

	
 
		if (_cargo_count != 0) {
 
			CargoPacket *cp = new CargoPacket((_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source, _cargo_count);
 
			cp->days_in_transit = _cargo_days;
 
			v->cargo.Append(cp);
 
		}
src/roadveh_cmd.cpp
Show inline comments
 
@@ -701,13 +701,13 @@ static void HandleBrokenRoadVeh(Vehicle 
 
			SndPlayVehicleFx((_opt.landscape != LT_TOYLAND) ?
 
				SND_0F_VEHICLE_BREAKDOWN : SND_35_COMEDY_BREAKDOWN, v);
 
		}
 

	
 
		if (!(v->vehstatus & VS_HIDDEN)) {
 
			Vehicle *u = CreateEffectVehicleRel(v, 4, 4, 5, EV_BREAKDOWN_SMOKE);
 
			if (u != NULL) u->u.special.animation_state = v->breakdown_delay * 2;
 
			if (u != NULL) u->u.effect.animation_state = v->breakdown_delay * 2;
 
		}
 
	}
 

	
 
	if ((v->tick_counter & 1) == 0) {
 
		if (--v->breakdown_delay == 0) {
 
			v->breakdown_ctr = 0;
src/ship_cmd.cpp
Show inline comments
 
@@ -207,13 +207,13 @@ static void HandleBrokenShip(Vehicle *v)
 
			SndPlayVehicleFx((_opt.landscape != LT_TOYLAND) ?
 
				SND_10_TRAIN_BREAKDOWN : SND_3A_COMEDY_BREAKDOWN_2, v);
 
		}
 

	
 
		if (!(v->vehstatus & VS_HIDDEN)) {
 
			Vehicle *u = CreateEffectVehicleRel(v, 4, 4, 5, EV_BREAKDOWN_SMOKE);
 
			if (u != NULL) u->u.special.animation_state = v->breakdown_delay * 2;
 
			if (u != NULL) u->u.effect.animation_state = v->breakdown_delay * 2;
 
		}
 
	}
 

	
 
	if (!(v->tick_counter & 1)) {
 
		if (!--v->breakdown_delay) {
 
			v->breakdown_ctr = 0;
src/smallmap_gui.cpp
Show inline comments
 
@@ -679,13 +679,13 @@ skip_column:
 
	if (type == SMT_CONTOUR || type == SMT_VEHICLES) {
 
		Vehicle *v;
 
		bool skip;
 
		byte color;
 

	
 
		FOR_ALL_VEHICLES(v) {
 
			if (v->type != VEH_SPECIAL &&
 
			if (v->type != VEH_EFFECT &&
 
					(v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0) {
 
				/* Remap into flat coordinates. */
 
				Point pt = RemapCoords(
 
					v->x_pos / TILE_SIZE - WP(w, smallmap_d).scroll_x / TILE_SIZE, // divide each one separately because (a-b)/c != a/c-b/c in integer world
 
					v->y_pos / TILE_SIZE - WP(w, smallmap_d).scroll_y / TILE_SIZE, //    dtto
 
					0);
src/train_cmd.cpp
Show inline comments
 
@@ -3234,13 +3234,13 @@ static void HandleBrokenTrain(Vehicle *v
 
			SndPlayVehicleFx((_opt.landscape != LT_TOYLAND) ?
 
				SND_10_TRAIN_BREAKDOWN : SND_3A_COMEDY_BREAKDOWN_2, v);
 
		}
 

	
 
		if (!(v->vehstatus & VS_HIDDEN)) {
 
			Vehicle *u = CreateEffectVehicleRel(v, 4, 4, 5, EV_BREAKDOWN_SMOKE);
 
			if (u != NULL) u->u.special.animation_state = v->breakdown_delay * 2;
 
			if (u != NULL) u->u.effect.animation_state = v->breakdown_delay * 2;
 
		}
 
	}
 

	
 
	if (!(v->tick_counter & 3)) {
 
		if (!--v->breakdown_delay) {
 
			v->breakdown_ctr = 0;
src/vehicle.cpp
Show inline comments
 
@@ -1041,14 +1041,14 @@ static void BreakdownSmokeTick(Vehicle *
 
			v->cur_image = SPR_BREAKDOWN_SMOKE_0;
 
		}
 
		VehiclePositionChanged(v);
 
		EndVehicleMove(v);
 
	}
 

	
 
	v->u.special.animation_state--;
 
	if (v->u.special.animation_state == 0) {
 
	v->u.effect.animation_state--;
 
	if (v->u.effect.animation_state == 0) {
 
		BeginVehicleMove(v);
 
		EndVehicleMove(v);
 
		delete v;
 
	}
 
}
 

	
 
@@ -1075,14 +1075,14 @@ static void ExplosionSmallTick(Vehicle *
 
}
 

	
 
static void BulldozerInit(Vehicle *v)
 
{
 
	v->cur_image = SPR_BULLDOZER_NE;
 
	v->progress = 0;
 
	v->u.special.animation_state = 0;
 
	v->u.special.animation_substate = 0;
 
	v->u.effect.animation_state = 0;
 
	v->u.effect.animation_substate = 0;
 
}
 

	
 
struct BulldozerMovement {
 
	byte direction:2;
 
	byte image:2;
 
	byte duration:3;
 
@@ -1122,26 +1122,26 @@ static const struct {
 
};
 

	
 
static void BulldozerTick(Vehicle *v)
 
{
 
	v->progress++;
 
	if ((v->progress & 7) == 0) {
 
		const BulldozerMovement* b = &_bulldozer_movement[v->u.special.animation_state];
 
		const BulldozerMovement* b = &_bulldozer_movement[v->u.effect.animation_state];
 

	
 
		BeginVehicleMove(v);
 

	
 
		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.special.animation_substate++;
 
		if (v->u.special.animation_substate >= b->duration) {
 
			v->u.special.animation_substate = 0;
 
			v->u.special.animation_state++;
 
			if (v->u.special.animation_state == lengthof(_bulldozer_movement)) {
 
		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)) {
 
				EndVehicleMove(v);
 
				delete v;
 
				return;
 
			}
 
		}
 
		VehiclePositionChanged(v);
 
@@ -1325,13 +1325,13 @@ static void BubbleTick(Vehicle *v)
 
		v->cur_image++;
 
		if (v->cur_image < SPR_BUBBLE_GENERATE_3) {
 
			VehiclePositionChanged(v);
 
			EndVehicleMove(v);
 
			return;
 
		}
 
		if (v->u.special.animation_substate != 0) {
 
		if (v->u.effect.animation_substate != 0) {
 
			v->spritenum = GB(InteractiveRandom(), 0, 2) + 1;
 
		} else {
 
			v->spritenum = 6;
 
		}
 
		et = 0;
 
	} else {
 
@@ -1404,15 +1404,15 @@ static EffectTickProc * const _effect_ti
 
	ExplosionSmallTick,
 
	BulldozerTick,
 
	BubbleTick,
 
};
 

	
 

	
 
Vehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicle type)
 
Vehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicleType type)
 
{
 
	Vehicle *v = new SpecialVehicle();
 
	Vehicle *v = new EffectVehicle();
 
	if (v != NULL) {
 
		v->subtype = type;
 
		v->x_pos = x;
 
		v->y_pos = y;
 
		v->z_pos = z;
 
		v->tile = 0;
 
@@ -1425,25 +1425,25 @@ Vehicle *CreateEffectVehicle(int x, int 
 
		BeginVehicleMove(v);
 
		EndVehicleMove(v);
 
	}
 
	return v;
 
}
 

	
 
Vehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicle type)
 
Vehicle *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, EffectVehicle type)
 
Vehicle *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);
 
}
 

	
 
void SpecialVehicle::Tick()
 
void EffectVehicle::Tick()
 
{
 
	_effect_tick_procs[this->subtype](this);
 
}
 

	
 
Vehicle *CheckClickOnVehicle(const ViewPort *vp, int x, int y)
 
{
 
@@ -2495,13 +2495,13 @@ Trackdir GetVehicleTrackdir(const Vehicl
 
			/* If vehicle's state is a valid track direction (vehicle is not turning around) return it */
 
			if (!IsReversingRoadTrackdir((Trackdir)v->u.road.state)) return (Trackdir)v->u.road.state;
 

	
 
			/* Vehicle is turning around, get the direction from vehicle's direction */
 
			return DiagdirToDiagTrackdir(DirToDiagDir(v->direction));
 

	
 
		/* case VEH_AIRCRAFT: case VEH_SPECIAL: case VEH_DISASTER: */
 
		/* case VEH_AIRCRAFT: case VEH_EFFECT: case VEH_DISASTER: */
 
		default: return INVALID_TRACKDIR;
 
	}
 
}
 

	
 
/**
 
 * Returns some meta-data over the to be entered tile.
 
@@ -2952,13 +2952,13 @@ static const SaveLoad _aircraft_desc[] =
 
	SLE_CONDNULL(15,                                                                                      2, SL_MAX_VERSION),
 

	
 
	SLE_END()
 
};
 

	
 
static const SaveLoad _special_desc[] = {
 
	SLE_WRITEBYTE(Vehicle, type, VEH_SPECIAL),
 
	SLE_WRITEBYTE(Vehicle, type, VEH_EFFECT),
 

	
 
	    SLE_VAR(Vehicle, subtype,       SLE_UINT8),
 

	
 
	SLE_CONDVAR(Vehicle, tile,          SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
 
	SLE_CONDVAR(Vehicle, tile,          SLE_UINT32,                 6, SL_MAX_VERSION),
 

	
 
@@ -2970,14 +2970,14 @@ static const SaveLoad _special_desc[] = 
 

	
 
	    SLE_VAR(Vehicle, cur_image,     SLE_UINT16),
 
	SLE_CONDNULL(5,                                                 0, 57),
 
	    SLE_VAR(Vehicle, progress,      SLE_UINT8),
 
	    SLE_VAR(Vehicle, vehstatus,     SLE_UINT8),
 

	
 
	    SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleSpecial, animation_state),    SLE_UINT16),
 
	    SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleSpecial, animation_substate), 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),
 

	
 
	/* reserve extra space in savegame here. (currently 16 bytes) */
 
	SLE_CONDNULL(16, 2, SL_MAX_VERSION),
 

	
 
	SLE_END()
 
};
 
@@ -3059,13 +3059,13 @@ void Load_VEHS()
 

	
 
		switch (vtype) {
 
			case VEH_TRAIN:    v = new (index) Train();           break;
 
			case VEH_ROAD:     v = new (index) RoadVehicle();     break;
 
			case VEH_SHIP:     v = new (index) Ship();            break;
 
			case VEH_AIRCRAFT: v = new (index) Aircraft();        break;
 
			case VEH_SPECIAL:  v = new (index) SpecialVehicle();  break;
 
			case VEH_EFFECT:   v = new (index) EffectVehicle();   break;
 
			case VEH_DISASTER: v = new (index) DisasterVehicle(); break;
 
			case VEH_INVALID:  v = new (index) InvalidVehicle();  break;
 
			default: NOT_REACHED();
 
		}
 

	
 
		SlObject(v, GetVehicleDescription(vtype));
 
@@ -3279,13 +3279,13 @@ void Vehicle::SetNext(Vehicle *next)
 
		for (Vehicle *v = this->next; v != NULL; v = v->Next()) {
 
			v->first = this->first;
 
		}
 
	}
 
}
 

	
 
void SpecialVehicle::UpdateDeltaXY(Direction direction)
 
void EffectVehicle::UpdateDeltaXY(Direction direction)
 
{
 
	this->x_offs        = 0;
 
	this->y_offs        = 0;
 
	this->x_extent      = 1;
 
	this->y_extent      = 1;
 
	this->z_extent      = 1;
src/vehicle_base.h
Show inline comments
 
@@ -166,13 +166,13 @@ struct VehicleRoad {
 
	byte cached_veh_length;
 

	
 
	RoadType roadtype;
 
	RoadTypes compatible_roadtypes;
 
};
 

	
 
struct VehicleSpecial {
 
struct VehicleEffect {
 
	uint16 animation_state;
 
	byte animation_substate;
 
};
 

	
 
struct VehicleDisaster {
 
	uint16 image_override;
 
@@ -310,13 +310,13 @@ public:
 
	SpriteID colormap; // NOSAVE: cached color mapping
 

	
 
	union {
 
		VehicleRail rail;
 
		VehicleAir air;
 
		VehicleRoad road;
 
		VehicleSpecial special;
 
		VehicleEffect effect;
 
		VehicleDisaster disaster;
 
		VehicleShip ship;
 
	} u;
 

	
 

	
 
	/**
 
@@ -544,18 +544,18 @@ public:
 
 *  - smoke
 
 *  - electric sparks for trains
 
 *  - explosions
 
 *  - bulldozer (road works)
 
 *  - bubbles (industry)
 
 */
 
struct SpecialVehicle : public Vehicle {
 
struct EffectVehicle : public Vehicle {
 
	/** Initializes the Vehicle to a special vehicle */
 
	SpecialVehicle() { this->type = VEH_SPECIAL; }
 
	EffectVehicle() { this->type = VEH_EFFECT; }
 

	
 
	/** We want to 'destruct' the right class. */
 
	virtual ~SpecialVehicle() {}
 
	virtual ~EffectVehicle() {}
 

	
 
	const char *GetTypeString() const { return "special vehicle"; }
 
	void UpdateDeltaXY(Direction direction);
 
	void Tick();
 
};
 

	
src/vehicle_func.h
Show inline comments
 
@@ -168,15 +168,15 @@ static inline uint32 GetCmdSendToDepot(c
 
	return GetCmdSendToDepot(v->type);
 
}
 

	
 
bool EnsureNoVehicleOnGround(TileIndex tile);
 
void StopAllVehicles();
 

	
 
Vehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicle type);
 
Vehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicle type);
 
Vehicle *CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVehicle type);
 
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);
 

	
 
extern VehicleID _vehicle_id_ctr_day;
 
extern Vehicle *_place_clicked_vehicle;
 
extern VehicleID _new_vehicle_id;
 
extern uint16 _returned_refit_capacity;
 

	
src/vehicle_type.h
Show inline comments
 
@@ -11,13 +11,13 @@ typedef uint16 VehicleID;
 

	
 
enum VehicleType {
 
	VEH_TRAIN,
 
	VEH_ROAD,
 
	VEH_SHIP,
 
	VEH_AIRCRAFT,
 
	VEH_SPECIAL,
 
	VEH_EFFECT,
 
	VEH_DISASTER,
 
	VEH_END,
 
	VEH_INVALID = 0xFF,
 
};
 
DECLARE_POSTFIX_INCREMENT(VehicleType);
 
template <> struct EnumPropsT<VehicleType> : MakeEnumPropsT<VehicleType, byte, VEH_TRAIN, VEH_END, VEH_INVALID> {};
 
@@ -36,13 +36,13 @@ struct BaseVehicle
 
	inline bool IsValid() const { return this->type != VEH_INVALID; }
 
};
 

	
 
static const VehicleID INVALID_VEHICLE = 0xFFFF;
 

	
 
/* Effect vehicle types */
 
enum EffectVehicle {
 
enum EffectVehicleType {
 
	EV_CHIMNEY_SMOKE   = 0,
 
	EV_STEAM_SMOKE     = 1,
 
	EV_DIESEL_SMOKE    = 2,
 
	EV_ELECTRIC_SPARK  = 3,
 
	EV_SMOKE           = 4,
 
	EV_EXPLOSION_LARGE = 5,
0 comments (0 inline, 0 general)