summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-13 12:34:32 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-13 13:06:24 +0100
commit5a674a9c4d6cbd66d9ab700b11c3d7f8082dd84a (patch)
tree96d0b4cac279cc92f7c9ccda34f923e0c7fc6d79 /crawl-ref/source
parentaffe43ff3d51dfd9ae8c87021ace90e7964d74cf (diff)
downloadcrawl-ref-5a674a9c4d6cbd66d9ab700b11c3d7f8082dd84a.tar.gz
crawl-ref-5a674a9c4d6cbd66d9ab700b11c3d7f8082dd84a.zip
Make tiles and non-tiles use the "same" screen_buffer_t buffy.
This change also gets rid of the ugly intermediate macroing.
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/view.cc129
-rw-r--r--crawl-ref/source/viewgeom.cc28
-rw-r--r--crawl-ref/source/viewgeom.h29
3 files changed, 84 insertions, 102 deletions
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index a2703490d5..bb60030779 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -775,61 +775,40 @@ static void player_view_update()
update_exclusion_los(update_excludes);
}
-#ifndef USE_TILE
-#define DRAW(kind) draw_##kind(&buffy[bufcount], gc, ep);
-#define DRAWFN(kind) \
- static void draw_##kind(screen_buffer_t *buffy, \
- const coord_def &gc, const coord_def &ep)
-#else
-#define DRAW(kind) draw_##kind(&buffy[bufcount], &tileb[bufcount], gc, ep)
-#define DRAWFN(kind) \
- static void draw_##kind(screen_buffer_t *buffy, tile_buffer_t *tileb, \
- const coord_def &gc, const coord_def &ep)
-#endif
-
-DRAWFN(unseen)
+static void draw_unseen(screen_buffer_t* buffy, const coord_def &gc)
{
- // off the map
+#ifndef USE_TILE
buffy[0] = ' ';
buffy[1] = DARKGREY;
-#ifdef USE_TILE
- tileidx_unseen(tileb[0], tileb[1], ' ', gc);
+#else
+ tileidx_unseen(buffy[0], buffy[1], ' ', gc);
#endif
}
-DRAWFN(outside_los)
+static void draw_outside_los(screen_buffer_t* buffy, const coord_def &gc)
{
+#ifndef USE_TILE
// Outside the env.show area.
buffy[0] = get_map_knowledge_char(gc);
buffy[1] = DARKGREY;
if (Options.colour_map)
buffy[1] = colour_code_map(gc, Options.item_colour);
-
-#ifdef USE_TILE
+#else 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);
- tileb[0] = fg;
- tileb[1] = bg | tile_unseen_flag(gc);
+ buffy[0] = fg;
+ buffy[1] = bg | tile_unseen_flag(gc);
#endif
}
-DRAWFN(player)
+static void draw_player(screen_buffer_t* buffy,
+ const coord_def& gc, const coord_def& ep)
{
-#ifdef USE_TILE
- if (player_in_mappable_area())
- {
- env.tile_bk_bg(gc) = env.tile_bg(ep);
- env.tile_bk_fg(gc) = env.tile_fg(ep);
- }
-
- tileb[0] = env.tile_fg(ep) = tileidx_player(you.char_class);
- tileb[1] = env.tile_bg(ep);
-#endif
-
+#ifndef USE_TILE
// Player overrides everything in cell.
buffy[0] = you.symbol;
buffy[1] = you.colour;
@@ -840,42 +819,52 @@ DRAWFN(player)
else
buffy[1] = CYAN;
}
+#else
+ if (player_in_mappable_area())
+ {
+ env.tile_bk_bg(gc) = env.tile_bg(ep);
+ env.tile_bk_fg(gc) = env.tile_fg(ep);
+ }
+
+ buffy[0] = env.tile_fg(ep) = tileidx_player(you.char_class);
+ buffy[1] = env.tile_bg(ep);
+#endif
}
-DRAWFN(los)
+static void draw_los(screen_buffer_t* buffy,
+ const coord_def& gc, const coord_def& ep)
{
+#ifndef USE_TILE
show_type object = env.show(ep);
unsigned short colour = object.colour;
unsigned ch;
-
get_symbol(gc, object, &ch, &colour);
-
buffy[0] = ch;
buffy[1] = colour;
-#ifdef USE_TILE
- tileb[0] = env.tile_fg(ep);
- tileb[1] = env.tile_bg(ep);
+#else
+ buffy[0] = env.tile_fg(ep);
+ buffy[1] = env.tile_bg(ep);
#endif
}
-DRAWFN(los_backup)
+static void draw_los_backup(screen_buffer_t* buffy,
+ const coord_def& gc, const coord_def& ep)
{
- // Show map.
+#ifndef USE_TILE
buffy[0] = get_map_knowledge_char(gc);
buffy[1] = DARKGREY;
if (Options.colour_map)
buffy[1] = colour_code_map(gc, Options.item_colour);
-
-#ifdef USE_TILE
+#else
if (env.tile_bk_fg(gc) != 0
|| env.tile_bk_bg(gc) != 0)
{
- tileb[0] = env.tile_bk_fg(gc);
- tileb[1] = env.tile_bk_bg(gc) | tile_unseen_flag(gc);
+ buffy[0] = env.tile_bk_fg(gc);
+ buffy[1] = env.tile_bk_bg(gc) | tile_unseen_flag(gc);
}
else
- tileidx_unseen(tileb[0], tileb[1], get_map_knowledge_char(gc), gc);
+ tileidx_unseen(buffy[0], buffy[1], get_map_knowledge_char(gc), gc);
#endif
}
@@ -897,10 +886,6 @@ void viewwindow(bool do_updates)
screen_buffer_t *buffy(crawl_view.vbuf);
-#ifdef USE_TILE
- tile_buffer_t *tileb(crawl_view.tbuf);
-#endif
-
calc_show_los();
#ifdef USE_TILE
@@ -938,34 +923,37 @@ void viewwindow(bool do_updates)
const coord_def ep = view2show(grid2view(gc));
if (!map_bounds(gc))
- DRAW(unseen);
+ draw_unseen(&buffy[bufcount], gc);
else if (!crawl_view.in_grid_los(gc))
- DRAW(outside_los);
+ draw_outside_los(&buffy[bufcount], gc);
else if (gc == you.pos() &&
!crawl_state.arena && !crawl_state.arena_suspended)
{
- DRAW(player);
+ draw_player(&buffy[bufcount], gc, ep);
}
else if (observe_cell(gc))
- DRAW(los);
+ draw_los(&buffy[bufcount], gc, ep);
else
- DRAW(los_backup);
+ draw_los_backup(&buffy[bufcount], gc, ep);
// Alter colour if flashing the characters vision.
if (flash_colour)
{
+#ifndef USE_TILE
buffy[bufcount + 1] = observe_cell(gc) ? real_colour(flash_colour)
: DARKGREY;
+#endif
}
else
{
bool out_of_range = Options.target_range > 0
&& (grid_distance(you.pos(), gc) > Options.target_range);
+#ifndef USE_TILE
if (!observe_cell(gc) || out_of_range)
buffy[bufcount + 1] = DARKGREY;
-#ifdef USE_TILE
+#else
if (out_of_range)
- tileb[bufcount + 1] |= TILE_FLAG_OOR;
+ buffy[bufcount + 1] |= TILE_FLAG_OOR;
#endif
}
}
@@ -974,22 +962,12 @@ void viewwindow(bool do_updates)
// and this simply works without requiring a stack.
you.flash_colour = BLACK;
- // Avoiding unneeded draws when running.
- 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();
-
- if (draw)
+ // TODO: move this before the loop
+ if ((!you.running || Options.travel_delay > -1
+ || you.running.is_explore() && Options.explore_delay > -1)
+ && !you.asleep())
{
-#ifdef USE_TILE
- tiles.set_need_redraw();
- tiles.load_dungeon(&tileb[0], crawl_view.vgrdc);
- tiles.update_inventory();
-#else
+#ifndef USE_TILE
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,
@@ -997,6 +975,13 @@ void viewwindow(bool do_updates)
buffy);
update_monster_pane();
+#else
+ if (!is_resting())
+ {
+ tiles.set_need_redraw();
+ tiles.load_dungeon(&buffy[0], crawl_view.vgrdc);
+ tiles.update_inventory();
+ }
#endif
}
diff --git a/crawl-ref/source/viewgeom.cc b/crawl-ref/source/viewgeom.cc
index 56542cd849..0ee155b3cc 100644
--- a/crawl-ref/source/viewgeom.cc
+++ b/crawl-ref/source/viewgeom.cc
@@ -220,6 +220,25 @@ class _mlist_col_layout : public _layout
}
};
+//////////////////////////////////////////////////////////////////////////////
+// crawl_view_buffer
+
+crawl_view_buffer::crawl_view_buffer()
+ : buffer(NULL)
+{
+}
+
+crawl_view_buffer::~crawl_view_buffer()
+{
+ delete [] buffer;
+}
+
+void crawl_view_buffer::size(const coord_def &sz)
+{
+ delete [] buffer;
+ buffer = new screen_buffer_t [ sz.x * sz.y * 2 ];
+}
+
// ----------------------------------------------------------------------
// crawl_view_geometry
// ----------------------------------------------------------------------
@@ -231,11 +250,7 @@ crawl_view_geometry::crawl_view_geometry()
msgp(1, viewp.y + viewsz.y), msgsz(80, 7),
mlistp(hudp.x, hudp.y + hudsz.y),
mlistsz(hudsz.x, msgp.y - mlistp.y),
- vbuf(),
-#ifdef USE_TILE
- tbuf(),
-#endif
- vgrdc(), viewhalfsz(), glos1(), glos2(),
+ vbuf(), vgrdc(), viewhalfsz(), glos1(), glos2(),
vlos1(), vlos2(), mousep(), last_player_pos()
{
}
@@ -244,9 +259,6 @@ void crawl_view_geometry::init_view()
{
viewhalfsz = viewsz / 2;
vbuf.size(viewsz);
-#ifdef USE_TILE
- tbuf.size(viewsz);
-#endif
set_player_at(you.pos(), true);
}
diff --git a/crawl-ref/source/viewgeom.h b/crawl-ref/source/viewgeom.h
index 72e68ce3ec..6913849679 100644
--- a/crawl-ref/source/viewgeom.h
+++ b/crawl-ref/source/viewgeom.h
@@ -1,29 +1,19 @@
#ifndef VIEWGEOM_H
#define VIEWGEOM_H
-template<typename T>
class crawl_view_buffer
{
public:
- crawl_view_buffer() : buffer(NULL) {}
- ~crawl_view_buffer() { delete [] buffer; }
-
- void size(const coord_def &sz)
- {
- delete [] buffer;
- buffer = new T[sz.x * sz.y * 2];
- }
-
- operator T * () { return (buffer); }
+ crawl_view_buffer();
+ ~crawl_view_buffer();
+ void size(const coord_def &size);
+ operator screen_buffer_t * () { return (buffer); }
+ void draw();
private:
- T *buffer;
+ screen_buffer_t *buffer;
};
-#ifdef USE_TILE
-typedef unsigned int tile_buffer_t;
-#endif
-
struct crawl_view_geometry
{
public:
@@ -38,12 +28,7 @@ public:
coord_def mlistp; // Left-top pos of the monster list.
coord_def mlistsz; // Size of the monster list.
- crawl_view_buffer<screen_buffer_t> vbuf;
- // Buffer for drawing the main game map.
-#ifdef USE_TILE
- crawl_view_buffer<tile_buffer_t> tbuf;
- // Tiles buffer.
-#endif
+ crawl_view_buffer vbuf; // Buffer for drawing the main game map.
coord_def vgrdc; // What grid pos is at the centre of the view
// usually you.pos().