diff options
-rw-r--r-- | crawl-ref/source/dungeon.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/tilepick.cc | 95 | ||||
-rw-r--r-- | crawl-ref/source/tiles.h | 1 |
3 files changed, 54 insertions, 45 deletions
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 0cfc1166ac..3f1d5c514a 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -8307,6 +8307,9 @@ void vault_placement::apply_grid() const dungeon_feature_type oldgrid = grd(*ri); _vault_grid( *this, feat, *ri ); +#ifdef USE_TILE + tile_init_flavour(*ri); +#endif if (!Generating_Level) { // Have to link items each square at a time, or diff --git a/crawl-ref/source/tilepick.cc b/crawl-ref/source/tilepick.cc index 29613058ba..75703a9fa4 100644 --- a/crawl-ref/source/tilepick.cc +++ b/crawl-ref/source/tilepick.cc @@ -3981,56 +3981,61 @@ void tile_clear_flavour() // set them to a random instance of the default floor and wall tileset. void tile_init_flavour() { - for (int y = 0; y < GYM; y++) - for (int x = 0; x < GXM; x++) - { - int max_wall_flavor = tile_dngn_count(env.tile_default.wall) - 1; - int max_floor_flavor = tile_dngn_count(env.tile_default.floor) - 1; - int wall_rnd = random_range(0, max_wall_flavor); - int floor_rnd = random_range(0, max_floor_flavor); + for (rectangle_iterator ri(1); ri; ++ri) + tile_init_flavour(*ri); +} - if (!env.tile_flv[x][y].floor) - env.tile_flv[x][y].floor = env.tile_default.floor + floor_rnd; - if (!env.tile_flv[x][y].wall) - env.tile_flv[x][y].wall = env.tile_default.wall + wall_rnd; +void tile_init_flavour(const coord_def &gc) +{ + if (!in_bounds(gc)) + return; - if (grd[x][y] == DNGN_CLOSED_DOOR || grd[x][y] == DNGN_OPEN_DOOR) - { - // Check for horizontal gates. + int wall_rnd = random2(tile_dngn_count(env.tile_default.wall)); + int floor_rnd = random2(tile_dngn_count(env.tile_default.floor)); - bool door_left = (x > 0 && grd[x-1][y] == grd[x][y]); - bool door_right = (x < GXM - 1 && grd[x+1][y] == grd[x][y]); + if (!env.tile_flv(gc).floor) + env.tile_flv(gc).floor = env.tile_default.floor + floor_rnd; + if (!env.tile_flv(gc).wall) + env.tile_flv(gc).wall = env.tile_default.wall + wall_rnd; - if (door_left || door_right) - { - int target; - if (door_left && door_right) - target = TILE_DNGN_GATE_CLOSED_MIDDLE; - else if (door_left) - target = TILE_DNGN_GATE_CLOSED_RIGHT; - else - target = TILE_DNGN_GATE_CLOSED_LEFT; - - // NOTE: This requires that closed gates and open gates - // are positioned in the tile set relative to their - // door counterpart. - env.tile_flv[x][y].special = - target - TILE_DNGN_CLOSED_DOOR; - } - else - { - env.tile_flv[x][y].special = 0; - } - } - else if (grd[x][y] == DNGN_SECRET_DOOR) - { - env.tile_flv[x][y].special = 0; - } - else if (!env.tile_flv[x][y].special) - { - env.tile_flv[x][y].special = random2(256); - } + if (grd(gc) == DNGN_CLOSED_DOOR || grd(gc) == DNGN_OPEN_DOOR) + { + // Check for horizontal gates. + + const coord_def left(gc.x - 1, gc.y); + const coord_def right(gc.x + 1, gc.y); + + bool door_left = (grd(left) == grd(gc)); + bool door_right = (grd(right) == grd(gc)); + + if (door_left || door_right) + { + int target; + if (door_left && door_right) + target = TILE_DNGN_GATE_CLOSED_MIDDLE; + else if (door_left) + target = TILE_DNGN_GATE_CLOSED_RIGHT; + else + target = TILE_DNGN_GATE_CLOSED_LEFT; + + // NOTE: This requires that closed gates and open gates + // are positioned in the tile set relative to their + // door counterpart. + env.tile_flv(gc).special = target - TILE_DNGN_CLOSED_DOOR; } + else + { + env.tile_flv(gc).special = 0; + } + } + else if (grd(gc) == DNGN_SECRET_DOOR) + { + env.tile_flv(gc).special = 0; + } + else if (!env.tile_flv(gc).special) + { + env.tile_flv(gc).special = random2(256); + } } static bool _adjacent_target(dungeon_feature_type target, int x, int y) diff --git a/crawl-ref/source/tiles.h b/crawl-ref/source/tiles.h index 54e513ae79..38f0f8d2de 100644 --- a/crawl-ref/source/tiles.h +++ b/crawl-ref/source/tiles.h @@ -100,6 +100,7 @@ void tile_default_flv(level_area_type lev, branch_type br, tile_flavour &flv); void tile_clear_flavour(); // Initialize per-cell types of walls and floors using defaults. void tile_init_flavour(); +void tile_init_flavour(const coord_def &gc); void tile_floor_halo(dungeon_feature_type target, int tile); |