From a124171efd9ff0f38532b3a15a008705ad58ae38 Mon Sep 17 00:00:00 2001 From: haranp Date: Tue, 27 Jan 2009 08:46:50 +0000 Subject: Various cleanups. (I can't run tiles, but it compiled fine, so I hope I didn't introduce a subtle bug.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8811 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/shopping.cc | 42 ++++++++++---------- crawl-ref/source/view.cc | 91 ++++++++++++++++++++++---------------------- crawl-ref/source/view.h | 3 ++ 3 files changed, 70 insertions(+), 66 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/shopping.cc b/crawl-ref/source/shopping.cc index 9345a5ba28..70227a4f2d 100644 --- a/crawl-ref/source/shopping.cc +++ b/crawl-ref/source/shopping.cc @@ -1801,7 +1801,7 @@ std::string shop_name(const coord_def& where) return ("Buggy Shop"); } - int shop_type = cshop->type; + const shop_type type = cshop->type; unsigned long seed = static_cast( cshop->keeper_name[0] ) | (static_cast( cshop->keeper_name[1] ) << 8) @@ -1809,27 +1809,28 @@ std::string shop_name(const coord_def& where) std::string sh_name = apostrophise(make_name(seed, false)) + " "; - if (shop_type == SHOP_WEAPON_ANTIQUE || shop_type == SHOP_ARMOUR_ANTIQUE) + if (type == SHOP_WEAPON_ANTIQUE || type == SHOP_ARMOUR_ANTIQUE) sh_name += "Antique "; sh_name += - (shop_type == SHOP_WEAPON - || shop_type == SHOP_WEAPON_ANTIQUE) ? "Weapon" : - (shop_type == SHOP_ARMOUR - || shop_type == SHOP_ARMOUR_ANTIQUE) ? "Armour" : - - (shop_type == SHOP_JEWELLERY) ? "Jewellery" : - (shop_type == SHOP_WAND) ? "Magical Wand" : - (shop_type == SHOP_BOOK) ? "Book" : - (shop_type == SHOP_FOOD) ? "Food" : - (shop_type == SHOP_SCROLL) ? "Magic Scroll" : - (shop_type == SHOP_GENERAL_ANTIQUE) ? "Assorted Antiques" : - (shop_type == SHOP_DISTILLERY) ? "Distillery" : - (shop_type == SHOP_GENERAL) ? "General Store" - : "Bug"; - - if (shop_type != SHOP_GENERAL - && shop_type != SHOP_GENERAL_ANTIQUE && shop_type != SHOP_DISTILLERY) + (type == SHOP_WEAPON + || type == SHOP_WEAPON_ANTIQUE) ? "Weapon" : + (type == SHOP_ARMOUR + || type == SHOP_ARMOUR_ANTIQUE) ? "Armour" : + + (type == SHOP_JEWELLERY) ? "Jewellery" : + (type == SHOP_WAND) ? "Magical Wand" : + (type == SHOP_BOOK) ? "Book" : + (type == SHOP_FOOD) ? "Food" : + (type == SHOP_SCROLL) ? "Magic Scroll" : + (type == SHOP_GENERAL_ANTIQUE) ? "Assorted Antiques" : + (type == SHOP_DISTILLERY) ? "Distillery" : + (type == SHOP_GENERAL) ? "General Store" + : "Bug"; + + if (type != SHOP_GENERAL + && type != SHOP_GENERAL_ANTIQUE + && type != SHOP_DISTILLERY) { const char* suffixnames[] = {"Shoppe", "Boutique", "Emporium", "Shop"}; const int temp = (where.x + where.y) % 4; @@ -1842,6 +1843,5 @@ std::string shop_name(const coord_def& where) bool is_shop_item(const item_def &item) { - return (item.pos.x == 0 && item.pos.y >= 5 - && item.pos.y < (MAX_SHOPS + 5)); + return (item.pos.x == 0 && item.pos.y >= 5 && item.pos.y < (MAX_SHOPS + 5)); } diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index 69ca694249..6b473aa9bd 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -189,6 +189,11 @@ void set_envmap_glyph(int x, int y, int object, int col) #endif } +void set_envmap_glyph(const coord_def& c, int object, int col) +{ + set_envmap_glyph(c.x, c.y, object, col); +} + void set_envmap_obj( const coord_def& where, int obj ) { env.map(where).object = obj; @@ -5167,6 +5172,9 @@ void viewwindow(bool draw_it, bool do_updates) // in grid coords const coord_def gc(view2grid(coord_def(count_x, count_y))); const coord_def ep = view2show(grid2view(gc)); +#ifdef USE_TILE + const coord_def sep = ep - coord_def(1,1); +#endif // Print tutorial messages for features in LOS. if (Options.tutorial_left && in_bounds(gc) @@ -5192,7 +5200,7 @@ void viewwindow(bool draw_it, bool do_updates) else if (grd(gc) == DNGN_ENTER_SHOP) learned_something_new(TUT_SEEN_SHOP, gc); - if (igrd[gc.x][gc.y] != NON_ITEM + if (igrd(gc) != NON_ITEM && Options.feature_item_brand != CHATTR_NORMAL && (is_feature('>', gc) || is_feature('<', gc))) { @@ -5214,7 +5222,7 @@ void viewwindow(bool draw_it, bool do_updates) else if (!crawl_view.in_grid_los(gc)) { // Outside the env.show area. - buffy[bufcount] = get_envmap_char( gc.x, gc.y ); + buffy[bufcount] = get_envmap_char(gc); buffy[bufcount + 1] = DARKGREY; if (Options.colour_map) @@ -5224,10 +5232,10 @@ void viewwindow(bool draw_it, bool do_updates) } #ifdef USE_TILE - unsigned int bg = env.tile_bk_bg[gc.x][gc.y]; - unsigned int fg = env.tile_bk_fg[gc.x][gc.y]; + unsigned int bg = env.tile_bk_bg(gc); + unsigned int fg = env.tile_bk_fg(gc); if (bg == 0 && fg == 0) - tileidx_unseen(fg, bg, get_envmap_char(gc.x, gc.y), gc); + tileidx_unseen(fg, bg, get_envmap_char(gc), gc); tileb[bufcount] = fg; tileb[bufcount + 1] = bg | tile_unseen_flag(gc); @@ -5239,30 +5247,28 @@ void viewwindow(bool draw_it, bool do_updates) int object = env.show(ep); unsigned short colour = env.show_col(ep); unsigned ch; - _get_symbol( gc, object, &ch, &colour ); + _get_symbol(gc, object, &ch, &colour); if (map) { - set_envmap_glyph( gc.x, gc.y, object, colour ); + set_envmap_glyph(gc, object, colour); if (is_terrain_changed(gc) || !is_terrain_seen(gc)) update_excludes.push_back(gc); - set_terrain_seen( gc.x, gc.y ); - set_envmap_detected_mons(gc.x, gc.y, false); - set_envmap_detected_item(gc.x, gc.y, false); + set_terrain_seen(gc); + set_envmap_detected_mons(gc, false); + set_envmap_detected_item(gc, false); } #ifdef USE_TILE if (map) { - env.tile_bk_bg[gc.x][gc.y] = - env.tile_bg[ep.x-1][ep.y-1]; - env.tile_bk_fg[gc.x][gc.y] = - env.tile_fg[ep.x-1][ep.y-1]; + env.tile_bk_bg(gc) = env.tile_bg(sep); + env.tile_bk_fg(gc) = env.tile_fg(sep); } - tileb[bufcount] = env.tile_fg[ep.x-1][ep.y-1] = + tileb[bufcount] = env.tile_fg(sep) = tileidx_player(you.char_class); - tileb[bufcount+1] = env.tile_bg[ep.x-1][ep.y-1]; + tileb[bufcount+1] = env.tile_bg(sep); #endif // Player overrides everything in cell. @@ -5288,8 +5294,8 @@ void viewwindow(bool draw_it, bool do_updates) buffy[bufcount] = ch; buffy[bufcount + 1] = colour; #ifdef USE_TILE - tileb[bufcount] = env.tile_fg[ep.x-1][ep.y-1]; - tileb[bufcount+1] = env.tile_bg[ep.x-1][ep.y-1]; + tileb[bufcount] = env.tile_fg(sep); + tileb[bufcount+1] = env.tile_bg(sep); #endif if (map) @@ -5305,26 +5311,23 @@ void viewwindow(bool draw_it, bool do_updates) if (is_terrain_changed(gc) || !is_terrain_seen(gc)) update_excludes.push_back(gc); - set_terrain_seen( gc.x, gc.y ); - set_envmap_glyph( gc.x, gc.y, object, colour ); - set_envmap_detected_mons(gc.x, gc.y, false); - set_envmap_detected_item(gc.x, gc.y, false); + set_terrain_seen(gc); + set_envmap_glyph(gc, object, colour ); + set_envmap_detected_mons(gc, false); + set_envmap_detected_item(gc, false); #ifdef USE_TILE // We remove any references to mcache when // writing to the background. if (Options.clean_map) { - env.tile_bk_fg[gc.x][gc.y] = - get_clean_map_idx( - env.tile_fg[ep.x-1][ep.y-1]); + env.tile_bk_fg(gc) = + get_clean_map_idx(env.tile_fg(sep)); } else { - env.tile_bk_fg[gc.x][gc.y] = - env.tile_fg[ep.x-1][ep.y-1]; + env.tile_bk_fg(gc) = env.tile_fg(sep); } - env.tile_bk_bg[gc.x][gc.y] = - env.tile_bg[ep.x-1][ep.y-1]; + env.tile_bk_bg(gc) = env.tile_bg(sep); #endif } @@ -5339,12 +5342,12 @@ void viewwindow(bool draw_it, bool do_updates) // have a monster or cloud on it, and is equal // to the grid before monsters and clouds were // added otherwise. - if (Options.clean_map && Show_Backup(ep) - && is_terrain_seen( gc.x, gc.y )) + if (Options.clean_map + && Show_Backup(ep) + && is_terrain_seen(gc)) { - _get_symbol( gc, Show_Backup(ep), &ch, &colour ); - set_envmap_glyph( gc.x, gc.y, Show_Backup(ep), - colour ); + _get_symbol(gc, Show_Backup(ep), &ch, &colour); + set_envmap_glyph(gc, Show_Backup(ep), colour); } // Now we get to filling in both the unseen @@ -5360,7 +5363,7 @@ void viewwindow(bool draw_it, bool do_updates) if (buffy[bufcount] == 0) { // Show map. - buffy[bufcount] = get_envmap_char( gc.x, gc.y ); + buffy[bufcount] = get_envmap_char(gc); buffy[bufcount + 1] = DARKGREY; if (Options.colour_map) @@ -5369,21 +5372,19 @@ void viewwindow(bool draw_it, bool do_updates) colour_code_map(gc, Options.item_colour); } #ifdef USE_TILE - if (env.tile_bk_fg[gc.x][gc.y] != 0 - || env.tile_bk_bg[gc.x][gc.y] != 0) + if (env.tile_bk_fg(gc) != 0 + || env.tile_bk_bg(gc) != 0) { - tileb[bufcount] = - env.tile_bk_fg[gc.x][gc.y]; + tileb[bufcount] = env.tile_bk_fg(gc); tileb[bufcount + 1] = - env.tile_bk_bg[gc.x][gc.y] - | tile_unseen_flag(gc); + env.tile_bk_bg(gc) | tile_unseen_flag(gc); } else { tileidx_unseen(tileb[bufcount], tileb[bufcount+1], - get_envmap_char(gc.x, gc.y), + get_envmap_char(gc), gc); } #endif @@ -5395,8 +5396,8 @@ void viewwindow(bool draw_it, bool do_updates) if (flash_colour && buffy[bufcount]) { buffy[bufcount + 1] = - see_grid(gc.x, gc.y) ? real_colour(flash_colour) - : DARKGREY; + see_grid(gc) ? real_colour(flash_colour) + : DARKGREY; } bufcount += 2; @@ -5435,7 +5436,7 @@ void viewwindow(bool draw_it, bool do_updates) } _debug_pane_bounds(); -} // end viewwindow() +} ////////////////////////////////////////////////////////////////////////////// // crawl_view_buffer diff --git a/crawl-ref/source/view.h b/crawl-ref/source/view.h index 43977a523c..6f710dbb24 100644 --- a/crawl-ref/source/view.h +++ b/crawl-ref/source/view.h @@ -150,6 +150,9 @@ const feature_def &get_feature_def(dungeon_feature_type feat); void set_envmap_obj( const coord_def& where, int object ); unsigned get_envmap_char(int x, int y); +inline unsigned get_envmap_char(const coord_def& c) { + return get_envmap_char(c.x, c.y); +} bool inside_level_bounds(int x, int y); bool inside_level_bounds(const coord_def &p); int get_envmap_obj(int x, int y); -- cgit v1.2.3-54-g00ecf