Changeset - r12492:6a787b05475e
[Not reviewed]
master
0 18 0
rubidium - 15 years ago 2009-07-24 11:47:12
rubidium@openttd.org
(svn r16939) -Codechange: s/RailwayStation/RailStation/ to unify the way it's written.
18 files changed with 80 insertions and 79 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_rail.cpp
Show inline comments
 
@@ -38,7 +38,7 @@
 
{
 
	if (!::IsValidTile(tile)) return false;
 

	
 
	return ::IsRailwayStationTile(tile);
 
	return ::IsRailStationTile(tile);
 
}
 

	
 
/* static */ bool AIRail::IsRailWaypointTile(TileIndex tile)
src/newgrf_station.cpp
Show inline comments
 
@@ -54,8 +54,8 @@ struct ETileArea : TileArea {
 
				Axis axis = GetRailStationAxis(tile);
 
				TileIndexDiff delta = TileOffsByDiagDir(AxisToDiagDir(axis));
 

	
 
				for (end = tile; IsRailwayStationTile(end + delta) && IsCompatibleTrainStationTile(tile, end + delta); end += delta) { /* Nothing */ }
 
				for (start = tile; IsRailwayStationTile(start - delta) && IsCompatibleTrainStationTile(tile, start - delta); start -= delta) { /* Nothing */ }
 
				for (end = tile; IsRailStationTile(end + delta) && IsCompatibleTrainStationTile(tile, end + delta); end += delta) { /* Nothing */ }
 
				for (start = tile; IsRailStationTile(start - delta) && IsCompatibleTrainStationTile(tile, start - delta); start -= delta) { /* Nothing */ }
 

	
 
				this->tile = start;
 
				this->w = TileX(end) - TileX(start) + 1;
src/npf.cpp
Show inline comments
 
@@ -480,8 +480,8 @@ static void ClearPathReservation(const P
 
{
 
	bool first_run = true;
 
	for (; start != end; start = start->parent) {
 
		if (IsRailwayStationTile(start->node.tile) && first_run) {
 
			SetRailwayStationPlatformReservation(start->node.tile, TrackdirToExitdir(start->node.direction), false);
 
		if (IsRailStationTile(start->node.tile) && first_run) {
 
			SetRailStationPlatformReservation(start->node.tile, TrackdirToExitdir(start->node.direction), false);
 
		} else {
 
			UnreserveRailTrack(start->node.tile, TrackdirToTrack(start->node.direction));
 
		}
 
@@ -512,7 +512,7 @@ static void NPFSaveTargetData(AyStar *as
 
		ftd->node = target->node;
 

	
 
		/* If the target is a station skip to platform end. */
 
		if (IsRailwayStationTile(target->node.tile)) {
 
		if (IsRailStationTile(target->node.tile)) {
 
			DiagDirection dir = TrackdirToExitdir(target->node.direction);
 
			uint len = Station::GetByTile(target->node.tile)->GetPlatformLength(target->node.tile, dir);
 
			TileIndex end_tile = TILE_ADD(target->node.tile, (len - 1) * TileOffsByDiagDir(dir));
 
@@ -520,8 +520,8 @@ static void NPFSaveTargetData(AyStar *as
 
			/* Update only end tile, trackdir of a station stays the same. */
 
			ftd->node.tile = end_tile;
 
			if (!IsWaitingPositionFree(v, end_tile, target->node.direction, _settings_game.pf.forbid_90_deg)) return;
 
			SetRailwayStationPlatformReservation(target->node.tile, dir, true);
 
			SetRailwayStationReservation(target->node.tile, false);
 
			SetRailStationPlatformReservation(target->node.tile, dir, true);
 
			SetRailStationReservation(target->node.tile, false);
 
		} else {
 
			if (!IsWaitingPositionFree(v, target->node.tile, target->node.direction, _settings_game.pf.forbid_90_deg)) return;
 
		}
src/pbs.cpp
Show inline comments
 
@@ -41,21 +41,21 @@ TrackBits GetReservedTrackbits(TileIndex
 

	
 
/**
 
 * Set the reservation for a complete station platform.
 
 * @pre IsRailwayStationTile(start)
 
 * @pre IsRailStationTile(start)
 
 * @param start starting tile of the platform
 
 * @param dir the direction in which to follow the platform
 
 * @param b the state the reservation should be set to
 
 */
 
void SetRailwayStationPlatformReservation(TileIndex start, DiagDirection dir, bool b)
 
void SetRailStationPlatformReservation(TileIndex start, DiagDirection dir, bool b)
 
{
 
	TileIndex     tile = start;
 
	TileIndexDiff diff = TileOffsByDiagDir(dir);
 

	
 
	assert(IsRailwayStationTile(start));
 
	assert(IsRailStationTile(start));
 
	assert(GetRailStationAxis(start) == DiagDirToAxis(dir));
 

	
 
	do {
 
		SetRailwayStationReservation(tile, b);
 
		SetRailStationReservation(tile, b);
 
		MarkTileDirtyByTile(tile);
 
		tile = TILE_ADD(tile, diff);
 
	} while (IsCompatibleTrainStationTile(tile, start));
 
@@ -100,7 +100,7 @@ bool TryReserveRailTrack(TileIndex tile,
 

	
 
		case MP_STATION:
 
			if (HasStationRail(tile) && !HasStationReservation(tile)) {
 
				SetRailwayStationReservation(tile, true);
 
				SetRailStationReservation(tile, true);
 
				MarkTileDirtyByTile(tile); // some GRFs need redraw after reserving track
 
				return true;
 
			}
 
@@ -151,7 +151,7 @@ bool TryReserveRailTrack(TileIndex tile,
 

	
 
		case MP_STATION:
 
			if (HasStationRail(tile)) {
 
				SetRailwayStationReservation(tile, false);
 
				SetRailStationReservation(tile, false);
 
				MarkTileDirtyByTile(tile);
 
			}
 
			break;
 
@@ -295,7 +295,7 @@ Train *GetTrainForReservation(TileIndex 
 
		if (ftoti.best != NULL) return ftoti.best;
 

	
 
		/* Special case for stations: check the whole platform for a vehicle. */
 
		if (IsRailwayStationTile(ftoti.res.tile)) {
 
		if (IsRailStationTile(ftoti.res.tile)) {
 
			TileIndexDiff diff = TileOffsByDiagDir(TrackdirToExitdir(ReverseTrackdir(ftoti.res.trackdir)));
 
			for (TileIndex st_tile = ftoti.res.tile + diff; IsCompatibleTrainStationTile(st_tile, ftoti.res.tile); st_tile += diff) {
 
				FindVehicleOnPos(st_tile, &ftoti, FindTrainOnTrackEnum);
src/pbs.h
Show inline comments
 
@@ -12,7 +12,7 @@
 

	
 
TrackBits GetReservedTrackbits(TileIndex t);
 

	
 
void SetRailwayStationPlatformReservation(TileIndex start, DiagDirection dir, bool b);
 
void SetRailStationPlatformReservation(TileIndex start, DiagDirection dir, bool b);
 

	
 
bool TryReserveRailTrack(TileIndex tile, Track t);
 
void UnreserveRailTrack(TileIndex tile, Track t);
src/saveload/afterload.cpp
Show inline comments
 
@@ -561,7 +561,7 @@ bool AfterLoadGame()
 
					if (HasBit(_m[t].m6, 3)) SetBit(_m[t].m6, 2);
 
					StationGfx gfx = GetStationGfx(t);
 
					StationType st;
 
					if (       IsInsideMM(gfx,   0,   8)) { // Railway station
 
					if (       IsInsideMM(gfx,   0,   8)) { // Rail station
 
						st = STATION_RAIL;
 
						SetStationGfx(t, gfx - 0);
 
					} else if (IsInsideMM(gfx,   8,  67)) { // Airport
 
@@ -573,13 +573,13 @@ bool AfterLoadGame()
 
					} else if (IsInsideMM(gfx,  71,  75)) { // Bus
 
						st = STATION_BUS;
 
						SetStationGfx(t, gfx - 71);
 
					} else if (gfx == 75) {                    // Oil rig
 
					} else if (gfx == 75) {                 // Oil rig
 
						st = STATION_OILRIG;
 
						SetStationGfx(t, gfx - 75);
 
					} else if (IsInsideMM(gfx,  76,  82)) { // Dock
 
						st = STATION_DOCK;
 
						SetStationGfx(t, gfx - 76);
 
					} else if (gfx == 82) {                    // Buoy
 
					} else if (gfx == 82) {                 // Buoy
 
						st = STATION_BUOY;
 
						SetStationGfx(t, gfx - 82);
 
					} else if (IsInsideMM(gfx,  83, 168)) { // Extended airport
 
@@ -1654,7 +1654,7 @@ bool AfterLoadGame()
 
					break;
 

	
 
				case MP_STATION: // Clear PBS reservation on station
 
					if (IsRailwayStation(t)) SetRailwayStationReservation(t, false);
 
					if (HasStationRail(t)) SetRailStationReservation(t, false);
 
					break;
 

	
 
				case MP_TUNNELBRIDGE: // Clear PBS reservation on tunnels/birdges
src/saveload/labelmaps_sl.cpp
Show inline comments
 
@@ -64,7 +64,7 @@ void AfterLoadLabelMaps()
 
					break;
 

	
 
				case MP_STATION:
 
					if (IsRailwayStation(t)) {
 
					if (HasStationRail(t)) {
 
						SetRailType(t, railtype_conversion_map[GetRailType(t)]);
 
					}
 
					break;
src/saveload/waypoint_sl.cpp
Show inline comments
 
@@ -104,7 +104,7 @@ void MoveWaypointsToBaseStations()
 
			new_wp->facilities |= FACIL_TRAIN;
 
			new_wp->owner = GetTileOwner(t);
 

	
 
			SetRailwayStationReservation(t, reserved);
 
			SetRailStationReservation(t, reserved);
 

	
 
			if (wp->spec != NULL) {
 
				SetCustomStationSpecIndex(t, AllocateSpecToStation(wp->spec, new_wp, true));
src/station.cpp
Show inline comments
 
@@ -182,7 +182,7 @@ void Station::MarkTilesDirty(bool cargo_
 
}
 

	
 
/** Obtain the length of a platform
 
 * @pre tile must be a railway station tile
 
 * @pre tile must be a rail station tile
 
 * @param tile A tile that contains the platform in question
 
 * @return The length of the platform
 
 */
 
@@ -210,7 +210,7 @@ uint Station::GetPlatformLength(TileInde
 

	
 
/** Determines the REMAINING length of a platform, starting at (and including)
 
 * the given tile.
 
 * @param tile the tile from which to start searching. Must be a railway station tile
 
 * @param tile the tile from which to start searching. Must be a rail station tile
 
 * @param dir The direction in which to search.
 
 * @return The platform length
 
 */
 
@@ -218,7 +218,7 @@ uint Station::GetPlatformLength(TileInde
 
{
 
	TileIndex start_tile = tile;
 
	uint length = 0;
 
	assert(IsRailwayStationTile(tile));
 
	assert(IsRailStationTile(tile));
 
	assert(dir < DIAGDIR_END);
 

	
 
	do {
src/station_base.h
Show inline comments
 
@@ -133,7 +133,7 @@ public:
 

	
 
	/* virtual */ FORCEINLINE bool TileBelongsToRailStation(TileIndex tile) const
 
	{
 
		return IsRailwayStationTile(tile) && GetStationIndex(tile) == this->index;
 
		return IsRailStationTile(tile) && GetStationIndex(tile) == this->index;
 
	}
 

	
 
	/* virtual */ uint32 GetNewGRFVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) const;
src/station_cmd.cpp
Show inline comments
 
@@ -700,7 +700,7 @@ CommandCost CheckFlatLandBelow(TileIndex
 
		 * so station points to INVALID_STATION if we can build on any station.
 
		 * Or it points to a station if we're only allowed to build on exactly that station. */
 
		if (station != NULL && IsTileType(tile_cur, MP_STATION)) {
 
			if (!IsRailwayStation(tile_cur)) {
 
			if (!IsRailStation(tile_cur)) {
 
				return ClearTile_Station(tile_cur, DC_AUTO); // get error message
 
			} else {
 
				StationID st = GetStationIndex(tile_cur);
 
@@ -1013,15 +1013,15 @@ CommandCost CmdBuildRailroadStation(Tile
 
			int w = plat_len;
 
			do {
 
				byte layout = *layout_ptr++;
 
				if (IsRailwayStationTile(tile) && HasStationReservation(tile)) {
 
				if (IsRailStationTile(tile) && HasStationReservation(tile)) {
 
					/* Check for trains having a reservation for this tile. */
 
					Train *v = GetTrainForReservation(tile, AxisToTrack(GetRailStationAxis(tile)));
 
					if (v != NULL) {
 
						FreeTrainTrackReservation(v);
 
						*affected_vehicles.Append() = v;
 
						if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), false);
 
						if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), false);
 
						for (; v->Next() != NULL; v = v->Next()) ;
 
						if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(v->GetVehicleTrackdir())), false);
 
						if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(v->GetVehicleTrackdir())), false);
 
					}
 
				}
 

	
 
@@ -1058,10 +1058,10 @@ CommandCost CmdBuildRailroadStation(Tile
 
		for (uint i = 0; i < affected_vehicles.Length(); ++i) {
 
			/* Restore reservations of trains. */
 
			Train *v = affected_vehicles[i];
 
			if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), true);
 
			if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), true);
 
			TryPathReserve(v, true, true);
 
			for (; v->Next() != NULL; v = v->Next()) ;
 
			if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(v->GetVehicleTrackdir())), true);
 
			if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(v->GetVehicleTrackdir())), true);
 
		}
 

	
 
		st->MarkTilesDirty(false);
 
@@ -1076,7 +1076,7 @@ CommandCost CmdBuildRailroadStation(Tile
 
	return cost;
 
}
 

	
 
static void MakeRailwayStationAreaSmaller(Station *st)
 
static void MakeRailStationAreaSmaller(Station *st)
 
{
 
	uint w = st->trainst_w;
 
	uint h = st->trainst_h;
 
@@ -1165,7 +1165,7 @@ CommandCost CmdRemoveFromRailroadStation
 
	/* Do the action for every tile into the area */
 
	BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) {
 
		/* Make sure the specified tile is a railroad station */
 
		if (!IsRailwayStationTile(tile2)) {
 
		if (!IsRailStationTile(tile2)) {
 
			continue;
 
		}
 

	
 
@@ -1200,10 +1200,10 @@ CommandCost CmdRemoveFromRailroadStation
 
				if (v != NULL) {
 
					/* Free train reservation. */
 
					FreeTrainTrackReservation(v);
 
					if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), false);
 
					if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), false);
 
					Vehicle *temp = v;
 
					for (; temp->Next() != NULL; temp = temp->Next()) ;
 
					if (IsRailwayStationTile(temp->tile)) SetRailwayStationPlatformReservation(temp->tile, TrackdirToExitdir(ReverseTrackdir(temp->GetVehicleTrackdir())), false);
 
					if (IsRailStationTile(temp->tile)) SetRailStationPlatformReservation(temp->tile, TrackdirToExitdir(ReverseTrackdir(temp->GetVehicleTrackdir())), false);
 
				}
 
			}
 

	
 
@@ -1218,10 +1218,10 @@ CommandCost CmdRemoveFromRailroadStation
 

	
 
			if (v != NULL) {
 
				/* Restore station reservation. */
 
				if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), true);
 
				if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), true);
 
				TryPathReserve(v, true, true);
 
				for (; v->Next() != NULL; v = v->Next()) ;
 
				if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(v->GetVehicleTrackdir())), true);
 
				if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(v->GetVehicleTrackdir())), true);
 
			}
 
		}
 
	} END_TILE_LOOP(tile2, size_x, size_y, tile)
 
@@ -1232,7 +1232,7 @@ CommandCost CmdRemoveFromRailroadStation
 
		/* now we need to make the "spanned" area of the railway station smaller
 
		 * if we deleted something at the edges.
 
		 * we also need to adjust train_tile. */
 
		MakeRailwayStationAreaSmaller(st);
 
		MakeRailStationAreaSmaller(st);
 
		st->MarkTilesDirty(false);
 
		UpdateStationSignCoord(st);
 

	
 
@@ -2135,7 +2135,7 @@ static void DrawTile_Station(TileInfo *t
 
	int32 total_offset;
 
	int32 custom_ground_offset;
 

	
 
	if (IsRailwayStation(ti->tile) || IsRailWaypoint(ti->tile)) {
 
	if (HasStationRail(ti->tile)) {
 
		const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile));
 
		roadtypes = ROADTYPES_NONE;
 
		total_offset = rti->total_offset;
 
@@ -2212,13 +2212,13 @@ static void DrawTile_Station(TileInfo *t
 
		DrawGroundSprite(image, GroundSpritePaletteTransform(image, pal, palette));
 

	
 
		/* PBS debugging, draw reserved tracks darker */
 
		if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && (IsRailwayStation(ti->tile) || IsRailWaypoint(ti->tile)) && HasStationReservation(ti->tile)) {
 
		if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasStationRail(ti->tile) && HasStationReservation(ti->tile)) {
 
			const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile));
 
			DrawGroundSprite(GetRailStationAxis(ti->tile) == AXIS_X ? rti->base_sprites.single_y : rti->base_sprites.single_x, PALETTE_CRASH);
 
		}
 
	}
 

	
 
	if ((IsRailwayStation(ti->tile) || IsRailWaypoint(ti->tile)) && HasCatenaryDrawn(GetRailType(ti->tile)) && IsStationTileElectrifiable(ti->tile)) DrawCatenary(ti);
 
	if (HasStationRail(ti->tile) && HasCatenaryDrawn(GetRailType(ti->tile)) && IsStationTileElectrifiable(ti->tile)) DrawCatenary(ti);
 

	
 
	if (HasBit(roadtypes, ROADTYPE_TRAM)) {
 
		Axis axis = GetRoadStopDir(ti->tile) == DIAGDIR_NE ? AXIS_X : AXIS_Y;
 
@@ -2359,7 +2359,7 @@ static TrackStatus GetTileTrackStatus_St
 

	
 
	switch (mode) {
 
		case TRANSPORT_RAIL:
 
			if ((IsRailwayStation(tile) || IsRailWaypoint(tile)) && !IsStationTileBlocked(tile)) {
 
			if (HasStationRail(tile) && !IsStationTileBlocked(tile)) {
 
				trackbits = TrackToTrackBits(GetRailStationTrack(tile));
 
			}
 
			break;
 
@@ -2444,7 +2444,7 @@ static void AnimateTile_Station(TileInde
 
		{ GFX_WINDSACK_INTERCON_FIRST,   GFX_WINDSACK_INTERCON_LAST,   1 }
 
	};
 

	
 
	if (IsRailwayStation(tile)) {
 
	if (HasStationRail(tile)) {
 
		AnimateStationTile(tile);
 
		return;
 
	}
 
@@ -2483,7 +2483,7 @@ static VehicleEnterTileStatus VehicleEnt
 

	
 
	if (v->type == VEH_TRAIN) {
 
		if (!v->current_order.ShouldStopAtStation(v, station_id)) return VETSB_CONTINUE;
 
		if (!IsRailwayStation(tile) || !Train::From(v)->IsFrontEngine()) return VETSB_CONTINUE;
 
		if (!IsRailStation(tile) || !Train::From(v)->IsFrontEngine()) return VETSB_CONTINUE;
 

	
 
		int station_ahead;
 
		int station_length;
src/station_map.h
Show inline comments
 
@@ -45,6 +45,7 @@ enum {
 

	
 
static inline StationType GetStationType(TileIndex t)
 
{
 
	assert(IsTileType(t, MP_STATION));
 
	return (StationType)GB(_m[t].m6, 3, 3);
 
}
 

	
 
@@ -78,14 +79,14 @@ static inline void SetStationAnimationFr
 
	_me[t].m7 = frame;
 
}
 

	
 
static inline bool IsRailwayStation(TileIndex t)
 
static inline bool IsRailStation(TileIndex t)
 
{
 
	return GetStationType(t) == STATION_RAIL;
 
}
 

	
 
static inline bool IsRailwayStationTile(TileIndex t)
 
static inline bool IsRailStationTile(TileIndex t)
 
{
 
	return IsTileType(t, MP_STATION) && IsRailwayStation(t);
 
	return IsTileType(t, MP_STATION) && IsRailStation(t);
 
}
 

	
 
/**
 
@@ -118,7 +119,7 @@ static inline bool IsRailWaypointTile(Ti
 
 */
 
static inline bool HasStationRail(TileIndex t)
 
{
 
	return IsRailwayStation(t) || IsRailWaypoint(t);
 
	return IsRailStation(t) || IsRailWaypoint(t);
 
}
 

	
 
/**
 
@@ -230,7 +231,7 @@ static inline bool IsHangarTile(TileInde
 

	
 
static inline Axis GetRailStationAxis(TileIndex t)
 
{
 
	assert(IsRailwayStation(t) || IsRailWaypoint(t));
 
	assert(HasStationRail(t));
 
	return HasBit(GetStationGfx(t), 0) ? AXIS_Y : AXIS_X;
 
}
 

	
 
@@ -247,9 +248,9 @@ static inline TrackBits GetRailStationTr
 

	
 
static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2)
 
{
 
	assert(IsRailwayStationTile(t2));
 
	assert(IsRailStationTile(t2));
 
	return
 
		IsRailwayStationTile(t1) &&
 
		IsRailStationTile(t1) &&
 
		IsCompatibleRail(GetRailType(t1), GetRailType(t2)) &&
 
		GetRailStationAxis(t1) == GetRailStationAxis(t2) &&
 
		GetStationIndex(t1) == GetStationIndex(t2) &&
 
@@ -258,31 +259,31 @@ static inline bool IsCompatibleTrainStat
 

	
 
/**
 
 * Get the reservation state of the rail station
 
 * @pre IsRailwayStation(t) || IsRailWaypoint(t)
 
 * @pre HasStationRail(t)
 
 * @param t the station tile
 
 * @return reservation state
 
 */
 
static inline bool HasStationReservation(TileIndex t)
 
{
 
	assert(IsRailwayStation(t) || IsRailWaypoint(t));
 
	assert(HasStationRail(t));
 
	return HasBit(_m[t].m6, 2);
 
}
 

	
 
/**
 
 * Set the reservation state of the rail station
 
 * @pre IsRailwayStation(t) || IsRailWaypoint(t)
 
 * @pre HasStationRail(t)
 
 * @param t the station tile
 
 * @param b the reservation state
 
 */
 
static inline void SetRailwayStationReservation(TileIndex t, bool b)
 
static inline void SetRailStationReservation(TileIndex t, bool b)
 
{
 
	assert(IsRailwayStation(t) || IsRailWaypoint(t));
 
	assert(HasStationRail(t));
 
	SB(_m[t].m6, 2, 1, b ? 1 : 0);
 
}
 

	
 
/**
 
 * Get the reserved track bits for a waypoint
 
 * @pre IsRailwayStation(t) || IsRailWaypoint(t)
 
 * @pre HasStationRail(t)
 
 * @param t the tile
 
 * @return reserved track bits
 
 */
 
@@ -366,14 +367,14 @@ static inline void MakeRailStation(TileI
 
{
 
	MakeStation(t, o, sid, STATION_RAIL, section + a);
 
	SetRailType(t, rt);
 
	SetRailwayStationReservation(t, false);
 
	SetRailStationReservation(t, false);
 
}
 

	
 
static inline void MakeRailWaypoint(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
 
{
 
	MakeStation(t, o, sid, STATION_WAYPOINT, section + a);
 
	SetRailType(t, rt);
 
	SetRailwayStationReservation(t, false);
 
	SetRailStationReservation(t, false);
 
}
 

	
 
static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStopType rst, RoadTypes rt, DiagDirection d)
src/train_cmd.cpp
Show inline comments
 
@@ -482,7 +482,7 @@ static int GetTrainAcceleration(Train *v
 
	assert(max_speed == GetTrainCurveSpeedLimit(v)); // safety check, will be removed later
 
	int speed = v->cur_speed * 10 / 16; // km-ish/h -> mp/h
 

	
 
	if (IsRailwayStationTile(v->tile) && v->IsFrontEngine()) {
 
	if (IsRailStationTile(v->tile) && v->IsFrontEngine()) {
 
		StationID sid = GetStationIndex(v->tile);
 
		if (v->current_order.ShouldStopAtStation(v, sid)) {
 
			int station_ahead;
 
@@ -1977,7 +1977,7 @@ static void ReverseTrainDirection(Train 
 
			HasSignalOnTrackdir(v->tile, v->GetVehicleTrackdir()) &&
 
			!IsPbsSignal(GetSignalType(v->tile, FindFirstTrack(v->track))));
 

	
 
		if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), true);
 
		if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), true);
 
		if (TryPathReserve(v, false, first_tile_okay)) {
 
			/* Do a look-ahead now in case our current tile was already a safe tile. */
 
			CheckNextTrainTile(v);
 
@@ -2404,7 +2404,7 @@ static void CheckNextTrainTile(Train *v)
 
	/* Exit if we reached our destination depot or are inside a depot. */
 
	if ((v->tile == v->dest_tile && v->current_order.IsType(OT_GOTO_DEPOT)) || v->track == TRACK_BIT_DEPOT) return;
 
	/* Exit if we are on a station tile and are going to stop. */
 
	if (IsRailwayStationTile(v->tile) && v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile))) return;
 
	if (IsRailStationTile(v->tile) && v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile))) return;
 
	/* Exit if the current order doesn't have a destination, but the train has orders. */
 
	if ((v->current_order.IsType(OT_NOTHING) || v->current_order.IsType(OT_LEAVESTATION) || v->current_order.IsType(OT_LOADING)) && v->GetNumOrders() > 0) return;
 

	
 
@@ -2529,12 +2529,12 @@ static void ClearPathReservation(const T
 
				}
 
			}
 
		}
 
	} else if (IsRailwayStationTile(tile)) {
 
	} else if (IsRailStationTile(tile)) {
 
		TileIndex new_tile = TileAddByDiagDir(tile, dir);
 
		/* If the new tile is not a further tile of the same station, we
 
		 * clear the reservation for the whole platform. */
 
		if (!IsCompatibleTrainStationTile(new_tile, tile)) {
 
			SetRailwayStationPlatformReservation(tile, ReverseDiagDir(dir), false);
 
			SetRailStationPlatformReservation(tile, ReverseDiagDir(dir), false);
 
		}
 
	} else {
 
		/* Any other tile */
 
@@ -2549,8 +2549,8 @@ void FreeTrainTrackReservation(const Tra
 

	
 
	TileIndex tile = origin != INVALID_TILE ? origin : v->tile;
 
	Trackdir  td = orig_td != INVALID_TRACKDIR ? orig_td : v->GetVehicleTrackdir();
 
	bool      free_tile = tile != v->tile || !(IsRailwayStationTile(v->tile) || IsTileType(v->tile, MP_TUNNELBRIDGE));
 
	StationID station_id = IsRailwayStationTile(v->tile) ? GetStationIndex(v->tile) : INVALID_STATION;
 
	bool      free_tile = tile != v->tile || !(IsRailStationTile(v->tile) || IsTileType(v->tile, MP_TUNNELBRIDGE));
 
	StationID station_id = IsRailStationTile(v->tile) ? GetStationIndex(v->tile) : INVALID_STATION;
 

	
 
	/* Don't free reservation if it's not ours. */
 
	if (TracksOverlap(GetReservedTrackbits(tile) | TrackToTrackBits(TrackdirToTrack(td)))) return;
 
@@ -2607,7 +2607,7 @@ static bool NtpCallbFindStation(TileInde
 

	
 
	/* did we reach the final station? */
 
	if ((ttfd->station_index == INVALID_STATION && tile == ttfd->dest_coords) || (
 
				IsRailwayStationTile(tile) &&
 
				IsRailStationTile(tile) &&
 
				GetStationIndex(tile) == ttfd->station_index
 
			)) {
 
		/* We do not check for dest_coords if we have a station_index,
 
@@ -3010,7 +3010,7 @@ static Track ChooseTrainTrack(Train *v, 
 
		orders.SwitchToNextOrder(false);
 
	} else if (v->current_order.IsType(OT_LOADING) || (!v->current_order.IsType(OT_GOTO_DEPOT) && (
 
			v->current_order.IsType(OT_GOTO_STATION) ?
 
			IsRailwayStationTile(v->tile) && v->current_order.GetDestination() == GetStationIndex(v->tile) :
 
			IsRailStationTile(v->tile) && v->current_order.GetDestination() == GetStationIndex(v->tile) :
 
			v->tile == v->dest_tile))) {
 
		orders.SwitchToNextOrder(true);
 
	}
src/waypoint_cmd.cpp
Show inline comments
 
@@ -186,7 +186,7 @@ CommandCost CmdBuildTrainWaypoint(TileIn
 

	
 
		bool reserved = HasBit(GetRailReservationTrackBits(tile), AxisToTrack(axis));
 
		MakeRailWaypoint(tile, owner, wp->index, axis, 0, GetRailType(tile));
 
		SetRailwayStationReservation(tile, reserved);
 
		SetRailStationReservation(tile, reserved);
 
		MarkTileDirtyByTile(tile);
 

	
 
		SetCustomStationSpecIndex(tile, AllocateSpecToStation(GetCustomStationSpec(STAT_CLASS_WAYP, p1), wp, true));
src/yapf/follow_track.hpp
Show inline comments
 
@@ -191,7 +191,7 @@ protected:
 
		m_new_tile = TILE_ADD(m_old_tile, diff);
 

	
 
		/* special handling for stations */
 
		if (IsRailTT() && IsRailwayStationTile(m_new_tile)) {
 
		if (IsRailTT() && IsRailStationTile(m_new_tile)) {
 
			m_is_station = true;
 
		} else if (IsRoadTT() && IsRoadStopTile(m_new_tile)) {
 
			m_is_station = true;
src/yapf/yapf_costrail.hpp
Show inline comments
 
@@ -163,7 +163,7 @@ public:
 
	{
 
		if (n.m_num_signals_passed >= m_sig_look_ahead_costs.Size() / 2) return 0;
 

	
 
		if (IsRailwayStationTile(tile) && IsAnyStationTileReserved(tile, trackdir, skipped)) {
 
		if (IsRailStationTile(tile) && IsAnyStationTileReserved(tile, trackdir, skipped)) {
 
			return Yapf().PfGetSettings().rail_pbs_station_penalty * (skipped + 1);
 
		} else if (TrackOverlapsTracks(GetReservedTrackbits(tile), TrackdirToTrack(trackdir))) {
 
			int cost = Yapf().PfGetSettings().rail_pbs_cross_penalty;
src/yapf/yapf_destrail.hpp
Show inline comments
 
@@ -160,7 +160,7 @@ public:
 
	{
 
		bool bDest;
 
		if (m_dest_station_id != INVALID_STATION) {
 
			bDest = IsRailwayStationTile(tile)
 
			bDest = IsRailStationTile(tile)
 
				&& (GetStationIndex(tile) == m_dest_station_id)
 
				&& (GetRailStationTrack(tile) == TrackdirToTrack(td));
 
		} else {
src/yapf/yapf_rail.cpp
Show inline comments
 
@@ -63,14 +63,14 @@ private:
 
	}
 

	
 
	/** Reserve a railway platform. Tile contains the failed tile on abort. */
 
	bool ReserveRailwayStationPlatform(TileIndex &tile, DiagDirection dir)
 
	bool ReserveRailStationPlatform(TileIndex &tile, DiagDirection dir)
 
	{
 
		TileIndex     start = tile;
 
		TileIndexDiff diff = TileOffsByDiagDir(dir);
 

	
 
		do {
 
			if (HasStationReservation(tile)) return false;
 
			SetRailwayStationReservation(tile, true);
 
			SetRailStationReservation(tile, true);
 
			MarkTileDirtyByTile(tile);
 
			tile = TILE_ADD(tile, diff);
 
		} while (IsCompatibleTrainStationTile(tile, start));
 
@@ -81,8 +81,8 @@ private:
 
	/** Try to reserve a single track/platform. */
 
	bool ReserveSingleTrack(TileIndex tile, Trackdir td)
 
	{
 
		if (IsRailwayStationTile(tile)) {
 
			if (!ReserveRailwayStationPlatform(tile, TrackdirToExitdir(ReverseTrackdir(td)))) {
 
		if (IsRailStationTile(tile)) {
 
			if (!ReserveRailStationPlatform(tile, TrackdirToExitdir(ReverseTrackdir(td)))) {
 
				/* Platform could not be reserved, undo. */
 
				m_res_fail_tile = tile;
 
				m_res_fail_td = td;
 
@@ -102,11 +102,11 @@ private:
 
	/** Unreserve a single track/platform. Stops when the previous failer is reached. */
 
	bool UnreserveSingleTrack(TileIndex tile, Trackdir td)
 
	{
 
		if (IsRailwayStationTile(tile)) {
 
		if (IsRailStationTile(tile)) {
 
			TileIndex     start = tile;
 
			TileIndexDiff diff = TileOffsByDiagDir(TrackdirToExitdir(ReverseTrackdir(td)));
 
			while ((tile != m_res_fail_tile || td != m_res_fail_td) && IsCompatibleTrainStationTile(tile, start)) {
 
				SetRailwayStationReservation(tile, false);
 
				SetRailStationReservation(tile, false);
 
				tile = TILE_ADD(tile, diff);
 
			}
 
		} else if (tile != m_res_fail_tile || td != m_res_fail_td) {
0 comments (0 inline, 0 general)