3 #include "stdafx.h" |
3 #include "stdafx.h" |
4 #include "openttd.h" |
4 #include "openttd.h" |
5 #include "bridge_map.h" |
5 #include "bridge_map.h" |
6 #include "heightmap.h" |
6 #include "heightmap.h" |
7 #include "clear_map.h" |
7 #include "clear_map.h" |
8 #include "date.h" |
|
9 #include "functions.h" |
|
10 #include "map.h" |
|
11 #include "player.h" |
|
12 #include "spritecache.h" |
8 #include "spritecache.h" |
13 #include "table/sprites.h" |
|
14 #include "tile.h" |
|
15 #include <stdarg.h> |
9 #include <stdarg.h> |
16 #include "viewport.h" |
10 #include "viewport_func.h" |
17 #include "command.h" |
11 #include "command_func.h" |
18 #include "landscape.h" |
12 #include "landscape.h" |
19 #include "vehicle.h" |
|
20 #include "variables.h" |
13 #include "variables.h" |
21 #include "void_map.h" |
14 #include "void_map.h" |
22 #include "water_map.h" |
15 #include "water_map.h" |
23 #include "tgp.h" |
16 #include "tgp.h" |
24 #include "genworld.h" |
17 #include "genworld.h" |
|
18 #include "tile_cmd.h" |
|
19 #include "core/alloc_func.hpp" |
|
20 #include "fios.h" |
|
21 #include "window_func.h" |
|
22 #include "functions.h" |
|
23 #include "date_func.h" |
|
24 #include "vehicle_func.h" |
|
25 #include "settings_type.h" |
|
26 #include "water.h" |
|
27 |
|
28 #include "table/sprites.h" |
25 |
29 |
26 extern const TileTypeProcs |
30 extern const TileTypeProcs |
27 _tile_type_clear_procs, |
31 _tile_type_clear_procs, |
28 _tile_type_rail_procs, |
32 _tile_type_rail_procs, |
29 _tile_type_road_procs, |
33 _tile_type_road_procs, |
287 if ((tileh & corners[edge][1]) != 0) *z2 += TILE_HEIGHT; // z2 is raised |
291 if ((tileh & corners[edge][1]) != 0) *z2 += TILE_HEIGHT; // z2 is raised |
288 if ((tileh & ~SLOPE_HALFTILE_MASK) == corners[edge][2]) *z1 += TILE_HEIGHT; // z1 is highest corner of a steep slope |
292 if ((tileh & ~SLOPE_HALFTILE_MASK) == corners[edge][2]) *z1 += TILE_HEIGHT; // z1 is highest corner of a steep slope |
289 if ((tileh & ~SLOPE_HALFTILE_MASK) == corners[edge][3]) *z2 += TILE_HEIGHT; // z2 is highest corner of a steep slope |
293 if ((tileh & ~SLOPE_HALFTILE_MASK) == corners[edge][3]) *z2 += TILE_HEIGHT; // z2 is highest corner of a steep slope |
290 } |
294 } |
291 |
295 |
292 static Slope GetFoundationSlope(TileIndex tile, uint* z) |
296 Slope GetFoundationSlope(TileIndex tile, uint* z) |
293 { |
297 { |
294 Slope tileh = GetTileSlope(tile, z); |
298 Slope tileh = GetTileSlope(tile, z); |
295 Foundation f = _tile_type_procs[GetTileType(tile)]->get_foundation_proc(tile, tileh); |
299 Foundation f = _tile_type_procs[GetTileType(tile)]->get_foundation_proc(tile, tileh); |
296 *z += ApplyFoundationToSlope(f, &tileh); |
300 uint z_inc = ApplyFoundationToSlope(f, &tileh); |
|
301 if (z != NULL) *z += z_inc; |
297 return tileh; |
302 return tileh; |
298 } |
303 } |
299 |
304 |
300 |
305 |
301 static bool HasFoundationNW(TileIndex tile, Slope slope_here, uint z_here) |
306 static bool HasFoundationNW(TileIndex tile, Slope slope_here, uint z_here) |
520 * @param p1 unused |
525 * @param p1 unused |
521 * @param p2 unused |
526 * @param p2 unused |
522 */ |
527 */ |
523 CommandCost CmdLandscapeClear(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
528 CommandCost CmdLandscapeClear(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
524 { |
529 { |
525 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
526 |
|
527 return _tile_type_procs[GetTileType(tile)]->clear_tile_proc(tile, flags); |
530 return _tile_type_procs[GetTileType(tile)]->clear_tile_proc(tile, flags); |
528 } |
531 } |
529 |
532 |
530 /** Clear a big piece of landscape |
533 /** Clear a big piece of landscape |
531 * @param tile end tile of area dragging |
534 * @param tile end tile of area dragging |
533 * @param flags of operation to conduct |
536 * @param flags of operation to conduct |
534 * @param p2 unused |
537 * @param p2 unused |
535 */ |
538 */ |
536 CommandCost CmdClearArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
539 CommandCost CmdClearArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
537 { |
540 { |
538 CommandCost cost, ret, money; |
541 CommandCost ret, money; |
|
542 CommandCost cost(EXPENSES_CONSTRUCTION); |
539 int ex; |
543 int ex; |
540 int ey; |
544 int ey; |
541 int sx, sy; |
545 int sx, sy; |
542 int x, y; |
546 int x, y; |
543 bool success = false; |
547 bool success = false; |
544 |
548 |
545 if (p1 >= MapSize()) return CMD_ERROR; |
549 if (p1 >= MapSize()) return CMD_ERROR; |
546 |
|
547 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
548 |
550 |
549 /* make sure sx,sy are smaller than ex,ey */ |
551 /* make sure sx,sy are smaller than ex,ey */ |
550 ex = TileX(tile); |
552 ex = TileX(tile); |
551 ey = TileY(tile); |
553 ey = TileY(tile); |
552 sx = TileX(p1); |
554 sx = TileX(p1); |
633 ClearBridgeMiddle(sizex * y + x); |
635 ClearBridgeMiddle(sizex * y + x); |
634 } |
636 } |
635 MakeVoid(sizex * y + x); |
637 MakeVoid(sizex * y + x); |
636 } |
638 } |
637 for (x = 0; x < sizex; x++) MakeVoid(sizex * y + x); |
639 for (x = 0; x < sizex; x++) MakeVoid(sizex * y + x); |
638 } |
|
639 |
|
640 void ConvertGroundTilesIntoWaterTiles() |
|
641 { |
|
642 TileIndex tile; |
|
643 uint z; |
|
644 Slope slope; |
|
645 |
|
646 for (tile = 0; tile < MapSize(); ++tile) { |
|
647 slope = GetTileSlope(tile, &z); |
|
648 if (IsTileType(tile, MP_CLEAR) && z == 0) { |
|
649 /* Make both water for tiles at level 0 |
|
650 * and make shore, as that looks much better |
|
651 * during the generation. */ |
|
652 switch (slope) { |
|
653 case SLOPE_FLAT: |
|
654 MakeWater(tile); |
|
655 break; |
|
656 |
|
657 case SLOPE_N: |
|
658 case SLOPE_E: |
|
659 case SLOPE_S: |
|
660 case SLOPE_W: |
|
661 MakeShore(tile); |
|
662 break; |
|
663 |
|
664 case SLOPE_NW: |
|
665 if (GetTileSlope(TileAddByDiagDir(tile, DIAGDIR_SE), NULL) != SLOPE_SE) MakeShore(tile); |
|
666 break; |
|
667 |
|
668 case SLOPE_SW: |
|
669 if (GetTileSlope(TileAddByDiagDir(tile, DIAGDIR_NE), NULL) != SLOPE_NE) MakeShore(tile); |
|
670 break; |
|
671 |
|
672 case SLOPE_SE: |
|
673 if (GetTileSlope(TileAddByDiagDir(tile, DIAGDIR_NW), NULL) != SLOPE_NW) MakeShore(tile); |
|
674 break; |
|
675 |
|
676 case SLOPE_NE: |
|
677 if (GetTileSlope(TileAddByDiagDir(tile, DIAGDIR_SW), NULL) != SLOPE_SW) MakeShore(tile); |
|
678 break; |
|
679 |
|
680 default: |
|
681 break; |
|
682 } |
|
683 } |
|
684 } |
|
685 } |
640 } |
686 |
641 |
687 static const byte _genterrain_tbl_1[5] = { 10, 22, 33, 37, 4 }; |
642 static const byte _genterrain_tbl_1[5] = { 10, 22, 33, 37, 4 }; |
688 static const byte _genterrain_tbl_2[5] = { 0, 0, 0, 0, 33 }; |
643 static const byte _genterrain_tbl_2[5] = { 0, 0, 0, 0, 33 }; |
689 |
644 |