|
16 | 16 | #include "grid/terrain.h"
|
17 | 17 | #include "grid/property.h"
|
18 | 18 | #include "grid/image.h"
|
| 19 | +#include "grid/gardens.h" |
19 | 20 | #include "grid/random.h"
|
20 | 21 | #include "grid/building_tiles.h"
|
21 | 22 | #include "figure/formation_herd.h"
|
|
26 | 27 |
|
27 | 28 | building_garden::static_params garden_m;
|
28 | 29 |
|
29 |
| -int building_garden::static_params::place_impl(tile2i start, tile2i end) const { |
| 30 | +int building_garden::static_params::place_impl(tile2i start, tile2i end, bool place) const { |
30 | 31 | game_undo_restore_map(1);
|
31 | 32 |
|
32 | 33 | grid_area area = map_grid_get_area(start, end);
|
33 | 34 |
|
34 | 35 | int items_placed = 0;
|
35 |
| - map_grid_area_foreach(area.tmin, area.tmax, [&] (tile2i tile) { |
36 |
| - int grid_offset = tile.grid_offset(); |
37 |
| - if (map_terrain_is(grid_offset, TERRAIN_NOT_CLEAR)) { |
| 36 | + map_grid_area_foreach(area.tmin, area.tmax, [&] (tile2i rtile) { |
| 37 | + if (map_terrain_is(rtile, TERRAIN_NOT_CLEAR)) { |
38 | 38 | return;
|
39 | 39 | }
|
40 | 40 |
|
41 |
| - if (map_terrain_exists_tile_in_radius_with_type(tile, 1, 1, TERRAIN_FLOODPLAIN)) { |
| 41 | + if (map_terrain_exists_tile_in_radius_with_type(rtile, 1, 1, TERRAIN_FLOODPLAIN)) { |
42 | 42 | return;
|
43 | 43 | }
|
44 | 44 |
|
45 |
| - if (formation_herd_breeding_ground_at(tile, 1)) { |
| 45 | + if (formation_herd_breeding_ground_at(rtile, 1)) { |
46 | 46 | map_property_clear_constructing_and_deleted();
|
47 | 47 | city_warning_show(WARNING_HERD_BREEDING_GROUNDS);
|
48 |
| - } else { |
49 |
| - items_placed++; |
50 |
| - map_terrain_add(grid_offset, TERRAIN_GARDEN); |
51 |
| - } |
| 48 | + return; |
| 49 | + } |
| 50 | + |
| 51 | + items_placed++; |
| 52 | + int addition_flag = place ? 0 : TERRAIN_PLANER_FUTURE; |
| 53 | + map_terrain_add(rtile, TERRAIN_GARDEN| addition_flag); |
52 | 54 | });
|
53 |
| - map_tiles_update_all_gardens(); |
| 55 | + map_tiles_gardens_update_all(); |
54 | 56 |
|
55 | 57 | return items_placed;
|
56 | 58 | }
|
57 | 59 |
|
58 | 60 | int building_garden::static_params::planer_construction_update(build_planner &planer, tile2i start, tile2i end) const {
|
59 |
| - return place_impl(start, end); |
| 61 | + return place_impl(start, end, false); |
60 | 62 | }
|
61 | 63 |
|
62 | 64 | int building_garden::static_params::planer_construction_place(build_planner &planer, tile2i start, tile2i end, int orientation, int variant) const {
|
63 | 65 | planer.should_update_land_routing = true;
|
64 |
| - return place_impl(start, end); |
| 66 | + return place_impl(start, end, true); |
65 | 67 | }
|
66 | 68 |
|
67 | 69 | void building_garden::on_place_checks() { /*nothing*/ }
|
|
0 commit comments