Changeset - r13826:2077419a88c9
[Not reviewed]
master
0 1 0
rubidium - 15 years ago 2009-12-01 23:19:46
rubidium@openttd.org
(svn r18365) -Cleanup: remove duplicate table
1 file changed with 5 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/ship_cmd.cpp
Show inline comments
 
@@ -39,19 +39,12 @@
 

	
 
#include "table/strings.h"
 
#include "table/sprites.h"
 

	
 
static const uint16 _ship_sprites[] = {0x0E5D, 0x0E55, 0x0E65, 0x0E6D};
 

	
 
static const TrackBits _ship_sometracks[4] = {
 
	TRACK_BIT_X | TRACK_BIT_LOWER | TRACK_BIT_LEFT,  // 0x19, // DIAGDIR_NE
 
	TRACK_BIT_Y | TRACK_BIT_UPPER | TRACK_BIT_LEFT,  // 0x16, // DIAGDIR_SE
 
	TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_RIGHT, // 0x25, // DIAGDIR_SW
 
	TRACK_BIT_Y | TRACK_BIT_LOWER | TRACK_BIT_RIGHT, // 0x2A, // DIAGDIR_NW
 
};
 

	
 
static inline TrackBits GetTileShipTrackStatus(TileIndex tile)
 
{
 
	return TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_WATER, 0));
 
}
 

	
 
static SpriteID GetShipIcon(EngineID engine)
 
@@ -309,16 +302,16 @@ static void CheckShipLeaveDepot(Ship *v)
 
	if (!v->IsInDepot()) return;
 

	
 
	TileIndex tile = v->tile;
 
	Axis axis = GetShipDepotAxis(tile);
 

	
 
	/* Check first (north) side */
 
	if (_ship_sometracks[axis] & GetTileShipTrackStatus(TILE_ADD(tile, ToTileIndexDiff(_ship_leave_depot_offs[axis])))) {
 
	if (DiagdirReachesTracks((DiagDirection)axis) & GetTileShipTrackStatus(TILE_ADD(tile, ToTileIndexDiff(_ship_leave_depot_offs[axis])))) {
 
		v->direction = ReverseDir(AxisToDirection(axis));
 
	/* Check second (south) side */
 
	} else if (_ship_sometracks[axis + 2] & GetTileShipTrackStatus(TILE_ADD(tile, -2 * ToTileIndexDiff(_ship_leave_depot_offs[axis])))) {
 
	} else if (DiagdirReachesTracks((DiagDirection)(axis + 2)) & GetTileShipTrackStatus(TILE_ADD(tile, -2 * ToTileIndexDiff(_ship_leave_depot_offs[axis])))) {
 
		v->direction = AxisToDirection(axis);
 
	} else {
 
		return;
 
	}
 

	
 
	v->state = AxisToTrackBits(axis);
 
@@ -504,13 +497,13 @@ static Track ChooseShipTrack(Ship *v, Ti
 
		default:
 
		case VPF_OPF: { // OPF
 
			TileIndex tile2 = TILE_ADD(tile, -TileOffsByDiagDir(enterdir));
 
			Track track;
 

	
 
			/* Let's find out how far it would be if we would reverse first */
 
			TrackBits b = GetTileShipTrackStatus(tile2) & _ship_sometracks[ReverseDiagDir(enterdir)] & v->state;
 
			TrackBits b = GetTileShipTrackStatus(tile2) & DiagdirReachesTracks(ReverseDiagDir(enterdir)) & v->state;
 

	
 
			uint distr = UINT_MAX; // distance if we reversed
 
			if (b != 0) {
 
				distr = FindShipTrack(v, tile2, ReverseDiagDir(enterdir), b, tile, &track);
 
				if (distr != UINT_MAX) distr++; // penalty for reversing
 
			}
 
@@ -543,15 +536,15 @@ static Direction ShipGetNewDirection(Veh
 
{
 
	uint offs = (y - v->y_pos + 1) * 4 + (x - v->x_pos + 1);
 
	assert(offs < 11 && offs != 3 && offs != 7);
 
	return _new_vehicle_direction_table[offs];
 
}
 

	
 
static inline TrackBits GetAvailShipTracks(TileIndex tile, int dir)
 
static inline TrackBits GetAvailShipTracks(TileIndex tile, DiagDirection dir)
 
{
 
	return GetTileShipTrackStatus(tile) & _ship_sometracks[dir];
 
	return GetTileShipTrackStatus(tile) & DiagdirReachesTracks(dir);
 
}
 

	
 
static const byte _ship_subcoord[4][6][3] = {
 
	{
 
		{15, 8, 1},
 
		{ 0, 0, 0},
0 comments (0 inline, 0 general)