diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-11-09 22:44:43 +0100 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-11-09 23:21:41 +0100 |
commit | f8d69cbe96b1bcb39b90554800a60d99c0a596f7 (patch) | |
tree | 331391fc0aac88b357e8a6fae173cb08c380fa98 /crawl-ref/source/view.cc | |
parent | 4faab1b80eaf21e1e12c41316d596fb5be45e79d (diff) | |
download | crawl-ref-f8d69cbe96b1bcb39b90554800a60d99c0a596f7.tar.gz crawl-ref-f8d69cbe96b1bcb39b90554800a60d99c0a596f7.zip |
Remove option draw_it from viewwindow.
The only use was just removed.
Also move the draw check closer to where it's used.
Diffstat (limited to 'crawl-ref/source/view.cc')
-rw-r--r-- | crawl-ref/source/view.cc | 428 |
1 files changed, 210 insertions, 218 deletions
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index 8968ea16fc..9c9deba2ac 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -1203,7 +1203,7 @@ bool view_update() { if (you.num_turns > you.last_view_update) { - viewwindow(true, false); + viewwindow(false); return (true); } return (false); @@ -1213,7 +1213,6 @@ static void _debug_pane_bounds() { #if DEBUG_PANE_BOUNDS // Doesn't work for HUD because print_stats() overwrites it. - // To debug HUD, add viewwindow(false,false) at end of _prep_input. if (crawl_view.mlistsz.y > 0) { @@ -1255,7 +1254,7 @@ static void _debug_pane_bounds() // monsters). // //--------------------------------------------------------------- -void viewwindow(bool draw_it, bool do_updates) +void viewwindow(bool do_updates) { if (you.duration[DUR_TIME_STEP]) return; @@ -1288,276 +1287,269 @@ void viewwindow(bool draw_it, bool do_updates) tiles.clear_overlays(); #endif - if (draw_it) - { - cursor_control cs(false); + cursor_control cs(false); - const bool map = player_in_mappable_area(); - const bool draw = -#ifdef USE_TILE - !is_resting() && -#endif - (!you.running || Options.travel_delay > -1 - || you.running.is_explore() && Options.explore_delay > -1) - && !you.asleep(); + const bool map = player_in_mappable_area(); - int bufcount = 0; + int bufcount = 0; - int flash_colour = you.flash_colour; - if (flash_colour == BLACK) - flash_colour = _viewmap_flash_colour(); + int flash_colour = you.flash_colour; + if (flash_colour == BLACK) + flash_colour = _viewmap_flash_colour(); - std::vector<coord_def> update_excludes; - for (count_y = crawl_view.viewp.y; - count_y < crawl_view.viewp.y + crawl_view.viewsz.y; count_y++) + std::vector<coord_def> update_excludes; + for (count_y = crawl_view.viewp.y; + count_y < crawl_view.viewp.y + crawl_view.viewsz.y; count_y++) + { + for (count_x = crawl_view.viewp.x; + count_x < crawl_view.viewp.x + crawl_view.viewsz.x; count_x++) { - for (count_x = crawl_view.viewp.x; - count_x < crawl_view.viewp.x + crawl_view.viewsz.x; count_x++) + // in grid coords + const coord_def gc(view2grid(coord_def(count_x, count_y))); + const coord_def ep = view2show(grid2view(gc)); + + if (in_bounds(gc) && you.see_cell(gc)) + maybe_remove_autoexclusion(gc); + + // Print tutorial messages for features in LOS. + if (Options.tutorial_left + && in_bounds(gc) + && crawl_view.in_grid_los(gc) + && env.show(ep)) + { + tutorial_observe_cell(gc); + } + + // Order is important here. + if (!map_bounds(gc)) + { + // off the map + buffy[bufcount] = 0; + buffy[bufcount + 1] = DARKGREY; +#ifdef USE_TILE + tileidx_unseen(tileb[bufcount], tileb[bufcount+1], ' ', gc); +#endif + } + else if (!crawl_view.in_grid_los(gc)) { - // in grid coords - const coord_def gc(view2grid(coord_def(count_x, count_y))); - const coord_def ep = view2show(grid2view(gc)); - - if (in_bounds(gc) && you.see_cell(gc)) - maybe_remove_autoexclusion(gc); - - // Print tutorial messages for features in LOS. - if (Options.tutorial_left - && in_bounds(gc) - && crawl_view.in_grid_los(gc) - && env.show(ep)) + // Outside the env.show area. + buffy[bufcount] = get_map_knowledge_char(gc); + buffy[bufcount + 1] = DARKGREY; + + if (Options.colour_map) { - tutorial_observe_cell(gc); + buffy[bufcount + 1] = + colour_code_map(gc, Options.item_colour); } - // Order is important here. - if (!map_bounds(gc)) - { - // off the map - buffy[bufcount] = 0; - buffy[bufcount + 1] = DARKGREY; #ifdef USE_TILE - tileidx_unseen(tileb[bufcount], tileb[bufcount+1], ' ', gc); + 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_map_knowledge_char(gc), gc); + + tileb[bufcount] = fg; + tileb[bufcount + 1] = bg | tile_unseen_flag(gc); #endif - } - else if (!crawl_view.in_grid_los(gc)) - { - // Outside the env.show area. - buffy[bufcount] = get_map_knowledge_char(gc); - buffy[bufcount + 1] = DARKGREY; + } + else if (gc == you.pos() && !crawl_state.arena + && !crawl_state.arena_suspended) + { + show_type object = env.show(ep); + unsigned short colour = object.colour; + unsigned ch; + get_symbol(gc, object, &ch, &colour); - if (Options.colour_map) - { - buffy[bufcount + 1] = - colour_code_map(gc, Options.item_colour); - } + if (map) + { + set_map_knowledge_glyph(gc, object, colour); + if (is_terrain_changed(gc) || !is_terrain_seen(gc)) + update_excludes.push_back(gc); + set_terrain_seen(gc); + set_map_knowledge_detected_mons(gc, false); + set_map_knowledge_detected_item(gc, false); + } #ifdef USE_TILE - 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_map_knowledge_char(gc), gc); + if (map) + { + env.tile_bk_bg(gc) = env.tile_bg(ep); + env.tile_bk_fg(gc) = env.tile_fg(ep); + } - tileb[bufcount] = fg; - tileb[bufcount + 1] = bg | tile_unseen_flag(gc); + tileb[bufcount] = env.tile_fg(ep) = + tileidx_player(you.char_class); + tileb[bufcount+1] = env.tile_bg(ep); #endif + + // Player overrides everything in cell. + buffy[bufcount] = you.symbol; + buffy[bufcount + 1] = you.colour; + if (you.swimming()) + { + if (grd(gc) == DNGN_DEEP_WATER) + buffy[bufcount + 1] = BLUE; + else + buffy[bufcount + 1] = CYAN; } - else if (gc == you.pos() && !crawl_state.arena - && !crawl_state.arena_suspended) + } + else + { + show_type object = env.show(ep); + unsigned short colour = object.colour; + unsigned ch; + + get_symbol( gc, object, &ch, &colour ); + + buffy[bufcount] = ch; + buffy[bufcount + 1] = colour; +#ifdef USE_TILE + tileb[bufcount] = env.tile_fg(ep); + tileb[bufcount+1] = env.tile_bg(ep); +#endif + + if (map) { - show_type object = env.show(ep); - unsigned short colour = object.colour; - unsigned ch; - get_symbol(gc, object, &ch, &colour); + // This section is very tricky because it + // duplicates the old code (which was horrid). - if (map) + // If the grid is in LoS env.show was set and + // we set the buffer already, so... + if (buffy[bufcount] != 0) { - set_map_knowledge_glyph(gc, object, colour); + // ... map that we've seen this if (is_terrain_changed(gc) || !is_terrain_seen(gc)) update_excludes.push_back(gc); set_terrain_seen(gc); + set_map_knowledge_glyph(gc, object, colour ); set_map_knowledge_detected_mons(gc, false); set_map_knowledge_detected_item(gc, false); - } #ifdef USE_TILE - if (map) - { + // We remove any references to mcache when + // writing to the background. + if (Options.clean_map) + env.tile_bk_fg(gc) = + get_clean_map_idx(env.tile_fg(ep)); + else + env.tile_bk_fg(gc) = env.tile_fg(ep); env.tile_bk_bg(gc) = env.tile_bg(ep); - env.tile_bk_fg(gc) = env.tile_fg(ep); - } - - tileb[bufcount] = env.tile_fg(ep) = - tileidx_player(you.char_class); - tileb[bufcount+1] = env.tile_bg(ep); #endif + } - // Player overrides everything in cell. - buffy[bufcount] = you.symbol; - buffy[bufcount + 1] = you.colour; - - if (you.swimming()) + // Check if we're looking to clean_map... + // but don't touch the buffer to clean it, + // instead we modify the env.map_knowledge itself so + // that the map stays clean as it moves out + // of the env.show radius. + // + // Note: show_backup is 0 on every square which + // is inside the env.show radius and doesn't + // have a monster or cloud on it, and is equal + // to the grid before monsters and clouds were + // added otherwise. + if (Options.clean_map + && env.show.get_backup(ep) + && is_terrain_seen(gc)) { - if (grd(gc) == DNGN_DEEP_WATER) - buffy[bufcount + 1] = BLUE; - else - buffy[bufcount + 1] = CYAN; + get_symbol(gc, env.show.get_backup(ep), &ch, &colour); + set_map_knowledge_glyph(gc, env.show.get_backup(ep), colour); } - } - else - { - show_type object = env.show(ep); - unsigned short colour = object.colour; - unsigned ch; - - get_symbol( gc, object, &ch, &colour ); - buffy[bufcount] = ch; - buffy[bufcount + 1] = colour; -#ifdef USE_TILE - tileb[bufcount] = env.tile_fg(ep); - tileb[bufcount+1] = env.tile_bg(ep); -#endif - - if (map) + // Now we get to filling in both the unseen + // grids in the env.show radius area as + // well doing the clean_map. The clean_map + // is done by having the env.map_knowledge set to the + // backup character above, and down here we + // procede to override that character if it's + // out of LoS! If it wasn't, buffy would have + // already been set (but we'd still have + // clobbered env.map_knowledge... which is important + // to do for when we move away from the area!) + if (buffy[bufcount] == 0) { - // This section is very tricky because it - // duplicates the old code (which was horrid). + // Show map. + buffy[bufcount] = get_map_knowledge_char(gc); + buffy[bufcount + 1] = DARKGREY; - // If the grid is in LoS env.show was set and - // we set the buffer already, so... - if (buffy[bufcount] != 0) + if (Options.colour_map) { - // ... map that we've seen this - if (is_terrain_changed(gc) || !is_terrain_seen(gc)) - update_excludes.push_back(gc); - - set_terrain_seen(gc); - set_map_knowledge_glyph(gc, object, colour ); - set_map_knowledge_detected_mons(gc, false); - set_map_knowledge_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) = - get_clean_map_idx(env.tile_fg(ep)); - } - else - { - env.tile_bk_fg(gc) = env.tile_fg(ep); - } - env.tile_bk_bg(gc) = env.tile_bg(ep); -#endif + buffy[bufcount + 1] = + colour_code_map(gc, Options.item_colour); } - - // Check if we're looking to clean_map... - // but don't touch the buffer to clean it, - // instead we modify the env.map_knowledge itself so - // that the map stays clean as it moves out - // of the env.show radius. - // - // Note: show_backup is 0 on every square which - // is inside the env.show radius and doesn't - // have a monster or cloud on it, and is equal - // to the grid before monsters and clouds were - // added otherwise. - if (Options.clean_map - && env.show.get_backup(ep) - && is_terrain_seen(gc)) +#ifdef USE_TILE + if (env.tile_bk_fg(gc) != 0 + || env.tile_bk_bg(gc) != 0) { - get_symbol(gc, env.show.get_backup(ep), &ch, &colour); - set_map_knowledge_glyph(gc, env.show.get_backup(ep), colour); - } + tileb[bufcount] = env.tile_bk_fg(gc); - // Now we get to filling in both the unseen - // grids in the env.show radius area as - // well doing the clean_map. The clean_map - // is done by having the env.map_knowledge set to the - // backup character above, and down here we - // procede to override that character if it's - // out of LoS! If it wasn't, buffy would have - // already been set (but we'd still have - // clobbered env.map_knowledge... which is important - // to do for when we move away from the area!) - if (buffy[bufcount] == 0) + tileb[bufcount + 1] = + env.tile_bk_bg(gc) | tile_unseen_flag(gc); + } + else { - // Show map. - buffy[bufcount] = get_map_knowledge_char(gc); - buffy[bufcount + 1] = DARKGREY; - - if (Options.colour_map) - { - buffy[bufcount + 1] = - colour_code_map(gc, Options.item_colour); - } -#ifdef USE_TILE - if (env.tile_bk_fg(gc) != 0 - || env.tile_bk_bg(gc) != 0) - { - tileb[bufcount] = env.tile_bk_fg(gc); - - tileb[bufcount + 1] = - env.tile_bk_bg(gc) | tile_unseen_flag(gc); - } - else - { - tileidx_unseen(tileb[bufcount], - tileb[bufcount+1], - get_map_knowledge_char(gc), - gc); - } -#endif + tileidx_unseen(tileb[bufcount], + tileb[bufcount+1], + get_map_knowledge_char(gc), + gc); } +#endif } } + } - // Alter colour if flashing the characters vision. - if (flash_colour && buffy[bufcount]) - { - buffy[bufcount + 1] = - observe_cell(gc) ? real_colour(flash_colour) - : DARKGREY; - } - else if (Options.target_range > 0 && buffy[bufcount] - && (grid_distance(you.pos(), gc) > Options.target_range - || !observe_cell(gc))) - { - buffy[bufcount + 1] = DARKGREY; + // Alter colour if flashing the characters vision. + if (flash_colour && buffy[bufcount]) + { + buffy[bufcount + 1] = + observe_cell(gc) ? real_colour(flash_colour) + : DARKGREY; + } + else if (Options.target_range > 0 && buffy[bufcount] + && (grid_distance(you.pos(), gc) > Options.target_range + || !observe_cell(gc))) + { + buffy[bufcount + 1] = DARKGREY; #ifdef USE_TILE - if (observe_cell(gc)) - tileb[bufcount + 1] |= TILE_FLAG_OOR; + if (observe_cell(gc)) + tileb[bufcount + 1] |= TILE_FLAG_OOR; #endif - } - - bufcount += 2; } + + bufcount += 2; } + } - update_exclusion_los(update_excludes); + update_exclusion_los(update_excludes); - // Leaving it this way because short flashes can occur in long ones, - // and this simply works without requiring a stack. - you.flash_colour = BLACK; + // Leaving it this way because short flashes can occur in long ones, + // and this simply works without requiring a stack. + you.flash_colour = BLACK; - // Avoiding unneeded draws when running. - if (draw) - { + // Avoiding unneeded draws when running. + const bool draw = #ifdef USE_TILE - tiles.set_need_redraw(); - tiles.load_dungeon(&tileb[0], crawl_view.vgrdc); - tiles.update_inventory(); + !is_resting() && +#endif + (!you.running || Options.travel_delay > -1 + || you.running.is_explore() && Options.explore_delay > -1) + && !you.asleep(); + + if (draw) + { +#ifdef USE_TILE + tiles.set_need_redraw(); + tiles.load_dungeon(&tileb[0], crawl_view.vgrdc); + tiles.update_inventory(); #else - you.last_view_update = you.num_turns; - puttext(crawl_view.viewp.x, crawl_view.viewp.y, - crawl_view.viewp.x + crawl_view.viewsz.x - 1, - crawl_view.viewp.y + crawl_view.viewsz.y - 1, - buffy); + you.last_view_update = you.num_turns; + puttext(crawl_view.viewp.x, crawl_view.viewp.y, + crawl_view.viewp.x + crawl_view.viewsz.x - 1, + crawl_view.viewp.y + crawl_view.viewsz.y - 1, + buffy); - update_monster_pane(); + update_monster_pane(); #endif - } } _debug_pane_bounds(); |