water_cmd.c
changeset 3900 2c84ed52709d
parent 3884 793081f80381
child 3933 231ae3c419f4
equal deleted inserted replaced
3899:5ba7f20a14ca 3900:2c84ed52709d
   326 
   326 
   327 		default:
   327 		default:
   328 			NOT_REACHED();
   328 			NOT_REACHED();
   329 			return 0;
   329 			return 0;
   330 	}
   330 	}
       
   331 
       
   332 	return 0; // useless but silences warning
   331 }
   333 }
   332 
   334 
   333 // return true if a tile is a water tile.
   335 // return true if a tile is a water tile.
   334 static bool IsWateredTile(TileIndex tile)
   336 static bool IsWateredTile(TileIndex tile)
   335 {
   337 {
   657 
   659 
   658 static uint32 GetTileTrackStatus_Water(TileIndex tile, TransportType mode)
   660 static uint32 GetTileTrackStatus_Water(TileIndex tile, TransportType mode)
   659 {
   661 {
   660 	static const byte coast_tracks[] = {0, 32, 4, 0, 16, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0};
   662 	static const byte coast_tracks[] = {0, 32, 4, 0, 16, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0};
   661 	static const byte water_tracks_by_axis[] = {1, 2};
   663 	static const byte water_tracks_by_axis[] = {1, 2};
       
   664 	uint32 ts;
   662 	if (mode != TRANSPORT_WATER) return 0;
   665 	if (mode != TRANSPORT_WATER) return 0;
   663 
   666 
   664 	switch (GetWaterTileType(tile)) {
   667 	switch (GetWaterTileType(tile)) {
   665 		case WATER_CLEAR: return 0x3F * 0x101; /* We can go everywhere */
   668 		case WATER_CLEAR: ts = 0x3F; break;/* We can go everywhere */
   666 		case WATER_COAST: return coast_tracks[GetTileSlope(tile, NULL) & 0xF] * 0x101;
   669 		case WATER_COAST: ts = coast_tracks[GetTileSlope(tile, NULL) & 0xF]; break;
   667 		case WATER_LOCK: return water_tracks_by_axis[DiagDirToAxis(GetLockDirection(tile))] * 0x101;
   670 		case WATER_LOCK: ts = water_tracks_by_axis[DiagDirToAxis(GetLockDirection(tile))]; break;
   668 		case WATER_DEPOT: return water_tracks_by_axis[GetShipDepotAxis(tile)] * 0x101;
   671 		case WATER_DEPOT: ts = water_tracks_by_axis[GetShipDepotAxis(tile)]; break;
   669 		default: return 0;
   672 		default: return 0;
   670 	}
   673 	}
       
   674 	if (TileX(tile) == 0) {
       
   675 		// NE border: remove tracks that connects NE tile edge
       
   676 		ts &= ~(TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_RIGHT);
       
   677 	}
       
   678 	if (TileY(tile) == 0) {
       
   679 		// NW border: remove tracks that connects NW tile edge
       
   680 		ts &= ~(TRACK_BIT_Y | TRACK_BIT_LEFT | TRACK_BIT_UPPER);
       
   681 	}
       
   682 	return ts * 0x101;
   671 }
   683 }
   672 
   684 
   673 extern void ShowShipDepotWindow(TileIndex tile);
   685 extern void ShowShipDepotWindow(TileIndex tile);
   674 
   686 
   675 static void ClickTile_Water(TileIndex tile)
   687 static void ClickTile_Water(TileIndex tile)