Changeset - r7334:9402325cee09
[Not reviewed]
master
0 8 0
rubidium - 17 years ago 2007-07-26 15:37:19
rubidium@openttd.org
(svn r10697) -Codechange: give a more sensible names to some of the unkX variables.
8 files changed with 27 insertions and 27 deletions:
0 comments (0 inline, 0 general)
src/disaster_cmd.cpp
Show inline comments
 
@@ -562,157 +562,157 @@ static void DisasterTick_Big_Ufo(Vehicle
 
	Town *t;
 
	TileIndex tile;
 
	TileIndex tile_org;
 

	
 
	v->tick_counter++;
 

	
 
	if (v->current_order.dest == 1) {
 
		int x = TileX(v->dest_tile) * TILE_SIZE + TILE_SIZE / 2;
 
		int y = TileY(v->dest_tile) * TILE_SIZE + TILE_SIZE / 2;
 
		if (delta(v->x_pos, x) + delta(v->y_pos, y) >= 8) {
 
			v->direction = GetDirectionTowards(v, x, y);
 

	
 
			GetNewVehiclePosResult gp = GetNewVehiclePos(v);
 
			SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
 
			return;
 
		}
 

	
 
		z = GetSlopeZ(v->x_pos, v->y_pos);
 
		if (z < v->z_pos) {
 
			SetDisasterVehiclePos(v, v->x_pos, v->y_pos, v->z_pos - 1);
 
			return;
 
		}
 

	
 
		v->current_order.dest = 2;
 

	
 
		FOR_ALL_VEHICLES(u) {
 
			if (u->type == VEH_TRAIN || u->type == VEH_ROAD) {
 
				if (delta(u->x_pos, v->x_pos) + delta(u->y_pos, v->y_pos) <= 12 * TILE_SIZE) {
 
					u->breakdown_ctr = 5;
 
					u->breakdown_delay = 0xF0;
 
				}
 
			}
 
		}
 

	
 
		t = ClosestTownFromTile(v->dest_tile, (uint)-1);
 
		SetDParam(0, t->index);
 
		AddNewsItem(STR_B004_UFO_LANDS_NEAR,
 
			NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, 0),
 
			v->tile,
 
			0);
 

	
 
		u = ForceAllocateSpecialVehicle();
 
		if (u == NULL) {
 
			DeleteDisasterVeh(v);
 
			return;
 
		}
 

	
 
		InitializeDisasterVehicle(u, -6 * TILE_SIZE, v->y_pos, 135, DIR_SW, ST_Big_Ufo_Destroyer);
 
		u->u.disaster.unk2 = v->index;
 
		u->u.disaster.big_ufo_destroyer_target = v->index;
 

	
 
		w = ForceAllocateSpecialVehicle();
 
		if (w == NULL) return;
 

	
 
		u->next = w;
 
		InitializeDisasterVehicle(w, -6 * TILE_SIZE, v->y_pos, 0, DIR_SW, ST_Big_Ufo_Destroyer_Shadow);
 
		w->vehstatus |= VS_SHADOW;
 
	} else if (v->current_order.dest == 0) {
 
		int x = TileX(v->dest_tile) * TILE_SIZE;
 
		int y = TileY(v->dest_tile) * TILE_SIZE;
 
		if (delta(x, v->x_pos) + delta(y, v->y_pos) >= TILE_SIZE) {
 
			v->direction = GetDirectionTowards(v, x, y);
 
			GetNewVehiclePosResult gp = GetNewVehiclePos(v);
 
			SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
 
			return;
 
		}
 

	
 
		if (++v->age < 6) {
 
			v->dest_tile = RandomTile();
 
			return;
 
		}
 
		v->current_order.dest = 1;
 

	
 
		tile_org = tile = RandomTile();
 
		do {
 
			if (IsTileType(tile, MP_RAILWAY) &&
 
					IsPlainRailTile(tile) &&
 
					IsHumanPlayer(GetTileOwner(tile))) {
 
				break;
 
			}
 
			tile = TILE_MASK(tile + 1);
 
		} while (tile != tile_org);
 
		v->dest_tile = tile;
 
		v->age = 0;
 
	} else {
 
		return;
 
	}
 
}
 

	
 
/**
 
 * Skyranger destroying (Big) Ufo handling, v->current_order.dest states:
 
 * 0: Home in on landed Ufo and shoot it down
 
 */
 
static void DisasterTick_Big_Ufo_Destroyer(Vehicle *v)
 
{
 
	Vehicle *u;
 
	int i;
 

	
 
	v->tick_counter++;
 

	
 
	GetNewVehiclePosResult gp = GetNewVehiclePos(v);
 
	SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
 

	
 
	if (gp.x > (int)MapSizeX() * TILE_SIZE + 9 * TILE_SIZE - 1) {
 
		DeleteDisasterVeh(v);
 
		return;
 
	}
 

	
 
	if (v->current_order.dest == 0) {
 
		u = GetVehicle(v->u.disaster.unk2);
 
		u = GetVehicle(v->u.disaster.big_ufo_destroyer_target);
 
		if (delta(v->x_pos, u->x_pos) > TILE_SIZE) return;
 
		v->current_order.dest = 1;
 

	
 
		CreateEffectVehicleRel(u, 0, 7, 8, EV_EXPLOSION_LARGE);
 
		SndPlayVehicleFx(SND_12_EXPLOSION, u);
 

	
 
		DeleteDisasterVeh(u);
 

	
 
		for (i = 0; i != 80; i++) {
 
			uint32 r = Random();
 
			CreateEffectVehicleAbove(
 
				GB(r, 0, 6) + v->x_pos - 32,
 
				GB(r, 5, 6) + v->y_pos - 32,
 
				0,
 
				EV_EXPLOSION_SMALL);
 
		}
 

	
 
		BEGIN_TILE_LOOP(tile, 6, 6, v->tile - TileDiffXY(3, 3))
 
			tile = TILE_MASK(tile);
 
			DisasterClearSquare(tile);
 
		END_TILE_LOOP(tile, 6, 6, v->tile - TileDiffXY(3, 3))
 
	}
 
}
 

	
 
/**
 
 * Submarine, v->current_order.dest states:
 
 * Unused, just float around aimlessly and pop up at different places, turning around
 
 */
 
static void DisasterTick_Submarine(Vehicle *v)
 
{
 
	TileIndex tile;
 

	
 
	v->tick_counter++;
 

	
 
	if (++v->age > 8880) {
 
		VehiclePositionChanged(v);
 
		BeginVehicleMove(v);
 
		EndVehicleMove(v);
 
		DeleteVehicle(v);
 
		return;
 
	}
 

	
 
	if (!HASBIT(v->tick_counter, 0)) return;
 

	
 
	tile = v->tile + TileOffsByDiagDir(DirToDiagDir(v->direction));
 
	if (IsValidTile(tile)) {
 
		TrackdirBits r = (TrackdirBits)GetTileTrackStatus(tile, TRANSPORT_WATER, 0);
 

	
src/industry_cmd.cpp
Show inline comments
 
@@ -651,97 +651,97 @@ static void MakeIndustryTileBigger(TileI
 
	}
 

	
 
	switch (gfx) {
 
	case GFX_POWERPLANT_CHIMNEY:
 
		CreateIndustryEffectSmoke(tile);
 
		break;
 

	
 
	case GFX_OILRIG_1:
 
		if (GetIndustryGfx(tile + TileDiffXY(0, 1)) == GFX_OILRIG_1) BuildOilRig(tile);
 
		break;
 

	
 
	case GFX_TOY_FACTORY:
 
	case GFX_BUBBLE_CATCHER:
 
	case GFX_TOFFEE_QUARY:
 
		SetIndustryAnimationState(tile, 0);
 
		SetIndustryAnimationLoop(tile, 0);
 
		break;
 

	
 
	case GFX_PLASTIC_FOUNTAIN_ANIMATED_1: case GFX_PLASTIC_FOUNTAIN_ANIMATED_2:
 
	case GFX_PLASTIC_FOUNTAIN_ANIMATED_3: case GFX_PLASTIC_FOUNTAIN_ANIMATED_4:
 
	case GFX_PLASTIC_FOUNTAIN_ANIMATED_5: case GFX_PLASTIC_FOUNTAIN_ANIMATED_6:
 
	case GFX_PLASTIC_FOUNTAIN_ANIMATED_7: case GFX_PLASTIC_FOUNTAIN_ANIMATED_8:
 
		AddAnimatedTile(tile);
 
		break;
 
	}
 
}
 

	
 
static void TileLoopIndustry_BubbleGenerator(TileIndex tile)
 
{
 
	int dir;
 
	Vehicle *v;
 
	static const int8 _tileloop_ind_case_161[12] = {
 
		11,   0, -4, -14,
 
		-4, -10, -4,   1,
 
		49,  59, 60,  65,
 
	};
 

	
 
	SndPlayTileFx(SND_2E_EXTRACT_AND_POP, tile);
 

	
 
	dir = Random() & 3;
 

	
 
	v = CreateEffectVehicleAbove(
 
		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.unk2 = dir;
 
	if (v != NULL) v->u.special.animation_substate = dir;
 
}
 

	
 
static void TileLoop_Industry(TileIndex tile)
 
{
 
	IndustryGfx newgfx;
 
	IndustryGfx gfx;
 

	
 
	if (!IsIndustryCompleted(tile)) {
 
		MakeIndustryTileBigger(tile);
 
		return;
 
	}
 

	
 
	if (_game_mode == GM_EDITOR) return;
 

	
 
	TransportIndustryGoods(tile);
 

	
 
	if (StartStopIndustryTileAnimation(tile, IAT_TILELOOP)) return;
 

	
 
	newgfx = GetIndustryTileSpec(GetIndustryGfx(tile))->anim_next;
 
	if (newgfx != INDUSTRYTILE_NOANIM) {
 
		ResetIndustryConstructionStage(tile);
 
		SetIndustryGfx(tile, newgfx);
 
		MarkTileDirtyByTile(tile);
 
		return;
 
	}
 

	
 
	gfx = GetIndustryGfx(tile);
 

	
 
	switch (gfx) {
 
	case GFX_OILRIG_1: // coast line at oilrigs
 
	case GFX_OILRIG_2:
 
	case GFX_OILRIG_3:
 
	case GFX_OILRIG_4:
 
	case GFX_OILRIG_5:
 
		TileLoop_Water(tile);
 
		break;
 

	
 
	case GFX_COAL_MINE_TOWER_NOT_ANIMATED:
 
	case GFX_COPPER_MINE_TOWER_NOT_ANIMATED:
 
	case GFX_GOLD_MINE_TOWER_NOT_ANIMATED:
 
		if (!(_tick_counter & 0x400) && CHANCE16(1, 2)) {
 
			switch (gfx) {
 
				case GFX_COAL_MINE_TOWER_NOT_ANIMATED:   gfx = GFX_COAL_MINE_TOWER_ANIMATED;   break;
 
				case GFX_COPPER_MINE_TOWER_NOT_ANIMATED: gfx = GFX_COPPER_MINE_TOWER_ANIMATED; break;
 
				case GFX_GOLD_MINE_TOWER_NOT_ANIMATED:   gfx = GFX_GOLD_MINE_TOWER_ANIMATED;   break;
 
			}
 
			SetIndustryGfx(tile, gfx);
 
			SetIndustryAnimationState(tile, 0x80);
src/oldloader.cpp
Show inline comments
 
@@ -1008,107 +1008,107 @@ static uint32 _old_order_ptr;
 
static uint16 _old_next_ptr;
 
static uint32 _current_vehicle_id;
 

	
 
static const OldChunks vehicle_train_chunk[] = {
 
	OCL_SVAR(  OC_UINT8, VehicleRail, track ),
 
	OCL_SVAR(  OC_UINT8, VehicleRail, force_proceed ),
 
	OCL_SVAR( OC_UINT16, VehicleRail, crash_anim_pos ),
 
	OCL_SVAR(  OC_UINT8, VehicleRail, railtype ),
 

	
 
	OCL_NULL( 5 ), ///< Junk
 

	
 
	OCL_END()
 
};
 

	
 
static const OldChunks vehicle_road_chunk[] = {
 
	OCL_SVAR(  OC_UINT8, VehicleRoad, state ),
 
	OCL_SVAR(  OC_UINT8, VehicleRoad, frame ),
 
	OCL_SVAR( OC_UINT16, VehicleRoad, blocked_ctr ),
 
	OCL_SVAR(  OC_UINT8, VehicleRoad, overtaking ),
 
	OCL_SVAR(  OC_UINT8, VehicleRoad, overtaking_ctr ),
 
	OCL_SVAR( OC_UINT16, VehicleRoad, crashed_ctr ),
 
	OCL_SVAR(  OC_UINT8, VehicleRoad, reverse_ctr ),
 

	
 
	OCL_NULL( 1 ), ///< Junk
 

	
 
	OCL_END()
 
};
 

	
 
static const OldChunks vehicle_ship_chunk[] = {
 
	OCL_SVAR(  OC_UINT8, VehicleShip, state ),
 

	
 
	OCL_NULL( 9 ), ///< Junk
 

	
 
	OCL_END()
 
};
 

	
 
static const OldChunks vehicle_air_chunk[] = {
 
	OCL_SVAR(  OC_UINT8, VehicleAir, pos ),
 
	OCL_SVAR(  OC_FILE_U8 | OC_VAR_U16, VehicleAir, targetairport ),
 
	OCL_SVAR( OC_UINT16, VehicleAir, crashed_counter ),
 
	OCL_SVAR(  OC_UINT8, VehicleAir, state ),
 

	
 
	OCL_NULL( 5 ), ///< Junk
 

	
 
	OCL_END()
 
};
 

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

	
 
	OCL_NULL( 7 ), // Junk
 

	
 
	OCL_END()
 
};
 

	
 
static const OldChunks vehicle_disaster_chunk[] = {
 
	OCL_SVAR( OC_UINT16, VehicleDisaster, image_override ),
 
	OCL_SVAR( OC_UINT16, VehicleDisaster, unk2 ),
 
	OCL_SVAR( OC_UINT16, VehicleDisaster, big_ufo_destroyer_target ),
 

	
 
	OCL_NULL( 6 ), ///< Junk
 

	
 
	OCL_END()
 
};
 

	
 
static const OldChunks vehicle_empty_chunk[] = {
 
	OCL_NULL( 10 ), ///< Junk
 

	
 
	OCL_END()
 
};
 

	
 
static bool LoadOldVehicleUnion(LoadgameState *ls, int num)
 
{
 
	Vehicle *v = GetVehicle(_current_vehicle_id);
 
	uint temp = ls->total_read;
 
	bool res;
 

	
 
	/* We changed the offset of the vehicle types, so fix it
 
	 * Basically v->type -= 0x10; would suffice, but play safely */
 
	switch (v->type) {
 
		default: NOT_REACHED();
 
		case 0x00 /*VEH_INVALID */: v = new (v) InvalidVehicle();  res = LoadChunk(ls, NULL,           vehicle_empty_chunk);    break;
 
		case 0x10 /*VEH_TRAIN   */: v = new (v) Train();           res = LoadChunk(ls, &v->u.rail,     vehicle_train_chunk);    break;
 
		case 0x11 /*VEH_ROAD    */: v = new (v) RoadVehicle();     res = LoadChunk(ls, &v->u.road,     vehicle_road_chunk);     break;
 
		case 0x12 /*VEH_SHIP    */: v = new (v) Ship();            res = LoadChunk(ls, &v->u.ship,     vehicle_ship_chunk);     break;
 
		case 0x13 /*VEH_AIRCRAFT*/: v = new (v) Aircraft();        res = LoadChunk(ls, &v->u.air,      vehicle_air_chunk);      break;
 
		case 0x14 /*VEH_SPECIAL */: v = new (v) SpecialVehicle();  res = LoadChunk(ls, &v->u.special,  vehicle_special_chunk);  break;
 
		case 0x15 /*VEH_DISASTER*/: v = new (v) DisasterVehicle(); 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");
 
		return false;
 
	}
 

	
 
	return res;
 
}
 

	
 
static uint16 _cargo_count;
 

	
 
static const OldChunks vehicle_chunk[] = {
 
	OCL_SVAR(  OC_UINT8, Vehicle, type ),
 
	OCL_SVAR(  OC_UINT8, Vehicle, subtype ),
 

	
 
	OCL_NULL( 2 ),         ///< Hash, calculated automatically
 
	OCL_NULL( 2 ),         ///< Index, calculated automatically
src/roadveh_cmd.cpp
Show inline comments
 
@@ -692,97 +692,97 @@ static void RoadVehCrash(Vehicle *v)
 
	SetDParam(0, pass);
 
	AddNewsItem(
 
		(pass == 1) ?
 
			STR_9031_ROAD_VEHICLE_CRASH_DRIVER : STR_9032_ROAD_VEHICLE_CRASH_DIE,
 
		NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ACCIDENT, 0),
 
		v->index,
 
		0
 
	);
 

	
 
	ModifyStationRatingAround(v->tile, v->owner, -160, 22);
 
	SndPlayVehicleFx(SND_12_EXPLOSION, v);
 
}
 

	
 
static void RoadVehCheckTrainCrash(Vehicle *v)
 
{
 
	for (Vehicle *u = v; u != NULL; u = u->next) {
 
		if (u->u.road.state == RVSB_WORMHOLE) continue;
 

	
 
		TileIndex tile = u->tile;
 

	
 
		if (!IsLevelCrossingTile(tile)) continue;
 

	
 
		if (VehicleFromPosXY(v->x_pos, v->y_pos, u, EnumCheckRoadVehCrashTrain) != NULL) {
 
			RoadVehCrash(v);
 
			return;
 
		}
 
	}
 
}
 

	
 
static void HandleBrokenRoadVeh(Vehicle *v)
 
{
 
	if (v->breakdown_ctr != 1) {
 
		v->breakdown_ctr = 1;
 
		v->cur_speed = 0;
 

	
 
		if (v->breakdowns_since_last_service != 255)
 
			v->breakdowns_since_last_service++;
 

	
 
		InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 

	
 
		if (!PlayVehicleSound(v, VSE_BREAKDOWN)) {
 
			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.unk0 = v->breakdown_delay * 2;
 
			if (u != NULL) u->u.special.animation_state = v->breakdown_delay * 2;
 
		}
 
	}
 

	
 
	if ((v->tick_counter & 1) == 0) {
 
		if (--v->breakdown_delay == 0) {
 
			v->breakdown_ctr = 0;
 
			InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
		}
 
	}
 
}
 

	
 
static void ProcessRoadVehOrder(Vehicle *v)
 
{
 
	const Order *order;
 

	
 
	switch (v->current_order.type) {
 
		case OT_GOTO_DEPOT:
 
			/* Let a depot order in the orderlist interrupt. */
 
			if (!(v->current_order.flags & OF_PART_OF_ORDERS)) return;
 
			if (v->current_order.flags & OF_SERVICE_IF_NEEDED &&
 
					!VehicleNeedsService(v)) {
 
				UpdateVehicleTimetable(v, true);
 
				v->cur_order_index++;
 
			}
 
			break;
 

	
 
		case OT_LOADING:
 
		case OT_LEAVESTATION:
 
			return;
 

	
 
		default: break;
 
	}
 

	
 
	if (v->cur_order_index >= v->num_orders) v->cur_order_index = 0;
 

	
 
	order = GetVehicleOrder(v, v->cur_order_index);
 

	
 
	if (order == NULL) {
 
		v->current_order.Free();
 
		v->dest_tile = 0;
 
		ClearSlot(v);
 
		return;
 
	}
 

	
 
	if (order->type  == v->current_order.type &&
 
			order->flags == v->current_order.flags &&
 
			order->dest  == v->current_order.dest) {
 
		return;
src/ship_cmd.cpp
Show inline comments
 
@@ -175,97 +175,97 @@ static void CheckIfShipNeedsService(Vehi
 
	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 
}
 

	
 
void OnNewDay_Ship(Vehicle *v)
 
{
 
	CommandCost cost;
 

	
 
	if ((++v->day_counter & 7) == 0)
 
		DecreaseVehicleValue(v);
 

	
 
	CheckVehicleBreakdown(v);
 
	AgeVehicle(v);
 
	CheckIfShipNeedsService(v);
 

	
 
	CheckOrders(v);
 

	
 
	if (v->vehstatus & VS_STOPPED) return;
 

	
 
	cost.AddCost(GetVehicleProperty(v, 0x0F, ShipVehInfo(v->engine_type)->running_cost) * _price.ship_running / 364);
 
	v->profit_this_year -= cost.GetCost() >> 8;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN);
 
	SubtractMoneyFromPlayerFract(v->owner, CommandCost(cost));
 

	
 
	InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
	/* we need this for the profit */
 
	InvalidateWindowClasses(WC_SHIPS_LIST);
 
}
 

	
 
static void HandleBrokenShip(Vehicle *v)
 
{
 
	if (v->breakdown_ctr != 1) {
 
		v->breakdown_ctr = 1;
 
		v->cur_speed = 0;
 

	
 
		if (v->breakdowns_since_last_service != 255)
 
			v->breakdowns_since_last_service++;
 

	
 
		InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 

	
 
		if (!PlayVehicleSound(v, VSE_BREAKDOWN)) {
 
			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.unk0 = v->breakdown_delay * 2;
 
			if (u != NULL) u->u.special.animation_state = v->breakdown_delay * 2;
 
		}
 
	}
 

	
 
	if (!(v->tick_counter & 1)) {
 
		if (!--v->breakdown_delay) {
 
			v->breakdown_ctr = 0;
 
			InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
		}
 
	}
 
}
 

	
 
void Ship::MarkDirty()
 
{
 
	this->cur_image = this->GetImage(this->direction);
 
	MarkAllViewportsDirty(this->left_coord, this->top_coord, this->right_coord + 1, this->bottom_coord + 1);
 
}
 

	
 
static void PlayShipSound(const Vehicle *v)
 
{
 
	if (!PlayVehicleSound(v, VSE_START)) {
 
		SndPlayVehicleFx(ShipVehInfo(v->engine_type)->sfx, v);
 
	}
 
}
 

	
 
void Ship::PlayLeaveStationSound() const
 
{
 
	PlayShipSound(this);
 
}
 

	
 
static void ProcessShipOrder(Vehicle *v)
 
{
 
	const Order *order;
 

	
 
	switch (v->current_order.type) {
 
		case OT_GOTO_DEPOT:
 
			if (!(v->current_order.flags & OF_PART_OF_ORDERS)) return;
 
			if (v->current_order.flags & OF_SERVICE_IF_NEEDED &&
 
					!VehicleNeedsService(v)) {
 
				UpdateVehicleTimetable(v, true);
 
				v->cur_order_index++;
 
			}
 
			break;
 

	
 
		case OT_LOADING:
 
		case OT_LEAVESTATION:
 
			return;
 

	
 
		default: break;
src/train_cmd.cpp
Show inline comments
 
@@ -3093,97 +3093,97 @@ static void HandleCrashedTrain(Vehicle *
 
	}
 

	
 
	uint32 r;
 
	if (state <= 200 && CHANCE16R(1, 7, r)) {
 
		int index = (r * 10 >> 16);
 

	
 
		Vehicle *u = v;
 
		do {
 
			if (--index < 0) {
 
				r = Random();
 

	
 
				CreateEffectVehicleRel(u,
 
					GB(r,  8, 3) + 2,
 
					GB(r, 16, 3) + 2,
 
					GB(r,  0, 3) + 5,
 
					EV_EXPLOSION_SMALL);
 
				break;
 
			}
 
		} while ((u = u->next) != NULL);
 
	}
 

	
 
	if (state <= 240 && !(v->tick_counter & 3)) ChangeTrainDirRandomly(v);
 

	
 
	if (state >= 4440 && !(v->tick_counter&0x1F)) {
 
		DeleteLastWagon(v);
 
		InvalidateWindow(WC_REPLACE_VEHICLE, (v->group_id << 16) | VEH_TRAIN);
 
	}
 
}
 

	
 
static void HandleBrokenTrain(Vehicle *v)
 
{
 
	if (v->breakdown_ctr != 1) {
 
		v->breakdown_ctr = 1;
 
		v->cur_speed = 0;
 

	
 
		if (v->breakdowns_since_last_service != 255)
 
			v->breakdowns_since_last_service++;
 

	
 
		InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 

	
 
		if (!PlayVehicleSound(v, VSE_BREAKDOWN)) {
 
			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.unk0 = v->breakdown_delay * 2;
 
			if (u != NULL) u->u.special.animation_state = v->breakdown_delay * 2;
 
		}
 
	}
 

	
 
	if (!(v->tick_counter & 3)) {
 
		if (!--v->breakdown_delay) {
 
			v->breakdown_ctr = 0;
 
			InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
		}
 
	}
 
}
 

	
 
static const byte _breakdown_speeds[16] = {
 
	225, 210, 195, 180, 165, 150, 135, 120, 105, 90, 75, 60, 45, 30, 15, 15
 
};
 

	
 
static bool TrainCheckIfLineEnds(Vehicle *v)
 
{
 
	int t = v->breakdown_ctr;
 
	if (t > 1) {
 
		v->vehstatus |= VS_TRAIN_SLOWING;
 

	
 
		uint16 break_speed = _breakdown_speeds[GB(~t, 4, 4)];
 
		if (break_speed < v->cur_speed) v->cur_speed = break_speed;
 
	} else {
 
		v->vehstatus &= ~VS_TRAIN_SLOWING;
 
	}
 

	
 
	if (v->u.rail.track == TRACK_BIT_WORMHOLE) return true; // exit if inside a tunnel
 
	if (v->u.rail.track == TRACK_BIT_DEPOT) return true; // exit if inside a depot
 

	
 
	TileIndex tile = v->tile;
 

	
 
	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 
		DiagDirection dir = IsTunnel(tile) ? GetTunnelDirection(tile) : GetBridgeRampDirection(tile);
 
		if (DiagDirToDir(dir) == v->direction) return true;
 
	}
 

	
 
	// depot?
 
	/* XXX -- When enabled, this makes it possible to crash trains of others
 
	     (by building a depot right against a station) */
 
/*	if (IsTileType(tile, MP_RAILWAY) && GetRailTileType(tile) == RAIL_TILE_DEPOT_WAYPOINT)
 
		return true;*/
 

	
 
	/* Determine the non-diagonal direction in which we will exit this tile */
 
	DiagDirection dir = DirToDiagDir(v->direction);
 
	if (!(v->direction & 1) && v->u.rail.track != _state_dir_table[dir]) {
 
		dir = ChangeDiagDir(dir, DIAGDIRDIFF_90LEFT);
 
	}
src/vehicle.cpp
Show inline comments
 
@@ -1068,191 +1068,191 @@ static void SmokeTick(Vehicle *v)
 
	if (moved) {
 
		VehiclePositionChanged(v);
 
		EndVehicleMove(v);
 
	}
 
}
 

	
 
static void ExplosionLargeInit(Vehicle *v)
 
{
 
	v->cur_image = SPR_EXPLOSION_LARGE_0;
 
	v->progress = 0;
 
}
 

	
 
static void ExplosionLargeTick(Vehicle *v)
 
{
 
	v->progress++;
 
	if ((v->progress & 3) == 0) {
 
		BeginVehicleMove(v);
 
		if (v->cur_image != SPR_EXPLOSION_LARGE_F) {
 
			v->cur_image++;
 
			VehiclePositionChanged(v);
 
			EndVehicleMove(v);
 
		} else {
 
			EndVehicleMove(v);
 
			DeleteVehicle(v);
 
		}
 
	}
 
}
 

	
 
static void BreakdownSmokeInit(Vehicle *v)
 
{
 
	v->cur_image = SPR_BREAKDOWN_SMOKE_0;
 
	v->progress = 0;
 
}
 

	
 
static void BreakdownSmokeTick(Vehicle *v)
 
{
 
	v->progress++;
 
	if ((v->progress & 7) == 0) {
 
		BeginVehicleMove(v);
 
		if (v->cur_image != SPR_BREAKDOWN_SMOKE_3) {
 
			v->cur_image++;
 
		} else {
 
			v->cur_image = SPR_BREAKDOWN_SMOKE_0;
 
		}
 
		VehiclePositionChanged(v);
 
		EndVehicleMove(v);
 
	}
 

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

	
 
static void ExplosionSmallInit(Vehicle *v)
 
{
 
	v->cur_image = SPR_EXPLOSION_SMALL_0;
 
	v->progress = 0;
 
}
 

	
 
static void ExplosionSmallTick(Vehicle *v)
 
{
 
	v->progress++;
 
	if ((v->progress & 3) == 0) {
 
		BeginVehicleMove(v);
 
		if (v->cur_image != SPR_EXPLOSION_SMALL_B) {
 
			v->cur_image++;
 
			VehiclePositionChanged(v);
 
			EndVehicleMove(v);
 
		} else {
 
			EndVehicleMove(v);
 
			DeleteVehicle(v);
 
		}
 
	}
 
}
 

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

	
 
struct BulldozerMovement {
 
	byte direction:2;
 
	byte image:2;
 
	byte duration:3;
 
};
 

	
 
static const BulldozerMovement _bulldozer_movement[] = {
 
	{ 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 }
 
};
 

	
 
static const struct {
 
	int8 x;
 
	int8 y;
 
} _inc_by_dir[] = {
 
	{ -1,  0 },
 
	{  0,  1 },
 
	{  1,  0 },
 
	{  0, -1 }
 
};
 

	
 
static void BulldozerTick(Vehicle *v)
 
{
 
	v->progress++;
 
	if ((v->progress & 7) == 0) {
 
		const BulldozerMovement* b = &_bulldozer_movement[v->u.special.unk0];
 
		const BulldozerMovement* b = &_bulldozer_movement[v->u.special.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.unk2++;
 
		if (v->u.special.unk2 >= b->duration) {
 
			v->u.special.unk2 = 0;
 
			v->u.special.unk0++;
 
			if (v->u.special.unk0 == lengthof(_bulldozer_movement)) {
 
		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)) {
 
				EndVehicleMove(v);
 
				DeleteVehicle(v);
 
				return;
 
			}
 
		}
 
		VehiclePositionChanged(v);
 
		EndVehicleMove(v);
 
	}
 
}
 

	
 
static void BubbleInit(Vehicle *v)
 
{
 
	v->cur_image = SPR_BUBBLE_GENERATE_0;
 
	v->spritenum = 0;
 
	v->progress = 0;
 
}
 

	
 
struct BubbleMovement {
 
	int8 x:4;
 
	int8 y:4;
 
	int8 z:4;
 
	byte image:4;
 
};
 

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

	
 
static const BubbleMovement _bubble_float_sw[] = {
 
	MK(0, 0, 1, 0),
 
	MK(1, 0, 1, 1),
 
	MK(0, 0, 1, 0),
 
	MK(1, 0, 1, 2),
 
	ME(1)
 
};
 

	
 

	
 
static const BubbleMovement _bubble_float_ne[] = {
 
	MK( 0, 0, 1, 0),
 
	MK(-1, 0, 1, 1),
 
	MK( 0, 0, 1, 0),
 
	MK(-1, 0, 1, 2),
 
	ME(1)
 
};
 

	
 
static const BubbleMovement _bubble_float_se[] = {
 
	MK(0, 0, 1, 0),
 
	MK(0, 1, 1, 1),
 
	MK(0, 0, 1, 0),
 
@@ -1354,97 +1354,97 @@ static const BubbleMovement _bubble_abso
 
	MK(0, 0, 1, 0),
 
	MK(1, 0, 1, 1),
 
	MK(0, 0, 1, 0),
 
	MK(1, 0, 1, 2),
 
	ME(2),
 
	MK(0, 0, 0, 0xA),
 
	MK(0, 0, 0, 0xB),
 
	MK(0, 0, 0, 0xC),
 
	MK(0, 0, 0, 0xD),
 
	MK(0, 0, 0, 0xE),
 
	ME(0)
 
};
 
#undef ME
 
#undef MK
 

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

	
 
static void BubbleTick(Vehicle *v)
 
{
 
	/*
 
	 * Warning: those effects can NOT use Random(), and have to use
 
	 *  InteractiveRandom(), because somehow someone forgot to save
 
	 *  spritenum to the savegame, and so it will cause desyncs in
 
	 *  multiplayer!! (that is: in ToyLand)
 
	 */
 
	uint et;
 
	const BubbleMovement *b;
 

	
 
	v->progress++;
 
	if ((v->progress & 3) != 0)
 
		return;
 

	
 
	BeginVehicleMove(v);
 

	
 
	if (v->spritenum == 0) {
 
		v->cur_image++;
 
		if (v->cur_image < SPR_BUBBLE_GENERATE_3) {
 
			VehiclePositionChanged(v);
 
			EndVehicleMove(v);
 
			return;
 
		}
 
		if (v->u.special.unk2 != 0) {
 
		if (v->u.special.animation_substate != 0) {
 
			v->spritenum = GB(InteractiveRandom(), 0, 2) + 1;
 
		} else {
 
			v->spritenum = 6;
 
		}
 
		et = 0;
 
	} else {
 
		et = v->engine_type + 1;
 
	}
 

	
 
	b = &_bubble_movement[v->spritenum - 1][et];
 

	
 
	if (b->y == 4 && b->x == 0) {
 
		EndVehicleMove(v);
 
		DeleteVehicle(v);
 
		return;
 
	}
 

	
 
	if (b->y == 4 && b->x == 1) {
 
		if (v->z_pos > 180 || CHANCE16I(1, 96, InteractiveRandom())) {
 
			v->spritenum = 5;
 
			SndPlayVehicleFx(SND_2F_POP, v);
 
		}
 
		et = 0;
 
	}
 

	
 
	if (b->y == 4 && b->x == 2) {
 
		TileIndex tile;
 

	
 
		et++;
 
		SndPlayVehicleFx(SND_31_EXTRACT, v);
 

	
 
		tile = TileVirtXY(v->x_pos, v->y_pos);
 
		if (IsTileType(tile, MP_INDUSTRY) && GetIndustryGfx(tile) == 0xA2) AddAnimatedTile(tile);
 
	}
 

	
 
	v->engine_type = et;
 
	b = &_bubble_movement[v->spritenum - 1][et];
 

	
 
	v->x_pos += b->x;
 
	v->y_pos += b->y;
 
	v->z_pos += b->z;
 
	v->cur_image = SPR_BUBBLE_0 + b->image;
 

	
 
	VehiclePositionChanged(v);
 
	EndVehicleMove(v);
 
}
 

	
 

	
 
@@ -2997,136 +2997,136 @@ static const SaveLoad _ship_desc[] = {
 
	SLE_WRITEBYTE(Vehicle, type, VEH_SHIP),
 
	SLE_INCLUDEX(0, INC_VEHICLE_COMMON),
 
	SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleShip, state), SLE_UINT8),
 

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

	
 
	SLE_END()
 
};
 

	
 
static const SaveLoad _aircraft_desc[] = {
 
	SLE_WRITEBYTE(Vehicle, type, VEH_AIRCRAFT),
 
	SLE_INCLUDEX(0, INC_VEHICLE_COMMON),
 
	    SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleAir, crashed_counter), SLE_UINT16),
 
	    SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleAir, pos),             SLE_UINT8),
 

	
 
	SLE_CONDVARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleAir, targetairport),   SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
 
	SLE_CONDVARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleAir, targetairport),   SLE_UINT16,                5, SL_MAX_VERSION),
 

	
 
	    SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleAir, state),           SLE_UINT8),
 

	
 
	SLE_CONDVARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleAir, previous_pos),    SLE_UINT8,                 2, SL_MAX_VERSION),
 

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

	
 
	SLE_END()
 
};
 

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

	
 
	    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),
 

	
 
	SLE_CONDVAR(Vehicle, x_pos,         SLE_FILE_I16 | SLE_VAR_I32, 0, 5),
 
	SLE_CONDVAR(Vehicle, x_pos,         SLE_INT32,                  6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Vehicle, y_pos,         SLE_FILE_I16 | SLE_VAR_I32, 0, 5),
 
	SLE_CONDVAR(Vehicle, y_pos,         SLE_INT32,                  6, SL_MAX_VERSION),
 
	    SLE_VAR(Vehicle, z_pos,         SLE_UINT8),
 

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

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

	
 
	SLE_END()
 
};
 

	
 
static const SaveLoad _disaster_desc[] = {
 
	SLE_WRITEBYTE(Vehicle, type, VEH_DISASTER),
 

	
 
	    SLE_REF(Vehicle, next,          REF_VEHICLE_OLD),
 

	
 
	    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),
 
	SLE_CONDVAR(Vehicle, dest_tile,     SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 
	SLE_CONDVAR(Vehicle, dest_tile,     SLE_UINT32,                  6, SL_MAX_VERSION),
 

	
 
	SLE_CONDVAR(Vehicle, x_pos,         SLE_FILE_I16 | SLE_VAR_I32,  0, 5),
 
	SLE_CONDVAR(Vehicle, x_pos,         SLE_INT32,                   6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Vehicle, y_pos,         SLE_FILE_I16 | SLE_VAR_I32,  0, 5),
 
	SLE_CONDVAR(Vehicle, y_pos,         SLE_INT32,                   6, SL_MAX_VERSION),
 
	    SLE_VAR(Vehicle, z_pos,         SLE_UINT8),
 
	    SLE_VAR(Vehicle, direction,     SLE_UINT8),
 

	
 
	SLE_CONDNULL(5,                                                  0, 57),
 
	    SLE_VAR(Vehicle, owner,         SLE_UINT8),
 
	    SLE_VAR(Vehicle, vehstatus,     SLE_UINT8),
 
	SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, dest), SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
 
	SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, dest), SLE_UINT16,                5, SL_MAX_VERSION),
 

	
 
	    SLE_VAR(Vehicle, cur_image,     SLE_UINT16),
 
	SLE_CONDVAR(Vehicle, age,           SLE_FILE_U16 | SLE_VAR_I32,  0, 30),
 
	SLE_CONDVAR(Vehicle, age,           SLE_INT32,                  31, SL_MAX_VERSION),
 
	    SLE_VAR(Vehicle, tick_counter,  SLE_UINT8),
 

	
 
	   SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleDisaster, image_override), SLE_UINT16),
 
	   SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleDisaster, unk2),           SLE_UINT16),
 
	   SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleDisaster, image_override),           SLE_UINT16),
 
	   SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleDisaster, big_ufo_destroyer_target), SLE_UINT16),
 

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

	
 
	SLE_END()
 
};
 

	
 

	
 
static const void *_veh_descs[] = {
 
	_train_desc,
 
	_roadveh_desc,
 
	_ship_desc,
 
	_aircraft_desc,
 
	_special_desc,
 
	_disaster_desc,
 
};
 

	
 
/** Will be called when the vehicles need to be saved. */
 
static void Save_VEHS()
 
{
 
	Vehicle *v;
 
	/* Write the vehicles */
 
	FOR_ALL_VEHICLES(v) {
 
		SlSetArrayIndex(v->index);
 
		SlObject(v, (SaveLoad*)_veh_descs[v->type]);
 
	}
 
}
 

	
 
/** Will be called when vehicles need to be loaded. */
 
static void Load_VEHS()
 
{
 
	int index;
 
	Vehicle *v;
 

	
 
	_cargo_count = 0;
 

	
 
	while ((index = SlIterateArray()) != -1) {
 
		Vehicle *v;
 

	
 
		if (!AddBlockIfNeeded(&_Vehicle_pool, index))
 
			error("Vehicles: failed loading savegame: too many vehicles");
 

	
 
		v = GetVehicle(index);
 
		VehicleType vtype = (VehicleType)SlReadByte();
 

	
 
		switch (vtype) {
 
			case VEH_TRAIN:    v = new (v) Train();           break;
 
			case VEH_ROAD:     v = new (v) RoadVehicle();     break;
src/vehicle.h
Show inline comments
 
@@ -157,103 +157,103 @@ struct VehicleRail {
 

	
 
enum {
 
	VRF_REVERSING         = 0,
 

	
 
	/* used to calculate if train is going up or down */
 
	VRF_GOINGUP           = 1,
 
	VRF_GOINGDOWN         = 2,
 

	
 
	/* used to store if a wagon is powered or not */
 
	VRF_POWEREDWAGON      = 3,
 

	
 
	/* used to reverse the visible direction of the vehicle */
 
	VRF_REVERSE_DIRECTION = 4,
 

	
 
	/* used to mark train as lost because PF can't find the route */
 
	VRF_NO_PATH_TO_DESTINATION = 5,
 

	
 
	/* used to mark that electric train engine is allowed to run on normal rail */
 
	VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL = 6,
 
};
 

	
 
struct VehicleAir {
 
	uint16 crashed_counter;
 
	uint16 cached_max_speed;
 
	byte pos;
 
	byte previous_pos;
 
	StationID targetairport;
 
	byte state;
 
};
 

	
 
struct VehicleRoad {
 
	byte state;             ///< @see RoadVehicleStates
 
	byte frame;
 
	uint16 blocked_ctr;
 
	byte overtaking;
 
	byte overtaking_ctr;
 
	uint16 crashed_ctr;
 
	byte reverse_ctr;
 
	struct RoadStop *slot;
 
	byte slot_age;
 
	EngineID first_engine;
 
	byte cached_veh_length;
 

	
 
	RoadType roadtype;
 
	RoadTypes compatible_roadtypes;
 
};
 

	
 
struct VehicleSpecial {
 
	uint16 unk0;
 
	byte unk2;
 
	uint16 animation_state;
 
	byte animation_substate;
 
};
 

	
 
struct VehicleDisaster {
 
	uint16 image_override;
 
	uint16 unk2;
 
	VehicleID big_ufo_destroyer_target;
 
};
 

	
 
struct VehicleShip {
 
	TrackBitsByte state;
 
};
 

	
 

	
 
struct Vehicle {
 
	VehicleTypeByte type;    ///< Type of vehicle
 
	byte subtype;            // subtype (Filled with values from EffectVehicles/TrainSubTypes/AircraftSubTypes)
 

	
 
	VehicleID index;         // NOSAVE: Index in vehicle array
 

	
 
	Vehicle *next;           // next
 
	Vehicle *first;          // NOSAVE: pointer to the first vehicle in the chain
 
	Vehicle *depot_list;     //NOSAVE: linked list to tell what vehicles entered a depot during the last tick. Used by autoreplace
 

	
 
	StringID string_id;      // Displayed string
 

	
 
	UnitID unitnumber;       // unit number, for display purposes only
 
	PlayerByte owner;        // which player owns the vehicle?
 

	
 
	TileIndex tile;          // Current tile index
 
	TileIndex dest_tile;     // Heading for this tile
 

	
 
	int32 x_pos;             // coordinates
 
	int32 y_pos;
 
	byte z_pos;
 
	DirectionByte direction; // facing
 

	
 
	byte spritenum;          // currently displayed sprite index
 
	                         // 0xfd == custom sprite, 0xfe == custom second head sprite
 
	                         // 0xff == reserved for another custom sprite
 
	uint16 cur_image;        // sprite number for this vehicle
 
	byte sprite_width;       // width of vehicle sprite
 
	byte sprite_height;      // height of vehicle sprite
 
	byte z_height;           // z-height of vehicle sprite
 
	int8 x_offs;             // x offset for vehicle sprite
 
	int8 y_offs;             // y offset for vehicle sprite
 
	EngineID engine_type;
 

	
 
	TextEffectID fill_percent_te_id; // a text-effect id to a loading indicator object
 

	
 
	/* for randomized variational spritegroups
 
	 * bitmask used to resolve them; parts of it get reseeded when triggers
 
	 * of corresponding spritegroups get matched */
 
	byte random_bits;
 
	byte waiting_triggers;   // triggers to be yet matched
0 comments (0 inline, 0 general)