Apply the new ground_level method.
[crawl.git] / crawl-ref / source / tiledgnbuf.cc
blobb0e812542f48d9c84bd883d1475aa8ea3cc57b64
1 /*
2 * File: tiledgnbuf.cc
3 */
5 #include "AppHdr.h"
7 #ifdef USE_TILE
9 #include "tiledgnbuf.h"
11 #include "cloud.h"
12 #include "coord.h"
13 #include "coordit.h"
14 #include "env.h"
15 #include "player.h"
16 #include "terrain.h"
17 #include "tiledef-dngn.h"
18 #include "tiledef-icons.h"
19 #include "tiledef-player.h"
20 #include "tiledoll.h"
21 #include "tilemcache.h"
22 #include "tilepick.h"
23 #include "tilepick-p.h"
25 void packed_cell::clear()
27 num_dngn_overlay = 0;
28 fg = 0;
29 bg = 0;
31 is_bloody = false;
32 is_silenced = false;
33 is_haloed = false;
34 is_moldy = false;
35 is_sanctuary = false;
36 swamp_tree_water = false;
39 DungeonCellBuffer::DungeonCellBuffer(ImageManager *im) :
40 m_buf_floor(&im->m_textures[TEX_FLOOR]),
41 m_buf_wall(&im->m_textures[TEX_WALL]),
42 m_buf_feat(&im->m_textures[TEX_FEAT]),
43 m_buf_feat_trans(&im->m_textures[TEX_FEAT], 17),
44 m_buf_doll(&im->m_textures[TEX_PLAYER], 17),
45 m_buf_main_trans(&im->m_textures[TEX_DEFAULT], 17),
46 m_buf_main(&im->m_textures[TEX_DEFAULT]),
47 m_buf_spells(&im->m_textures[TEX_GUI]),
48 m_buf_skills(&im->m_textures[TEX_GUI]),
49 m_buf_commands(&im->m_textures[TEX_GUI]),
50 m_buf_icons(&im->m_textures[TEX_ICONS])
54 static bool _in_water(const packed_cell &cell)
56 return ((cell.bg & TILE_FLAG_WATER) && !(cell.fg & TILE_FLAG_FLYING));
59 static void _lichform_add_weapon(SubmergedTileBuffer &buf, int x, int y,
60 bool in_water)
62 const int item = you.equip[EQ_WEAPON];
63 if (item == -1)
64 return;
66 const int wep = tilep_equ_weapon(you.inv[item]);
67 if (!wep)
68 return;
70 buf.add(wep, x, y, 0, in_water, false, -1, 0);
73 void DungeonCellBuffer::add(const packed_cell &cell, int x, int y)
75 pack_background(x, y, cell);
77 const tileidx_t fg_idx = cell.fg & TILE_FLAG_MASK;
78 const bool in_water = _in_water(cell);
80 if (fg_idx >= TILEP_MCACHE_START)
82 mcache_entry *entry = mcache.get(fg_idx);
83 if (entry)
84 pack_mcache(entry, x, y, in_water);
85 else
86 m_buf_doll.add(TILEP_MONS_UNKNOWN, x, y, 0, in_water, false);
88 else if (fg_idx == TILEP_PLAYER)
90 pack_player(x, y, in_water);
92 else if (fg_idx >= TILE_MAIN_MAX)
94 m_buf_doll.add(fg_idx, x, y, TILEP_PART_MAX, in_water, false);
95 if (fg_idx >= TILEP_TRAN_LICH_EQUIP_FIRST
96 && fg_idx <= TILEP_TRAN_LICH_EQUIP_LAST)
98 _lichform_add_weapon(m_buf_doll, x, y, in_water);
102 pack_foreground(x, y, cell);
106 void DungeonCellBuffer::add_dngn_tile(int tileidx, int x, int y,
107 bool in_water)
109 assert(tileidx < TILE_FEAT_MAX);
111 if (tileidx < TILE_FLOOR_MAX)
112 m_buf_floor.add(tileidx, x, y);
113 else if (tileidx < TILE_WALL_MAX)
114 m_buf_wall.add(tileidx, x, y);
115 else if (in_water)
116 m_buf_feat_trans.add(tileidx, x, y, 0, true, false);
117 else
118 m_buf_feat.add(tileidx, x, y);
121 void DungeonCellBuffer::add_main_tile(int tileidx, int x, int y)
123 tileidx_t base = tileidx_known_base_item(tileidx);
124 if (base)
125 m_buf_main.add(base, x, y);
127 m_buf_main.add(tileidx, x, y);
130 void DungeonCellBuffer::add_main_tile(int tileidx, int x, int y, int ox, int oy)
132 tileidx_t base = tileidx_known_base_item(tileidx);
133 if (base)
134 m_buf_main.add(base, x, y, ox, oy, false);
136 m_buf_main.add(tileidx, x, y, ox, oy, false);
139 void DungeonCellBuffer::add_spell_tile(int tileidx, int x, int y)
141 m_buf_spells.add(tileidx, x, y);
144 void DungeonCellBuffer::add_skill_tile(int tileidx, int x, int y)
146 m_buf_skills.add(tileidx, x, y);
149 void DungeonCellBuffer::add_command_tile(int tileidx, int x, int y)
151 m_buf_commands.add(tileidx, x, y);
154 void DungeonCellBuffer::add_icons_tile(int tileidx, int x, int y)
156 m_buf_icons.add(tileidx, x, y);
159 void DungeonCellBuffer::add_icons_tile(int tileidx, int x, int y,
160 int ox, int oy)
162 m_buf_icons.add(tileidx, x, y, ox, oy, false);
165 void DungeonCellBuffer::clear()
167 m_buf_floor.clear();
168 m_buf_wall.clear();
169 m_buf_feat.clear();
170 m_buf_feat_trans.clear();
171 m_buf_doll.clear();
172 m_buf_main_trans.clear();
173 m_buf_main.clear();
174 m_buf_spells.clear();
175 m_buf_skills.clear();
176 m_buf_commands.clear();
177 m_buf_icons.clear();
180 void DungeonCellBuffer::draw()
182 m_buf_floor.draw();
183 m_buf_wall.draw();
184 m_buf_feat.draw();
185 m_buf_feat_trans.draw();
186 m_buf_main_trans.draw();
187 m_buf_main.draw();
188 m_buf_doll.draw();
189 m_buf_skills.draw();
190 m_buf_spells.draw();
191 m_buf_commands.draw();
192 m_buf_icons.draw();
195 enum wave_type
197 WV_NONE = 0,
198 WV_SHALLOW,
199 WV_DEEP,
202 static wave_type _get_wave_type(bool shallow)
204 return (shallow ? WV_SHALLOW : WV_DEEP);
207 static void _add_overlay(int tileidx, packed_cell *cell)
209 cell->dngn_overlay[cell->num_dngn_overlay++] = tileidx;
212 static void _pack_shoal_waves(const coord_def &gc, packed_cell *cell)
214 // Add wave tiles on floor adjacent to shallow water.
215 const dungeon_feature_type feat = env.map_knowledge(gc).feat();
216 const bool feat_has_ink = (cloud_type_at(coord_def(gc)) == CLOUD_INK);
218 if (feat == DNGN_DEEP_WATER && feat_has_ink)
220 _add_overlay(TILE_WAVE_INK_FULL, cell);
221 return;
224 if (feat != DNGN_FLOOR && feat != DNGN_UNDISCOVERED_TRAP
225 && feat != DNGN_SHALLOW_WATER && feat != DNGN_DEEP_WATER)
227 return;
230 const bool ink_only = (feat == DNGN_DEEP_WATER);
232 wave_type north = WV_NONE, south = WV_NONE,
233 east = WV_NONE, west = WV_NONE,
234 ne = WV_NONE, nw = WV_NONE,
235 se = WV_NONE, sw = WV_NONE;
237 bool inkn = false, inks = false, inke = false, inkw = false,
238 inkne = false, inknw = false, inkse = false, inksw = false;
240 for (radius_iterator ri(gc, 1, true, false, true); ri; ++ri)
242 if (!env.map_knowledge(*ri).seen() && !env.map_knowledge(*ri).mapped())
243 continue;
245 const bool ink = (cloud_type_at(coord_def(*ri)) == CLOUD_INK);
247 bool shallow = false;
248 if (env.map_knowledge(*ri).feat() == DNGN_SHALLOW_WATER)
250 // Adjacent shallow water is only interesting for
251 // floor cells.
252 if (!ink && feat == DNGN_SHALLOW_WATER)
253 continue;
255 shallow = true;
257 else if (env.map_knowledge(*ri).feat() != DNGN_DEEP_WATER)
258 continue;
260 if (!ink_only)
262 if (ri->x == gc.x) // orthogonals
264 if (ri->y < gc.y)
265 north = _get_wave_type(shallow);
266 else
267 south = _get_wave_type(shallow);
269 else if (ri->y == gc.y)
271 if (ri->x < gc.x)
272 west = _get_wave_type(shallow);
273 else
274 east = _get_wave_type(shallow);
276 else // diagonals
278 if (ri->x < gc.x)
280 if (ri->y < gc.y)
281 nw = _get_wave_type(shallow);
282 else
283 sw = _get_wave_type(shallow);
285 else
287 if (ri->y < gc.y)
288 ne = _get_wave_type(shallow);
289 else
290 se = _get_wave_type(shallow);
294 if (!feat_has_ink && ink)
296 if (ri->x == gc.x) // orthogonals
298 if (ri->y < gc.y)
299 inkn = true;
300 else
301 inks = true;
303 else if (ri->y == gc.y)
305 if (ri->x < gc.x)
306 inkw = true;
307 else
308 inke = true;
310 else // diagonals
312 if (ri->x < gc.x)
314 if (ri->y < gc.y)
315 inknw = true;
316 else
317 inksw = true;
319 else
321 if (ri->y < gc.y)
322 inkne = true;
323 else
324 inkse = true;
330 if (!ink_only)
332 // First check for shallow water.
333 if (north == WV_SHALLOW)
334 _add_overlay(TILE_WAVE_N, cell);
335 if (south == WV_SHALLOW)
336 _add_overlay(TILE_WAVE_S, cell);
337 if (east == WV_SHALLOW)
338 _add_overlay(TILE_WAVE_E, cell);
339 if (west == WV_SHALLOW)
340 _add_overlay(TILE_WAVE_W, cell);
342 // Then check for deep water, overwriting shallow
343 // corner waves, if necessary.
344 if (north == WV_DEEP)
345 _add_overlay(TILE_WAVE_DEEP_N, cell);
346 if (south == WV_DEEP)
347 _add_overlay(TILE_WAVE_DEEP_S, cell);
348 if (east == WV_DEEP)
349 _add_overlay(TILE_WAVE_DEEP_E, cell);
350 if (west == WV_DEEP)
351 _add_overlay(TILE_WAVE_DEEP_W, cell);
353 if (ne == WV_SHALLOW && !north && !east)
354 _add_overlay(TILE_WAVE_CORNER_NE, cell);
355 else if (ne == WV_DEEP && north != WV_DEEP && east != WV_DEEP)
356 _add_overlay(TILE_WAVE_DEEP_CORNER_NE, cell);
357 if (nw == WV_SHALLOW && !north && !west)
358 _add_overlay(TILE_WAVE_CORNER_NW, cell);
359 else if (nw == WV_DEEP && north != WV_DEEP && west != WV_DEEP)
360 _add_overlay(TILE_WAVE_DEEP_CORNER_NW, cell);
361 if (se == WV_SHALLOW && !south && !east)
362 _add_overlay(TILE_WAVE_CORNER_SE, cell);
363 else if (se == WV_DEEP && south != WV_DEEP && east != WV_DEEP)
364 _add_overlay(TILE_WAVE_DEEP_CORNER_SE, cell);
365 if (sw == WV_SHALLOW && !south && !west)
366 _add_overlay(TILE_WAVE_CORNER_SW, cell);
367 else if (sw == WV_DEEP && south != WV_DEEP && west != WV_DEEP)
368 _add_overlay(TILE_WAVE_DEEP_CORNER_SW, cell);
371 // Overlay with ink sheen, if necessary.
372 if (feat_has_ink)
373 _add_overlay(TILE_WAVE_INK_FULL, cell);
374 else
376 if (inkn)
377 _add_overlay(TILE_WAVE_INK_N, cell);
378 if (inks)
379 _add_overlay(TILE_WAVE_INK_S, cell);
380 if (inke)
381 _add_overlay(TILE_WAVE_INK_E, cell);
382 if (inkw)
383 _add_overlay(TILE_WAVE_INK_W, cell);
384 if (inkne || inkn || inke)
385 _add_overlay(TILE_WAVE_INK_CORNER_NE, cell);
386 if (inknw || inkn || inkw)
387 _add_overlay(TILE_WAVE_INK_CORNER_NW, cell);
388 if (inkse || inks || inke)
389 _add_overlay(TILE_WAVE_INK_CORNER_SE, cell);
390 if (inksw || inks || inkw)
391 _add_overlay(TILE_WAVE_INK_CORNER_SW, cell);
395 static dungeon_feature_type _safe_feat(coord_def gc)
397 if (!map_bounds(gc))
398 return (DNGN_UNSEEN);
400 return (env.map_knowledge(gc).feat());
403 static bool _is_seen_land(coord_def gc)
405 const dungeon_feature_type feat = _safe_feat(gc);
407 return (feat != DNGN_UNSEEN && !feat_is_water(feat) && feat != DNGN_LAVA);
410 static bool _is_seen_shallow(coord_def gc)
412 const dungeon_feature_type feat = _safe_feat(gc);
414 return (feat == DNGN_SHALLOW_WATER || feat == DNGN_SWAMP_TREE);
417 static void _pack_default_waves(const coord_def &gc, packed_cell *cell)
419 // Any tile on water with an adjacent solid tile will get an extra
420 // bit of shoreline.
421 dungeon_feature_type feat = env.map_knowledge(gc).feat();
423 // Treat trees in Swamp as though they were shallow water.
424 if (cell->swamp_tree_water && feat == DNGN_TREE)
425 feat = DNGN_SHALLOW_WATER;
427 if (!feat_is_water(feat) && feat != DNGN_LAVA || env.grid_colours(gc))
428 return;
430 if (feat == DNGN_DEEP_WATER)
432 if (_is_seen_shallow(coord_def(gc.x, gc.y - 1)))
433 _add_overlay(TILE_DNGN_WAVE_N, cell);
434 if (_is_seen_shallow(coord_def(gc.x + 1, gc.y - 1)))
435 _add_overlay(TILE_DNGN_WAVE_NE, cell);
436 if (_is_seen_shallow(coord_def(gc.x + 1, gc.y)))
437 _add_overlay(TILE_DNGN_WAVE_E, cell);
438 if (_is_seen_shallow(coord_def(gc.x + 1, gc.y + 1)))
439 _add_overlay(TILE_DNGN_WAVE_SE, cell);
440 if (_is_seen_shallow(coord_def(gc.x, gc.y + 1)))
441 _add_overlay(TILE_DNGN_WAVE_S, cell);
442 if (_is_seen_shallow(coord_def(gc.x - 1, gc.y + 1)))
443 _add_overlay(TILE_DNGN_WAVE_SW, cell);
444 if (_is_seen_shallow(coord_def(gc.x - 1, gc.y)))
445 _add_overlay(TILE_DNGN_WAVE_W, cell);
446 if (_is_seen_shallow(coord_def(gc.x - 1, gc.y - 1)))
447 _add_overlay(TILE_DNGN_WAVE_NW, cell);
451 bool north = _is_seen_land(coord_def(gc.x, gc.y - 1));
452 bool west = _is_seen_land(coord_def(gc.x - 1, gc.y));
453 bool east = _is_seen_land(coord_def(gc.x + 1, gc.y));
455 if (north || west || east)
457 if (north)
458 _add_overlay(TILE_SHORE_N, cell);
459 if (west)
460 _add_overlay(TILE_SHORE_W, cell);
461 if (east)
462 _add_overlay(TILE_SHORE_E, cell);
463 if (north && west)
464 _add_overlay(TILE_SHORE_NW, cell);
465 if (north && east)
466 _add_overlay(TILE_SHORE_NE, cell);
470 static bool _is_seen_wall(coord_def gc)
472 dungeon_feature_type feat = _safe_feat(gc);
473 return (feat != DNGN_UNSEEN && feat <= DNGN_MAXWALL);
476 static void _pack_wall_shadows(const coord_def &gc, packed_cell *cell)
478 if (_is_seen_wall(gc))
479 return;
481 if (_is_seen_wall(coord_def(gc.x - 1, gc.y)))
482 _add_overlay(TILE_DNGN_WALL_SHADOW_W, cell);
483 if (_is_seen_wall(coord_def(gc.x - 1, gc.y - 1)))
484 _add_overlay(TILE_DNGN_WALL_SHADOW_NW, cell);
485 if (_is_seen_wall(coord_def(gc.x, gc.y - 1)))
486 _add_overlay(TILE_DNGN_WALL_SHADOW_N, cell);
487 if (_is_seen_wall(coord_def(gc.x + 1, gc.y - 1)))
488 _add_overlay(TILE_DNGN_WALL_SHADOW_NE, cell);
489 if (_is_seen_wall(coord_def(gc.x + 1, gc.y)))
490 _add_overlay(TILE_DNGN_WALL_SHADOW_E, cell);
493 void pack_cell_overlays(const coord_def &gc, packed_cell *cell)
495 if (player_in_branch(BRANCH_SHOALS))
497 _pack_shoal_waves(gc, cell);
499 else
501 _pack_default_waves(gc, cell);
502 _pack_wall_shadows(gc, cell);
506 void DungeonCellBuffer::add_blood_overlay(int x, int y, const packed_cell &cell)
508 if (!cell.is_bloody && !cell.is_moldy)
509 return;
511 if (cell.is_bloody)
513 int offset = cell.flv.special % tile_dngn_count(TILE_BLOOD);
514 m_buf_feat.add(TILE_BLOOD + offset, x, y);
516 else if (cell.is_moldy)
518 int offset = cell.flv.special % tile_dngn_count(TILE_MOLD);
519 m_buf_feat.add(TILE_MOLD + offset, x, y);
523 void DungeonCellBuffer::pack_background(int x, int y, const packed_cell &cell)
525 const tileidx_t bg = cell.bg;
526 const tileidx_t bg_idx = cell.bg & TILE_FLAG_MASK;
528 if (cell.swamp_tree_water && bg_idx > TILE_DNGN_UNSEEN)
529 m_buf_feat.add(TILE_DNGN_SHALLOW_WATER, x, y);
531 if (bg_idx >= TILE_DNGN_WAX_WALL)
532 add_dngn_tile(cell.flv.floor, x, y);
534 // Draw blood beneath feature tiles.
535 if (bg_idx > TILE_WALL_MAX)
536 add_blood_overlay(x, y, cell);
538 add_dngn_tile(bg_idx, x, y, cell.swamp_tree_water);
540 if (bg_idx > TILE_DNGN_UNSEEN)
542 if (bg & TILE_FLAG_WAS_SECRET)
543 m_buf_feat.add(TILE_DNGN_DETECTED_SECRET_DOOR, x, y);
545 // Draw blood on top of wall tiles.
546 if (bg_idx <= TILE_WALL_MAX)
547 add_blood_overlay(x, y, cell);
549 for (int i = 0; i < cell.num_dngn_overlay; ++i)
550 add_dngn_tile(cell.dngn_overlay[i], x, y);
552 if (!(bg & TILE_FLAG_UNSEEN))
554 if (bg & TILE_FLAG_KRAKEN_NW)
555 m_buf_feat.add(TILE_KRAKEN_OVERLAY_NW, x, y);
556 if (bg & TILE_FLAG_KRAKEN_NE)
557 m_buf_feat.add(TILE_KRAKEN_OVERLAY_NE, x, y);
558 if (bg & TILE_FLAG_KRAKEN_SE)
559 m_buf_feat.add(TILE_KRAKEN_OVERLAY_SE, x, y);
560 if (bg & TILE_FLAG_KRAKEN_SW)
561 m_buf_feat.add(TILE_KRAKEN_OVERLAY_SW, x, y);
564 if (cell.is_haloed)
565 m_buf_feat.add(TILE_HALO, x, y);
567 if (!(bg & TILE_FLAG_UNSEEN))
569 if (cell.is_sanctuary)
570 m_buf_feat.add(TILE_SANCTUARY, x, y);
571 if (cell.is_silenced)
572 m_buf_feat.add(TILE_SILENCED, x, y);
574 // Apply the travel exclusion under the foreground if the cell is
575 // visible. It will be applied later if the cell is unseen.
576 if (bg & TILE_FLAG_EXCL_CTR)
577 m_buf_feat.add(TILE_TRAVEL_EXCLUSION_CENTRE_BG, x, y);
578 else if (bg & TILE_FLAG_TRAV_EXCL)
579 m_buf_feat.add(TILE_TRAVEL_EXCLUSION_BG, x, y);
582 if (bg & TILE_FLAG_RAY)
583 m_buf_feat.add(TILE_RAY, x, y);
584 else if (bg & TILE_FLAG_RAY_OOR)
585 m_buf_feat.add(TILE_RAY_OUT_OF_RANGE, x, y);
589 void DungeonCellBuffer::pack_foreground(int x, int y, const packed_cell &cell)
591 const tileidx_t fg = cell.fg;
592 const tileidx_t bg = cell.bg;
593 const tileidx_t fg_idx = cell.fg & TILE_FLAG_MASK;
594 const bool in_water = _in_water(cell);
596 if (fg_idx && fg_idx <= TILE_MAIN_MAX)
598 const tileidx_t base_idx = tileidx_known_base_item(fg_idx);
600 if (in_water)
602 if (base_idx)
603 m_buf_main_trans.add(base_idx, x, y, 0, true, false);
604 m_buf_main_trans.add(fg_idx, x, y, 0, true, false);
606 else
608 if (base_idx)
609 m_buf_main.add(base_idx, x, y);
611 m_buf_main.add(fg_idx, x, y);
615 if (fg & TILE_FLAG_NET)
616 m_buf_icons.add(TILEI_TRAP_NET, x, y);
618 if (fg & TILE_FLAG_S_UNDER)
619 m_buf_icons.add(TILEI_SOMETHING_UNDER, x, y);
621 int status_shift = 0;
622 if (fg & TILE_FLAG_MIMIC)
623 m_buf_icons.add(TILEI_MIMIC, x, y);
625 if (fg & TILE_FLAG_BERSERK)
627 m_buf_icons.add(TILEI_BERSERK, x, y);
628 status_shift += 10;
631 // Pet mark
632 if (fg & TILE_FLAG_ATT_MASK)
634 const tileidx_t att_flag = fg & TILE_FLAG_ATT_MASK;
635 if (att_flag == TILE_FLAG_PET)
637 m_buf_icons.add(TILEI_HEART, x, y);
638 status_shift += 10;
640 else if (att_flag == TILE_FLAG_GD_NEUTRAL)
642 m_buf_icons.add(TILEI_GOOD_NEUTRAL, x, y);
643 status_shift += 8;
645 else if (att_flag == TILE_FLAG_NEUTRAL)
647 m_buf_icons.add(TILEI_NEUTRAL, x, y);
648 status_shift += 8;
651 else if (fg & TILE_FLAG_STAB)
653 m_buf_icons.add(TILEI_STAB_BRAND, x, y);
654 status_shift += 15;
656 else if (fg & TILE_FLAG_MAY_STAB)
658 m_buf_icons.add(TILEI_MAY_STAB_BRAND, x, y);
659 status_shift += 8;
662 if (fg & TILE_FLAG_POISON)
664 m_buf_icons.add(TILEI_POISON, x, y, -status_shift, 0);
665 status_shift += 5;
667 if (fg & TILE_FLAG_FLAME)
669 m_buf_icons.add(TILEI_FLAME, x, y, -status_shift, 0);
670 status_shift += 5;
673 if (fg & TILE_FLAG_ANIM_WEP)
674 m_buf_icons.add(TILEI_ANIMATED_WEAPON, x, y);
676 if (bg & TILE_FLAG_UNSEEN && (bg != TILE_FLAG_UNSEEN || fg))
677 m_buf_icons.add(TILEI_MESH, x, y);
679 if (bg & TILE_FLAG_OOR && (bg != TILE_FLAG_OOR || fg))
680 m_buf_icons.add(TILEI_OOR_MESH, x, y);
682 if (bg & TILE_FLAG_MM_UNSEEN && (bg != TILE_FLAG_MM_UNSEEN || fg))
683 m_buf_icons.add(TILEI_MAGIC_MAP_MESH, x, y);
685 // Don't let the "new stair" icon cover up any existing icons, but
686 // draw it otherwise.
687 if (bg & TILE_FLAG_NEW_STAIR && status_shift == 0)
688 m_buf_icons.add(TILEI_NEW_STAIR, x, y);
690 if (bg & TILE_FLAG_EXCL_CTR && (bg & TILE_FLAG_UNSEEN))
691 m_buf_icons.add(TILEI_TRAVEL_EXCLUSION_CENTRE_FG, x, y);
692 else if (bg & TILE_FLAG_TRAV_EXCL && (bg & TILE_FLAG_UNSEEN))
693 m_buf_icons.add(TILEI_TRAVEL_EXCLUSION_FG, x, y);
695 // Tutorial cursor takes precedence over other cursors.
696 if (bg & TILE_FLAG_TUT_CURSOR)
698 m_buf_icons.add(TILEI_TUTORIAL_CURSOR, x, y);
700 else if (bg & TILE_FLAG_CURSOR)
702 int type = ((bg & TILE_FLAG_CURSOR) == TILE_FLAG_CURSOR1) ?
703 TILEI_CURSOR : TILEI_CURSOR2;
705 if ((bg & TILE_FLAG_CURSOR) == TILE_FLAG_CURSOR3)
706 type = TILEI_CURSOR3;
708 m_buf_icons.add(type, x, y);
711 if (fg & TILE_FLAG_MDAM_MASK)
713 tileidx_t mdam_flag = fg & TILE_FLAG_MDAM_MASK;
714 if (mdam_flag == TILE_FLAG_MDAM_LIGHT)
715 m_buf_icons.add(TILEI_MDAM_LIGHTLY_DAMAGED, x, y);
716 else if (mdam_flag == TILE_FLAG_MDAM_MOD)
717 m_buf_icons.add(TILEI_MDAM_MODERATELY_DAMAGED, x, y);
718 else if (mdam_flag == TILE_FLAG_MDAM_HEAVY)
719 m_buf_icons.add(TILEI_MDAM_HEAVILY_DAMAGED, x, y);
720 else if (mdam_flag == TILE_FLAG_MDAM_SEV)
721 m_buf_icons.add(TILEI_MDAM_SEVERELY_DAMAGED, x, y);
722 else if (mdam_flag == TILE_FLAG_MDAM_ADEAD)
723 m_buf_icons.add(TILEI_MDAM_ALMOST_DEAD, x, y);
726 if (fg & TILE_FLAG_DEMON)
728 tileidx_t demon_flag = fg & TILE_FLAG_DEMON;
729 if (demon_flag == TILE_FLAG_DEMON_1)
730 m_buf_icons.add(TILEI_DEMON_NUM1, x, y);
731 else if (demon_flag == TILE_FLAG_DEMON_2)
732 m_buf_icons.add(TILEI_DEMON_NUM2, x, y);
733 else if (demon_flag == TILE_FLAG_DEMON_3)
734 m_buf_icons.add(TILEI_DEMON_NUM3, x, y);
735 else if (demon_flag == TILE_FLAG_DEMON_4)
736 m_buf_icons.add(TILEI_DEMON_NUM4, x, y);
737 else if (demon_flag == TILE_FLAG_DEMON_5)
738 m_buf_icons.add(TILEI_DEMON_NUM5, x, y);
742 void DungeonCellBuffer::pack_player(int x, int y, bool submerged)
744 dolls_data result = player_doll;
745 fill_doll_equipment(result);
746 pack_doll(result, x, y, submerged, false);
749 void DungeonCellBuffer::pack_doll(const dolls_data &doll, int x, int y,
750 bool submerged, bool ghost)
752 pack_doll_buf(m_buf_doll, doll, x, y, submerged, ghost);
756 void DungeonCellBuffer::pack_mcache(mcache_entry *entry, int x, int y,
757 bool submerged)
759 ASSERT(entry);
761 bool trans = entry->transparent();
763 const dolls_data *doll = entry->doll();
764 if (doll)
765 pack_doll(*doll, x, y, submerged, trans);
767 tile_draw_info dinfo[mcache_entry::MAX_INFO_COUNT];
768 int draw_info_count = entry->info(&dinfo[0]);
769 for (int i = 0; i < draw_info_count; i++)
771 m_buf_doll.add(dinfo[i].idx, x, y, TILEP_PART_MAX, submerged, trans,
772 dinfo[i].ofs_x, dinfo[i].ofs_y);
776 #endif