summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-15 21:19:26 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-15 23:11:41 +0100
commitddf80f7077a00bd04168c904b153fb1e657b9d38 (patch)
tree4b5d1b094e46b731f03b3665f4526bb6ed9c37dc
parentc6c0a0f71e0d459b8438ff2e998fbedcb9c1c99a (diff)
downloadcrawl-ref-ddf80f7077a00bd04168c904b153fb1e657b9d38.tar.gz
crawl-ref-ddf80f7077a00bd04168c904b153fb1e657b9d38.zip
Convert get_item_glyph to return a glyph struct.
Also don't use get_symbol.
-rw-r--r--crawl-ref/source/format.cc8
-rw-r--r--crawl-ref/source/invent.cc8
-rw-r--r--crawl-ref/source/itemname.cc8
-rw-r--r--crawl-ref/source/items.cc9
-rw-r--r--crawl-ref/source/show.cc4
-rw-r--r--crawl-ref/source/showsymb.cc9
-rw-r--r--crawl-ref/source/showsymb.h4
-rw-r--r--crawl-ref/source/tutorial.cc16
8 files changed, 30 insertions, 36 deletions
diff --git a/crawl-ref/source/format.cc b/crawl-ref/source/format.cc
index 224bfda38f..d4c8d16a6c 100644
--- a/crawl-ref/source/format.cc
+++ b/crawl-ref/source/format.cc
@@ -494,11 +494,9 @@ formatted_string formatted_string::substr(size_t start, size_t substr_length) co
void formatted_string::add_glyph(const item_def *item)
{
const int last_col = find_last_colour();
- unsigned ch;
- unsigned short col;
- get_item_glyph(item, &ch, &col);
- this->textcolor(col);
- this->cprintf("%s", stringize_glyph(ch).c_str());
+ glyph g = get_item_glyph(item);
+ this->textcolor(g.col);
+ this->cprintf("%s", stringize_glyph(g.ch).c_str());
this->textcolor(last_col);
}
diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc
index 6149d99b48..571eabe96d 100644
--- a/crawl-ref/source/invent.cc
+++ b/crawl-ref/source/invent.cc
@@ -191,13 +191,11 @@ std::string InvEntry::get_text() const
if (InvEntry::show_glyph)
{
- unsigned glyph_char;
- unsigned short glyph_col;
- get_item_glyph( item, &glyph_char, &glyph_col );
+ glyph g = get_item_glyph(item);
- const std::string col_string = colour_to_str(glyph_col);
+ const std::string col_string = colour_to_str(g.col);
const std::string prefix = " (<" + col_string + ">"
- + static_cast<char>(glyph_char)
+ + static_cast<char>(g.ch)
+ "</" + col_string + ">)";
tstr << prefix;
}
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index d1b01e9a1e..46ffb389da 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -3014,9 +3014,7 @@ void init_item_name_cache()
item.special = 0;
std::string name = item.name(DESC_DBNAME, true, true);
- unsigned glyph;
- unsigned short colour;
- get_item_glyph(&item, &glyph, &colour);
+ glyph g = get_item_glyph(&item);
destroy_item(o, true);
lowercase(name);
@@ -3032,8 +3030,8 @@ void init_item_name_cache()
if (item_names_cache.find(name) == item_names_cache.end())
{
item_names_cache[name] = pair;
- if (glyph)
- item_names_by_glyph_cache[glyph].push_back(name);
+ if (g.ch)
+ item_names_by_glyph_cache[g.ch].push_back(name);
}
}
}
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index 9c012ee199..73751e1ab0 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -690,11 +690,10 @@ void item_check(bool verbose)
std::vector<unsigned short int> item_chars;
for (unsigned int i = 0; i < items.size() && i < 50; ++i)
{
- unsigned glyph_char;
- unsigned short glyph_col;
- get_item_glyph( items[i], &glyph_char, &glyph_col );
- item_chars.push_back( glyph_char * 0x100 +
- (10 - item_name_specialness(*(items[i]))) );
+ glyph g = get_item_glyph(items[i]);
+ get_item_glyph(items[i]);
+ item_chars.push_back(g.ch * 0x100 +
+ (10 - item_name_specialness(*(items[i]))));
}
std::sort(item_chars.begin(), item_chars.end());
diff --git a/crawl-ref/source/show.cc b/crawl-ref/source/show.cc
index 14edff3161..cc040dd408 100644
--- a/crawl-ref/source/show.cc
+++ b/crawl-ref/source/show.cc
@@ -189,6 +189,8 @@ void show_def::_update_item_at(const coord_def &gp, const coord_def &ep)
const item_def &eitem = mitm[igrd(gp)];
unsigned short &ecol = grid(ep).colour;
+ glyph g = get_item_glyph(&eitem);
+
const dungeon_feature_type feat = grd(gp);
if (Options.feature_item_brand && is_critical_feature(feat))
ecol |= COLFLAG_FEATURE_ITEM;
@@ -198,7 +200,7 @@ void show_def::_update_item_at(const coord_def &gp, const coord_def &ep)
{
const unsigned short gcol = env.grid_colours(gp);
ecol = (feat == DNGN_SHALLOW_WATER) ?
- (gcol != BLACK ? gcol : CYAN) : eitem.colour;
+ (gcol != BLACK ? gcol : CYAN) : g.col;
if (eitem.link != NON_ITEM && !crawl_state.arena)
ecol |= COLFLAG_ITEM_HEAP;
grid(ep).cls = SH_ITEM;
diff --git a/crawl-ref/source/showsymb.cc b/crawl-ref/source/showsymb.cc
index c2e67d171f..6fbcb10ca9 100644
--- a/crawl-ref/source/showsymb.cc
+++ b/crawl-ref/source/showsymb.cc
@@ -116,11 +116,12 @@ int get_mons_colour(const monsters *mons)
return (col);
}
-void get_item_glyph(const item_def *item, unsigned *glych,
- unsigned short *glycol)
+glyph get_item_glyph(const item_def *item)
{
- *glycol = item->colour;
- get_symbol(coord_def(0,0), show_type(*item), glych, glycol);
+ glyph g;
+ g.ch = get_feature_def(show_type(*item)).symbol;
+ g.col = item->colour;
+ return (g);
}
void get_mons_glyph(const monsters *mons, unsigned *glych,
diff --git a/crawl-ref/source/showsymb.h b/crawl-ref/source/showsymb.h
index 85d1593523..97ed0b90b1 100644
--- a/crawl-ref/source/showsymb.h
+++ b/crawl-ref/source/showsymb.h
@@ -9,8 +9,8 @@ struct glyph
unsigned short col;
};
-void get_item_glyph(const item_def *item, unsigned *glych,
- unsigned short *glycol);
+glyph get_item_glyph(const item_def *item);
+
void get_mons_glyph(const monsters *mons, unsigned *glych,
unsigned short *glycol);
unsigned get_screen_glyph( int x, int y );
diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc
index f54ff9337b..6bf0ed1231 100644
--- a/crawl-ref/source/tutorial.cc
+++ b/crawl-ref/source/tutorial.cc
@@ -1206,6 +1206,11 @@ static std::string _colourize_glyph(int col, unsigned glyph)
text << "</" << colour_str << ">";
return text.str();
}
+
+static std::string _colourize_glyph(glyph g)
+{
+ return (_colourize_glyph(g.col, g.ch));
+}
#endif
static bool _mons_is_highlighted(const monsters *mons)
@@ -1444,11 +1449,7 @@ void tutorial_first_item(const item_def &item)
std::string text = "That ";
#ifndef USE_TILE
- unsigned ch;
- unsigned short col;
- get_item_glyph(&item, &ch, &col);
-
- text += _colourize_glyph(col, ch);
+ text += _colourize_glyph(get_item_glyph(&item));
text += " ";
#else
const coord_def gc = item.pos;
@@ -1906,10 +1907,7 @@ void learned_something_new(tutorial_event_type seen_what, coord_def gc)
{
text << "That ";
#ifndef USE_TILE
- unsigned short col;
- get_item_glyph(&mitm[i], &ch, &col);
-
- text << _colourize_glyph(col, ch);
+ text << _colourize_glyph(get_item_glyph(&mitm[i]));
text << " ";
#else
tiles.place_cursor(CURSOR_TUTORIAL, gc);