summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/view.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-06 10:58:37 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-06 11:33:08 +0100
commita37af0a7641b0178d66e09d51ad8dcb9ec5e42c6 (patch)
tree81f0e136343b518faed64b53bdb3ebc9ba4cccd9 /crawl-ref/source/view.cc
parent89eaa39aa96039062a4d1a0efc2e5c1fe9f54a95 (diff)
downloadcrawl-ref-a37af0a7641b0178d66e09d51ad8dcb9ec5e42c6.tar.gz
crawl-ref-a37af0a7641b0178d66e09d51ad8dcb9ec5e42c6.zip
Split get_symbol from view.cc.
Diffstat (limited to 'crawl-ref/source/view.cc')
-rw-r--r--crawl-ref/source/view.cc244
1 files changed, 6 insertions, 238 deletions
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index a17925354d..1f9155c926 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -25,6 +25,7 @@
#include "viewchar.h"
#include "viewgeom.h"
#include "viewmap.h"
+#include "showsymb.h"
#include "branch.h"
#include "command.h"
@@ -84,11 +85,6 @@ crawl_view_geometry crawl_view;
extern int stealth; // defined in acr.cc
-static void _get_symbol( const coord_def& where,
- show_type object, unsigned *ch,
- unsigned short *colour,
- bool magic_mapped = false );
-
bool inside_level_bounds(int x, int y)
{
return (x > 0 && x < GXM && y > 0 && y < GYM);
@@ -104,200 +100,6 @@ bool is_notable_terrain(dungeon_feature_type ftype)
return (get_feature_def(ftype).is_notable());
}
-unsigned get_symbol(show_type object, unsigned short *colour,
- bool magic_mapped)
-{
- unsigned ch;
- _get_symbol(coord_def(0,0), object, &ch, NULL, magic_mapped);
- return (ch);
-}
-
-static bool _show_bloodcovered(const coord_def& where)
-{
- if (!is_bloodcovered(where))
- return (false);
-
- dungeon_feature_type grid = grd(where);
-
- // Altars, stairs (of any kind) and traps should not be coloured red.
- return (!is_critical_feature(grid) && !feat_is_trap(grid));
-}
-
-static unsigned short _tree_colour(const coord_def& where)
-{
- uint32_t h = where.x;
- h+=h<<10; h^=h>>6;
- h += where.y;
- h+=h<<10; h^=h>>6;
- h+=h<<3; h^=h>>11; h+=h<<15;
- return (h>>30) ? GREEN : LIGHTGREEN;
-}
-
-static void _get_symbol( const coord_def& where,
- show_type object, unsigned *ch,
- unsigned short *colour,
- bool magic_mapped )
-{
- ASSERT( ch != NULL );
-
- if (object.cls < SH_MONSTER)
- {
- const feature_def &fdef = get_feature_def(object);
-
- *ch = magic_mapped? fdef.magic_symbol
- : fdef.symbol;
-
- // Don't recolor items
- if (colour && object.cls == SH_FEATURE)
- {
- dungeon_feature_type feat = object.feat;
- const int colmask = *colour & COLFLAG_MASK;
-
- // TODO: consolidate with feat_is_stair etc.
- bool excluded_stairs = (feat >= DNGN_STONE_STAIRS_DOWN_I
- && feat <= DNGN_ESCAPE_HATCH_UP
- && is_exclude_root(where));
-
- if (excluded_stairs)
- *colour = Options.tc_excluded | colmask;
- else if (feat >= DNGN_MINMOVE && you.get_beholder(where))
- {
- // Colour grids that cannot be reached due to beholders
- // dark grey.
- *colour = DARKGREY | colmask;
- }
- else if (feat >= DNGN_MINMOVE && is_sanctuary(where))
- {
- if (testbits(env.map(where).property, FPROP_SANCTUARY_1))
- *colour = YELLOW | colmask;
- else if (testbits(env.map(where).property, FPROP_SANCTUARY_2))
- {
- if (!one_chance_in(4))
- *colour = WHITE | colmask; // 3/4
- else if (!one_chance_in(3))
- *colour = LIGHTCYAN | colmask; // 1/6
- else
- *colour = LIGHTGREY | colmask; // 1/12
- }
- }
- else if (_show_bloodcovered(where))
- *colour = RED | colmask;
- else if (env.grid_colours(where))
- *colour = env.grid_colours(where) | colmask;
- else
- {
- // Don't clobber with BLACK, because the colour should be
- // already set.
- if (fdef.colour != BLACK)
- *colour = fdef.colour | colmask;
- else if (feat == DNGN_TREES)
- *colour = _tree_colour(where) | colmask;
-
- if (fdef.em_colour && fdef.em_colour != fdef.colour &&
- emphasise(where, feat))
- {
- *colour = (fdef.em_colour | colmask);
- }
- }
-
- // TODO: should be a feat_is_whatever(feat)
- if (feat >= DNGN_FLOOR_MIN && feat <= DNGN_FLOOR_MAX
- || feat == DNGN_UNDISCOVERED_TRAP)
- {
- if (inside_halo(where))
- {
- if (silenced(where))
- *colour = LIGHTCYAN | colmask;
- else
- *colour = YELLOW | colmask;
- }
- else if (silenced(where))
- *colour = CYAN | colmask;
- }
- }
-
- // Note anything we see that's notable
- if (!where.origin() && fdef.is_notable())
- {
- if (object.cls == SH_FEATURE) // other notable things?
- seen_notable_thing(object.feat, where);
- }
- }
- else
- {
- ASSERT(object.cls == SH_MONSTER);
- *ch = mons_char(object.mons);
- }
-
- if (colour)
- *colour = real_colour(*colour);
-}
-
-unsigned grid_character_at(const coord_def &c)
-{
- unsigned glych;
- unsigned short glycol = 0;
-
- _get_symbol(c, grd(c), &glych, &glycol );
- return glych;
-}
-
-dungeon_char_type get_feature_dchar(dungeon_feature_type feat)
-{
- return (get_feature_def(feat).dchar);
-}
-
-int get_mons_colour(const monsters *mons)
-{
- int col = mons->colour;
-
- if (mons->has_ench(ENCH_BERSERK))
- col = RED;
-
- if (mons_friendly_real(mons))
- {
- col |= COLFLAG_FRIENDLY_MONSTER;
- }
- else if (mons_neutral(mons))
- {
- col |= COLFLAG_NEUTRAL_MONSTER;
- }
- else if (Options.stab_brand != CHATTR_NORMAL
- && mons_looks_stabbable(mons))
- {
- col |= COLFLAG_WILLSTAB;
- }
- else if (Options.may_stab_brand != CHATTR_NORMAL
- && mons_looks_distracted(mons))
- {
- col |= COLFLAG_MAYSTAB;
- }
- else if (mons_is_stationary(mons))
- {
- if (Options.feature_item_brand != CHATTR_NORMAL
- && is_critical_feature(grd(mons->pos()))
- && feat_stair_direction(grd(mons->pos())) != CMD_NO_CMD)
- {
- col |= COLFLAG_FEATURE_ITEM;
- }
- else if (Options.heap_brand != CHATTR_NORMAL
- && igrd(mons->pos()) != NON_ITEM
- && !crawl_state.arena)
- {
- col |= COLFLAG_ITEM_HEAP;
- }
- }
-
- // Backlit monsters are fuzzy and override brands.
- if (!you.can_see_invisible() && mons->has_ench(ENCH_INVIS)
- && mons->backlit())
- {
- col = DARKGREY;
- }
-
- return (col);
-}
-
static void _good_god_follower_attitude_change(monsters *monster)
{
if (you.is_unholy() || crawl_state.arena)
@@ -875,40 +677,6 @@ bool check_awaken(monsters* monster)
return (false);
}
-void get_item_glyph(const item_def *item, unsigned *glych,
- unsigned short *glycol)
-{
- *glycol = item->colour;
- _get_symbol(coord_def(0,0), show_type(*item), glych, glycol);
-}
-
-void get_mons_glyph(const monsters *mons, unsigned *glych,
- unsigned short *glycol)
-{
- *glycol = get_mons_colour(mons);
- _get_symbol(coord_def(0,0), show_type(mons), glych, glycol);
-}
-
-unsigned get_screen_glyph( int x, int y )
-{
- return get_screen_glyph(coord_def(x,y));
-}
-
-unsigned get_screen_glyph(const coord_def& p)
-{
- const coord_def ep = view2show(grid2view(p));
-
- show_type object = env.show(ep);
- unsigned short colour = object.colour;
- unsigned ch;
-
- if (!object)
- return get_envmap_char(p.x, p.y);
-
- _get_symbol(p, object, &ch, &colour);
- return (ch);
-}
-
// Noisy now has a messenging service for giving messages to the
// player is appropriate.
//
@@ -1417,7 +1185,7 @@ std::string screenshot(bool fullscreen)
unsigned glych;
unsigned short glycol = 0;
- _get_symbol( gc, object, &glych, &glycol );
+ get_symbol( gc, object, &glych, &glycol );
ch = glych;
}
@@ -1495,7 +1263,7 @@ void view_update_at(const coord_def &pos)
unsigned short colour = object.colour;
unsigned ch = 0;
- _get_symbol( pos, object, &ch, &colour );
+ get_symbol( pos, object, &ch, &colour );
int flash_colour = you.flash_colour;
if (flash_colour == BLACK)
@@ -1700,7 +1468,7 @@ void viewwindow(bool draw_it, bool do_updates)
show_type object = env.show(ep);
unsigned short colour = object.colour;
unsigned ch;
- _get_symbol(gc, object, &ch, &colour);
+ get_symbol(gc, object, &ch, &colour);
if (map)
{
@@ -1742,7 +1510,7 @@ void viewwindow(bool draw_it, bool do_updates)
unsigned short colour = object.colour;
unsigned ch;
- _get_symbol( gc, object, &ch, &colour );
+ get_symbol( gc, object, &ch, &colour );
buffy[bufcount] = ch;
buffy[bufcount + 1] = colour;
@@ -1799,7 +1567,7 @@ void viewwindow(bool draw_it, bool do_updates)
&& env.show.get_backup(ep)
&& is_terrain_seen(gc))
{
- _get_symbol(gc, env.show.get_backup(ep), &ch, &colour);
+ get_symbol(gc, env.show.get_backup(ep), &ch, &colour);
set_envmap_glyph(gc, env.show.get_backup(ep), colour);
}