src/water_cmd.cpp
branchNewGRF_ports
changeset 10994 cd9968b6f96b
parent 10991 d8811e327d12
equal deleted inserted replaced
10991:d8811e327d12 10994:cd9968b6f96b
    38 #include "station_base.h"
    38 #include "station_base.h"
    39 #include "airport.h"
    39 #include "airport.h"
    40 #include "newgrf_cargo.h"
    40 #include "newgrf_cargo.h"
    41 #include "effectvehicle_func.h"
    41 #include "effectvehicle_func.h"
    42 #include "oldpool_func.h"
    42 #include "oldpool_func.h"
       
    43 #include "tunnelbridge_map.h"
    43 
    44 
    44 #include "table/sprites.h"
    45 #include "table/sprites.h"
    45 #include "table/strings.h"
    46 #include "table/strings.h"
    46 
    47 
    47 /**
    48 /**
   480  */
   481  */
   481 static bool IsWateredTile(TileIndex tile, Direction from)
   482 static bool IsWateredTile(TileIndex tile, Direction from)
   482 {
   483 {
   483 	switch (GetTileType(tile)) {
   484 	switch (GetTileType(tile)) {
   484 		case MP_WATER:
   485 		case MP_WATER:
   485 			if (!IsCoast(tile)) return true;
   486 			switch (GetWaterTileType(tile)) {
   486 			switch (GetTileSlope(tile, NULL)) {
   487 				default: NOT_REACHED();
   487 				case SLOPE_W: return (from == DIR_SE) || (from == DIR_E) || (from == DIR_NE);
   488 				case WATER_TILE_DEPOT: case WATER_TILE_CLEAR: return true;
   488 				case SLOPE_S: return (from == DIR_NE) || (from == DIR_N) || (from == DIR_NW);
   489 				case WATER_TILE_LOCK: return DiagDirToAxis(GetLockDirection(tile)) == DiagDirToAxis(DirToDiagDir(from));
   489 				case SLOPE_E: return (from == DIR_NW) || (from == DIR_W) || (from == DIR_SW);
   490 
   490 				case SLOPE_N: return (from == DIR_SW) || (from == DIR_S) || (from == DIR_SE);
   491 				case WATER_TILE_COAST:
   491 				default: return false;
   492 					switch (GetTileSlope(tile, NULL)) {
       
   493 						case SLOPE_W: return (from == DIR_SE) || (from == DIR_E) || (from == DIR_NE);
       
   494 						case SLOPE_S: return (from == DIR_NE) || (from == DIR_N) || (from == DIR_NW);
       
   495 						case SLOPE_E: return (from == DIR_NW) || (from == DIR_W) || (from == DIR_SW);
       
   496 						case SLOPE_N: return (from == DIR_SW) || (from == DIR_S) || (from == DIR_SE);
       
   497 						default: return false;
       
   498 					}
   492 			}
   499 			}
   493 
   500 
   494 		case MP_RAILWAY:
   501 		case MP_RAILWAY:
   495 			if (GetRailGroundType(tile) == RAIL_GROUND_WATER) {
   502 			if (GetRailGroundType(tile) == RAIL_GROUND_WATER) {
   496 				assert(IsPlainRailTile(tile));
   503 				assert(IsPlainRailTile(tile));
   504 			}
   511 			}
   505 			return false;
   512 			return false;
   506 
   513 
   507 		case MP_STATION:  return IsCustomFSMportsSpecIndex(tile) || IsOilRig(tile) || (IsDock(tile) && GetTileSlope(tile, NULL) == SLOPE_FLAT) || IsBuoy(tile);
   514 		case MP_STATION:  return IsCustomFSMportsSpecIndex(tile) || IsOilRig(tile) || (IsDock(tile) && GetTileSlope(tile, NULL) == SLOPE_FLAT) || IsBuoy(tile);
   508 		case MP_INDUSTRY: return (GetIndustrySpec(GetIndustryType(tile))->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0;
   515 		case MP_INDUSTRY: return (GetIndustrySpec(GetIndustryType(tile))->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0;
       
   516 		case MP_TUNNELBRIDGE: return GetTunnelBridgeTransportType(tile) == TRANSPORT_WATER && ReverseDiagDir(GetTunnelBridgeDirection(tile)) == DirToDiagDir(from);
   509 		default:          return false;
   517 		default:          return false;
   510 	}
   518 	}
   511 }
   519 }
   512 
   520 
   513 static void DrawWaterEdges(SpriteID base, TileIndex tile)
   521 static void DrawWaterEdges(SpriteID base, TileIndex tile)
   724 
   732 
   725 static void GetTileDesc_Water(TileIndex tile, TileDesc *td)
   733 static void GetTileDesc_Water(TileIndex tile, TileDesc *td)
   726 {
   734 {
   727 	switch (GetWaterTileType(tile)) {
   735 	switch (GetWaterTileType(tile)) {
   728 		case WATER_TILE_CLEAR:
   736 		case WATER_TILE_CLEAR:
   729 			if (!IsCanal(tile)) {
   737 			switch (GetWaterClass(tile)) {
   730 				td->str = STR_3804_WATER;
   738 				case WATER_CLASS_SEA:   td->str = STR_3804_WATER;     break;
   731 			} else {
   739 				case WATER_CLASS_CANAL: td->str = STR_LANDINFO_CANAL; break;
   732 				td->str = STR_LANDINFO_CANAL;
   740 				case WATER_CLASS_RIVER: td->str = STR_LANDINFO_RIVER; break;
       
   741 				default: assert(0); break;
   733 			}
   742 			}
   734 			break;
   743 			break;
   735 		case WATER_TILE_COAST: td->str = STR_3805_COAST_OR_RIVERBANK; break;
   744 		case WATER_TILE_COAST: td->str = STR_3805_COAST_OR_RIVERBANK; break;
   736 		case WATER_TILE_LOCK : td->str = STR_LANDINFO_LOCK; break;
   745 		case WATER_TILE_LOCK : td->str = STR_LANDINFO_LOCK;           break;
   737 		case WATER_TILE_DEPOT: td->str = STR_3806_SHIP_DEPOT; break;
   746 		case WATER_TILE_DEPOT: td->str = STR_3806_SHIP_DEPOT;         break;
   738 		default: assert(0); break;
   747 		default: assert(0); break;
   739 	}
   748 	}
   740 
   749 
   741 	td->owner[0] = GetTileOwner(tile);
   750 	td->owner[0] = GetTileOwner(tile);
   742 }
   751 }