src/water_cmd.cpp
branchNewGRF_ports
changeset 10184 fcf5fb2548eb
parent 6880 6d6f00b2baee
child 10242 52b4a9006029
equal deleted inserted replaced
10179:eec5a7dcbf61 10184:fcf5fb2548eb
    11 #include "tile_cmd.h"
    11 #include "tile_cmd.h"
    12 #include "landscape.h"
    12 #include "landscape.h"
    13 #include "viewport_func.h"
    13 #include "viewport_func.h"
    14 #include "command_func.h"
    14 #include "command_func.h"
    15 #include "town.h"
    15 #include "town.h"
    16 #include "news.h"
    16 #include "news_func.h"
    17 #include "depot.h"
    17 #include "depot.h"
    18 #include "vehicle_gui.h"
    18 #include "vehicle_gui.h"
    19 #include "train.h"
    19 #include "train.h"
    20 #include "roadveh.h"
    20 #include "roadveh.h"
    21 #include "water.h"
    21 #include "water.h"
    33 #include "variables.h"
    33 #include "variables.h"
    34 #include "player_func.h"
    34 #include "player_func.h"
    35 #include "settings_type.h"
    35 #include "settings_type.h"
    36 #include "clear_map.h"
    36 #include "clear_map.h"
    37 #include "tree_map.h"
    37 #include "tree_map.h"
       
    38 #include "station_base.h"
       
    39 #include "airport.h"
       
    40 #include "newgrf_cargo.h"
    38 
    41 
    39 #include "table/sprites.h"
    42 #include "table/sprites.h"
    40 #include "table/strings.h"
    43 #include "table/strings.h"
    41 
    44 
    42 /**
    45 /**
   592 
   595 
   593 	image = wdts++->image;
   596 	image = wdts++->image;
   594 	if (image < 4) image += water_base;
   597 	if (image < 4) image += water_base;
   595 	if (draw_ground) DrawGroundSprite(image, PAL_NONE);
   598 	if (draw_ground) DrawGroundSprite(image, PAL_NONE);
   596 
   599 
       
   600 	/* End now if buildings are invisible */
       
   601 	if (IsInvisibilitySet(TO_BUILDINGS)) return;
       
   602 
   597 	for (; wdts->delta_x != 0x80; wdts++) {
   603 	for (; wdts->delta_x != 0x80; wdts++) {
   598 		AddSortableSpriteToDraw(wdts->image + base + ((wdts->image < 24) ? locks_base : 0), palette,
   604 		AddSortableSpriteToDraw(wdts->image + base + ((wdts->image < 24) ? locks_base : 0), palette,
   599 			ti->x + wdts->delta_x, ti->y + wdts->delta_y,
   605 			ti->x + wdts->delta_x, ti->y + wdts->delta_y,
   600 			wdts->width, wdts->height,
   606 			wdts->width, wdts->height,
   601 			wdts->unk, ti->z + wdts->delta_z,
   607 			wdts->unk, ti->z + wdts->delta_z,
   857 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
   863 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
   858 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
   864 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
   859 
   865 
   860 		SetDParam(0, pass);
   866 		SetDParam(0, pass);
   861 		AddNewsItem(STR_B006_FLOOD_VEHICLE_DESTROYED,
   867 		AddNewsItem(STR_B006_FLOOD_VEHICLE_DESTROYED,
   862 			NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, 0),
   868 			NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, DNC_NONE,
   863 			v->index,
   869 			v->index,
   864 			0);
   870 			0);
   865 		CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
   871 		CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
   866 		SndPlayVehicleFx(SND_12_EXPLOSION, v);
   872 		SndPlayVehicleFx(SND_12_EXPLOSION, v);
   867 	}
   873 	}
  1042 				if (dest == INVALID_TILE) continue;
  1048 				if (dest == INVALID_TILE) continue;
  1043 				/* do not try to flood water tiles - increases performance a lot */
  1049 				/* do not try to flood water tiles - increases performance a lot */
  1044 				if (IsTileType(dest, MP_WATER)) continue;
  1050 				if (IsTileType(dest, MP_WATER)) continue;
  1045 
  1051 
  1046 				uint z_dest;
  1052 				uint z_dest;
  1047 				Slope slope_dest = (Slope)(GetFoundationSlope(dest, &z_dest) & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP);
  1053 				Slope slope_dest = GetFoundationSlope(dest, &z_dest) & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP;
  1048 				if (z_dest > 0) continue;
  1054 				if (z_dest > 0) continue;
  1049 
  1055 
  1050 				if (!HasBit(_flood_from_dirs[slope_dest], ReverseDir(dir))) continue;
  1056 				if (!HasBit(_flood_from_dirs[slope_dest], ReverseDir(dir))) continue;
  1051 
  1057 
  1052 				DoFloodTile(dest);
  1058 				DoFloodTile(dest);
  1053 			}
  1059 			}
  1054 			break;
  1060 			break;
  1055 
  1061 
  1056 		case FLOOD_DRYUP: {
  1062 		case FLOOD_DRYUP: {
  1057 			Slope slope_here = (Slope)(GetFoundationSlope(tile, NULL) & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP);
  1063 			Slope slope_here = GetFoundationSlope(tile, NULL) & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP;
  1058 			uint check_dirs = _flood_from_dirs[slope_here];
  1064 			uint check_dirs = _flood_from_dirs[slope_here];
  1059 			uint dir;
  1065 			uint dir;
  1060 			FOR_EACH_SET_BIT(dir, check_dirs) {
  1066 			FOR_EACH_SET_BIT(dir, check_dirs) {
  1061 				TileIndex dest = AddTileIndexDiffCWrap(tile, TileIndexDiffCByDir((Direction)dir));
  1067 				TileIndex dest = AddTileIndexDiffCWrap(tile, TileIndexDiffCByDir((Direction)dir));
  1062 				if (dest == INVALID_TILE) continue;
  1068 				if (dest == INVALID_TILE) continue;
  1099 				default:
  1105 				default:
  1100 					uint check_dirs = _flood_from_dirs[slope & ~SLOPE_STEEP];
  1106 					uint check_dirs = _flood_from_dirs[slope & ~SLOPE_STEEP];
  1101 					uint dir;
  1107 					uint dir;
  1102 					FOR_EACH_SET_BIT(dir, check_dirs) {
  1108 					FOR_EACH_SET_BIT(dir, check_dirs) {
  1103 						TileIndex dest = TILE_ADD(tile, TileOffsByDir((Direction)dir));
  1109 						TileIndex dest = TILE_ADD(tile, TileOffsByDir((Direction)dir));
  1104 						Slope slope_dest = (Slope)(GetTileSlope(dest, NULL) & ~SLOPE_STEEP);
  1110 						Slope slope_dest = GetTileSlope(dest, NULL) & ~SLOPE_STEEP;
  1105 						if (slope_dest == SLOPE_FLAT || IsSlopeWithOneCornerRaised(slope_dest)) {
  1111 						if (slope_dest == SLOPE_FLAT || IsSlopeWithOneCornerRaised(slope_dest)) {
  1106 							MakeShore(tile);
  1112 							MakeShore(tile);
  1107 							break;
  1113 							break;
  1108 						}
  1114 						}
  1109 					}
  1115 					}