From b305accdee3ce085e65639f874e59f9592f234d3 Mon Sep 17 00:00:00 2001 From: ennewalker Date: Sat, 19 Jan 2008 03:55:41 +0000 Subject: Tile support to show travel exclusions. Added status graphic for poisoned monsters. Changing tile storage type from unsigned short to unsigned int to have room for more flag bits. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3300 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/externs.h | 8 +- crawl-ref/source/guic-x11.cc | 2 +- crawl-ref/source/rltiles/dc-misc.txt | 4 + crawl-ref/source/rltiles/dc-misc/heart.bmp | Bin 2102 -> 2102 bytes crawl-ref/source/rltiles/dc-misc/poison.bmp | Bin 0 -> 2102 bytes .../source/rltiles/dc-misc/travel_exclusion.bmp | Bin 0 -> 2102 bytes crawl-ref/source/tile1.cc | 32 ++-- crawl-ref/source/tile2.cc | 172 ++++++++++++--------- crawl-ref/source/tiles.h | 14 +- crawl-ref/source/travel.cc | 2 +- crawl-ref/source/travel.h | 1 + crawl-ref/source/view.cc | 2 +- 12 files changed, 146 insertions(+), 91 deletions(-) create mode 100644 crawl-ref/source/rltiles/dc-misc/poison.bmp create mode 100644 crawl-ref/source/rltiles/dc-misc/travel_exclusion.bmp (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index fef107e412..42faecea03 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -1360,12 +1360,12 @@ public: #ifdef USE_TILE // indexed by grid coords - FixedArray tile_bk_fg; // tile fg - FixedArray tile_bk_bg; // tile bg + FixedArray tile_bk_fg; // tile fg + FixedArray tile_bk_bg; // tile bg FixedArray tile_flavor; // indexed by (show-1) coords - FixedArray tile_fg; - FixedArray tile_bg; + FixedArray tile_fg; + FixedArray tile_bg; #endif FixedVector< cloud_struct, MAX_CLOUDS > cloud; // cloud list diff --git a/crawl-ref/source/guic-x11.cc b/crawl-ref/source/guic-x11.cc index 941ac914ad..564754e3ab 100644 --- a/crawl-ref/source/guic-x11.cc +++ b/crawl-ref/source/guic-x11.cc @@ -249,7 +249,7 @@ void WinClass::create(char *name) LeaveWindowMask | EnterWindowMask | StructureNotifyMask ); move(ox, oy); - XStoreName(display, win, CRAWL VERSION); + XStoreName(display, win, CRAWL " " VERSION); } else resize(0,0); diff --git a/crawl-ref/source/rltiles/dc-misc.txt b/crawl-ref/source/rltiles/dc-misc.txt index 5ec32a2160..ac0233d764 100644 --- a/crawl-ref/source/rltiles/dc-misc.txt +++ b/crawl-ref/source/rltiles/dc-misc.txt @@ -50,7 +50,10 @@ sink_mask SINK_MASK cursor CURSOR cursor_red CURSOR2 cursor_green CURSOR3 +%rim 1 heart HEART +poison POISON +%rim 0 may_stab_brand MAY_STAB_BRAND stab_brand STAB_BRAND unseen PLAYER @@ -65,6 +68,7 @@ txt3 TEXT_PARTS_E txt4 TEXT_DOLLS_E something_under SOMETHING_UNDER error ERROR +travel_exclusion TRAVEL_EXCLUSION %rim 1 todo TODO %rim 0 diff --git a/crawl-ref/source/rltiles/dc-misc/heart.bmp b/crawl-ref/source/rltiles/dc-misc/heart.bmp index 4efc69da69..fa3a95fdc9 100644 Binary files a/crawl-ref/source/rltiles/dc-misc/heart.bmp and b/crawl-ref/source/rltiles/dc-misc/heart.bmp differ diff --git a/crawl-ref/source/rltiles/dc-misc/poison.bmp b/crawl-ref/source/rltiles/dc-misc/poison.bmp new file mode 100644 index 0000000000..35fbd445bb Binary files /dev/null and b/crawl-ref/source/rltiles/dc-misc/poison.bmp differ diff --git a/crawl-ref/source/rltiles/dc-misc/travel_exclusion.bmp b/crawl-ref/source/rltiles/dc-misc/travel_exclusion.bmp new file mode 100644 index 0000000000..622f07f142 Binary files /dev/null and b/crawl-ref/source/rltiles/dc-misc/travel_exclusion.bmp differ diff --git a/crawl-ref/source/tile1.cc b/crawl-ref/source/tile1.cc index 374ad62cde..0fe3771d50 100644 --- a/crawl-ref/source/tile1.cc +++ b/crawl-ref/source/tile1.cc @@ -18,11 +18,12 @@ #include "terrain.h" #include "tiles.h" #include "tiledef-p.h" +#include "travel.h" #include "view.h" // tile index cache to reduce tileidx() calls -static FixedArray < unsigned short, GXM, GYM > tile_dngn; -// // gv backup +static FixedArray < unsigned int, GXM, GYM > tile_dngn; +// gv backup static FixedArray < unsigned char, GXM, GYM > gv_now; bool is_bazaar() @@ -795,24 +796,28 @@ int tileidx_monster_base(int mon_idx, bool detected) int tileidx_monster(int mon_idx, bool detected) { int ch = tileidx_monster_base(mon_idx, detected); + const monsters* mons = &menv[mon_idx]; - if(mons_flies(&menv[mon_idx])) + if (mons_flies(mons)) ch |= TILE_FLAG_FLYING; - if(menv[mon_idx].has_ench(ENCH_HELD)) + if (mons->has_ench(ENCH_HELD)) ch |= TILE_FLAG_NET; + if (mons->has_ench(ENCH_POISON)) + ch |= TILE_FLAG_POISON; - if(mons_friendly(&menv[mon_idx])) + if (mons_friendly(mons)) { ch |= TILE_FLAG_PET; } - else if (mons_looks_stabbable(&menv[mon_idx])) + else if (mons_looks_stabbable(mons)) { ch |= TILE_FLAG_STAB; } - else if (mons_looks_distracted(&menv[mon_idx])) + else if (mons_looks_distracted(mons)) { ch |= TILE_FLAG_MAY_STAB; } + return ch; } @@ -2008,7 +2013,7 @@ int tileidx_zap(int color) // Plus modify wall tile index depending on // 1: floor/wall flavor in 2D mode // 2: connectivity in 3D mode -void finalize_tile(short unsigned int *tile, bool is_special, +void finalize_tile(unsigned int *tile, bool is_special, char wall_flv, char floor_flv, char special_flv) { int orig = (*tile) & TILE_FLAG_MASK; @@ -3803,7 +3808,7 @@ void tile_draw_rays(bool resetCount) tileRayCount = 0; } -void tile_finish_dngn(short unsigned int *tileb, int cx, int cy) +void tile_finish_dngn(unsigned int *tileb, int cx, int cy) { int x, y; int count = 0; @@ -3836,12 +3841,19 @@ void tile_finish_dngn(short unsigned int *tileb, int cx, int cy) wall_flv, floor_flv, special_flv); finalize_tile(&tileb[count+1], is_special, wall_flv, floor_flv, special_flv); + + const coord_def gc(gx, gy); + if (is_excluded(gc)) + { + tileb[count+1] |= TILE_FLAG_TRAVEL_EX; + } + count += 2; } } } -void tile_draw_dungeon(short unsigned int *tileb) +void tile_draw_dungeon(unsigned int *tileb) { tile_finish_dngn(tileb, you.x_pos, you.y_pos); TileDrawDungeon(tileb); diff --git a/crawl-ref/source/tile2.cc b/crawl-ref/source/tile2.cc index e5b9ebd716..23ecf4fa6a 100644 --- a/crawl-ref/source/tile2.cc +++ b/crawl-ref/source/tile2.cc @@ -75,9 +75,9 @@ void tile_set_force_redraw_inv(bool redraw) force_redraw_inv = redraw; } -static unsigned short int t1buf[TILE_DAT_XMAX+2][TILE_DAT_YMAX+2], +static unsigned int t1buf[TILE_DAT_XMAX+2][TILE_DAT_YMAX+2], t2buf[TILE_DAT_XMAX+2][TILE_DAT_YMAX+2]; -static short unsigned int tb_bk[TILE_DAT_YMAX*TILE_DAT_XMAX*2]; +static unsigned int tb_bk[TILE_DAT_YMAX*TILE_DAT_XMAX*2]; #define MAX_ITEMLIST 200 int itemlist[MAX_ITEMLIST]; @@ -424,63 +424,51 @@ void lift_tcache(int ix, int kind, int hash){ // If not found, compose and cache it static int tcache_find_id_normal(int kind, int *fg, int *bg, int *is_new) { - unsigned int id[4]; - int i; int hash = 0; // Don't use hash - int kind_n_hash = kind*tc_hash + hash; - int nlayer = tcache_nlayer_normal[kind]; + int kind_n_hash = kind * tc_hash + hash; + tile_cache *tc = tcache[kind]; tile_cache *tc0 = &tc[tcache_head[kind_n_hash]]; -#if DEBUG - int search_count =0; -#endif *is_new=0; - for(i=0;inext; - if(tc0->id[0] == id[0]) break; + if ((int)tc0->id[0] == fg[0] && (int)tc0->id[1] == bg[0]) + break; - if(tc0->id[0]==0 || next == NULL) + if ((int)tc0->id[0] == 0 || next == NULL) { - //end of used cache + //end of used cache *is_new = 1; tcache_compose_normal(tc0->idx, fg, bg); - for(i=0;iid[i] = id[i]; + tc0->id[0] = fg[0]; + tc0->id[1] = bg[0]; break; } tc0 = next; -#if DEBUG - search_count++; -#endif } lift_tcache(tc0->idx, kind, hash); -#if DEBUG -//DEBUGLOG("%d\n",search_count); -#endif - return tc0->idx; } /*** overlay a tile onto an exsisting image with transpalency operation */ void tcache_overlay(img_type img, int idx, - int tile, int region, int *copy, char *mask) + int tile, int region, int *copy, char *mask, unsigned int shift_left = 0) { int x0, y0; - int sx= region_sx_normal[region]; - int sy= region_sy_normal[region]; - int wx= region_wx_normal[region]; - int wy= region_wy_normal[region]; - int ox=0; - int oy=0; + int sx = region_sx_normal[region] + shift_left; + int sy = region_sy_normal[region]; + int wx = region_wx_normal[region] - shift_left; + int wy = region_wy_normal[region]; + int ox = 0; + int oy = 0; img_type src = TileImg; - int uy=wy; + int uy = wy; tile &= TILE_FLAG_MASK; @@ -489,26 +477,27 @@ void tcache_overlay(img_type img, int idx, if (mask != NULL) { - if(*copy ==2) + if (*copy ==2) + { ImgCopyMaskedH(src, x0 + sx, y0 + sy, wx, wy, - img, ox, oy + idx*uy, mask); + img, ox, oy + idx*uy, mask); + } else + { ImgCopyMasked(src, x0 + sx, y0 + sy, wx, wy, - img, ox, oy + idx*uy, mask); - *copy = 0; - return; + img, ox, oy + idx*uy, mask); + } } // Hack: hilite rim color - else if(*copy ==2) + else if (*copy ==2) { - *copy=0; ImgCopyH(src, x0 + sx, y0 + sy, wx, wy, - img, ox, oy + idx*uy, *copy); - return; - } else + img, ox, oy + idx*uy, *copy); + } + else { ImgCopy(src, x0 + sx, y0 + sy, wx, wy, - img, ox, oy + idx*uy, *copy); + img, ox, oy + idx*uy, *copy); } *copy = 0; } @@ -691,71 +680,116 @@ int sink_mask_tile(int bg, int fg) } //normal -void tcache_compose_normal(int ix, int *fg, int *bg){ +void tcache_compose_normal(int ix, int *fg, int *bg) +{ int bbg; int new_bg; - int c=1; - int fg0=fg[0]; - int bg0=bg[0]; + int c = 1; + int fg0 = fg[0]; + int bg0 = bg[0]; int sink; img_type tc_img = tcache_image[TCACHE0_NORMAL]; get_bbg(bg0, &new_bg, &bbg); - if(bbg) tcache_overlay(tc_img, ix, bbg, TREGION_0_NORMAL, &c, NULL); - if(new_bg) tcache_overlay(tc_img, ix, new_bg, TREGION_0_NORMAL, &c, NULL); + if (bbg) + tcache_overlay(tc_img, ix, bbg, TREGION_0_NORMAL, &c, NULL); + if(new_bg) + tcache_overlay(tc_img, ix, new_bg, TREGION_0_NORMAL, &c, NULL); - //Tile cursor - if(bg0&TILE_FLAG_CURSOR) + // Tile cursor + if (bg0 & TILE_FLAG_CURSOR) { - int type = ((bg0&TILE_FLAG_CURSOR) == TILE_FLAG_CURSOR1) ? + int type = ((bg0 & TILE_FLAG_CURSOR) == TILE_FLAG_CURSOR1) ? TILE_CURSOR : TILE_CURSOR2; - if ((bg0&TILE_FLAG_CURSOR) == TILE_FLAG_CURSOR3) type = TILE_CURSOR3; + if ((bg0 & TILE_FLAG_CURSOR) == TILE_FLAG_CURSOR3) + type = TILE_CURSOR3; tcache_overlay(tc_img, ix, type, TREGION_0_NORMAL, &c, NULL); - if (type != TILE_CURSOR3) c = 2;// Hilite + if (type != TILE_CURSOR3) + c = 2; + } + + // Apply the travel exclusion under the foreground if the cell is + // visible. It will be applied later if the cell is unseen. + if ((bg0 & TILE_FLAG_TRAVEL_EX) && !(bg0 & TILE_FLAG_UNSEEN)) + { + tcache_overlay(tc_img, ix, TILE_TRAVEL_EXCLUSION, TREGION_0_NORMAL, &c, + NULL); } if (bg0 & TILE_FLAG_RAY) tcache_overlay(tc_img, ix, TILE_RAY_MESH, TREGION_0_NORMAL, &c, NULL); - if(fg0) + if (fg0) { sink = sink_mask_tile(bg0, fg0); if (sink) { - int flag=2; + int flag = 2; register_tile_mask(sink, TREGION_0_NORMAL, &flag, sink_mask); tcache_overlay(tc_img, ix, fg0, TREGION_0_NORMAL, &c, sink_mask); } else + { tcache_overlay(tc_img, ix, fg0, TREGION_0_NORMAL, &c, NULL); + } } if (fg0 & TILE_FLAG_NET) tcache_overlay(tc_img, ix, TILE_TRAP_NET, TREGION_0_NORMAL, &c, NULL); - if(fg0 & TILE_FLAG_S_UNDER) + if (fg0 & TILE_FLAG_S_UNDER) + { tcache_overlay(tc_img, ix, TILE_SOMETHING_UNDER, - TREGION_0_NORMAL, &c, NULL); - - //Pet mark - if((fg0&TILE_FLAG_MAY_STAB) == TILE_FLAG_PET) - tcache_overlay(tc_img, ix, TILE_HEART, TREGION_0_NORMAL, &c, NULL); + TREGION_0_NORMAL, &c, NULL); + } - if((fg0&TILE_FLAG_MAY_STAB) == TILE_FLAG_STAB) + // Pet mark + int status_shift = 0; + if ((fg0 & TILE_FLAG_MAY_STAB) == TILE_FLAG_PET) + { + tcache_overlay(tc_img, ix, TILE_HEART, TREGION_0_NORMAL, &c, NULL); + status_shift += 10; + } + else if ((fg0 & TILE_FLAG_MAY_STAB) == TILE_FLAG_STAB) + { tcache_overlay(tc_img, ix, TILE_STAB_BRAND, TREGION_0_NORMAL, &c, NULL); - else if((fg0&TILE_FLAG_MAY_STAB) == TILE_FLAG_MAY_STAB) + status_shift += 8; + } + else if ((fg0 & TILE_FLAG_MAY_STAB) == TILE_FLAG_MAY_STAB) + { tcache_overlay(tc_img, ix, TILE_MAY_STAB_BRAND, TREGION_0_NORMAL, &c, NULL); + status_shift += 5; + } + + if (fg0 & TILE_FLAG_POISON) + { + tcache_overlay(tc_img, ix, TILE_POISON, TREGION_0_NORMAL, &c, NULL, + status_shift); + status_shift += 5; + } - if(bg0&TILE_FLAG_UNSEEN) + if (bg0 & TILE_FLAG_UNSEEN) + { tcache_overlay(tc_img, ix, TILE_MESH, TREGION_0_NORMAL, &c, NULL); + } + + if (bg0 & TILE_FLAG_MM_UNSEEN) + { + tcache_overlay(tc_img, ix, TILE_MAGIC_MAP_MESH, TREGION_0_NORMAL, &c, + NULL); + } + + if ((bg0 & TILE_FLAG_TRAVEL_EX) && (bg0 & TILE_FLAG_UNSEEN)) + { + tcache_overlay(tc_img, ix, TILE_TRAVEL_EXCLUSION, TREGION_0_NORMAL, &c, + NULL); + } - if(bg0&TILE_FLAG_MM_UNSEEN) - tcache_overlay(tc_img, ix, TILE_MAGIC_MAP_MESH, TREGION_0_NORMAL, &c, NULL); } // Tile cursor @@ -774,7 +808,7 @@ void TileDrawBolt(int x, int y, int fg){ update_single_grid(x, y); } -void StoreDungeonView(short unsigned int *tileb) +void StoreDungeonView(unsigned int *tileb) { int x, y; int count = 0; @@ -791,7 +825,7 @@ void StoreDungeonView(short unsigned int *tileb) }} } -void LoadDungeonView(short unsigned int *tileb) +void LoadDungeonView(unsigned int *tileb) { int x, y; int count = 0; @@ -814,7 +848,7 @@ void LoadDungeonView(short unsigned int *tileb) } //Draw the tile screen once and for all -void TileDrawDungeon(short unsigned int *tileb) +void TileDrawDungeon(unsigned int *tileb) { int x, y, kind; if(!TileImg) @@ -843,7 +877,7 @@ void TileDrawDungeon(short unsigned int *tileb) void TileDrawFarDungeon(int cx, int cy) { - short unsigned int tb[TILE_DAT_YMAX*TILE_DAT_XMAX*2]; + unsigned int tb[TILE_DAT_YMAX*TILE_DAT_XMAX*2]; int count = 0; for(int y=0; y* coords = NULL); diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index d4a92bc38f..3a26d599d4 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -4377,7 +4377,7 @@ bool view_update() void viewwindow(bool draw_it, bool do_updates) { #ifdef USE_TILE - std::vector tileb( + std::vector tileb( crawl_view.viewsz.y * crawl_view.viewsz.x * 2); #endif screen_buffer_t *buffy(crawl_view.vbuf); -- cgit v1.2.3-54-g00ecf