Changeset - r5991:254bad51c6b2
[Not reviewed]
master
0 11 0
rubidium - 17 years ago 2007-02-13 10:26:53
rubidium@openttd.org
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
11 files changed with 67 insertions and 51 deletions:
0 comments (0 inline, 0 general)
src/openttd.h
Show inline comments
 
@@ -340,52 +340,49 @@ typedef void GetTileDescProc(TileIndex t
 
 * that can be taken on a given tile by a given transport. The return value is
 
 * composed as follows: 0xaabbccdd. ccdd and aabb are bitmasks of trackdirs,
 
 * where bit n corresponds to trackdir n. ccdd are the trackdirs that are
 
 * present in the tile (1==present, 0==not present), aabb is the signal
 
 * status, if applicable (0==green/no signal, 1==red, note that this is
 
 * reversed from map3/2[tile] for railway signals).
 
 *
 
 * The result (let's call it ts) is often used as follows:
 
 * tracks = (byte)(ts | ts >>8)
 
 * This effectively converts the present part of the result (ccdd) to a
 
 * track bitmask, which disregards directions. Normally, this is the same as just
 
 * doing (byte)ts I think, although I am not really sure
 
 *
 
 * A trackdir is combination of a track and a dir, where the lower three bits
 
 * are a track, the fourth bit is the direction. these give 12 (or 14)
 
 * possible options: 0-5 and 8-13, so we need 14 bits for a trackdir bitmask
 
 * above.
 
 */
 
typedef uint32 GetTileTrackStatusProc(TileIndex tile, TransportType mode);
 
typedef void GetProducedCargoProc(TileIndex tile, CargoID *b);
 
typedef void ClickTileProc(TileIndex tile);
 
typedef void AnimateTileProc(TileIndex tile);
 
typedef void TileLoopProc(TileIndex tile);
 
typedef void ChangeTileOwnerProc(TileIndex tile, PlayerID old_player, PlayerID new_player);
 
/* Return value has bit 0x2 set, when the vehicle enters a station. Then,
 
 * result << 8 contains the id of the station entered. If the return value has
 
 * bit 0x8 set, the vehicle could not and did not enter the tile. Are there
 
 * other bits that can be set? */
 
/** @see VehicleEnterTileStatus to see what the return values mean */
 
typedef uint32 VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y);
 
typedef Slope GetSlopeTilehProc(TileIndex, Slope tileh);
 

	
 
typedef struct {
 
	DrawTileProc *draw_tile_proc;
 
	GetSlopeZProc *get_slope_z_proc;
 
	ClearTileProc *clear_tile_proc;
 
	GetAcceptedCargoProc *get_accepted_cargo_proc;
 
	GetTileDescProc *get_tile_desc_proc;
 
	GetTileTrackStatusProc *get_tile_track_status_proc;
 
	ClickTileProc *click_tile_proc;
 
	AnimateTileProc *animate_tile_proc;
 
	TileLoopProc *tile_loop_proc;
 
	ChangeTileOwnerProc *change_tile_owner_proc;
 
	GetProducedCargoProc *get_produced_cargo_proc;
 
	VehicleEnterTileProc *vehicle_enter_tile_proc;
 
	GetSlopeTilehProc *get_slope_tileh_proc;
 
} TileTypeProcs;
 

	
 

	
 
enum WindowClass {
 
	WC_NONE,
 
	WC_MAIN_WINDOW = WC_NONE,
 
	WC_MAIN_TOOLBAR,
src/rail_cmd.cpp
Show inline comments
 
@@ -1925,85 +1925,85 @@ static void ChangeTileOwner_Track(TileIn
 
	if (!IsTileOwner(tile, old_player)) return;
 

	
 
	if (new_player != PLAYER_SPECTATOR) {
 
		SetTileOwner(tile, new_player);
 
	} else {
 
		DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
 
	}
 
}
 

	
 
static const byte _fractcoords_behind[4] = { 0x8F, 0x8, 0x80, 0xF8 };
 
static const byte _fractcoords_enter[4] = { 0x8A, 0x48, 0x84, 0xA8 };
 
static const signed char _deltacoord_leaveoffset[8] = {
 
	-1,  0,  1,  0, /* x */
 
	 0,  1,  0, -1  /* y */
 
};
 

	
 
static uint32 VehicleEnter_Track(Vehicle *v, TileIndex tile, int x, int y)
 
{
 
	byte fract_coord;
 
	byte fract_coord_leave;
 
	DiagDirection dir;
 
	int length;
 

	
 
	// this routine applies only to trains in depot tiles
 
	if (v->type != VEH_Train || !IsTileDepotType(tile, TRANSPORT_RAIL)) return 0;
 
	if (v->type != VEH_Train || !IsTileDepotType(tile, TRANSPORT_RAIL)) return VETSB_CONTINUE;
 

	
 
	/* depot direction */
 
	dir = GetRailDepotDirection(tile);
 

	
 
	/* calculate the point where the following wagon should be activated */
 
	/* this depends on the length of the current vehicle */
 
	length = v->u.rail.cached_veh_length;
 

	
 
	fract_coord_leave =
 
		((_fractcoords_enter[dir] & 0x0F) + // x
 
			(length + 1) * _deltacoord_leaveoffset[dir]) +
 
		(((_fractcoords_enter[dir] >> 4) +  // y
 
			((length + 1) * _deltacoord_leaveoffset[dir+4])) << 4);
 

	
 
	fract_coord = (x & 0xF) + ((y & 0xF) << 4);
 

	
 
	if (_fractcoords_behind[dir] == fract_coord) {
 
		/* make sure a train is not entering the tile from behind */
 
		return 8;
 
		return VETSB_CANNOT_ENTER;
 
	} else if (_fractcoords_enter[dir] == fract_coord) {
 
		if (DiagDirToDir(ReverseDiagDir(dir)) == v->direction) {
 
			/* enter the depot */
 
			v->u.rail.track = TRACK_BIT_SPECIAL,
 
			v->vehstatus |= VS_HIDDEN; /* hide it */
 
			v->direction = ReverseDir(v->direction);
 
			if (v->next == NULL) VehicleEnterDepot(v);
 
			v->tile = tile;
 

	
 
			InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
 
			return 4;
 
			return VETSB_ENTERED_WORMHOLE;
 
		}
 
	} else if (fract_coord_leave == fract_coord) {
 
		if (DiagDirToDir(dir) == v->direction) {
 
			/* leave the depot? */
 
			if ((v = v->next) != NULL) {
 
				v->vehstatus &= ~VS_HIDDEN;
 
				v->u.rail.track = (DiagDirToAxis(dir) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y);
 
			}
 
		}
 
	}
 

	
 
	return 0;
 
	return VETSB_CONTINUE;
 
}
 

	
 

	
 
extern const TileTypeProcs _tile_type_rail_procs = {
 
	DrawTile_Track,           /* draw_tile_proc */
 
	GetSlopeZ_Track,          /* get_slope_z_proc */
 
	ClearTile_Track,          /* clear_tile_proc */
 
	GetAcceptedCargo_Track,   /* get_accepted_cargo_proc */
 
	GetTileDesc_Track,        /* get_tile_desc_proc */
 
	GetTileTrackStatus_Track, /* get_tile_track_status_proc */
 
	ClickTile_Track,          /* click_tile_proc */
 
	AnimateTile_Track,        /* animate_tile_proc */
 
	TileLoop_Track,           /* tile_loop_clear */
 
	ChangeTileOwner_Track,    /* change_tile_owner_clear */
 
	NULL,                     /* get_produced_cargo_proc */
 
	VehicleEnter_Track,       /* vehicle_enter_tile_proc */
 
	GetSlopeTileh_Track,      /* get_slope_tileh_proc */
 
};
src/road_cmd.cpp
Show inline comments
 
@@ -995,55 +995,55 @@ static void GetTileDesc_Road(TileIndex t
 
	}
 
}
 

	
 
static const byte _roadveh_enter_depot_unk0[4] = {
 
	8, 9, 0, 1
 
};
 

	
 
static uint32 VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y)
 
{
 
	switch (GetRoadTileType(tile)) {
 
		case ROAD_TILE_CROSSING:
 
			if (v->type == VEH_Train && !IsCrossingBarred(tile)) {
 
				/* train crossing a road */
 
				SndPlayVehicleFx(SND_0E_LEVEL_CROSSING, v);
 
				BarCrossing(tile);
 
				MarkTileDirtyByTile(tile);
 
			}
 
			break;
 

	
 
		case ROAD_TILE_DEPOT:
 
			if (v->type == VEH_Road &&
 
					v->u.road.frame == 11 &&
 
					_roadveh_enter_depot_unk0[GetRoadDepotDirection(tile)] == v->u.road.state) {
 
				VehicleEnterDepot(v);
 
				return 4;
 
				return VETSB_ENTERED_WORMHOLE;
 
			}
 
			break;
 

	
 
		default: break;
 
	}
 
	return 0;
 
	return VETSB_CONTINUE;
 
}
 

	
 

	
 
static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID new_player)
 
{
 
	if (IsLevelCrossing(tile) && GetCrossingRoadOwner(tile) == old_player) {
 
		SetCrossingRoadOwner(tile, new_player == PLAYER_SPECTATOR ? OWNER_NONE : new_player);
 
	}
 

	
 
	if (!IsTileOwner(tile, old_player)) return;
 

	
 
	if (new_player != PLAYER_SPECTATOR) {
 
		SetTileOwner(tile, new_player);
 
	} else {
 
		switch (GetRoadTileType(tile)) {
 
			case ROAD_TILE_NORMAL:
 
				SetTileOwner(tile, OWNER_NONE);
 
				break;
 

	
 
			case ROAD_TILE_CROSSING:
 
				MakeRoadNormal(tile, GetCrossingRoadOwner(tile), GetCrossingRoadBits(tile), GetTownIndex(tile));
 
				break;
 

	
 
			default:
src/roadveh_cmd.cpp
Show inline comments
 
@@ -1319,166 +1319,166 @@ static void RoadVehController(Vehicle *v
 
			 *  overtake if we are on straight road, which are the 8 states below */
 
			if (v->u.road.state == 0  || v->u.road.state == 1  ||
 
					v->u.road.state == 8  || v->u.road.state == 9  ||
 
					v->u.road.state == 16 || v->u.road.state == 17 ||
 
					v->u.road.state == 24 || v->u.road.state == 25) {
 
				v->u.road.overtaking = 0;
 
			}
 
	}
 

	
 
	/* Save old vehicle position to use at end of move to set viewport area dirty */
 
	BeginVehicleMove(v);
 

	
 
	if (v->u.road.state == 255) {
 
		/* Vehicle is on a bridge or in a tunnel */
 
		GetNewVehiclePosResult gp;
 

	
 
		GetNewVehiclePos(v, &gp);
 

	
 
		const Vehicle *u = RoadVehFindCloseTo(v, gp.x, gp.y, v->direction);
 
		if (u != NULL && u->cur_speed < v->cur_speed) {
 
			v->cur_speed = u->cur_speed;
 
			return;
 
		}
 

	
 
		if ((IsTunnelTile(gp.new_tile) || IsBridgeTile(gp.new_tile)) && VehicleEnterTile(v, gp.new_tile, gp.x, gp.y) & 4) {
 
		if ((IsTunnelTile(gp.new_tile) || IsBridgeTile(gp.new_tile)) && HASBIT(VehicleEnterTile(v, gp.new_tile, gp.x, gp.y), VETS_ENTERED_WORMHOLE)) {
 
			/* Vehicle has just entered a bridge or tunnel */
 
			v->cur_image = GetRoadVehImage(v, v->direction);
 
			UpdateRoadVehDeltaXY(v);
 
			SetRoadVehPosition(v,gp.x,gp.y);
 
			return;
 
		}
 

	
 
		v->x_pos = gp.x;
 
		v->y_pos = gp.y;
 
		VehiclePositionChanged(v);
 
		if (!(v->vehstatus & VS_HIDDEN)) EndVehicleMove(v);
 
		return;
 
	}
 

	
 
	/* Get move position data for next frame */
 
	rd = _road_drive_data[(v->u.road.state + (_opt.road_side << 4)) ^ v->u.road.overtaking][v->u.road.frame + 1];
 

	
 
	if (rd.x & 0x80) {
 
		/* Vehicle is moving to the next tile */
 
		TileIndex tile = v->tile + TileOffsByDiagDir(rd.x & 3);
 
		int dir = RoadFindPathToDest(v, tile, (DiagDirection)(rd.x & 3));
 
		uint32 r;
 
		Direction newdir;
 
		const RoadDriveEntry *rdp;
 

	
 
		if (dir == -1) {
 
			/* No path was found to destination */
 
			v->cur_speed = 0;
 
			return;
 
		}
 

	
 
again:
 
		if ((dir & 7) >= 6) {
 
			/* Turning around */
 
			tile = v->tile;
 
		}
 

	
 
		/* Get position data for first frame on the new tile */
 
		rdp = _road_drive_data[(dir + (_opt.road_side << 4)) ^ v->u.road.overtaking];
 

	
 
		x = TileX(tile) * TILE_SIZE + rdp[0].x;
 
		y = TileY(tile) * TILE_SIZE + rdp[0].y;
 

	
 
		newdir = RoadVehGetSlidingDirection(v, x, y);
 
		if (RoadVehFindCloseTo(v, x, y, newdir) != NULL) return;
 

	
 
		r = VehicleEnterTile(v, tile, x, y);
 
		if (r & 8) {
 
		if (HASBIT(r, VETS_CANNOT_ENTER)) {
 
			/* Vehicle cannot enter the tile */
 
			if (!IsTileType(tile, MP_TUNNELBRIDGE)) {
 
				v->cur_speed = 0;
 
				return;
 
			}
 
			/* Try an about turn to re-enter the previous tile */
 
			dir = _road_reverse_table[rd.x&3];
 
			goto again;
 
		}
 

	
 
		if (IS_BYTE_INSIDE(v->u.road.state, 0x20, 0x30) && IsTileType(v->tile, MP_STATION)) {
 
			if ((dir & 7) >= 6) {
 
				/* New direction is trying to turn vehicle around.
 
				 * We can't turn at the exit of a road stop so wait.*/
 
				v->cur_speed = 0;
 
				return;
 
			}
 
			if (IsRoadStop(v->tile)) {
 
				/* The tile that the vehicle is leaving is a road stop */
 
				RoadStop *rs = GetRoadStopByTile(v->tile, GetRoadStopType(v->tile));
 

	
 
				/* Vehicle is leaving a road stop tile, mark bay as free and clear the usage bit */
 
				rs->FreeBay(HASBIT(v->u.road.state, 1) ? 1 : 0);
 
				rs->SetEntranceBusy(false);
 
			}
 
		}
 

	
 
		if (!(r & 4)) {
 
		if (!HASBIT(r, VETS_ENTERED_WORMHOLE)) {
 
			/* Set vehicle to first frame on new tile */
 
			v->tile = tile;
 
			v->u.road.state = (byte)dir;
 
			v->u.road.frame = 0;
 
		}
 
		if (newdir != v->direction) {
 
			v->direction = newdir;
 
			v->cur_speed -= v->cur_speed >> 2;
 
		}
 

	
 
		v->cur_image = GetRoadVehImage(v, newdir);
 
		UpdateRoadVehDeltaXY(v);
 
		RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y));
 
		return;
 
	}
 

	
 
	if (rd.x & 0x40) {
 
		/* Vehicle has finished turning around, it will now head back onto the same tile */
 
		int dir = RoadFindPathToDest(v, v->tile, (DiagDirection)(rd.x & 3));
 
		uint32 r;
 
		int tmp;
 
		Direction newdir;
 
		const RoadDriveEntry *rdp;
 

	
 
		if (dir == -1) {
 
			/* No path was found to destination */
 
			v->cur_speed = 0;
 
			return;
 
		}
 

	
 
		tmp = (_opt.road_side << 4) + dir;
 
		rdp = _road_drive_data[tmp];
 

	
 
		x = TileX(v->tile) * TILE_SIZE + rdp[1].x;
 
		y = TileY(v->tile) * TILE_SIZE + rdp[1].y;
 

	
 
		newdir = RoadVehGetSlidingDirection(v, x, y);
 
		if (RoadVehFindCloseTo(v, x, y, newdir) != NULL) return;
 

	
 
		r = VehicleEnterTile(v, v->tile, x, y);
 
		if (r & 8) {
 
		if (HASBIT(r, VETS_CANNOT_ENTER)) {
 
			/* Vehicle cannot enter the tile */
 
			v->cur_speed = 0;
 
			return;
 
		}
 

	
 
		/* Set vehicle to second frame on the tile */
 
		v->u.road.state = tmp & ~16;
 
		v->u.road.frame = 1;
 

	
 
		if (newdir != v->direction) {
 
			v->direction = newdir;
 
			v->cur_speed -= v->cur_speed >> 2;
 
		}
 

	
 
		v->cur_image = GetRoadVehImage(v, newdir);
 
		UpdateRoadVehDeltaXY(v);
 
		RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y));
 
		return;
 
	}
 

	
 
	/* Calculate new position for the vehicle */
 
	x = (v->x_pos & ~15) + (rd.x & 15);
 
	y = (v->y_pos & ~15) + (rd.y & 15);
 

	
 
@@ -1578,57 +1578,57 @@ again:
 
				DEBUG(ms, 2, " current tile 0x%X is not destination tile 0x%X. Route problem", v->tile, v->dest_tile);
 
			}
 
			if (v->dest_tile != v->u.road.slot->xy) {
 
				DEBUG(ms, 2, " stop tile 0x%X is not destination tile 0x%X. Multistop desync", v->u.road.slot->xy, v->dest_tile);
 
			}
 
			if (v->current_order.type != OT_GOTO_STATION) {
 
				DEBUG(ms, 2, " current order type (%d) is not OT_GOTO_STATION", v->current_order.type);
 
			} else {
 
				if (v->current_order.dest != st->index)
 
					DEBUG(ms, 2, " current station %d is not target station in current_order.station (%d)",
 
							st->index, v->current_order.dest);
 
			}
 

	
 
			DEBUG(ms, 2, " force a slot clearing");
 
			ClearSlot(v);
 
		}
 

	
 
		StartRoadVehSound(v);
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 
	}
 

	
 
	/* Check tile position conditions - i.e. stop position in depot,
 
	 * entry onto bridge or into tunnel */
 
	r = VehicleEnterTile(v, v->tile, x, y);
 
	if (r & 8) {
 
	if (HASBIT(r, VETS_CANNOT_ENTER)) {
 
		/* Vehicle cannot continue */
 
		v->cur_speed = 0;
 
		return;
 
	}
 

	
 
	/* Move to next frame unless vehicle arrived at a stop position
 
	 * in a depot or entered a tunnel/bridge */
 
	if ((r & 4) == 0) v->u.road.frame++;
 
	if (!HASBIT(r, VETS_ENTERED_WORMHOLE)) v->u.road.frame++;
 

	
 
	v->cur_image = GetRoadVehImage(v, v->direction);
 
	UpdateRoadVehDeltaXY(v);
 
	RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y));
 
}
 

	
 
static void AgeRoadVehCargo(Vehicle *v)
 
{
 
	if (_age_cargo_skip_counter != 0) return;
 
	if (v->cargo_days != 255) v->cargo_days++;
 
}
 

	
 
void RoadVeh_Tick(Vehicle *v)
 
{
 
	AgeRoadVehCargo(v);
 
	RoadVehController(v);
 
}
 

	
 
static void CheckIfRoadVehNeedsService(Vehicle *v)
 
{
 
	const Depot* depot;
 

	
 
	if (_patches.servint_roadveh == 0) return;
 
	if (!VehicleNeedsService(v)) return;
src/ship_cmd.cpp
Show inline comments
 
@@ -679,49 +679,49 @@ static void ShipController(Vehicle *v)
 
		v->breakdown_ctr--;
 
	}
 

	
 
	if (v->vehstatus & VS_STOPPED) return;
 

	
 
	ProcessShipOrder(v);
 
	HandleShipLoading(v);
 

	
 
	if (v->current_order.type == OT_LOADING) return;
 

	
 
	CheckShipLeaveDepot(v);
 

	
 
	if (!ShipAccelerate(v)) return;
 

	
 
	BeginVehicleMove(v);
 

	
 
	if (GetNewVehiclePos(v, &gp)) {
 
		// staying in tile
 
		if (IsShipInDepot(v)) {
 
			gp.x = v->x_pos;
 
			gp.y = v->y_pos;
 
		} else {
 
			/* isnot inside depot */
 
			r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y);
 
			if (r & 0x8) goto reverse_direction;
 
			if (HASBIT(r, VETS_CANNOT_ENTER)) goto reverse_direction;
 

	
 
			/* A leave station order only needs one tick to get processed, so we can
 
			 * always skip ahead. */
 
			if (v->current_order.type == OT_LEAVESTATION) {
 
				v->current_order.type = OT_NOTHING;
 
				v->current_order.flags = 0;
 
				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 
			} else if (v->dest_tile != 0) {
 
				/* We have a target, let's see if we reached it... */
 
				if (v->current_order.type == OT_GOTO_STATION &&
 
						IsBuoyTile(v->dest_tile) &&
 
						DistanceManhattan(v->dest_tile, gp.new_tile) <= 3) {
 
					/* We got within 3 tiles of our target buoy, so let's skip to our
 
					 * next order */
 
					v->cur_order_index++;
 
					v->current_order.type = OT_DUMMY;
 
					InvalidateVehicleOrder(v);
 
				} else {
 
					/* Non-buoy orders really need to reach the tile */
 
					if (v->dest_tile == gp.new_tile) {
 
						if (v->current_order.type == OT_GOTO_DEPOT) {
 
							if ((gp.x&0xF)==8 && (gp.y&0xF)==8) {
 
								VehicleEnterDepot(v);
 
								return;
 
@@ -759,51 +759,51 @@ static void ShipController(Vehicle *v)
 
		DiagDirection diagdir;
 
		// new tile
 
		if (TileX(gp.new_tile) >= MapMaxX() || TileY(gp.new_tile) >= MapMaxY())
 
			goto reverse_direction;
 

	
 
		dir = ShipGetNewDirectionFromTiles(gp.new_tile, gp.old_tile);
 
		assert(dir == DIR_NE || dir == DIR_SE || dir == DIR_SW || dir == DIR_NW);
 
		diagdir = DirToDiagDir(dir);
 
		tracks = GetAvailShipTracks(gp.new_tile, diagdir);
 
		if (tracks == 0)
 
			goto reverse_direction;
 

	
 
		// Choose a direction, and continue if we find one
 
		track = ChooseShipTrack(v, gp.new_tile, diagdir, tracks);
 
		if (track == INVALID_TRACK)
 
			goto reverse_direction;
 

	
 
		b = _ship_subcoord[diagdir][track];
 

	
 
		gp.x = (gp.x&~0xF) | b[0];
 
		gp.y = (gp.y&~0xF) | b[1];
 

	
 
		/* Call the landscape function and tell it that the vehicle entered the tile */
 
		r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y);
 
		if (r&0x8) goto reverse_direction;
 
		if (HASBIT(r, VETS_CANNOT_ENTER)) goto reverse_direction;
 

	
 
		if (!(r&0x4)) {
 
		if (!HASBIT(r, VETS_ENTERED_WORMHOLE)) {
 
			v->tile = gp.new_tile;
 
			v->u.ship.state = TrackToTrackBits(track);
 
		}
 

	
 
		v->direction = (Direction)b[2];
 
	}
 

	
 
	/* update image of ship, as well as delta XY */
 
	dir = ShipGetNewDirection(v, gp.x, gp.y);
 
	v->x_pos = gp.x;
 
	v->y_pos = gp.y;
 
	v->z_pos = GetSlopeZ(gp.x, gp.y);
 

	
 
getout:
 
	UpdateShipDeltaXY(v, dir);
 
	v->cur_image = GetShipImage(v, dir);
 
	VehiclePositionChanged(v);
 
	EndVehicleMove(v);
 
	return;
 

	
 
reverse_direction:
 
	dir = ReverseDir(v->direction);
 
	v->direction = dir;
 
	goto getout;
src/station_cmd.cpp
Show inline comments
 
@@ -2239,82 +2239,82 @@ static void ClickTile_Station(TileIndex 
 
static const byte _enter_station_speedtable[12] = {
 
	215, 195, 175, 155, 135, 115, 95, 75, 55, 35, 15, 0
 
};
 

	
 
static uint32 VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y)
 
{
 
	if (v->type == VEH_Train) {
 
		if (IsRailwayStation(tile) && IsFrontEngine(v) &&
 
				!IsCompatibleTrainStationTile(tile + TileOffsByDiagDir(DirToDiagDir(v->direction)), tile)) {
 
			StationID station_id = GetStationIndex(tile);
 

	
 
			if ((!(v->current_order.flags & OF_NON_STOP) && !_patches.new_nonstop) ||
 
					(v->current_order.type == OT_GOTO_STATION && v->current_order.dest == station_id)) {
 
				if (!(_patches.new_nonstop && v->current_order.flags & OF_NON_STOP) &&
 
						v->current_order.type != OT_LEAVESTATION &&
 
						v->last_station_visited != station_id) {
 
					DiagDirection dir = DirToDiagDir(v->direction);
 

	
 
					x &= 0xF;
 
					y &= 0xF;
 

	
 
					if (DiagDirToAxis(dir) != AXIS_X) intswap(x, y);
 
					if (y == TILE_SIZE / 2) {
 
						if (dir != DIAGDIR_SE && dir != DIAGDIR_SW) x = TILE_SIZE - 1 - x;
 
						if (x == 12) return 2 | (station_id << 8); /* enter station */
 
						if (x == 12) return VETSB_ENTERED_STATION | (station_id << VETS_STATION_ID_OFFSET); /* enter station */
 
						if (x < 12) {
 
							uint16 spd;
 

	
 
							v->vehstatus |= VS_TRAIN_SLOWING;
 
							spd = _enter_station_speedtable[x];
 
							if (spd < v->cur_speed) v->cur_speed = spd;
 
						}
 
					}
 
				}
 
			}
 
		}
 
	} else if (v->type == VEH_Road) {
 
		if (v->u.road.state < 16 && !HASBIT(v->u.road.state, 2) && v->u.road.frame == 0) {
 
			if (IsRoadStop(tile)) {
 
				/* Attempt to allocate a parking bay in a road stop */
 
				RoadStop *rs = GetRoadStopByTile(tile, GetRoadStopType(tile));
 

	
 
				/* Check if station is busy or if there are no free bays. */
 
				if (rs->IsEntranceBusy() || !rs->HasFreeBay()) return 8;
 
				if (rs->IsEntranceBusy() || !rs->HasFreeBay()) return VETSB_CANNOT_ENTER;
 

	
 
				v->u.road.state += 32;
 

	
 
				/* Allocate a bay and update the road state */
 
				uint bay_nr = rs->AllocateBay();
 
				SB(v->u.road.state, 1, 1, bay_nr);
 

	
 
				/* Mark the station entrace as busy */
 
				rs->SetEntranceBusy(true);
 
			}
 
		}
 
	}
 

	
 
	return 0;
 
	return VETSB_CONTINUE;
 
}
 

	
 
/* this function is called for one station each tick */
 
static void StationHandleBigTick(Station *st)
 
{
 
	UpdateStationAcceptance(st, true);
 

	
 
	if (st->facilities == 0 && ++st->delete_ctr >= 8) delete st;
 

	
 
}
 

	
 
static inline void byte_inc_sat(byte *p) { byte b = *p + 1; if (b != 0) *p = b; }
 

	
 
static void UpdateStationRating(Station *st)
 
{
 
	GoodsEntry *ge;
 
	int rating;
 
	StationID index;
 
	int waiting;
 
	bool waiting_changed = false;
 

	
 
	byte_inc_sat(&st->time_since_load);
 
	byte_inc_sat(&st->time_since_unload);
 

	
src/train_cmd.cpp
Show inline comments
 
@@ -3001,54 +3001,53 @@ static void TrainController(Vehicle *v, 
 
	Direction dir;
 
	Direction newdir;
 
	Direction chosen_dir;
 
	TrackBits chosen_track;
 
	byte old_z;
 

	
 
	/* For every vehicle after and including the given vehicle */
 
	for (prev = GetPrevVehicleInChain(v); v != NULL; prev = v, v = v->next) {
 
		BeginVehicleMove(v);
 

	
 
		if (v->u.rail.track != 0x40) {
 
			/* Not inside tunnel */
 
			if (GetNewVehiclePos(v, &gp)) {
 
				/* Staying in the old tile */
 
				if (v->u.rail.track == 0x80) {
 
					/* inside depot */
 
					gp.x = v->x_pos;
 
					gp.y = v->y_pos;
 
				} else {
 
					/* is not inside depot */
 

	
 
					if (IsFrontEngine(v) && !TrainCheckIfLineEnds(v)) return;
 

	
 
					r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y);
 
					if (r & 0x8) {
 
						//debug("%x & 0x8", r);
 
					if (HASBIT(r, VETS_ENTERED_WORMHOLE)) {
 
						goto invalid_rail;
 
					}
 
					if (r & 0x2) {
 
						TrainEnterStation(v, r >> 8);
 
					if (HASBIT(r, VETS_ENTERED_STATION)) {
 
						TrainEnterStation(v, r >> VETS_STATION_ID_OFFSET);
 
						return;
 
					}
 

	
 
					if (v->current_order.type == OT_LEAVESTATION) {
 
						v->current_order.type = OT_NOTHING;
 
						v->current_order.flags = 0;
 
						InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 
					}
 
				}
 
			} else {
 
				/* A new tile is about to be entered. */
 

	
 
				TrackBits bits;
 
				/* Determine what direction we're entering the new tile from */
 
				dir = GetNewVehicleDirectionByTile(gp.new_tile, gp.old_tile);
 
				enterdir = DirToDiagDir(dir);
 
				assert(enterdir==0 || enterdir==1 || enterdir==2 || enterdir==3);
 

	
 
				/* Get the status of the tracks in the new tile and mask
 
				 * away the bits that aren't reachable. */
 
				ts = GetTileTrackStatus(gp.new_tile, TRANSPORT_RAIL) & _reachable_tracks[enterdir];
 

	
 
				/* Combine the from & to directions.
 
				 * Now, the lower byte contains the track status, and the byte at bit 16 contains
 
@@ -3080,89 +3079,88 @@ static void TrainController(Vehicle *v, 
 
					assert(chosen_track & tracks);
 

	
 
					/* Check if it's a red signal and that force proceed is not clicked. */
 
					if ( (tracks>>16)&chosen_track && v->u.rail.force_proceed == 0) goto red_light;
 
				} else {
 
					static byte _matching_tracks[8] = {0x30, 1, 0xC, 2, 0x30, 1, 0xC, 2};
 

	
 
					/* The wagon is active, simply follow the prev vehicle. */
 
					chosen_track = (TrackBits)(byte)(_matching_tracks[GetDirectionToVehicle(prev, gp.x, gp.y)] & bits);
 
				}
 

	
 
				/* make sure chosen track is a valid track */
 
				assert(chosen_track==1 || chosen_track==2 || chosen_track==4 || chosen_track==8 || chosen_track==16 || chosen_track==32);
 

	
 
				/* Update XY to reflect the entrance to the new tile, and select the direction to use */
 
				{
 
					const byte *b = _initial_tile_subcoord[FIND_FIRST_BIT(chosen_track)][enterdir];
 
					gp.x = (gp.x & ~0xF) | b[0];
 
					gp.y = (gp.y & ~0xF) | b[1];
 
					chosen_dir = (Direction)b[2];
 
				}
 

	
 
				/* Call the landscape function and tell it that the vehicle entered the tile */
 
				r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y);
 
				if (r & 0x8) {
 
					//debug("%x & 0x8", r);
 
				if (HASBIT(r, VETS_CANNOT_ENTER)) {
 
					goto invalid_rail;
 
				}
 

	
 
				if (IsLevelCrossingTile(v->tile) && v->next == NULL) {
 
					UnbarCrossing(v->tile);
 
					MarkTileDirtyByTile(v->tile);
 
				}
 

	
 
				if (IsFrontEngine(v)) v->load_unload_time_rem = 0;
 

	
 
				if (!(r&0x4)) {
 
				if (!HASBIT(r, VETS_ENTERED_WORMHOLE)) {
 
					v->tile = gp.new_tile;
 

	
 
					if (GetTileRailType(gp.new_tile, FindFirstTrack(chosen_track)) != GetTileRailType(gp.old_tile, FindFirstTrack(v->u.rail.track))) {
 
						TrainPowerChanged(GetFirstVehicleInChain(v));
 
					}
 

	
 
					v->u.rail.track = chosen_track;
 
					assert(v->u.rail.track);
 
				}
 

	
 
				if (IsFrontEngine(v)) TrainMovedChangeSignals(gp.new_tile, enterdir);
 

	
 
				/* Signals can only change when the first
 
				 * (above) or the last vehicle moves. */
 
				if (v->next == NULL)
 
					TrainMovedChangeSignals(gp.old_tile, ReverseDiagDir(enterdir));
 

	
 
				if (prev == NULL) AffectSpeedByDirChange(v, chosen_dir);
 

	
 
				v->direction = chosen_dir;
 
			}
 
		} else {
 
			/* in tunnel on on a bridge */
 
			GetNewVehiclePos(v, &gp);
 

	
 
			SetSpeedLimitOnBridge(v);
 

	
 
			if (!(IsTunnelTile(gp.new_tile) || IsBridgeTile(gp.new_tile)) || !(VehicleEnterTile(v, gp.new_tile, gp.x, gp.y) & 0x4)) {
 
			if (!(IsTunnelTile(gp.new_tile) || IsBridgeTile(gp.new_tile)) || !HASBIT(VehicleEnterTile(v, gp.new_tile, gp.x, gp.y), VETS_ENTERED_WORMHOLE)) {
 
				v->x_pos = gp.x;
 
				v->y_pos = gp.y;
 
				VehiclePositionChanged(v);
 
				if (!(v->vehstatus & VS_HIDDEN)) EndVehicleMove(v);
 
				continue;
 
			}
 
		}
 

	
 
		/* update image of train, as well as delta XY */
 
		newdir = GetNewVehicleDirection(v, gp.x, gp.y);
 
		UpdateTrainDeltaXY(v, newdir);
 
		if (update_image) v->cur_image = GetTrainImage(v, newdir);
 

	
 
		v->x_pos = gp.x;
 
		v->y_pos = gp.y;
 

	
 
		/* update the Z position of the vehicle */
 
		old_z = AfterSetTrainPos(v, (gp.new_tile != gp.old_tile));
 

	
 
		if (prev == NULL) {
 
			/* This is the first vehicle in the train */
 
			AffectSpeedByZChange(v, old_z);
 
		}
 
	}
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -1241,154 +1241,154 @@ static void ChangeTileOwner_TunnelBridge
 
		SetTileOwner(tile, new_player);
 
	} else {
 
		DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
 
	}
 
}
 

	
 

	
 
static const byte _tunnel_fractcoord_1[4]    = {0x8E, 0x18, 0x81, 0xE8};
 
static const byte _tunnel_fractcoord_2[4]    = {0x81, 0x98, 0x87, 0x38};
 
static const byte _tunnel_fractcoord_3[4]    = {0x82, 0x88, 0x86, 0x48};
 
static const byte _exit_tunnel_track[4]      = {1, 2, 1, 2};
 

	
 
static const byte _road_exit_tunnel_state[4] = {8, 9, 0, 1};
 
static const byte _road_exit_tunnel_frame[4] = {2, 7, 9, 4};
 

	
 
static const byte _tunnel_fractcoord_4[4]    = {0x52, 0x85, 0x98, 0x29};
 
static const byte _tunnel_fractcoord_5[4]    = {0x92, 0x89, 0x58, 0x25};
 
static const byte _tunnel_fractcoord_6[4]    = {0x92, 0x89, 0x56, 0x45};
 
static const byte _tunnel_fractcoord_7[4]    = {0x52, 0x85, 0x96, 0x49};
 

	
 
static uint32 VehicleEnter_TunnelBridge(Vehicle *v, TileIndex tile, int x, int y)
 
{
 
	int z = GetSlopeZ(x, y) - v->z_pos;
 

	
 
	if (myabs(z) > 2) return 8;
 
	if (myabs(z) > 2) return VETSB_CANNOT_ENTER;
 

	
 
	if (IsTunnel(tile)) {
 
		byte fc;
 
		DiagDirection dir;
 
		DiagDirection vdir;
 

	
 
		if (v->type == VEH_Train) {
 
			fc = (x & 0xF) + (y << 4);
 

	
 
			dir = GetTunnelDirection(tile);
 
			vdir = DirToDiagDir(v->direction);
 

	
 
			if (v->u.rail.track != 0x40 && dir == vdir) {
 
				if (IsFrontEngine(v) && fc == _tunnel_fractcoord_1[dir]) {
 
					if (!PlayVehicleSound(v, VSE_TUNNEL) && v->spritenum < 4) {
 
						SndPlayVehicleFx(SND_05_TRAIN_THROUGH_TUNNEL, v);
 
					}
 
					return 0;
 
					return VETSB_CONTINUE;
 
				}
 
				if (fc == _tunnel_fractcoord_2[dir]) {
 
					v->tile = tile;
 
					v->u.rail.track = TRACK_BIT_WORMHOLE;
 
					v->vehstatus |= VS_HIDDEN;
 
					return 4;
 
					return VETSB_ENTERED_WORMHOLE;
 
				}
 
			}
 

	
 
			if (dir == ReverseDiagDir(vdir) && fc == _tunnel_fractcoord_3[dir] && z == 0) {
 
				/* We're at the tunnel exit ?? */
 
				v->tile = tile;
 
				v->u.rail.track = (TrackBits)_exit_tunnel_track[dir];
 
				assert(v->u.rail.track);
 
				v->vehstatus &= ~VS_HIDDEN;
 
				return 4;
 
				return VETSB_ENTERED_WORMHOLE;
 
			}
 
		} else if (v->type == VEH_Road) {
 
			fc = (x & 0xF) + (y << 4);
 
			dir = GetTunnelDirection(tile);
 
			vdir = DirToDiagDir(v->direction);
 

	
 
			// Enter tunnel?
 
			if (v->u.road.state != 0xFF && dir == vdir) {
 
				if (fc == _tunnel_fractcoord_4[dir] ||
 
						fc == _tunnel_fractcoord_5[dir]) {
 
					v->tile = tile;
 
					v->u.road.state = 0xFF;
 
					v->vehstatus |= VS_HIDDEN;
 
					return 4;
 
					return VETSB_ENTERED_WORMHOLE;
 
				} else {
 
					return 0;
 
					return VETSB_CONTINUE;
 
				}
 
			}
 

	
 
			if (dir == ReverseDiagDir(vdir) && (
 
						/* We're at the tunnel exit ?? */
 
						fc == _tunnel_fractcoord_6[dir] ||
 
						fc == _tunnel_fractcoord_7[dir]
 
					) &&
 
					z == 0) {
 
				v->tile = tile;
 
				v->u.road.state = _road_exit_tunnel_state[dir];
 
				v->u.road.frame = _road_exit_tunnel_frame[dir];
 
				v->vehstatus &= ~VS_HIDDEN;
 
				return 4;
 
				return VETSB_ENTERED_WORMHOLE;
 
			}
 
		}
 
	} else if (IsBridge(tile)) { // XXX is this necessary?
 
		DiagDirection dir;
 

	
 
		if (v->type == VEH_Road || (v->type == VEH_Train && IsFrontEngine(v))) {
 
			/* modify speed of vehicle */
 
			uint16 spd = _bridge[GetBridgeType(tile)].speed;
 

	
 
			if (v->type == VEH_Road) spd *= 2;
 
			if (v->cur_speed > spd) v->cur_speed = spd;
 
		}
 

	
 
		dir = GetBridgeRampDirection(tile);
 
		if (DirToDiagDir(v->direction) == dir) {
 
			switch (dir) {
 
				default: NOT_REACHED();
 
				case DIAGDIR_NE: if ((x & 0xF) != 0)             return 0; break;
 
				case DIAGDIR_SE: if ((y & 0xF) != TILE_SIZE - 1) return 0; break;
 
				case DIAGDIR_SW: if ((x & 0xF) != TILE_SIZE - 1) return 0; break;
 
				case DIAGDIR_NW: if ((y & 0xF) != 0)             return 0; break;
 
				case DIAGDIR_NE: if ((x & 0xF) != 0)             return VETSB_CONTINUE; break;
 
				case DIAGDIR_SE: if ((y & 0xF) != TILE_SIZE - 1) return VETSB_CONTINUE; break;
 
				case DIAGDIR_SW: if ((x & 0xF) != TILE_SIZE - 1) return VETSB_CONTINUE; break;
 
				case DIAGDIR_NW: if ((y & 0xF) != 0)             return VETSB_CONTINUE; break;
 
			}
 
			if (v->type == VEH_Train) {
 
				v->u.rail.track = TRACK_BIT_WORMHOLE;
 
				CLRBIT(v->u.rail.flags, VRF_GOINGUP);
 
				CLRBIT(v->u.rail.flags, VRF_GOINGDOWN);
 
			} else {
 
				v->u.road.state = 0xFF;
 
			}
 
			return 4;
 
			return VETSB_ENTERED_WORMHOLE;
 
		} else if (DirToDiagDir(v->direction) == ReverseDiagDir(dir)) {
 
			v->tile = tile;
 
			if (v->type == VEH_Train) {
 
				if (v->u.rail.track == 0x40) {
 
					v->u.rail.track = (DiagDirToAxis(dir) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y);
 
					return 4;
 
					return VETSB_ENTERED_WORMHOLE;
 
				}
 
			} else {
 
				if (v->u.road.state == 0xFF) {
 
					v->u.road.state = _road_exit_tunnel_state[dir];
 
					v->u.road.frame = 0;
 
					return 4;
 
					return VETSB_ENTERED_WORMHOLE;
 
				}
 
			}
 
			return 0;
 
			return VETSB_CONTINUE;
 
		}
 
	}
 
	return 0;
 
	return VETSB_CONTINUE;
 
}
 

	
 
extern const TileTypeProcs _tile_type_tunnelbridge_procs = {
 
	DrawTile_TunnelBridge,           /* draw_tile_proc */
 
	GetSlopeZ_TunnelBridge,          /* get_slope_z_proc */
 
	ClearTile_TunnelBridge,          /* clear_tile_proc */
 
	GetAcceptedCargo_TunnelBridge,   /* get_accepted_cargo_proc */
 
	GetTileDesc_TunnelBridge,        /* get_tile_desc_proc */
 
	GetTileTrackStatus_TunnelBridge, /* get_tile_track_status_proc */
 
	ClickTile_TunnelBridge,          /* click_tile_proc */
 
	AnimateTile_TunnelBridge,        /* animate_tile_proc */
 
	TileLoop_TunnelBridge,           /* tile_loop_clear */
 
	ChangeTileOwner_TunnelBridge,    /* change_tile_owner_clear */
 
	NULL,                            /* get_produced_cargo_proc */
 
	VehicleEnter_TunnelBridge,       /* vehicle_enter_tile_proc */
 
	GetSlopeTileh_TunnelBridge,      /* get_slope_tileh_proc */
 
};
src/vehicle.cpp
Show inline comments
 
@@ -2748,52 +2748,53 @@ Trackdir GetVehicleTrackdir(const Vehicl
 
		case VEH_Ship:
 
			if (IsShipInDepot(v))
 
				/* We'll assume the ship is facing outwards */
 
				return DiagdirToDiagTrackdir(GetShipDepotDirection(v->tile));
 

	
 
			return TrackDirectionToTrackdir(FindFirstTrack(v->u.ship.state), v->direction);
 

	
 
		case VEH_Road:
 
			if (IsRoadVehInDepot(v)) /* We'll assume the road vehicle is facing outwards */
 
				return DiagdirToDiagTrackdir(GetRoadDepotDirection(v->tile));
 

	
 
			if (IsRoadStopTile(v->tile)) /* We'll assume the road vehicle is facing outwards */
 
				return DiagdirToDiagTrackdir(GetRoadStopDir(v->tile)); /* Road vehicle in a station */
 

	
 
			/* If vehicle's state is a valid track direction (vehicle is not turning around) return it */
 
			if ((v->u.road.state & 7) < 6) 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: */
 
		default: return INVALID_TRACKDIR;
 
	}
 
}
 
/* Return value has bit 0x2 set, when the vehicle enters a station. Then,
 
 * result << 8 contains the id of the station entered. If the return value has
 
 * bit 0x8 set, the vehicle could not and did not enter the tile. Are there
 
 * other bits that can be set? */
 

	
 
/**
 
 * Returns some meta-data over the to be entered tile.
 
 * @see VehicleEnterTileStatus to see what the bits in the return value mean.
 
 */
 
uint32 VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y)
 
{
 
	return _tile_type_procs[GetTileType(tile)]->vehicle_enter_tile_proc(v, tile, x, y);
 
}
 

	
 
UnitID GetFreeUnitNumber(byte type)
 
{
 
	UnitID unit, max = 0;
 
	const Vehicle *u;
 
	static bool *cache = NULL;
 
	static UnitID gmax = 0;
 

	
 
	switch (type) {
 
		case VEH_Train:    max = _patches.max_trains; break;
 
		case VEH_Road:     max = _patches.max_roadveh; break;
 
		case VEH_Ship:     max = _patches.max_ships; break;
 
		case VEH_Aircraft: max = _patches.max_aircraft; break;
 
		default: NOT_REACHED();
 
	}
 

	
 
	if (max == 0) {
 
		/* we can't build any of this kind of vehicle, so we just return 1 instead of looking for a free number
 
		 * a max of 0 will cause the following code to write to a NULL pointer
 
		 * We know that 1 is bigger than the max allowed vehicle number, so it's the same as returning something, that is too big
src/vehicle.h
Show inline comments
 
/* $Id$ */
 

	
 
#ifndef VEHICLE_H
 
#define VEHICLE_H
 

	
 
#include "oldpool.h"
 
#include "order.h"
 
#include "rail.h"
 

	
 
/** The returned bits of VehicleEnterTile. */
 
enum VehicleEnterTileStatus {
 
	VETS_ENTERED_STATION  = 1, ///< The vehicle entered a station
 
	VETS_ENTERED_WORMHOLE = 2, ///< The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/tunnel)
 
	VETS_CANNOT_ENTER     = 3, ///< The vehicle cannot enter the tile
 

	
 
	/**
 
	 * Shift the VehicleEnterTileStatus this many bits
 
	 * to the right to get the station ID when
 
	 * VETS_ENTERED_STATION is set
 
	 */
 
	VETS_STATION_ID_OFFSET = 8,
 

	
 
	/** Bit sets of the above specified bits */
 
	VETSB_CONTINUE         = 0,                          ///< The vehicle can continue normally
 
	VETSB_ENTERED_STATION  = 1 << VETS_ENTERED_STATION,  ///< The vehicle entered a station
 
	VETSB_ENTERED_WORMHOLE = 1 << VETS_ENTERED_WORMHOLE, ///< The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/tunnel)
 
	VETSB_CANNOT_ENTER     = 1 << VETS_CANNOT_ENTER,     ///< The vehicle cannot enter the tile
 
};
 

	
 
enum {
 
	VEH_Train,
 
	VEH_Road,
 
	VEH_Ship,
 
	VEH_Aircraft,
 
	VEH_Special,
 
	VEH_Disaster,
 
	VEH_Invalid = 0xFF,
 
} ;
 

	
 
enum VehStatus {
 
	VS_HIDDEN          = 0x01,
 
	VS_STOPPED         = 0x02,
 
	VS_UNCLICKABLE     = 0x04,
 
	VS_DEFPAL          = 0x08,
 
	VS_TRAIN_SLOWING   = 0x10,
 
	VS_SHADOW          = 0x20,
 
	VS_AIRCRAFT_BROKEN = 0x40,
 
	VS_CRASHED         = 0x80,
 
};
 

	
 
enum LoadStatus {
 
	LS_LOADING_FINISHED,
 
	LS_CARGO_UNLOADING,
src/water_cmd.cpp
Show inline comments
 
@@ -721,43 +721,43 @@ static uint32 GetTileTrackStatus_Water(T
 
}
 

	
 
static void ClickTile_Water(TileIndex tile)
 
{
 
	if (GetWaterTileType(tile) == WATER_DEPOT) {
 
		TileIndex tile2 = GetOtherShipDepotTile(tile);
 

	
 
		ShowDepotWindow(tile < tile2 ? tile : tile2, VEH_Ship);
 
	}
 
}
 

	
 
static void ChangeTileOwner_Water(TileIndex tile, PlayerID old_player, PlayerID new_player)
 
{
 
	if (!IsTileOwner(tile, old_player)) return;
 

	
 
	if (new_player != PLAYER_SPECTATOR) {
 
		SetTileOwner(tile, new_player);
 
	} else {
 
		DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
 
	}
 
}
 

	
 
static uint32 VehicleEnter_Water(Vehicle *v, TileIndex tile, int x, int y)
 
{
 
	return 0;
 
	return VETSB_CONTINUE;
 
}
 

	
 

	
 
extern const TileTypeProcs _tile_type_water_procs = {
 
	DrawTile_Water,           /* draw_tile_proc */
 
	GetSlopeZ_Water,          /* get_slope_z_proc */
 
	ClearTile_Water,          /* clear_tile_proc */
 
	GetAcceptedCargo_Water,   /* get_accepted_cargo_proc */
 
	GetTileDesc_Water,        /* get_tile_desc_proc */
 
	GetTileTrackStatus_Water, /* get_tile_track_status_proc */
 
	ClickTile_Water,          /* click_tile_proc */
 
	AnimateTile_Water,        /* animate_tile_proc */
 
	TileLoop_Water,           /* tile_loop_clear */
 
	ChangeTileOwner_Water,    /* change_tile_owner_clear */
 
	NULL,                     /* get_produced_cargo_proc */
 
	VehicleEnter_Water,       /* vehicle_enter_tile_proc */
 
	GetSlopeTileh_Water,      /* get_slope_tileh_proc */
 
};
0 comments (0 inline, 0 general)