summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/tilepick.cc
diff options
context:
space:
mode:
authorennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-17 22:07:13 +0000
committerennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-17 22:07:13 +0000
commit6290321f3ad6d27698dba57f0c2c6a3955d93678 (patch)
tree8cd36dd9887cdc5b1bd2b4cbe9a5c77586836021 /crawl-ref/source/tilepick.cc
parent739b54aa925884dbf45c686d63366bb5fb8bd58a (diff)
downloadcrawl-ref-6290321f3ad6d27698dba57f0c2c6a3955d93678.tar.gz
crawl-ref-6290321f3ad6d27698dba57f0c2c6a3955d93678.zip
Fixing &L vaults not having their tile flavor initialized properly. In particular, non-gate doors would appear as half a gate.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8517 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/tilepick.cc')
-rw-r--r--crawl-ref/source/tilepick.cc95
1 files changed, 50 insertions, 45 deletions
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)