From d13f2354db0c50108beccd90aea26ec416e20d07 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Sun, 15 Nov 2009 21:32:30 +0100 Subject: Convert get_mons_glyph to return a glyph struct. --- crawl-ref/source/format.cc | 8 +++----- crawl-ref/source/mon-info.cc | 4 +++- crawl-ref/source/show.cc | 2 +- crawl-ref/source/showsymb.cc | 11 ++++++----- crawl-ref/source/showsymb.h | 5 +---- crawl-ref/source/tutorial.cc | 11 ++--------- 6 files changed, 16 insertions(+), 25 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/format.cc b/crawl-ref/source/format.cc index d4c8d16a6c..69e8b9be5a 100644 --- a/crawl-ref/source/format.cc +++ b/crawl-ref/source/format.cc @@ -503,11 +503,9 @@ void formatted_string::add_glyph(const item_def *item) void formatted_string::add_glyph(const monsters *mons) { const int last_col = find_last_colour(); - unsigned ch; - unsigned short col; - get_mons_glyph(mons, &ch, &col); - this->textcolor(col); - this->cprintf("%s", stringize_glyph(ch).c_str()); + glyph g = get_mons_glyph(mons); + this->textcolor(g.col); + this->cprintf("%s", stringize_glyph(g.ch).c_str()); this->textcolor(last_col); } diff --git a/crawl-ref/source/mon-info.cc b/crawl-ref/source/mon-info.cc index d32b8466d1..a569a2982b 100644 --- a/crawl-ref/source/mon-info.cc +++ b/crawl-ref/source/mon-info.cc @@ -48,7 +48,9 @@ monster_info::monster_info(const monsters *m) if (mons_looks_distracted(m)) m_brands |= (1 << MB_DISTRACTED); if (m->berserk()) m_brands |= (1 << MB_BERSERK); - get_mons_glyph(m_mon, &m_glyph, &m_glyph_colour); + glyph g = get_mons_glyph(m_mon); + m_glyph = g.ch; + m_glyph_colour = g.col; mons_get_damage_level(m_mon, m_damage_desc, m_damage_level); // If no messages about wounds, don't display damage level either. diff --git a/crawl-ref/source/show.cc b/crawl-ref/source/show.cc index cc040dd408..2e25971d37 100644 --- a/crawl-ref/source/show.cc +++ b/crawl-ref/source/show.cc @@ -302,7 +302,7 @@ void show_def::_update_monster(const monsters* mons) grid(e).cls = SH_MONSTER; grid(e).mons = mons->type; - grid(e).colour = get_mons_colour(mons); + grid(e).colour = get_mons_glyph(mons).col; #ifdef USE_TILE tile_place_monster(mons->pos().x, mons->pos().y, mons->mindex(), true); diff --git a/crawl-ref/source/showsymb.cc b/crawl-ref/source/showsymb.cc index 6fbcb10ca9..55f3f51892 100644 --- a/crawl-ref/source/showsymb.cc +++ b/crawl-ref/source/showsymb.cc @@ -65,7 +65,7 @@ void get_show_symbol(show_type object, unsigned *ch, *colour = real_colour(*colour); } -int get_mons_colour(const monsters *mons) +static int _get_mons_colour(const monsters *mons) { int col = mons->colour; @@ -124,11 +124,12 @@ glyph get_item_glyph(const item_def *item) return (g); } -void get_mons_glyph(const monsters *mons, unsigned *glych, - unsigned short *glycol) +glyph get_mons_glyph(const monsters *mons) { - *glycol = get_mons_colour(mons); - get_symbol(coord_def(0,0), show_type(mons), glych, glycol); + glyph g; + g.ch = mons_char(mons->type); + g.col = _get_mons_colour(mons); + return (g); } unsigned get_screen_glyph( int x, int y ) diff --git a/crawl-ref/source/showsymb.h b/crawl-ref/source/showsymb.h index 97ed0b90b1..10fc84500d 100644 --- a/crawl-ref/source/showsymb.h +++ b/crawl-ref/source/showsymb.h @@ -10,14 +10,11 @@ struct glyph }; glyph get_item_glyph(const item_def *item); +glyph get_mons_glyph(const monsters *mons); -void get_mons_glyph(const monsters *mons, unsigned *glych, - unsigned short *glycol); unsigned get_screen_glyph( int x, int y ); unsigned get_screen_glyph( const coord_def &p ); -int get_mons_colour(const monsters *mons); - void get_symbol(const coord_def& where, show_type object, unsigned *ch, unsigned short *colour); diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc index 6bf0ed1231..5d9edbebfa 100644 --- a/crawl-ref/source/tutorial.cc +++ b/crawl-ref/source/tutorial.cc @@ -1338,11 +1338,7 @@ void tutorial_first_monster(const monsters &mon) "by hovering your mouse over its tile, and read the monster " "description by clicking on it with your right mouse button." #else - unsigned ch; - unsigned short col; - get_mons_glyph(&mon, &ch, &col); - - text += _colourize_glyph(col, ch); + text += _colourize_glyph(get_mons_glyph(&mon)); text += " is a monster, usually depicted by a letter. Some typical " "early monsters look like r, l, " "K or g. "; @@ -3234,10 +3230,7 @@ void learned_something_new(tutorial_event_type seen_what, coord_def gc) text << "is a "; #else - unsigned short col; - get_mons_glyph(m, &ch, &col); - - text << _colourize_glyph(col, ch) << " is a "; + text << _colourize_glyph(get_mons_glyph(m)) << " is a "; #endif text << m->name(DESC_PLAIN).c_str() << ". "; -- cgit v1.2.3-54-g00ecf