(svn r3831) Add and use GetRailDepotDirection()
This commit is contained in:
		@@ -4,6 +4,7 @@
 | 
				
			|||||||
#include "../../openttd.h"
 | 
					#include "../../openttd.h"
 | 
				
			||||||
#include "../../functions.h"
 | 
					#include "../../functions.h"
 | 
				
			||||||
#include "../../map.h"
 | 
					#include "../../map.h"
 | 
				
			||||||
 | 
					#include "../../rail_map.h"
 | 
				
			||||||
#include "../../road_map.h"
 | 
					#include "../../road_map.h"
 | 
				
			||||||
#include "../../tile.h"
 | 
					#include "../../tile.h"
 | 
				
			||||||
#include "../../player.h"
 | 
					#include "../../player.h"
 | 
				
			||||||
@@ -3625,8 +3626,9 @@ pos_3:
 | 
				
			|||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			static const byte _depot_bits[] = {0x19,0x16,0x25,0x2A};
 | 
								static const byte _depot_bits[] = {0x19,0x16,0x25,0x2A};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			m5 &= 3;
 | 
								DiagDirection dir = GetRailDepotDirection(tile);
 | 
				
			||||||
			if (GetRailTrackStatus(tile + TileOffsByDir(m5)) & _depot_bits[m5])
 | 
					
 | 
				
			||||||
 | 
								if (GetRailTrackStatus(tile + TileOffsByDir(dir)) & _depot_bits[dir])
 | 
				
			||||||
				return;
 | 
									return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
 | 
								DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										3
									
								
								depot.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								depot.h
									
									
									
									
									
								
							@@ -8,6 +8,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "direction.h"
 | 
					#include "direction.h"
 | 
				
			||||||
#include "pool.h"
 | 
					#include "pool.h"
 | 
				
			||||||
 | 
					#include "rail_map.h"
 | 
				
			||||||
#include "road_map.h"
 | 
					#include "road_map.h"
 | 
				
			||||||
#include "tile.h"
 | 
					#include "tile.h"
 | 
				
			||||||
#include "variables.h"
 | 
					#include "variables.h"
 | 
				
			||||||
@@ -103,7 +104,7 @@ static inline DiagDirection GetDepotDirection(TileIndex tile, TransportType type
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	switch (type)
 | 
						switch (type)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		case TRANSPORT_RAIL: return (DiagDirection)GB(_m[tile].m5, 0, 2);
 | 
							case TRANSPORT_RAIL: return GetRailDepotDirection(tile);
 | 
				
			||||||
		case TRANSPORT_ROAD: return GetRoadDepotDirection(tile);
 | 
							case TRANSPORT_ROAD: return GetRoadDepotDirection(tile);
 | 
				
			||||||
		case TRANSPORT_WATER:
 | 
							case TRANSPORT_WATER:
 | 
				
			||||||
			/* Water is stubborn, it stores the directions in a different order. */
 | 
								/* Water is stubborn, it stores the directions in a different order. */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1027,7 +1027,7 @@ static int32 RemoveTrainDepot(TileIndex tile, uint32 flags)
 | 
				
			|||||||
		return CMD_ERROR;
 | 
							return CMD_ERROR;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (flags & DC_EXEC) {
 | 
						if (flags & DC_EXEC) {
 | 
				
			||||||
		Track track = TrackdirToTrack(DiagdirToDiagTrackdir(GetDepotDirection(tile, TRANSPORT_RAIL)));
 | 
							Track track = TrackdirToTrack(DiagdirToDiagTrackdir(GetRailDepotDirection(tile)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		DoDeleteDepot(tile);
 | 
							DoDeleteDepot(tile);
 | 
				
			||||||
		SetSignalsOnBothDir(tile, track);
 | 
							SetSignalsOnBothDir(tile, track);
 | 
				
			||||||
@@ -2085,7 +2085,7 @@ static uint32 VehicleEnter_Track(Vehicle *v, TileIndex tile, int x, int y)
 | 
				
			|||||||
	if (v->type != VEH_Train || !IsTileDepotType(tile, TRANSPORT_RAIL)) return 0;
 | 
						if (v->type != VEH_Train || !IsTileDepotType(tile, TRANSPORT_RAIL)) return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* depot direction */
 | 
						/* depot direction */
 | 
				
			||||||
	dir = GetDepotDirection(tile, TRANSPORT_RAIL);
 | 
						dir = GetRailDepotDirection(tile);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* calculate the point where the following wagon should be activated */
 | 
						/* calculate the point where the following wagon should be activated */
 | 
				
			||||||
	/* this depends on the length of the current vehicle */
 | 
						/* this depends on the length of the current vehicle */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,6 +8,12 @@
 | 
				
			|||||||
#include "waypoint.h"
 | 
					#include "waypoint.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static inline DiagDirection GetRailDepotDirection(TileIndex t)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return (DiagDirection)GB(_m[t].m5, 0, 2);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline TrackBits GetRailWaypointBits(TileIndex t)
 | 
					static inline TrackBits GetRailWaypointBits(TileIndex t)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return _m[t].m5 & RAIL_WAYPOINT_TRACK_MASK ? TRACK_BIT_Y : TRACK_BIT_X;
 | 
						return _m[t].m5 & RAIL_WAYPOINT_TRACK_MASK ? TRACK_BIT_Y : TRACK_BIT_X;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -540,7 +540,7 @@ static int32 CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 flags)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			v->engine_type = engine;
 | 
								v->engine_type = engine;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			dir = GB(_m[tile].m5, 0, 2);
 | 
								dir = GetRailDepotDirection(tile);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			v->direction = DiagDirToDir(dir);
 | 
								v->direction = DiagDirToDir(dir);
 | 
				
			||||||
			v->tile = tile;
 | 
								v->tile = tile;
 | 
				
			||||||
@@ -699,7 +699,7 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			v->unitnumber = unit_num;
 | 
								v->unitnumber = unit_num;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			dir = GB(_m[tile].m5, 0, 2);
 | 
								dir = GetRailDepotDirection(tile);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			v->direction = DiagDirToDir(dir);
 | 
								v->direction = DiagDirToDir(dir);
 | 
				
			||||||
			v->tile = tile;
 | 
								v->tile = tile;
 | 
				
			||||||
@@ -3167,7 +3167,7 @@ static bool TrainCheckIfLineEnds(Vehicle *v)
 | 
				
			|||||||
		if (x + 4 > 15 &&
 | 
							if (x + 4 > 15 &&
 | 
				
			||||||
				(!CheckCompatibleRail(v, tile) ||
 | 
									(!CheckCompatibleRail(v, tile) ||
 | 
				
			||||||
				(IsTileDepotType(tile, TRANSPORT_RAIL) &&
 | 
									(IsTileDepotType(tile, TRANSPORT_RAIL) &&
 | 
				
			||||||
				GetDepotDirection(tile, TRANSPORT_RAIL) == dir))) {
 | 
									GetRailDepotDirection(tile) == dir))) {
 | 
				
			||||||
			v->cur_speed = 0;
 | 
								v->cur_speed = 0;
 | 
				
			||||||
			ReverseTrainDirection(v);
 | 
								ReverseTrainDirection(v);
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
@@ -3287,7 +3287,7 @@ static const byte _depot_track_ind[4] = {0,1,0,1};
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void TrainEnterDepot(Vehicle *v, TileIndex tile)
 | 
					void TrainEnterDepot(Vehicle *v, TileIndex tile)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	SetSignalsOnBothDir(tile, _depot_track_ind[GB(_m[tile].m5, 0, 2)]);
 | 
						SetSignalsOnBothDir(tile, _depot_track_ind[GetRailDepotDirection(tile)]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!IsFrontEngine(v)) v = GetFirstVehicleInChain(v);
 | 
						if (!IsFrontEngine(v)) v = GetFirstVehicleInChain(v);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1960,7 +1960,7 @@ Trackdir GetVehicleTrackdir(const Vehicle* v)
 | 
				
			|||||||
	switch (v->type) {
 | 
						switch (v->type) {
 | 
				
			||||||
		case VEH_Train:
 | 
							case VEH_Train:
 | 
				
			||||||
			if (v->u.rail.track == 0x80) /* We'll assume the train is facing outwards */
 | 
								if (v->u.rail.track == 0x80) /* We'll assume the train is facing outwards */
 | 
				
			||||||
				return DiagdirToDiagTrackdir(GetDepotDirection(v->tile, TRANSPORT_RAIL)); /* Train in depot */
 | 
									return DiagdirToDiagTrackdir(GetRailDepotDirection(v->tile)); /* Train in depot */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (v->u.rail.track == 0x40) /* train in tunnel, so just use his direction and assume a diagonal track */
 | 
								if (v->u.rail.track == 0x40) /* train in tunnel, so just use his direction and assume a diagonal track */
 | 
				
			||||||
				return DiagdirToDiagTrackdir(DirToDiagDir(v->direction));
 | 
									return DiagdirToDiagTrackdir(DirToDiagDir(v->direction));
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user