diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-03-23 21:06:01 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-03-23 21:06:01 +0000 |
commit | 9e511702e814c94093bb77ae460f8be8b7a49b16 (patch) | |
tree | e133213151a9871ed51a98f7356caab2f43639db /crawl-ref/source/tile2.cc | |
parent | 2055942d4ba70adfd48f939b2a6d140f2329a2b6 (diff) | |
download | crawl-ref-9e511702e814c94093bb77ae460f8be8b7a49b16.tar.gz crawl-ref-9e511702e814c94093bb77ae460f8be8b7a49b16.zip |
Refix tiles monster brands to show the heart for friendlies.
And another huge code cleanup.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3838 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/tile2.cc')
-rw-r--r-- | crawl-ref/source/tile2.cc | 1059 |
1 files changed, 534 insertions, 525 deletions
diff --git a/crawl-ref/source/tile2.cc b/crawl-ref/source/tile2.cc index a428ed3157..1da3ced842 100644 --- a/crawl-ref/source/tile2.cc +++ b/crawl-ref/source/tile2.cc @@ -58,19 +58,19 @@ extern TileRegionClass *region_item2; //Internal static img_type DollCacheImg; -static void tile_draw_grid(int kind, int xx, int yy); -static void clear_tcache(); -static void init_tcache(); -static void register_tile_mask(int tile, int region, int *cp, - char *ms, bool smalltile = false); -static void tcache_compose_normal(int ix, int *fg, int *bg); +static void _tile_draw_grid(int kind, int xx, int yy); +static void _clear_tcache(); +static void _init_tcache(); +static void _register_tile_mask(int tile, int region, int *cp, + char *ms, bool smalltile = false); +static void _tcache_compose_normal(int ix, int *fg, int *bg); -static void mcache_init(); +static void _mcache_init(); //Internal variables static bool force_redraw_tile = false; -static bool force_redraw_inv = false; +static bool force_redraw_inv = false; void tile_set_force_redraw_tiles(bool redraw) { @@ -83,7 +83,7 @@ void tile_set_force_redraw_inv(bool redraw) } static unsigned int t1buf[TILE_DAT_XMAX+2][TILE_DAT_YMAX+2], - t2buf[TILE_DAT_XMAX+2][TILE_DAT_YMAX+2]; + t2buf[TILE_DAT_XMAX+2][TILE_DAT_YMAX+2]; static unsigned int tb_bk[TILE_DAT_YMAX*TILE_DAT_XMAX*2]; #define MAX_ITEMLIST 200 @@ -95,11 +95,11 @@ int itemlist_iflag[MAX_ITEMLIST]; int itemlist_flag = -1; int itemlist_n=0; -static int wall_flavors = 0; -static int floor_flavors = 0; +static int wall_flavors = 0; +static int floor_flavors = 0; static int special_flavors = 0; -static int wall_tile_idx = 0; -static int floor_tile_idx = 0; +static int wall_tile_idx = 0; +static int floor_tile_idx = 0; static int special_tile_idx = 0; int get_num_wall_flavors() @@ -248,22 +248,23 @@ void TileInit() int x, y, k; textcolor(WHITE); - TileImg = ImgLoadFileSimple("tile"); + TileImg = ImgLoadFileSimple("tile"); PlayerImg = ImgLoadFileSimple("player"); - WallImg = ImgLoadFileSimple("wall2d"); + WallImg = ImgLoadFileSimple("wall2d"); if (!TileImg) { - cprintf("Main tile not initialized\n"); - getch(); - end(-1); + cprintf("Main tile not initialized\n"); + getch(); + end(-1); } ImgSetTransparentPix(TileImg); - if (ImgWidth(TileImg)!= TILE_X * TILE_PER_ROW || - ImgHeight(TileImg) < TILE_Y*( (TILE_TOTAL + TILE_PER_ROW -1)/TILE_PER_ROW)) + if (ImgWidth(TileImg)!= TILE_X * TILE_PER_ROW + || ImgHeight(TileImg) < + TILE_Y * ((TILE_TOTAL + TILE_PER_ROW -1)/TILE_PER_ROW) ) { cprintf("Main tile size invalid\n"); getch(); @@ -304,34 +305,35 @@ void TileInit() tcache_head = (int *)malloc(sizeof(int)*tcache_kind*tc_hash); - for(k=0;k<tcache_kind;k++) + for (k = 0; k < tcache_kind; k++) { screen_tcach_idx[k]= (int *)malloc(sizeof(int)* tile_xmax * tile_ymax); tcache[k] = (tile_cache *)malloc(sizeof(tile_cache)*max_tcache); - for(x=0;x<tile_xmax * tile_ymax;x++) - screen_tcach_idx[k][x] = -1; + for (x = 0; x < tile_xmax * tile_ymax; x++) + screen_tcach_idx[k][x] = -1; } sink_mask = (char *)malloc(TILE_X*TILE_Y); - init_tcache(); + _init_tcache(); DollCacheImg = ImgCreateSimple(TILE_X, TILE_Y); - for(x=0;x<TILE_DAT_XMAX+2;x++){ - for(y=0;y<TILE_DAT_YMAX+2;y++){ - t1buf[x][y]=0; - t2buf[x][y]=TILE_DNGN_UNSEEN|TILE_FLAG_UNSEEN; - }} + for (x = 0; x < TILE_DAT_XMAX + 2; x++) + { + for (y = 0; y < TILE_DAT_YMAX + 2; y++) + { + t1buf[x][y] = 0; + t2buf[x][y] = TILE_DNGN_UNSEEN|TILE_FLAG_UNSEEN; + } + } force_redraw_tile = false; - mcache_init(); + _mcache_init(); - for(x=0; x<MAX_ITEMLIST;x++) - { - itemlist[x]=itemlist_num[x]=itemlist_key[x]=itemlist_idx[x]=0; - } + for (x = 0; x < MAX_ITEMLIST; x++) + itemlist[x] = itemlist_num[x] = itemlist_key[x] = itemlist_idx[x] = 0; } void TileResizeScreen(int x0, int y0) @@ -341,7 +343,7 @@ void TileResizeScreen(int x0, int y0) tile_ymax = y0; max_tcache = 4*tile_xmax*tile_ymax; - for(k=0;k<tcache_kind;k++) + for (k = 0; k < tcache_kind; k++) { free(screen_tcach_idx[k]); screen_tcach_idx[k]= (int *)malloc(sizeof(int)* tile_xmax * tile_ymax); @@ -349,20 +351,18 @@ void TileResizeScreen(int x0, int y0) free(tcache[k]); tcache[k] = (tile_cache *)malloc(sizeof(tile_cache)*max_tcache); - for(x=0;x<tile_xmax * tile_ymax;x++) - { + for (x = 0; x < tile_xmax * tile_ymax; x++) screen_tcach_idx[k][x] = -1; - } } - clear_tcache(); + _clear_tcache(); crawl_view.viewsz.x = tile_xmax; crawl_view.viewsz.y = tile_ymax; crawl_view.vbuf.size(crawl_view.viewsz); } -void clear_tcache() +void _clear_tcache() { - for(int k = 0; k < tcache_kind; k++) + for (int k = 0; k < tcache_kind; k++) { tile_cache *tc = tcache[k]; @@ -370,10 +370,10 @@ void clear_tcache() for (int h = 0; h < tc_hash; h++) { int i_start = (max_tcache*h)/tc_hash; - int i_end = (max_tcache*(h+1))/tc_hash -1; + int i_end = (max_tcache*(h+1))/tc_hash - 1; tcache_head[k*tc_hash + h] = i_start; - for(int i = i_start; i <= i_end; i++) + for (int i = i_start; i <= i_end; i++) { tc[i].id[1] = tc[i].id[0] = 0; tc[i].idx = i; @@ -381,6 +381,7 @@ void clear_tcache() tc[i].prev = NULL; else tc[i].prev = &tc[i-1]; + if (i == i_end) tc[i].next = NULL; else @@ -390,39 +391,43 @@ void clear_tcache() } } -void init_tcache(){ +void _init_tcache() +{ int k; - clear_tcache(); + _clear_tcache(); tcache_image = (img_type *)malloc(sizeof(img_type)*tcache_kind); - for(k=0;k<tcache_kind;k++) + for (k = 0; k < tcache_kind; k++) { int wx = tcache_wx_normal[k]; int wy = tcache_wy_normal[k]; tcache_image[k] = ImgCreateSimple(wx, max_tcache*wy); } - } // Move a cache to the top of pointer string // to shorten the search time -void lift_tcache(int ix, int kind, int hash){ +void lift_tcache(int ix, int kind, int hash) +{ int kind_n_hash = kind * tc_hash + hash; int head_old=tcache_head[kind_n_hash]; tile_cache *tc = tcache[kind]; tile_cache *p = tc[ix].prev; tile_cache *n = tc[ix].next; - ASSERT(ix<max_tcache); - ASSERT(head_old<max_tcache); - ASSERT(kind<tcache_kind); - ASSERT(hash<tc_hash); + ASSERT(ix < max_tcache); + ASSERT(head_old < max_tcache); + ASSERT(kind < tcache_kind); + ASSERT(hash < tc_hash); - if(ix == head_old) return; - if(p!=NULL) p->next = n; - if(n!=NULL) n->prev = p; + if (ix == head_old) + return; + if (p!=NULL) + p->next = n; + if (n!=NULL) + n->prev = p; tcache_head[kind_n_hash] = ix; tc[head_old].prev = &tc[ix]; @@ -431,7 +436,7 @@ void lift_tcache(int ix, int kind, int hash){ // Find cached image of fg+bg // If not found, compose and cache it -static int tcache_find_id_normal(int kind, int *fg, int *bg, int *is_new) +static int _tcache_find_id_normal(int kind, int *fg, int *bg, int *is_new) { int hash = 0; // Don't use hash int kind_n_hash = kind * tc_hash + hash; @@ -441,7 +446,8 @@ static int tcache_find_id_normal(int kind, int *fg, int *bg, int *is_new) *is_new=0; - while(1){ + while (true) + { tile_cache *next = tc0->next; if ((int)tc0->id[0] == fg[0] && (int)tc0->id[1] == bg[0]) @@ -451,7 +457,7 @@ static int tcache_find_id_normal(int kind, int *fg, int *bg, int *is_new) { //end of used cache *is_new = 1; - tcache_compose_normal(tc0->idx, fg, bg); + _tcache_compose_normal(tc0->idx, fg, bg); tc0->id[0] = fg[0]; tc0->id[1] = bg[0]; break; @@ -543,65 +549,74 @@ void tcache_overlay_player(img_type img, int dx, int dy, *copy = 0; } -/** overlay a tile onto an exsisting image with transpalency operation */ -void register_tile_mask(int tile, int region, int *copy, - char *mask, bool smalltile) +/* overlay a tile onto an exsisting image with transpalency operation */ +void _register_tile_mask(int tile, int region, int *copy, + char *mask, bool smalltile) { int x0, y0, x, y; - 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]; + 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 ux = wx; + int uy = wy; img_type src = TileImg; - int ux=wx; - int uy=wy; - + tile &= TILE_FLAG_MASK; - x0 = (tile % TILE_PER_ROW)*TILE_X; - y0 = (tile / TILE_PER_ROW)*TILE_Y; + x0 = (tile % TILE_PER_ROW) * TILE_X; + y0 = (tile / TILE_PER_ROW) * TILE_Y; - if (*copy!=0) memset(mask, 0, ux*uy); + if (*copy!=0) + memset(mask, 0, ux*uy); if (*copy == 2) { if (smalltile) - { ux = wx; + + for (x = 0; x < wx; x++) + { + for (y = 0; y < wy; y++) + { + if (!ImgIsTransparentAt(src, x0+sx+x, y0+sy+y)) + mask[(y+oy) * ux + (x+ox)] = 1; + } } - for(x=0;x<wx;x++){ - for(y=0;y<wy;y++){ - if(! ImgIsTransparentAt(src, x0+sx+x, y0+sy+y)) - mask[(y+oy)*ux+(x+ox)]=1; - }} } else { - for(x=0;x<wx;x+=2){ - for(y=0;y<wy;y+=2){ - if(! ImgIsTransparentAt(src, x0+sx+x, y0+sy+y)) - mask[(y+oy)*ux+(x+ox)]=1; - }} + for (x = 0; x < wx; x += 2) + { + for (y = 0; y < wy; y += 2) + { + if (!ImgIsTransparentAt(src, x0+sx+x, y0+sy+y)) + mask[(y+oy) * ux + (x+ox)] = 1; + } + } } *copy = 0; - } -void tile_draw_grid(int kind, int xx, int yy){ +void _tile_draw_grid(int kind, int xx, int yy) +{ int fg[4],bg[4],ix, ix_old, is_new; - if (xx < 0 || yy < 0 || xx >= tile_xmax || yy>= tile_ymax) return; + if (xx < 0 || yy < 0 || xx >= tile_xmax || yy>= tile_ymax) + return; + fg[0] = t1buf[xx+1][yy+1]; bg[0] = t2buf[xx+1][yy+1]; ix_old = screen_tcach_idx[kind][xx+yy*tile_xmax]; - ix = tcache_find_id_normal(kind, fg, bg, &is_new); + ix = _tcache_find_id_normal(kind, fg, bg, &is_new); - screen_tcach_idx[kind][xx+yy*tile_xmax]=ix; - if(is_new || ix!=ix_old || force_redraw_tile) + screen_tcach_idx[kind][xx+yy*tile_xmax] = ix; + + if (is_new || ix!=ix_old || force_redraw_tile) { int x_dest = tcache_ox_normal[kind]+xx* TILE_UX_NORMAL; int y_dest = tcache_oy_normal[kind]+yy* TILE_UY_NORMAL; @@ -609,8 +624,7 @@ void tile_draw_grid(int kind, int xx, int yy){ int wy = tcache_wy_normal[kind]; ImgCopy(tcache_image[kind], - 0, ix*wy, wx, wy, - ScrBufImg, x_dest, y_dest, 1); + 0, ix*wy, wx, wy, ScrBufImg, x_dest, y_dest, 1); } } @@ -618,11 +632,13 @@ void update_single_grid(int x, int y) { int sx, sy, wx, wy; - tile_draw_grid(TCACHE0_NORMAL, x, y); + _tile_draw_grid(TCACHE0_NORMAL, x, y); + sx = x*TILE_UX_NORMAL; sy = y*TILE_UY_NORMAL; wx = TILE_UX_NORMAL; wy = TILE_UY_NORMAL; + region_tile->redraw(sx, sy, sx+wx-1, sy+wy-1); } @@ -636,10 +652,10 @@ void redraw_spx_tcache(int tile) { int fg = tcache[kind][idx].id[0]; int bg = tcache[kind][idx].id[1]; - if ((fg & TILE_FLAG_MASK) == tile || - (bg & TILE_FLAG_MASK) == tile) + if ((fg & TILE_FLAG_MASK) == tile + || (bg & TILE_FLAG_MASK) == tile) { - tcache_compose_normal(idx, &fg, &bg); + _tcache_compose_normal(idx, &fg, &bg); } } } @@ -648,15 +664,15 @@ void redraw_spx_tcache(int tile) void get_bbg(int bg, int *new_bg, int *bbg) { int bg0 = bg & TILE_FLAG_MASK; - *bbg=TILE_DNGN_FLOOR; - *new_bg= bg0; + *bbg = TILE_DNGN_FLOOR; + *new_bg = bg0; - if(bg0 == TILE_DNGN_UNSEEN || - (bg0 >= TILE_DNGN_ROCK_WALL_OFS && bg0 < TILE_DNGN_WAX_WALL) || - bg0 == 0) + if (bg0 == TILE_DNGN_UNSEEN || bg0 == 0 + || (bg0 >= TILE_DNGN_ROCK_WALL_OFS && bg0 < TILE_DNGN_WAX_WALL)) + { *bbg = 0; - else - if( bg0 >= TILE_DNGN_FLOOR && bg0 <= TILE_DNGN_SHALLOW_WATER) + } + else if (bg0 >= TILE_DNGN_FLOOR && bg0 <= TILE_DNGN_SHALLOW_WATER) { *bbg = bg; *new_bg = 0; @@ -680,7 +696,7 @@ 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; @@ -709,7 +725,7 @@ void tcache_compose_normal(int ix, int *fg, int *bg) if ((bg0 & TILE_FLAG_TRAVEL_EX) && !(bg0 & TILE_FLAG_UNSEEN)) { tcache_overlay(tc_img, ix, TILE_TRAVEL_EXCLUSION, TREGION_0_NORMAL, &c, - NULL); + NULL); } if (bg0 & TILE_FLAG_RAY) @@ -721,13 +737,11 @@ void tcache_compose_normal(int ix, int *fg, int *bg) if (sink) { int flag = 2; - register_tile_mask(sink, TREGION_0_NORMAL, &flag, sink_mask); + _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) @@ -736,12 +750,12 @@ void tcache_compose_normal(int ix, int *fg, int *bg) if (fg0 & TILE_FLAG_S_UNDER) { tcache_overlay(tc_img, ix, TILE_SOMETHING_UNDER, - TREGION_0_NORMAL, &c, NULL); + TREGION_0_NORMAL, &c, NULL); } // Pet mark int status_shift = 0; - if ((fg0 & TILE_FLAG_MAY_STAB) == TILE_FLAG_PET) + if (fg0 & TILE_FLAG_PET) { tcache_overlay(tc_img, ix, TILE_HEART, TREGION_0_NORMAL, &c, NULL); status_shift += 10; @@ -760,14 +774,14 @@ void tcache_compose_normal(int ix, int *fg, int *bg) 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); + 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); status_shift += 5; } @@ -779,7 +793,7 @@ void tcache_compose_normal(int ix, int *fg, int *bg) if (bg0 & TILE_FLAG_MM_UNSEEN) { tcache_overlay(tc_img, ix, TILE_MAGIC_MAP_MESH, TREGION_0_NORMAL, &c, - NULL); + NULL); } // Don't let the "new stair" icon cover up any existing icons, but @@ -787,13 +801,13 @@ void tcache_compose_normal(int ix, int *fg, int *bg) if (bg0 & TILE_FLAG_NEW_STAIR && status_shift == 0) { tcache_overlay(tc_img, ix, TILE_NEW_STAIR, - TREGION_0_NORMAL, &c, NULL); + 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); + NULL); } // Tile cursor @@ -837,13 +851,14 @@ void StoreDungeonView(unsigned int *tileb) if (tileb == NULL) tileb = tb_bk; - for(y=0;y<tile_dngn_y;y++){ - for(x=0;x<tile_dngn_x;x++){ - tileb[count] = t1buf[x+1][y+1]; - count ++; - tileb[count] = t2buf[x+1][y+1]; - count ++; - }} + for (y = 0; y < tile_dngn_y; y++) + { + for (x = 0; x < tile_dngn_x; x++) + { + tileb[count++] = t1buf[x+1][y+1]; + tileb[count++] = t2buf[x+1][y+1]; + } + } } void LoadDungeonView(unsigned int *tileb) @@ -854,16 +869,15 @@ void LoadDungeonView(unsigned int *tileb) if (tileb == NULL) tileb = tb_bk; - for(y=0;y<tile_dngn_y;y++) + for (y = 0; y < tile_dngn_y; y++) { - for(x=0;x<tile_dngn_x;x++) + for (x = 0; x < tile_dngn_x; x++) { - if(tileb[count]==tileb[count+1]) - tileb[count]=0; - t1buf[x+1][y+1] = tileb[count]; - count ++; - t2buf[x+1][y+1] = tileb[count]; - count ++; + if (tileb[count] == tileb[count+1]) + tileb[count] = 0; + + t1buf[x+1][y+1] = tileb[count++]; + t2buf[x+1][y+1] = tileb[count++]; } } } @@ -872,7 +886,7 @@ void LoadDungeonView(unsigned int *tileb) void TileDrawDungeon(unsigned int *tileb) { int x, y, kind; - if(!TileImg) + if (!TileImg) return; LoadDungeonView(tileb); @@ -880,14 +894,12 @@ void TileDrawDungeon(unsigned int *tileb) extern int tile_cursor_x; tile_cursor_x = -1; - for(kind=0;kind<tcache_kind;kind++) + for (kind = 0; kind < tcache_kind; kind++) { - for(x=0;x<tile_xmax;x++) + for (x = 0; x < tile_xmax; x++) { - for(y=0;y<tile_ymax;y++) - { - tile_draw_grid(kind, x, y); - } + for (y = 0; y < tile_ymax; y++) + _tile_draw_grid(kind, x, y); } } @@ -901,16 +913,15 @@ void TileDrawFarDungeon(int cx, int cy) unsigned int tb[TILE_DAT_YMAX*TILE_DAT_XMAX*2]; int count = 0; - for(int y=0; y<tile_dngn_y; y++) + for (int y = 0; y < tile_dngn_y; y++) { - for(int x=0; x<tile_dngn_x; x++) + for (int x = 0; x < tile_dngn_x; x++) { int fg; int bg; - const coord_def gc( - cx + x - tile_dngn_x/2, - cy + y - tile_dngn_y/2 ); + const coord_def gc(cx + x - tile_dngn_x/2, + cy + y - tile_dngn_y/2); const coord_def ep = view2show(grid2view(gc)); // mini "viewwindow" routine @@ -936,8 +947,8 @@ void TileDrawFarDungeon(int cx, int cy) if (gc.x == cx && gc.y == cy) bg |= TILE_FLAG_CURSOR1; - tb[count++]=fg; - tb[count++]=bg; + tb[count++] = fg; + tb[count++] = bg; } } tile_finish_dngn(tb, cx, cy); @@ -1222,7 +1233,7 @@ void WallIdx(int &wall, int &floor, int &special) } void TileLoadWall(bool wizard) { - clear_tcache(); + _clear_tcache(); force_redraw_tile = true; int wall_idx; @@ -1233,7 +1244,7 @@ void TileLoadWall(bool wizard) // Number of flavors are generated automatically... floor_tile_idx = TILE_DNGN_FLOOR; - floor_flavors = tile_W2D_count[floor_idx]; + floor_flavors = tile_W2D_count[floor_idx]; int offset = floor_tile_idx; for (int i = 0; i < floor_flavors; i++) { @@ -1243,7 +1254,7 @@ void TileLoadWall(bool wizard) } wall_tile_idx = offset; - wall_flavors = tile_W2D_count[wall_idx]; + wall_flavors = tile_W2D_count[wall_idx]; for (int i = 0; i < wall_flavors; i++) { int idx_src = tile_W2D_start[wall_idx] + i; @@ -1263,9 +1274,7 @@ void TileLoadWall(bool wizard) } } else - { special_flavors = 0; - } } #define DOLLS_MAX 11 @@ -1277,14 +1286,16 @@ typedef struct dolls_data { int parts[TILEP_PARTS_TOTAL]; } dolls_data; + static dolls_data current_doll; static int current_gender = 0; static int current_parts[TILEP_PARTS_TOTAL]; -static bool draw_doll(img_type img, dolls_data *doll, bool force_redraw = false, bool your_doll = true) +static bool _draw_doll(img_type img, dolls_data *doll, bool force_redraw = false, + bool your_doll = true) { - const int p_order[TILEP_PARTS_TOTAL]= - { + const int p_order[TILEP_PARTS_TOTAL] = + { TILEP_PART_SHADOW, TILEP_PART_DRCWING, TILEP_PART_CLOAK, @@ -1299,14 +1310,14 @@ static bool draw_doll(img_type img, dolls_data *doll, bool force_redraw = false, TILEP_PART_BEARD, TILEP_PART_HELM, TILEP_PART_DRCHEAD - }; + }; int p_order2[TILEP_PARTS_TOTAL]; int i; int flags[TILEP_PARTS_TOTAL]; int parts2[TILEP_PARTS_TOTAL]; int *parts = doll->parts; - int c=1; + int c = 1; bool changed = false; int default_parts[TILEP_PARTS_TOTAL]; @@ -1315,10 +1326,11 @@ static bool draw_doll(img_type img, dolls_data *doll, bool force_redraw = false, if (your_doll) { tilep_race_default(you.species, parts[TILEP_PART_BASE] % 2, - you.experience_level, default_parts); + you.experience_level, default_parts); if (default_parts[TILEP_PART_BASE] != parts[TILEP_PART_BASE]) force_redraw = true; + parts[TILEP_PART_BASE] = default_parts[TILEP_PART_BASE]; // TODO enne - make these configurable. @@ -1327,53 +1339,39 @@ static bool draw_doll(img_type img, dolls_data *doll, bool force_redraw = false, } // convert TILEP_SHOW_EQUIP into real parts number - for(i = 0; i < TILEP_PARTS_TOTAL; i++) + for (i = 0; i < TILEP_PARTS_TOTAL; i++) { parts2[i] = parts[i]; if (parts2[i] == TILEP_SHOW_EQUIP) { + int item = -1; switch (i) { - int item; case TILEP_PART_HAND1: item = you.equip[EQ_WEAPON]; - if (you.attribute[ATTR_TRANSFORMATION] == - TRAN_BLADE_HANDS) - { + if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BLADE_HANDS) parts2[i] = TILEP_HAND1_BLADEHAND; - } else if (item == -1) - { parts2[i] = 0; - } else - { parts2[i] = tilep_equ_weapon(you.inv[item]); - } - break; + break; case TILEP_PART_HAND2: item = you.equip[EQ_SHIELD]; - if (you.attribute[ATTR_TRANSFORMATION] == - TRAN_BLADE_HANDS) - { + if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BLADE_HANDS) parts2[i] = TILEP_HAND2_BLADEHAND; - } else if (item == -1) - { parts2[i] = 0; - } else - { parts2[i] = tilep_equ_shield(you.inv[item]); - } break; case TILEP_PART_BODY: item = you.equip[EQ_BODY_ARMOUR]; if (item == -1) parts2[i] = 0; - else + else parts2[i] = tilep_equ_armour(you.inv[item]); break; @@ -1456,16 +1454,14 @@ static bool draw_doll(img_type img, dolls_data *doll, bool force_redraw = false, if (!changed && !force_redraw) - { return false; - } tilep_calc_flags(parts2, flags); ImgClear(img); // Hack: change overlay order of boots/skirts - for(i = 0; i < TILEP_PARTS_TOTAL; i++) - p_order2[i]=p_order[i]; + for (i = 0; i < TILEP_PARTS_TOTAL; i++) + p_order2[i]=p_order[i]; // swap boot and leg-armor if (parts2[TILEP_PART_LEG] < TILEP_LEG_SKIRT_OFS) @@ -1474,35 +1470,38 @@ static bool draw_doll(img_type img, dolls_data *doll, bool force_redraw = false, p_order2[4] = TILEP_PART_BOOTS; } - for(i = 0; i < TILEP_PARTS_TOTAL; i++) + for (i = 0; i < TILEP_PARTS_TOTAL; i++) { int p = p_order2[i]; int ymax = TILE_Y; - if (flags[p]==TILEP_FLAG_CUT_CENTAUR) ymax=18; - if (flags[p]==TILEP_FLAG_CUT_NAGA) ymax=18; + if (flags[p] == TILEP_FLAG_CUT_CENTAUR + || flags[p] == TILEP_FLAG_CUT_NAGA) + { + ymax=18; + } - if (parts2[p] && p == TILEP_PART_BOOTS && - (parts2[p] == TILEP_BOOTS_NAGA_BARDING || - parts2[p] == TILEP_BOOTS_CENTAUR_BARDING)) + if (parts2[p] && p == TILEP_PART_BOOTS + && (parts2[p] == TILEP_BOOTS_NAGA_BARDING + || parts2[p] == TILEP_BOOTS_CENTAUR_BARDING)) { // Special case for barding. They should be in "boots" but because // they're double-wide, they're stored in a different part. We just // intercept it here before drawing. - char tile = parts2[p] == TILEP_BOOTS_NAGA_BARDING ? - TILEP_SHADOW_NAGA_BARDING : TILEP_SHADOW_CENTAUR_BARDING; - tcache_overlay_player(img, 0, 0, TILEP_PART_SHADOW, tile, - TILE_Y, &c); + char tile = (parts2[p] == TILEP_BOOTS_NAGA_BARDING) ? + TILEP_SHADOW_NAGA_BARDING : + TILEP_SHADOW_CENTAUR_BARDING; + + tcache_overlay_player(img, 0, 0, TILEP_PART_SHADOW, + tile, TILE_Y, &c); } else if(parts2[p] && flags[p]) - { tcache_overlay_player(img, 0, 0, p, parts2[p], ymax, &c); - } } return true; } static void load_doll_data(const char *fn, dolls_data *dolls, int max, - int *mode, int *cur) + int *mode, int *cur) { char fbuf[1024]; int cur0 = 0; @@ -1510,8 +1509,8 @@ static void load_doll_data(const char *fn, dolls_data *dolls, int max, FILE *fp = NULL; std::string dollsTxtString = datafile_path(fn, false, true); - const char *dollsTxt = dollsTxtString.c_str()[0] == 0 ? - "dolls.txt" : dollsTxtString.c_str(); + const char *dollsTxt = (dollsTxtString.c_str()[0] == 0) ? + "dolls.txt" : dollsTxtString.c_str(); if ( (fp = fopen(dollsTxt, "r")) == NULL ) { @@ -1522,19 +1521,19 @@ static void load_doll_data(const char *fn, dolls_data *dolls, int max, { // Don't take gender too seriously. -- Enne tilep_race_default(you.species, coinflip() ? 1 : 0, - you.experience_level, dolls[i].parts); + you.experience_level, dolls[i].parts); dolls[i].parts[TILEP_PART_SHADOW] = 1; - dolls[i].parts[TILEP_PART_CLOAK] = TILEP_SHOW_EQUIP; - dolls[i].parts[TILEP_PART_BOOTS] = TILEP_SHOW_EQUIP; - dolls[i].parts[TILEP_PART_LEG] = TILEP_SHOW_EQUIP; - dolls[i].parts[TILEP_PART_BODY] = TILEP_SHOW_EQUIP; - dolls[i].parts[TILEP_PART_ARM] = TILEP_SHOW_EQUIP; - dolls[i].parts[TILEP_PART_HAND1] = TILEP_SHOW_EQUIP; - dolls[i].parts[TILEP_PART_HAND2] = TILEP_SHOW_EQUIP; - dolls[i].parts[TILEP_PART_HAIR] = TILEP_SHOW_EQUIP; - dolls[i].parts[TILEP_PART_BEARD] = TILEP_SHOW_EQUIP; - dolls[i].parts[TILEP_PART_HELM] = TILEP_SHOW_EQUIP; + dolls[i].parts[TILEP_PART_CLOAK] = TILEP_SHOW_EQUIP; + dolls[i].parts[TILEP_PART_BOOTS] = TILEP_SHOW_EQUIP; + dolls[i].parts[TILEP_PART_LEG] = TILEP_SHOW_EQUIP; + dolls[i].parts[TILEP_PART_BODY] = TILEP_SHOW_EQUIP; + dolls[i].parts[TILEP_PART_ARM] = TILEP_SHOW_EQUIP; + dolls[i].parts[TILEP_PART_HAND1] = TILEP_SHOW_EQUIP; + dolls[i].parts[TILEP_PART_HAND2] = TILEP_SHOW_EQUIP; + dolls[i].parts[TILEP_PART_HAIR] = TILEP_SHOW_EQUIP; + dolls[i].parts[TILEP_PART_BEARD] = TILEP_SHOW_EQUIP; + dolls[i].parts[TILEP_PART_HELM] = TILEP_SHOW_EQUIP; } } @@ -1557,30 +1556,22 @@ static void load_doll_data(const char *fn, dolls_data *dolls, int max, } if (max == 1) { - for(int j = 0; j <= cur0; j++) + for (int j = 0; j <= cur0; j++) { if (fscanf(fp, "%s", fbuf) != EOF) - { tilep_scan_parts(fbuf, dolls[0].parts); - } else - { break; - } } } else { - for(int j = 0; j < max; j++) + for (int j = 0; j < max; j++) { if (fscanf(fp, "%s", fbuf) != EOF) - { tilep_scan_parts(fbuf, dolls[j].parts); - } else - { break; - } } } @@ -1595,7 +1586,7 @@ static void load_doll_data(const char *fn, dolls_data *dolls, int max, void TilePlayerEdit() { const int p_lines[PARTS_ITEMS]= - { + { TILEP_SELECT_DOLL, TILEP_PART_BASE, TILEP_PART_HELM, @@ -1608,7 +1599,7 @@ void TilePlayerEdit() TILEP_PART_LEG, TILEP_PART_BOOTS, TILEP_PART_CLOAK - }; + }; const char *p_names[PARTS_ITEMS]= { @@ -1626,7 +1617,7 @@ void TilePlayerEdit() " Cloak:" }; - const char *gender_name[2] ={ + const char *gender_name[2] = { "Male", "Fem " }; @@ -1660,24 +1651,23 @@ void TilePlayerEdit() memset( copy_doll, 0, sizeof(dolls_data) ); tilep_race_default(you.species, current_gender, - you.experience_level, copy_doll); + you.experience_level, copy_doll); - for(j = 0; j < DOLLS_MAX; j++) + for (j = 0; j < DOLLS_MAX; j++) { memset( dolls[j].parts, 0, sizeof(dolls_data) ); memset( undo_dolls[j].parts, 0, sizeof(dolls_data) ); tilep_race_default(you.species, current_gender, you.experience_level, - dolls[j].parts); + dolls[j].parts); tilep_race_default(you.species, current_gender, you.experience_level, - undo_dolls[j].parts); + undo_dolls[j].parts); } // load settings load_doll_data("dolls.txt", dolls, DOLLS_MAX, &mode, &cur_doll); - for(j = 0; j < DOLLS_MAX; j++) - { + for (j = 0; j < DOLLS_MAX; j++) undo_dolls[j] = dolls[j]; - } + clrscr(); cgotoxy(1,1, GOTO_MSG); mpr("Select Part : [j][k]or[up][down]"); @@ -1690,8 +1680,9 @@ void TilePlayerEdit() cgotoxy(1, 8, GOTO_MSG); cprintf("Toggle Startup mode : [m] (Current mode:%s)", - ( (mode == TILEP_M_LOADING) ? "Load User's Settings":"Class Default" )); - for (j=0; j < PARTS_ITEMS; j++) + (mode == TILEP_M_LOADING ? "Load User's Settings" + : "Class Default" )); + for (j = 0; j < PARTS_ITEMS; j++) { cgotoxy(1, 1+j, GOTO_STAT); cprintf(p_names[j]); @@ -1701,33 +1692,33 @@ void TilePlayerEdit() // draw strings "Dolls/Parts" into backbuffer tile_str = TILE_TEXT_PARTS_E; - sx = (tile_str % TILE_PER_ROW)*TILE_X; - sy = (tile_str / TILE_PER_ROW)*TILE_Y; + sx = (tile_str % TILE_PER_ROW) * TILE_X; + sy = (tile_str / TILE_PER_ROW) * TILE_Y; ImgCopy(TileImg, sx, sy, TILE_X, TILE_Y/2, - ScrBufImg, (TILE_X * 3) - 8,(TILE_Y * 4) - 8-24, 0); + ScrBufImg, (TILE_X * 3) - 8,(TILE_Y * 4) - 8-24, 0); ImgCopy(TileImg, sx, sy+ TILE_Y/2, TILE_X, TILE_Y/2, - ScrBufImg, (TILE_X * 4) - 8,(TILE_Y * 4) - 8-24, 0); + ScrBufImg, (TILE_X * 4) - 8,(TILE_Y * 4) - 8-24, 0); tile_str = TILE_TEXT_DOLLS_E; - sx = (tile_str % TILE_PER_ROW)*TILE_X; - sy = (tile_str / TILE_PER_ROW)*TILE_Y; + sx = (tile_str % TILE_PER_ROW) * TILE_X; + sy = (tile_str / TILE_PER_ROW) * TILE_Y; + ImgCopy(TileImg, sx, sy, TILE_X, TILE_Y/2, - ScrBufImg, (TILE_X * 3) - 8,PARTS_Y - 8 -24, 0); + ScrBufImg, (TILE_X * 3) - 8,PARTS_Y - 8 -24, 0); ImgCopy(TileImg, sx, sy+ TILE_Y/2, TILE_X, TILE_Y/2, - ScrBufImg, (TILE_X * 4) - 8,PARTS_Y - 8 -24, 0); + ScrBufImg, (TILE_X * 4) - 8,PARTS_Y - 8 -24, 0); ImgClear(DollsListImg); - for(j = 0; j < DOLLS_MAX; j++) + for (j = 0; j < DOLLS_MAX; j++) { - draw_doll(DollCacheImg, &dolls[j], true); + _draw_doll(DollCacheImg, &dolls[j], true); ImgCopy(DollCacheImg, 0, 0, ImgWidth(DollCacheImg), ImgHeight(DollCacheImg), - DollsListImg, j * TILE_X, 0, 1); + DollsListImg, j * TILE_X, 0, 1); } done = 0; - while (!done) { static int inc = 1; @@ -1751,7 +1742,7 @@ void TilePlayerEdit() current_gender = dolls[cur_doll].parts[TILEP_PART_BASE] % 2; cprintf("%s", gender_name[ current_gender ]); - for (i = 2; i<PARTS_ITEMS; i++) + for (i = 2; i < PARTS_ITEMS; i++) { cgotoxy(10 , i + 1, GOTO_STAT); tilep_part_to_str(dolls[cur_doll].parts[ p_lines[i] ], ibuf); @@ -1763,34 +1754,39 @@ void TilePlayerEdit() for(i = 0; i < PARTS_DISP_MAX; i++) { int index; - if (dolls[cur_doll].parts[ p_lines[cur_part] ] - == TILEP_SHOW_EQUIP) + if (dolls[cur_doll].parts[ p_lines[cur_part] ] + == TILEP_SHOW_EQUIP) + { index = 0; + } else + { index = i + dolls[cur_doll].parts[ p_lines[cur_part] ] - (PARTS_DISP_MAX / 2); + } if (index < 0) index = index + tilep_parts_total[ p_lines[cur_part] ] + 1; if (index > tilep_parts_total[ p_lines[cur_part] ]) index = index - tilep_parts_total[ p_lines[cur_part] ] - 1; + tcache_overlay_player(PartsImg, i * TILE_X, 0, p_lines[cur_part], index, TILE_Y, &d); } ImgCopy(PartsImg, 0, 0, ImgWidth(PartsImg), ImgHeight(PartsImg), - ScrBufImg, 3 * TILE_X, 4 * TILE_Y, 0); + ScrBufImg, 3 * TILE_X, 4 * TILE_Y, 0); ImgCopyFromTileImg( TILE_CURSOR, ScrBufImg, - (3 + PARTS_DISP_MAX / 2) * TILE_X, 4 * TILE_Y, 0); + (3 + PARTS_DISP_MAX / 2) * TILE_X, 4 * TILE_Y, 0); } - draw_doll(DollCacheImg, &dolls[cur_doll], true); + _draw_doll(DollCacheImg, &dolls[cur_doll], true); ImgCopy(DollCacheImg, 0, 0, TILE_X, TILE_Y, - DollsListImg, cur_doll*TILE_X, 0, 1); + DollsListImg, cur_doll*TILE_X, 0, 1); ImgCopyToTileImg(TILE_PLAYER, DollCacheImg, 0, 0, 1); ImgCopyFromTileImg(TILE_PLAYER, ScrBufImg, 8*TILE_X, 8*TILE_Y, 0); ImgCopy(DollsListImg, 0, 0, - ImgWidth(DollsListImg), ImgHeight(DollsListImg), - ScrBufImg, 3 * TILE_X, PARTS_Y, 0); + ImgWidth(DollsListImg), ImgHeight(DollsListImg), + ScrBufImg, 3 * TILE_X, PARTS_Y, 0); ImgCopyFromTileImg( TILE_CURSOR, ScrBufImg, (3 + cur_doll) * TILE_X, PARTS_Y, 0); region_tile->redraw(); @@ -1827,33 +1823,34 @@ void TilePlayerEdit() case 'h': inc = -1; break; + case 'l': inc = +1; break; + case 'H': inc = -PARTS_DISP_MAX; break; + case 'L': inc = +PARTS_DISP_MAX; break; + case 'j': - { if (cur_part < (PARTS_ITEMS-1) ) cur_part += 1; else cur_part = 0; break; - } + case 'k': - { if (cur_part > 0) cur_part -= 1; else cur_part = (PARTS_ITEMS-1); break; - } + case 'm': - { if (mode == TILEP_M_LOADING) mode = TILEP_M_DEFAULT; else @@ -1861,112 +1858,105 @@ void TilePlayerEdit() cgotoxy(1, 8, GOTO_MSG); cprintf("Toggle Startup mode : [m] (Current mode:%s)", - ( (mode == TILEP_M_LOADING) ? "Load User's Settings":"Class Default" )); + ( mode == TILEP_M_LOADING ? "Load User's Settings" + : "Class Default" )); break; - } case 't': - { if (cur_part >= 2) { dolls[cur_doll].parts[ p_lines[cur_part] ] = 0; display_parts_idx(cur_part); } break; - } case CONTROL('D'): - { tilep_job_default(you.char_class, current_gender, - dolls[cur_doll].parts); - for(i = 2; i < PARTS_ITEMS; i++) - { - display_parts_idx(i); - } + dolls[cur_doll].parts); + + for (i = 2; i < PARTS_ITEMS; i++) + display_parts_idx(i); break; - } case CONTROL('T'): - { - for(i = 2; i < PARTS_ITEMS; i++) + for (i = 2; i < PARTS_ITEMS; i++) { - undo_dolls[cur_doll].parts[ p_lines[i] ] = dolls[cur_doll].parts[ p_lines[i] ]; + undo_dolls[cur_doll].parts[ p_lines[i] ] + = dolls[cur_doll].parts[ p_lines[i] ]; dolls[cur_doll].parts[ p_lines[i] ] = 0; display_parts_idx(i); } break; - } case CONTROL('C'): - { - for(i = 2; i < PARTS_ITEMS; i++) + for (i = 2; i < PARTS_ITEMS; i++) { - copy_doll[ p_lines[i] ] = dolls[cur_doll].parts[ p_lines[i] ]; + copy_doll[ p_lines[i] ] + = dolls[cur_doll].parts[ p_lines[i] ]; } break; - } case CONTROL('V'): - { - for(i = 2; i < PARTS_ITEMS; i++) + for (i = 2; i < PARTS_ITEMS; i++) { - undo_dolls[cur_doll].parts[ p_lines[i] ] = dolls[cur_doll].parts[ p_lines[i] ]; - dolls[cur_doll].parts[ p_lines[i] ] = copy_doll[ p_lines[i] ]; + undo_dolls[cur_doll].parts[ p_lines[i] ] + = dolls[cur_doll].parts[ p_lines[i] ]; + dolls[cur_doll].parts[ p_lines[i] ] + = copy_doll[ p_lines[i] ]; display_parts_idx(i); } break; - } case CONTROL('Z'): - { - for(i = 2; i < PARTS_ITEMS; i++) + for (i = 2; i < PARTS_ITEMS; i++) { - dolls[cur_doll].parts[ p_lines[i] ] = undo_dolls[cur_doll].parts[ p_lines[i] ]; + dolls[cur_doll].parts[ p_lines[i] ] + = undo_dolls[cur_doll].parts[ p_lines[i] ]; display_parts_idx(i); } break; - } case CONTROL('R'): - { - for(i = 2; i < PARTS_ITEMS; i++) + for (i = 2; i < PARTS_ITEMS; i++) { - undo_dolls[cur_doll].parts[ p_lines[i] ] = dolls[cur_doll].parts[ p_lines[i] ]; + undo_dolls[cur_doll].parts[ p_lines[i] ] + = dolls[cur_doll].parts[ p_lines[i] ]; } - dolls[cur_doll].parts[TILEP_PART_CLOAK] = - one_chance_in(2) * ( random2(tilep_parts_total[ TILEP_PART_CLOAK ]) + 1); - dolls[cur_doll].parts[TILEP_PART_BOOTS] = - ( random2(tilep_parts_total[ TILEP_PART_BOOTS ] + 1) ); - dolls[cur_doll].parts[TILEP_PART_LEG] = - ( random2(tilep_parts_total[ TILEP_PART_LEG ] + 1) ); - dolls[cur_doll].parts[TILEP_PART_BODY] = - ( random2(tilep_parts_total[ TILEP_PART_BODY ] + 1) ); - dolls[cur_doll].parts[TILEP_PART_ARM] = - one_chance_in(2) * ( random2(tilep_parts_total[ TILEP_PART_ARM ]) + 1); - dolls[cur_doll].parts[TILEP_PART_HAND1] = - ( random2(tilep_parts_total[ TILEP_PART_HAND1 ] + 1) ); - dolls[cur_doll].parts[TILEP_PART_HAND2] = - one_chance_in(2) * ( random2(tilep_parts_total[ TILEP_PART_HAND2 ]) + 1); - dolls[cur_doll].parts[TILEP_PART_HAIR] = - ( random2(tilep_parts_total[ TILEP_PART_HAIR ] + 1) ); - dolls[cur_doll].parts[TILEP_PART_BEARD] = - ( (dolls[cur_doll].parts[TILEP_PART_BASE] + 1) % 2) * - one_chance_in(4) * ( random2(tilep_parts_total[ TILEP_PART_BEARD ]) + 1 ); - dolls[cur_doll].parts[TILEP_PART_HELM] = - one_chance_in(2) * ( random2(tilep_parts_total[ TILEP_PART_HELM ]) + 1 ); - for(i = 2; i < PARTS_ITEMS; i++) - { + dolls[cur_doll].parts[TILEP_PART_CLOAK] + = coinflip() * (random2(tilep_parts_total[ TILEP_PART_CLOAK ]) + 1); + dolls[cur_doll].parts[TILEP_PART_BOOTS] + = random2(tilep_parts_total[ TILEP_PART_BOOTS ] + 1); + dolls[cur_doll].parts[TILEP_PART_LEG] + = random2(tilep_parts_total[ TILEP_PART_LEG ] + 1); + dolls[cur_doll].parts[TILEP_PART_BODY] + = random2(tilep_parts_total[ TILEP_PART_BODY ] + 1); + dolls[cur_doll].parts[TILEP_PART_ARM] + = coinflip() * ( random2(tilep_parts_total[ TILEP_PART_ARM ]) + 1); + dolls[cur_doll].parts[TILEP_PART_HAND1] + = random2(tilep_parts_total[ TILEP_PART_HAND1 ] + 1); + dolls[cur_doll].parts[TILEP_PART_HAND2] + = coinflip() * ( random2(tilep_parts_total[ TILEP_PART_HAND2 ]) + 1); + dolls[cur_doll].parts[TILEP_PART_HAIR] + = random2(tilep_parts_total[ TILEP_PART_HAIR ] + 1); + dolls[cur_doll].parts[TILEP_PART_BEARD] + = ((dolls[cur_doll].parts[TILEP_PART_BASE] + 1) % 2) + * one_chance_in(4) + * ( random2(tilep_parts_total[ TILEP_PART_BEARD ]) + 1 ); + dolls[cur_doll].parts[TILEP_PART_HELM] + = coinflip() * ( random2(tilep_parts_total[ TILEP_PART_HELM ]) + 1 ); + + for (i = 2; i < PARTS_ITEMS; i++) display_parts_idx(i); - } + break; - } + case '*': { int part = p_lines[cur_part]; int *target = &dolls[cur_doll].parts[part]; if (part == TILEP_PART_BASE) - continue; + continue; if (*target == TILEP_SHOW_EQUIP) *target = 0; else @@ -1978,18 +1968,18 @@ void TilePlayerEdit() #ifdef WIZARD case '1': dolls[cur_doll].parts[TILEP_PART_DRCHEAD]++; - dolls[cur_doll].parts[TILEP_PART_DRCHEAD] %= - tilep_parts_total[TILEP_PART_DRCHEAD] -1; + dolls[cur_doll].parts[TILEP_PART_DRCHEAD] + %= tilep_parts_total[TILEP_PART_DRCHEAD] - 1; break; + case '2': dolls[cur_doll].parts[TILEP_PART_DRCWING]++; - dolls[cur_doll].parts[TILEP_PART_DRCWING] %= - tilep_parts_total[TILEP_PART_DRCWING] -1; + dolls[cur_doll].parts[TILEP_PART_DRCWING] + %= tilep_parts_total[TILEP_PART_DRCWING] - 1; break; #endif default: - { - } + break; } if (inc != 0) @@ -2002,8 +1992,9 @@ void TilePlayerEdit() cur_doll++; else cur_doll--; + if (cur_doll < 0) - cur_doll = DOLLS_MAX -1; + cur_doll = DOLLS_MAX - 1; else if (cur_doll == DOLLS_MAX) cur_doll = 0; } @@ -2016,10 +2007,12 @@ void TilePlayerEdit() } else { - if (*target == TILEP_SHOW_EQUIP) continue; + if (*target == TILEP_SHOW_EQUIP) + continue; + (*target) += inc; - (*target) += tilep_parts_total[ p_lines[cur_part] ]+1; - (*target) %= tilep_parts_total[ p_lines[cur_part] ]+1; + (*target) += tilep_parts_total[ p_lines[cur_part] ] + 1; + (*target) %= tilep_parts_total[ p_lines[cur_part] ] + 1; } } @@ -2027,21 +2020,19 @@ void TilePlayerEdit() } current_doll = dolls[cur_doll]; - draw_doll(DollCacheImg, ¤t_doll); + _draw_doll(DollCacheImg, ¤t_doll); ImgCopyToTileImg(TILE_PLAYER, DollCacheImg, 0, 0, 1); std::string dollsTxtString = datafile_path("dolls.txt", false, true); - const char *dollsTxt = dollsTxtString.c_str()[0] == 0 ? - "dolls.txt" : dollsTxtString.c_str(); + const char *dollsTxt = (dollsTxtString.c_str()[0] == 0) ? + "dolls.txt" : dollsTxtString.c_str(); - if ( (fp = fopen(dollsTxt, "w+")) == NULL ) - { - } - else + if ( (fp = fopen(dollsTxt, "w+")) != NULL ) { - fprintf(fp, "MODE=%s\n", ( (mode == TILEP_M_LOADING) ? "LOADING":"DEFAULT" ) ); + fprintf(fp, "MODE=%s\n", (mode == TILEP_M_LOADING) ? "LOADING" + : "DEFAULT" ); fprintf(fp, "NUM=%02d\n", cur_doll); - for(j = 0; j < DOLLS_MAX; j++) + for (j = 0; j < DOLLS_MAX; j++) { tilep_print_parts(fbuf, dolls[j].parts); fprintf(fp, "%s\n", fbuf); @@ -2055,18 +2046,20 @@ void TilePlayerEdit() ImgClear(ScrBufImg); redraw_spx_tcache(TILE_PLAYER); - for(x=0;x<TILE_DAT_XMAX+2;x++) + for (x = 0; x < TILE_DAT_XMAX + 2; x++) { - for(y=0;y<TILE_DAT_YMAX+2;y++) + for (y = 0; y < TILE_DAT_YMAX + 2; y++) { t1buf[x][y] = 0; t2buf[x][y] = TILE_DNGN_UNSEEN | TILE_FLAG_UNSEEN; } } - for(k=0;k<tcache_kind;k++) - for(x=0;x<tile_xmax*tile_ymax;x++) - screen_tcach_idx[k][x] = -1; + for (k = 0; k < tcache_kind; k++) + { + for( x = 0; x < tile_xmax * tile_ymax; x++) + screen_tcach_idx[k][x] = -1; + } clrscr(); redraw_screen(); @@ -2074,7 +2067,7 @@ void TilePlayerEdit() void TilePlayerRefresh() { - if (!draw_doll(DollCacheImg, ¤t_doll)) + if (!_draw_doll(DollCacheImg, ¤t_doll)) return; // Not changed ImgCopyToTileImg(TILE_PLAYER, DollCacheImg, 0, 0, 1); @@ -2094,64 +2087,64 @@ void TilePlayerInit() dolls_data doll; int gender = 0; - for(i = 0; i < TILEP_PARTS_TOTAL; i++) - doll.parts[i] = 0; + for (i = 0; i < TILEP_PARTS_TOTAL; i++) + doll.parts[i] = 0; tilep_race_default(you.species, gender, you.experience_level, doll.parts); tilep_job_default(you.char_class, gender, doll.parts); load_doll_data("dolls.txt", &doll, 1, &mode, &cur_doll); current_doll = doll; - draw_doll(DollCacheImg, &doll); + _draw_doll(DollCacheImg, &doll); ImgCopyToTileImg(TILE_PLAYER, DollCacheImg, 0, 0, 1); - } void TileGhostInit(const struct ghost_demon &ghost) { dolls_data doll; int x, y; - unsigned int pseudo_rand = ghost.max_hp*54321*54321; + unsigned int pseudo_rand = ghost.max_hp * 54321 * 54321; char mask[TILE_X*TILE_Y]; - int g_gender = (pseudo_rand >>8)&1; + int g_gender = (pseudo_rand >> 8) & 1; - for (x=0; x<TILE_X; x++) - for (y=0; y<TILE_X; y++) - mask[x+y*TILE_X] = (x+y)&1; + for (x = 0; x < TILE_X; x++) + for (y = 0; y < TILE_X; y++) + mask[x + y*TILE_X] = (x+y)&1; - for(x = 0; x < TILEP_PARTS_TOTAL; x++) + for (x = 0; x < TILEP_PARTS_TOTAL; x++) { - doll.parts[x] = 0; - current_parts[x] = 0; + doll.parts[x] = 0; + current_parts[x] = 0; } tilep_race_default(ghost.species, g_gender, - ghost.xl, doll.parts); + ghost.xl, doll.parts); tilep_job_default (ghost.job, g_gender, doll.parts); - for(x = TILEP_PART_CLOAK; x < TILEP_PARTS_TOTAL; x++) - { - if (doll.parts[x] == TILEP_SHOW_EQUIP) - { - doll.parts[x] = 1 + (pseudo_rand % tilep_parts_total[x]); - - if (x == TILEP_PART_BODY) - { - int p = 0; - int ac = ghost.ac; - ac *= (5 + (pseudo_rand/11) % 11); - ac /= 10; - - if (ac > 25) p= TILEP_BODY_PLATE_BLACK; - else - if (ac > 20) p= TILEP_BODY_BANDED; - else - if (ac > 15) p= TILEP_BODY_SCALEMAIL; - else - if (ac > 10) p= TILEP_BODY_CHAINMAIL; - else - if (ac > 5 ) p= TILEP_BODY_LEATHER_HEAVY; - else - p= TILEP_BODY_ROBE_BLUE; + for (x = TILEP_PART_CLOAK; x < TILEP_PARTS_TOTAL; x++) + { + if (doll.parts[x] == TILEP_SHOW_EQUIP) + { + doll.parts[x] = 1 + (pseudo_rand % tilep_parts_total[x]); + + if (x == TILEP_PART_BODY) + { + int p = 0; + int ac = ghost.ac; + ac *= (5 + (pseudo_rand/11) % 11); + ac /= 10; + + if (ac > 25) + p = TILEP_BODY_PLATE_BLACK; + else if (ac > 20) + p = TILEP_BODY_BANDED; + else if (ac > 15) + p = TILEP_BODY_SCALEMAIL; + else if (ac > 10) + p = TILEP_BODY_CHAINMAIL; + else if (ac > 5 ) + p = TILEP_BODY_LEATHER_HEAVY; + else + p = TILEP_BODY_ROBE_BLUE; doll.parts[x] = p; } } @@ -2164,100 +2157,108 @@ void TileGhostInit(const struct ghost_demon &ghost) dam *= (5 + pseudo_rand % 11); dam /= 10; - if (sk == SK_MACES_FLAILS) - { - if (dam>30) p = TILEP_HAND1_GREAT_FRAIL; - else - if (dam>25) p = TILEP_HAND1_GREAT_MACE; - else - if (dam>20) p = TILEP_HAND1_SPIKED_FRAIL; - else - if (dam>15) p = TILEP_HAND1_MORNINGSTAR; + switch (sk) + { + case SK_MACES_FLAILS: + if (dam > 30) + p = TILEP_HAND1_GREAT_FRAIL; + else if (dam > 25) + p = TILEP_HAND1_GREAT_MACE; + else if (dam > 20) + p = TILEP_HAND1_SPIKED_FRAIL; + else if (dam > 15) + p = TILEP_HAND1_MORNINGSTAR; + else if (dam > 10) + p = TILEP_HAND1_FRAIL; + else if (dam > 5) + p = TILEP_HAND1_MACE; else - if (dam>10) p = TILEP_HAND1_FRAIL; - else - if (dam>5) p = TILEP_HAND1_MACE; - else - p = TILEP_HAND1_CLUB_SLANT; + p = TILEP_HAND1_CLUB_SLANT; doll.parts[TILEP_PART_HAND1] = p; - } - else - if (sk == SK_SHORT_BLADES) - { - if (dam>20) p = TILEP_HAND1_SABRE; - else - if (dam>10) p = TILEP_HAND1_SHORT_SWORD_SLANT; + break; + + case SK_SHORT_BLADES: + if (dam > 20) + p = TILEP_HAND1_SABRE; + else if (dam > 10) + p = TILEP_HAND1_SHORT_SWORD_SLANT; else - p = TILEP_HAND1_DAGGER_SLANT; + p = TILEP_HAND1_DAGGER_SLANT; doll.parts[TILEP_PART_HAND1] = p; - } - else - if (sk == SK_LONG_BLADES) - { - if (dam>25) p = TILEP_HAND1_GREAT_SWORD_SLANT; - else - if (dam>20) p = TILEP_HAND1_KATANA_SLANT; - else - if (dam>15) p = TILEP_HAND1_SCIMITAR; - else - if (dam>10) p = TILEP_HAND1_LONG_SWORD_SLANT; + break; + + case SK_LONG_BLADES: + if (dam > 25) + p = TILEP_HAND1_GREAT_SWORD_SLANT; + else if (dam > 20) + p = TILEP_HAND1_KATANA_SLANT; + else if (dam > 15) + p = TILEP_HAND1_SCIMITAR; + else if (dam > 10) + p = TILEP_HAND1_LONG_SWORD_SLANT; else - p = TILEP_HAND1_FALCHION; + p = TILEP_HAND1_FALCHION; doll.parts[TILEP_PART_HAND1] = p; - } - else - if (sk == SK_AXES) - { - if (dam>30) p = TILEP_HAND1_EXECUTIONERS_AXE; + break; + + case SK_AXES: + if (dam > 30) + p = TILEP_HAND1_EXECUTIONERS_AXE; + else if (dam > 20) + p = TILEP_HAND1_BATTLEAXE; + else if (dam > 15) + p = TILEP_HAND1_BROAD_AXE; + else if (dam > 10) + p = TILEP_HAND1_WAR_AXE; else - if (dam>20) p = TILEP_HAND1_BATTLEAXE; - else - if (dam>15) p = TILEP_HAND1_BROAD_AXE; - else - if (dam>10) p = TILEP_HAND1_WAR_AXE; - else - p = TILEP_HAND1_HAND_AXE; + p = TILEP_HAND1_HAND_AXE; doll.parts[TILEP_PART_HAND1] = p; - } - else - if (sk == SK_POLEARMS) - { - if (dam>30) p = TILEP_HAND1_GLAIVE; - else - if (dam>20) p = TILEP_HAND1_SCYTHE; + break; + + case SK_POLEARMS: + if (dam > 30) + p = TILEP_HAND1_GLAIVE; + else if (dam > 20) + p = TILEP_HAND1_SCYTHE; + else if (dam > 15) + p = TILEP_HAND1_HALBERD; + else if (dam > 10) + p = TILEP_HAND1_TRIDENT2; + else if (dam > 10) + p = TILEP_HAND1_HAMMER; else - if (dam>15) p = TILEP_HAND1_HALBERD; - else - if (dam>10) p = TILEP_HAND1_TRIDENT2; - else - if (dam>10) p = TILEP_HAND1_HAMMER; - else - p = TILEP_HAND1_SPEAR; + p = TILEP_HAND1_SPEAR; doll.parts[TILEP_PART_HAND1] = p; - } - else - if (sk == SK_BOWS) + break; + + case SK_BOWS: doll.parts[TILEP_PART_HAND1] = TILEP_HAND1_BOW2; - else - if (sk == SK_CROSSBOWS) + break; + + case SK_CROSSBOWS: doll.parts[TILEP_PART_HAND1] = TILEP_HAND1_CROSSBOW; - else - if (sk == SK_SLINGS) + break; + + case SK_SLINGS: doll.parts[TILEP_PART_HAND1] = TILEP_HAND1_SLING; - else - if (sk == SK_UNARMED_COMBAT) + break; + + case SK_UNARMED_COMBAT: + default: doll.parts[TILEP_PART_HAND1] = doll.parts[TILEP_PART_HAND2] = 0; + break; + } ImgClear(DollCacheImg); // Clear ImgCopyToTileImg(TILE_MONS_PLAYER_GHOST, DollCacheImg, 0, 0, 1); - draw_doll(DollCacheImg, &doll); + _draw_doll(DollCacheImg, &doll); ImgCopyToTileImg(TILE_MONS_PLAYER_GHOST, DollCacheImg, 0, 0, 1, mask, false); redraw_spx_tcache(TILE_MONS_PLAYER_GHOST); } @@ -2314,12 +2315,12 @@ void TileInitItems() typedef struct mcache mcache; struct mcache { - bool lock_flag; - mcache *next; - int mon_tile; - int equ_tile; - int draco; - int idx; + bool lock_flag; + mcache *next; + int mon_tile; + int equ_tile; + int draco; + int idx; }; mcache mc_data[N_MCACHE]; @@ -2337,25 +2338,22 @@ static void ImgCopyDoll(int equ_tile, int hand, int ofs_x, int ofs_y) int wx = std::min(TILE_X/nx + ofs_x, TILE_X/nx); int wy = std::min(TILE_Y/ny + ofs_y, TILE_Y/ny); int idx = equ_tile -1; - int tidx = tilep_parts_start[handidx] + - idx/(nx*ny); + int tidx = tilep_parts_start[handidx] + idx/(nx*ny); //Source pos - int xs = (tidx % TILEP_PER_ROW)*TILE_X + - (idx % nx)*(TILE_X/nx) - ofs_x; - int ys = (tidx / TILEP_PER_ROW)*TILE_Y + - ((idx/nx) % ny)*(TILE_Y/ny) - ofs_y; + int xs = (tidx % TILEP_PER_ROW)*TILE_X + (idx % nx) * (TILE_X/nx) - ofs_x; + int ys = (tidx / TILEP_PER_ROW)*TILE_Y + + ((idx/nx) % ny) * (TILE_Y/ny) - ofs_y; - ImgCopy(PlayerImg, xs, ys, wx, wy, - DollCacheImg, ox, oy, 0); + ImgCopy(PlayerImg, xs, ys, wx, wy, DollCacheImg, ox, oy, 0); } static void mcache_compose(int tile_idx, int mon_tile, int equ_tile) { - int ofs_x=0; - int ofs_y=0; + int ofs_x = 0; + int ofs_y = 0; - switch(mon_tile) + switch (mon_tile) { case TILE_MONS_ORC: case TILE_MONS_URUG: @@ -2489,10 +2487,10 @@ static void mcache_compose_draco(int tile_idx, int race, int cls, int w) int weapon2 = 0; int arm = 0; - for(x = 0; x < TILEP_PARTS_TOTAL; x++) + for (x = 0; x < TILEP_PARTS_TOTAL; x++) { - doll.parts[x] = 0; - current_parts[x] = 0; + doll.parts[x] = 0; + current_parts[x] = 0; } doll.parts[TILEP_PART_SHADOW] = 1; @@ -2553,27 +2551,29 @@ static void mcache_compose_draco(int tile_idx, int race, int cls, int w) doll.parts[TILEP_PART_HAND1] = weapon; doll.parts[TILEP_PART_HAND2] = weapon2; - doll.parts[TILEP_PART_BODY] = armour; - doll.parts[TILEP_PART_LEG] = armour2; - doll.parts[TILEP_PART_ARM] = arm; + doll.parts[TILEP_PART_BODY] = armour; + doll.parts[TILEP_PART_LEG] = armour2; + doll.parts[TILEP_PART_ARM] = arm; ImgClear(DollCacheImg); - draw_doll(DollCacheImg, &doll, true, false); + _draw_doll(DollCacheImg, &doll, true, false); // Copy to the buffer ImgCopyToTileImg(tile_idx, DollCacheImg, 0, 0, 1); redraw_spx_tcache(tile_idx); } -static void mcache_init() +static void _mcache_init() { int i; - for(i=0;i<N_MCACHE;i++) + for (i = 0; i < N_MCACHE; i++) { mc_data[i].lock_flag = false; mc_data[i].next = NULL; - if (i!=N_MCACHE-1) + + if (i != N_MCACHE - 1) mc_data[i].next = &mc_data[i+1]; + mc_data[i].idx = TILE_MCACHE_START + i; mc_data[i].mon_tile = 0; mc_data[i].equ_tile = 0; @@ -2603,19 +2603,15 @@ int get_clean_map_idx(int tile_idx) return 0; } else - { return tile_idx; - } } void TileMcacheUnlock() { int i; - for(i=0;i<N_MCACHE;i++) - { - mc_data[i].lock_flag = false; - } + for (i = 0; i < N_MCACHE; i++) + mc_data[i].lock_flag = false; } int TileMcacheFind(int mon_tile, int equ_tile, int draco) @@ -2630,14 +2626,17 @@ int TileMcacheFind(int mon_tile, int equ_tile, int draco) int best2 = -1; int best3 = -1; - while(1){ - if(mon_tile == mc->mon_tile && equ_tile == mc->equ_tile + while (true) + { + if (mon_tile == mc->mon_tile && equ_tile == mc->equ_tile && draco == mc->draco) { // match found // move cache to the head to reduce future search time - if (prev != NULL) prev->next = mc->next; - if (mc != mc_head) mc->next = mc_head; + if (prev != NULL) + prev->next = mc->next; + if (mc != mc_head) + mc->next = mc_head; mc_head = mc; // lock it @@ -2645,10 +2644,10 @@ int TileMcacheFind(int mon_tile, int equ_tile, int draco) // return cache index return mc->idx; } - else if(draco != 0 && mon_tile == mc->mon_tile && draco == mc->draco) + else if (draco != 0 && mon_tile == mc->mon_tile && draco == mc->draco) // second best for draconian: only weapon differ best2 = mc->idx; - else if(draco != 0 && mon_tile == mc->mon_tile) + else if (draco != 0 && mon_tile == mc->mon_tile) // third best for draconian: only class matches best3 = mc->idx; @@ -2662,21 +2661,22 @@ int TileMcacheFind(int mon_tile, int equ_tile, int draco) #ifdef DEBUG_DIAGNOSTICS count++; #endif - - }//while + } // while // cache image not found and no room do draw it - if(empty == NULL) + if (empty == NULL) { #ifdef DEBUG_DIAGNOSTICS snprintf( cache_info, 39, "mcache (M %d, E %d) cache full", - mon_tile, equ_tile); + mon_tile, equ_tile); mpr(cache_info, MSGCH_DIAGNOSTICS ); #endif if (best2 != -1) return best2; + if (best3 != -1) return best3; + if (draco != 0) return TILE_ERROR; else @@ -2685,9 +2685,9 @@ int TileMcacheFind(int mon_tile, int equ_tile, int draco) mc = empty; #ifdef DEBUG_DIAGNOSTICS - snprintf( cache_info, 39, "mcache (M %d, E %d) newly composed", - mon_tile, equ_tile); - mpr(cache_info, MSGCH_DIAGNOSTICS ); + snprintf( cache_info, 39, "mcache (M %d, E %d) newly composed", + mon_tile, equ_tile); + mpr(cache_info, MSGCH_DIAGNOSTICS ); #endif // compose new image @@ -2696,16 +2696,20 @@ int TileMcacheFind(int mon_tile, int equ_tile, int draco) mcache_compose_draco(mc->idx, draco, mon_tile, equ_tile); else mcache_compose(mc->idx, mon_tile, equ_tile); + mc->mon_tile = mon_tile; mc->equ_tile = equ_tile; mc->draco = draco; + // move cache to the head to reduce future search time if (prev) prev->next = mc->next; - if(mc != mc_head) + if (mc != mc_head) mc->next = mc_head; + mc_head = mc; - mc->lock_flag=true; + mc->lock_flag = true; + return mc->idx; } @@ -2734,9 +2738,7 @@ void TileDrawTitle() tx = winx; } else - { x = (winx - tx)/2; - } if (ty > winy) { @@ -2744,9 +2746,7 @@ void TileDrawTitle() ty = winy; } else - { y = (winy - ty)/2; - } ImgCopy(TitleImg, 0, 0, tx, ty, pBuf, x, y, 1); title.make_active(); @@ -2768,7 +2768,7 @@ static void TilePutch(int c, img_type Dest, int dx, int dy) int sy = (tidx / TILE_PER_ROW)*TILE_Y + (tidx2 / 4)*(TILE_Y/2);; ImgCopy(TileImg, sx, sy, TILE_X/4, TILE_Y/2, - Dest, dx, dy, 0); + Dest, dx, dy, 0); } void TileRedrawInv(int region) @@ -2781,26 +2781,30 @@ void TileRedrawInv(int region) void TileClearInv(int region) { - TileRegionClass *r = (region == REGION_INV1) ? region_item:region_item2; + TileRegionClass *r = (region == REGION_INV1) ? region_item + : region_item2; for (int i = 0; i < r->mx * r->my; i++) { - TileDrawOneItem(region, i, 0, -1, -1, -1, false, false, false, false, false); + TileDrawOneItem(region, i, 0, -1, -1, -1, + false, false, false, false, false); } + last_cursor = -1; itemlist_n = 0; } void TileDrawOneItem(int region, int i, char key, int idx, - int tile, int num, bool floor, - bool select, bool equip, bool tried, bool cursed) + int tile, int num, bool floor, + bool select, bool equip, bool tried, bool cursed) { ASSERT(idx >= -1 && idx < MAX_ITEMS); - TileRegionClass *r = (region == REGION_INV1) ? region_item:region_item2; + TileRegionClass *r = (region == REGION_INV1) ? region_item + : region_item2; int item_x = r->mx; - int dx = (i % item_x)*TILE_X; - int dy = (i / item_x)*TILE_Y; + int dx = (i % item_x) * TILE_X; + int dy = (i / item_x) * TILE_Y; if (tile == -1) { @@ -2817,14 +2821,13 @@ void TileDrawOneItem(int region, int i, char key, int idx, { if (cursed) ImgCopyFromTileImg(TILE_ITEM_SLOT_EQUIP_CURSED, r->backbuf, - dx, dy, 0); + dx, dy, 0); else ImgCopyFromTileImg(TILE_ITEM_SLOT_EQUIP, r->backbuf, dx, dy, 0); } else if (cursed) - { ImgCopyFromTileImg(TILE_ITEM_SLOT_CURSED, r->backbuf, dx, dy, 0); - } + if (select) ImgCopyFromTileImg(TILE_RAY_MESH, r->backbuf, dx, dy, 0); @@ -2843,30 +2846,31 @@ void TileDrawOneItem(int region, int i, char key, int idx, const int offset_amount = TILE_X/4; int offset = 0; + int help = num; - int c100 = help/100; help -= c100*100; + if (c100) { TilePutch('0' + c100, r->backbuf, dx+offset, dy); offset += offset_amount; } + int c10 = help/10; if (c10 || c100) { TilePutch('0' + c10, r->backbuf, dx+offset, dy); offset += offset_amount; } + int c1 = help % 10; TilePutch('0' + c1, r->backbuf, dx+offset, dy); } // '?' mark if (tried) - { TilePutch('?', r->backbuf, dx, dy + TILE_Y/2); - } // record tile information as we draw it so that we can re-draw it at will itemlist[i] = tile; @@ -2874,6 +2878,7 @@ void TileDrawOneItem(int region, int i, char key, int idx, itemlist_key[i] = key; itemlist_idx[i] = idx; itemlist_iflag[i] = 0; + if (floor) itemlist_iflag[i] |= TILEI_FLAG_FLOOR; if (tried) @@ -2890,7 +2895,7 @@ void TileDrawOneItem(int region, int i, char key, int idx, } void TileDrawInvData(int n, int flag, int *tiles, int *num, int *idx, - int *iflags) + int *iflags) { int i; TileRegionClass *r = (flag == REGION_INV1) ? region_item:region_item2; @@ -2904,13 +2909,15 @@ void TileDrawInvData(int n, int flag, int *tiles, int *num, int *idx, int item_x = r->mx; int item_y = r->my; - for (i=0;i<item_x*item_y;i++) + for (i = 0; i < item_x * item_y; i++) { - if (i==MAX_ITEMLIST) break; + if (i == MAX_ITEMLIST) + break; int tile0 = (i>=n) ? -1 : tiles[i]; int idx0 = (i>=n) ? -1 : idx[i]; - char key = (iflags[i]&TILEI_FLAG_FLOOR) ? 0 : index_to_letter(idx[i]); + char key = (iflags[i] & TILEI_FLAG_FLOOR) ? 0 + : index_to_letter(idx[i]); if ( flag == itemlist_flag && tile0 == itemlist[i] @@ -2925,11 +2932,11 @@ void TileDrawInvData(int n, int flag, int *tiles, int *num, int *idx, } TileDrawOneItem(flag, i, key, idx0, tile0, num[i], - ((iflags[i]&TILEI_FLAG_FLOOR) != 0), - ((iflags[i]&TILEI_FLAG_SELECT) != 0), - ((iflags[i]&TILEI_FLAG_EQUIP) != 0), - ((iflags[i]&TILEI_FLAG_TRIED) != 0), - ((iflags[i]&TILEI_FLAG_CURSE) != 0)); + ((iflags[i]&TILEI_FLAG_FLOOR) != 0), + ((iflags[i]&TILEI_FLAG_SELECT) != 0), + ((iflags[i]&TILEI_FLAG_EQUIP) != 0), + ((iflags[i]&TILEI_FLAG_TRIED) != 0), + ((iflags[i]&TILEI_FLAG_CURSE) != 0)); } r->make_active(); @@ -2941,7 +2948,8 @@ void TileDrawInvData(int n, int flag, int *tiles, int *num, int *idx, void TileDrawInvCursor(int ix, bool flag) { TileRegionClass *r = - (itemlist_flag == REGION_INV1) ? region_item:region_item2; + (itemlist_flag == REGION_INV1) ? region_item + : region_item2; int tile0 = itemlist[ix]; int num0 = itemlist_num[ix]; @@ -2952,12 +2960,11 @@ void TileDrawInvCursor(int ix, bool flag) itemlist_iflag[ix] &= ~TILEI_FLAG_CURSOR; TileDrawOneItem(itemlist_flag, ix, itemlist_key[ix], itemlist_idx[ix], tile0, num0, - ((itemlist_iflag[ix]&TILEI_FLAG_FLOOR) != 0), - ((itemlist_iflag[ix]&TILEI_FLAG_SELECT) != 0), - ((itemlist_iflag[ix]&TILEI_FLAG_EQUIP) != 0), - ((itemlist_iflag[ix]&TILEI_FLAG_TRIED) != 0), - ((itemlist_iflag[ix]&TILEI_FLAG_CURSE) != 0) - ); + ((itemlist_iflag[ix]&TILEI_FLAG_FLOOR) != 0), + ((itemlist_iflag[ix]&TILEI_FLAG_SELECT) != 0), + ((itemlist_iflag[ix]&TILEI_FLAG_EQUIP) != 0), + ((itemlist_iflag[ix]&TILEI_FLAG_TRIED) != 0), + ((itemlist_iflag[ix]&TILEI_FLAG_CURSE) != 0)); r->redraw(); } @@ -2967,7 +2974,9 @@ void TileMoveInvCursor(int ix) if (last_cursor != -1) TileDrawInvCursor(last_cursor, false); - if (ix != -1) TileDrawInvCursor(ix, true); + if (ix != -1) + TileDrawInvCursor(ix, true); + last_cursor = ix; } |