summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-23 21:06:01 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-23 21:06:01 +0000
commit9e511702e814c94093bb77ae460f8be8b7a49b16 (patch)
treee133213151a9871ed51a98f7356caab2f43639db /crawl-ref/source
parent2055942d4ba70adfd48f939b2a6d140f2329a2b6 (diff)
downloadcrawl-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')
-rw-r--r--crawl-ref/source/libgui.cc519
-rw-r--r--crawl-ref/source/tile1.cc563
-rw-r--r--crawl-ref/source/tile2.cc1059
3 files changed, 1086 insertions, 1055 deletions
diff --git a/crawl-ref/source/libgui.cc b/crawl-ref/source/libgui.cc
index c6177d9b63..024b1bf52b 100644
--- a/crawl-ref/source/libgui.cc
+++ b/crawl-ref/source/libgui.cc
@@ -118,7 +118,7 @@ static int font_size = 12;
#define PREF_MODE_ISO 2
#define PREF_MODE_NUM 3
static const char *pref_mode_name[PREF_MODE_NUM]
- ={ "Text", "Tile", "Iso"};
+ = { "Text", "Tile", "Iso"};
typedef struct prefs
{
@@ -157,8 +157,8 @@ struct prefs pref_data[MAX_PREFS] =
};
static int pref_mode = 0;
-static void libgui_load_prefs();
-static void libgui_save_prefs();
+static void _libgui_load_prefs();
+static void _libgui_save_prefs();
//Internal variables
@@ -204,9 +204,9 @@ static int gmap_ox, gmap_oy;
#define PX_T 12
#define PX_MS 13
-static char gmap_to_colour(char gm)
+static char _gmap_to_colour(char gm)
{
- switch(gm)
+ switch (gm)
{
case PX_0: // unseen
default:
@@ -380,10 +380,10 @@ void GmapUpdate(int x, int y, int what, bool upd_tile)
// In some cases (like smoke), update the gmap with the ground color
// instead. This keeps it prettier in the case of lava + smoke.
case '#':
- c = gmap_to_colour(gmap_col[grid_symbol & 0xff]);
+ c = _gmap_to_colour(gmap_col[grid_symbol & 0xff]);
break;
default:
- c = gmap_to_colour(gmap_col[what & 0xff]);
+ c = _gmap_to_colour(gmap_col[what & 0xff]);
break;
}
@@ -488,7 +488,7 @@ void GmapDisplay(int linex, int liney)
}
/* initialize routines */
-static void do_layout()
+static void _do_layout()
{
// buffer between map region and stat region
const int map_stat_buffer = 5;
@@ -508,10 +508,10 @@ static void do_layout()
// tile 2d mode
win_main->placeRegion(region_tile, LAYER_NML, 0, 0);
win_main->placeRegion(region_msg, LAYER_NML, region_tile, PLACE_BOTTOM,
- tm, tm, tm, tm);
+ tm, tm, tm, tm);
- int sx = std::max(region_msg->ex + region_msg->dx, region_tile->ex) +
- map_stat_buffer;
+ int sx = std::max(region_msg->ex + region_msg->dx, region_tile->ex)
+ + map_stat_buffer;
int sy = 0;
win_main->placeRegion(region_stat, LAYER_NML, sx, sy);
@@ -523,9 +523,7 @@ static void do_layout()
lowest = region_tip;
}
else
- {
lowest = region_map;
- }
int item_x = (win_main->wx-2*tm) / TILE_X;
int item_y = (52 + item_x -1) / item_x;
@@ -540,8 +538,8 @@ static void do_layout()
region_crt->resize(crt_wx, crt_wy);
win_main->placeRegion(region_crt, LAYER_CRT, 0, 0, tm, tm, tm, tm);
- win_main->placeRegion (region_item2, LAYER_CRT, region_crt, PLACE_BOTTOM,
- tm, tm, tm, tm);
+ win_main->placeRegion(region_item2, LAYER_CRT, region_crt, PLACE_BOTTOM,
+ tm, tm, tm, tm);
if (Options.show_items[0] != 0)
{
@@ -553,15 +551,17 @@ static void do_layout()
int item_x2 = (win_main->wx - region_msg->ex) / TILE_X;
int item_y2 = (win_main->wy - region_msg->sy) / TILE_Y;
- if (item_x * item_y < item_x2 * item_y2 &&
- lowest->ey < region_msg->sy)
+ if (item_x * item_y < item_x2 * item_y2
+ && lowest->ey < region_msg->sy)
{
item_x = item_x2;
item_y = item_y2;
r0 = region_msg;
place = PLACE_RIGHT;
}
- while(item_x * item_y < 40) item_y++;
+ while (item_x * item_y < 40)
+ item_y++;
+
region_item -> resize(item_x, item_y, TILE_X, TILE_Y);
win_main->placeRegion (region_item, LAYER_NML, r0, place);
}
@@ -579,7 +579,7 @@ void libgui_init()
pref_mode = PREF_MODE_TILE;
- libgui_load_prefs();
+ _libgui_load_prefs();
// Adjust sizes
if (dngn_x & 1 ==0) dngn_x++;
@@ -666,10 +666,12 @@ void libgui_init()
region_stat->init_font(font_name);
region_msg->init_font(font_name);
region_tip->init_font(font_name);
- if (region_dngn) region_dngn->init_font(font_name);
+
+ if (region_dngn)
+ region_dngn->init_font(font_name);
#endif
- do_layout();
+ _do_layout();
win_main->create((char*)(CRAWL " " VERSION));
@@ -677,19 +679,25 @@ void libgui_init()
region_tile -> init_backbuf();
region_item2->init_backbuf();
- if (region_item) region_item->init_backbuf();
+
+ if (region_item)
+ region_item->init_backbuf();
}
void libgui_shutdown()
{
- if(TileImg) ImgDestroy(TileImg);
- if(PlayerImg) ImgDestroy(PlayerImg);
- if(WallImg) ImgDestroy(WallImg);
- if(TileIsoImg) ImgDestroy(TileIsoImg);
+ if (TileImg)
+ ImgDestroy(TileImg);
+ if (PlayerImg)
+ ImgDestroy(PlayerImg);
+ if (WallImg)
+ ImgDestroy(WallImg);
+ if (TileIsoImg)
+ ImgDestroy(TileIsoImg);
// do this before delete win_main
- libgui_save_prefs();
+ _libgui_save_prefs();
std::vector<RegionClass *>::iterator r;
for (r = win_main->regions.begin();r != win_main->regions.end();r++)
@@ -700,12 +708,11 @@ void libgui_shutdown()
delete win_main;
-
libgui_shutdown_sys();
}
/*** Save, Load, and Edit window prefs ***/
-static void libgui_load_prefs()
+static void _libgui_load_prefs()
{
int i, mode;
FILE *fp;
@@ -715,7 +722,7 @@ static void libgui_load_prefs()
// set default
for (mode = 0; mode < PREF_MODE_NUM; mode++)
{
- for(i=0;i<MAX_PREFS;i++)
+ for (i = 0; i < MAX_PREFS; i++)
{
struct prefs *p = &pref_data[i];
int idx = p->dummy_idx;
@@ -733,28 +740,30 @@ static void libgui_load_prefs()
if ( (fp = fopen(winTxt, "r")) != NULL )
{
- while(!feof(fp))
+ while (!feof(fp))
{
fgets(buf, 250, fp);
i = 0;
- while(buf[i] >= 32 && i< 120) i++;
+ while(buf[i] >= 32 && i< 120)
+ i++;
buf[i] = 0;
- for(i=0;i<MAX_PREFS;i++)
+ for (i = 0; i < MAX_PREFS; i++)
{
struct prefs *p = &pref_data[i];
for (mode = 0; mode < PREF_MODE_NUM; mode++)
{
- sprintf(tagbuf, "%s:%s",
- pref_mode_name[mode], p->tagname);
- if(strncmp(buf, tagbuf, strlen(tagbuf)) == 0)
+ sprintf(tagbuf, "%s:%s", pref_mode_name[mode], p->tagname);
+ if (strncmp(buf, tagbuf, strlen(tagbuf)) == 0)
{
char *dat = &buf[strlen(tagbuf)+1];
if (p->type == 'I')
{
int val = atoi(dat);
- if (val > p->max) val = p->max;
- if (val < p->min) val = p->min;
+ if (val > p->max)
+ val = p->max;
+ if (val < p->min)
+ val = p->min;
dummy_int[mode][p->dummy_idx] = val;
if (mode == pref_mode)
*(int *)p->ptr = val;
@@ -762,19 +771,19 @@ static void libgui_load_prefs()
if (p->type == 'S')
{
strncpy(dummy_str[mode][p->dummy_idx], dat,
- MAX_PREF_CHAR);
+ MAX_PREF_CHAR);
if (mode == pref_mode)
strncpy((char *)p->ptr, dat, MAX_PREF_CHAR);
}
break;
}// tag match
- } //mode
- }//i
+ }
+ }
}// while
}
}
-static void libgui_save_prefs()
+static void _libgui_save_prefs()
{
int i, mode;
FILE *fp;
@@ -785,7 +794,7 @@ static void libgui_save_prefs()
windows_get_winpos(&winox, &winoy);
#endif
- for(i=0;i<MAX_PREFS;i++)
+ for (i = 0; i < MAX_PREFS; i++)
{
struct prefs *p = &pref_data[i];
int idx = p->dummy_idx;
@@ -797,52 +806,57 @@ static void libgui_save_prefs()
const char *baseTxt = "wininit.txt";
std::string winTxtString = datafile_path(baseTxt, false, true);
- const char *winTxt = winTxtString.c_str()[0] == 0 ?
- baseTxt : winTxtString.c_str();
+ const char *winTxt = winTxtString.c_str()[0] == 0 ? baseTxt
+ : winTxtString.c_str();
if ( (fp = fopen(winTxt, "w")) != NULL )
{
for (mode = 0; mode < PREF_MODE_NUM; mode++)
{
- for(i=0;i<MAX_PREFS;i++)
+ for ( i = 0; i < MAX_PREFS; i++)
{
- struct prefs *p = &pref_data[i];
- int idx = p->dummy_idx;
- if (p->type == 'I')
- fprintf(fp, "%s:%s=%d\n", pref_mode_name[mode],
- p->tagname, dummy_int[mode][idx]);
- if (p->type == 'S')
- fprintf(fp, "%s:%s=%s\n", pref_mode_name[mode],
- p->tagname, dummy_str[mode][idx]);
+ struct prefs *p = &pref_data[i];
+ int idx = p->dummy_idx;
+
+ if (p->type == 'I')
+ {
+ fprintf(fp, "%s:%s=%d\n", pref_mode_name[mode],
+ p->tagname, dummy_int[mode][idx]);
+ }
+ else if (p->type == 'S')
+ {
+ fprintf(fp, "%s:%s=%s\n", pref_mode_name[mode],
+ p->tagname, dummy_str[mode][idx]);
+ }
}
fprintf(fp, "\n");
- }
+ }
fclose(fp);
}
}
-static void draw_hgauge(int x, int y, int ofs, int region, int len, int col)
+static void _draw_hgauge(int x, int y, int ofs, int region, int len, int col)
{
int i;
cgotoxy(x, y, region);
textcolor(col);
- for (i=0; i < len; i++)
+ for (i = 0; i < len; i++)
{
switch((i+ ofs) % 10)
{
- case 0: cprintf("%c",'+');break;
- case 4: cprintf("%c",'0' + (1+(i+ofs)/10)%10);break;
- case 5: cprintf("%c",'0');break;
+ case 0: cprintf("%c",'+'); break;
+ case 4: cprintf("%c",'0' + (1+(i+ofs)/10)%10); break;
+ case 5: cprintf("%c",'0'); break;
default: cprintf("%c",'-');
}
}
}
-static void draw_vgauge(int x, int y, int ofs, int region, int len, int col)
+static void _draw_vgauge(int x, int y, int ofs, int region, int len, int col)
{
int i;
textcolor(col);
- for (i=0; i < len; i++)
+ for (i = 0; i < len; i++)
{
cgotoxy(x, y+i, region);
cprintf("%02d", ofs+i);
@@ -851,7 +865,6 @@ static void draw_vgauge(int x, int y, int ofs, int region, int len, int col)
void edit_prefs()
{
-
int i;
int cur_pos = 0;
cursor_control cs(false);
@@ -864,193 +877,205 @@ void edit_prefs()
region_msg->clear();
viewwindow(true, false);
- while(1)
+ while (true)
{
- bool upd_msg = false;
- bool upd_dngn = false;
- bool upd_crt = false;
- bool upd_map = false;
- bool need_resize = false;
- int inc = 0;
+ bool upd_msg = false;
+ bool upd_dngn = false;
+ bool upd_crt = false;
+ bool upd_map = false;
+ bool need_resize = false;
+ int inc = 0;
- if (need_draw_msg)
- {
- textcolor(LIGHTGREY);
+ if (need_draw_msg)
+ {
+ textcolor(LIGHTGREY);
region_msg->clear();
- textcolor(WHITE);
- cgotoxy (4, 4, GOTO_MSG);
- cprintf("j, k, up, down : Select pref");
- cgotoxy (4, 5, GOTO_MSG);
- cprintf("h, l, left, right : Decrease/Increase");
- cgotoxy (4, 6, GOTO_MSG);
- cprintf("H, L : Dec/Inc by 10");
- need_draw_msg = false;
- }
+ textcolor(WHITE);
+ cgotoxy (4, 4, GOTO_MSG);
+ cprintf("j, k, up, down : Select pref");
+ cgotoxy (4, 5, GOTO_MSG);
+ cprintf("h, l, left, right : Decrease/Increase");
+ cgotoxy (4, 6, GOTO_MSG);
+ cprintf("H, L : Dec/Inc by 10");
+ need_draw_msg = false;
+ }
- if (need_draw_stat)
- {
+ if (need_draw_stat)
+ {
region_stat->clear();
- for(i=0; i<MAX_EDIT_PREFS;i++)
- {
- struct prefs *p = &pref_data[i];
- cgotoxy(2, i+2, GOTO_STAT);
- if (i == cur_pos)
+ for (i = 0; i < MAX_EDIT_PREFS; i++)
{
- textcolor(0xf0);
- cprintf(">");
- }
- else
- {
- textcolor(LIGHTGREY);
- cprintf(" ");
- }
- if (pref_data[i].type == 'I')
- cprintf(" %s: %3d ", p->name, *(int *)p->ptr);
- else
- cprintf(" %s: %s", p->name, (char *)p->ptr);
- }
- textcolor(LIGHTGREY);
+ struct prefs *p = &pref_data[i];
+ cgotoxy(2, i+2, GOTO_STAT);
+ if (i == cur_pos)
+ {
+ textcolor(0xf0);
+ cprintf(">");
+ }
+ else
+ {
+ textcolor(LIGHTGREY);
+ cprintf(" ");
+ }
+
+ if (pref_data[i].type == 'I')
+ cprintf(" %s: %3d ", p->name, *(int *)p->ptr);
+ else
+ cprintf(" %s: %s", p->name, (char *)p->ptr);
+ }
+ textcolor(LIGHTGREY);
#ifdef WIN32TILES
- cgotoxy(4, MAX_EDIT_PREFS+3, GOTO_STAT);
- cprintf("FONT: %s %d",font_name, font_size);
- if (UseDosChar)
- {
- cgotoxy(4, MAX_EDIT_PREFS+4, GOTO_STAT);
- cprintf("DOSFONT: %s %d", dos_font_name, dos_font_size);
- }
+ cgotoxy(4, MAX_EDIT_PREFS+3, GOTO_STAT);
+ cprintf("FONT: %s %d",font_name, font_size);
+ if (UseDosChar)
+ {
+ cgotoxy(4, MAX_EDIT_PREFS+4, GOTO_STAT);
+ cprintf("DOSFONT: %s %d", dos_font_name, dos_font_size);
+ }
#else
- cgotoxy(4, MAX_EDIT_PREFS+3, GOTO_STAT);
- cprintf("FONT: %s",font_name);
+ cgotoxy(4, MAX_EDIT_PREFS+3, GOTO_STAT);
+ cprintf("FONT: %s",font_name);
#endif
-
- int *dat = (int *)pref_data[cur_pos].ptr;
+ int *dat = (int *)pref_data[cur_pos].ptr;
#define WHITEIF(x) (dat == &x)?0xf0:LIGHTGREY
- draw_hgauge(3, 1, 3, GOTO_MSG, msg_x-2, WHITEIF(msg_x));
- clear_to_end_of_line();
- draw_vgauge(1, 1, 1, GOTO_MSG, msg_y, WHITEIF(msg_y));
- need_draw_stat = false;
+ _draw_hgauge(3, 1, 3, GOTO_MSG, msg_x-2, WHITEIF(msg_x));
+ clear_to_end_of_line();
+ _draw_vgauge(1, 1, 1, GOTO_MSG, msg_y, WHITEIF(msg_y));
+ need_draw_stat = false;
}
- int key = getch();
+ int key = getch();
struct prefs *p = &pref_data[cur_pos];
- int *dat = (int *)p->ptr;
-
- if (key == 0x1b || key == '\r') break;
- if (key == 'j' || key == CK_DOWN)
- {
- cur_pos++;
- need_draw_stat = true;
- }
- if (key == 'k' || key == CK_UP)
- {
- cur_pos--;
- need_draw_stat = true;
- }
- if (key == CK_LEFT) key = 'h';
- if (key == CK_RIGHT) key = 'l';
+ int *dat = (int *)p->ptr;
- cur_pos = (cur_pos + MAX_EDIT_PREFS) % MAX_EDIT_PREFS;
+ if (key == 0x1b || key == '\r')
+ break;
+
+ if (key == 'j' || key == CK_DOWN)
+ {
+ cur_pos++;
+ need_draw_stat = true;
+ }
+ if (key == 'k' || key == CK_UP)
+ {
+ cur_pos--;
+ need_draw_stat = true;
+ }
+ if (key == CK_LEFT)
+ key = 'h';
+ if (key == CK_RIGHT)
+ key = 'l';
- switch(key)
- {
- case 'l': inc=1; break;
- case 'L': inc=10; break;
- case 'h': inc=-1; break;
- case 'H': inc=-10; break;
- }
+ cur_pos = (cur_pos + MAX_EDIT_PREFS) % MAX_EDIT_PREFS;
- int crt_x_old = crt_x;
- int crt_y_old = crt_y;
- int map_px_old = map_px;
- int msg_x_old = msg_x;
- int msg_y_old = msg_y;
- int dngn_x_old = dngn_x;
- int dngn_y_old = dngn_y;
-
- if ( (p->type == 'I') && inc != 0)
- {
- if (dat == &dngn_x || dat == &dngn_y )
+ switch(key)
{
- if (inc==1) inc=2;
- if (inc==-1) inc=-2;
+ case 'l': inc = 1; break;
+ case 'L': inc = 10; break;
+ case 'h': inc = -1; break;
+ case 'H': inc = -10; break;
}
- int olddat = *dat;
- (*dat)+= inc;
-
- if (*dat > p->max) *dat = p->max;
- if (*dat < p->min) *dat = p->min;
- if (olddat == *dat) continue;
- need_resize = true;
- }// changed
+ int crt_x_old = crt_x;
+ int crt_y_old = crt_y;
+ int map_px_old = map_px;
+ int msg_x_old = msg_x;
+ int msg_y_old = msg_y;
+ int dngn_x_old = dngn_x;
+ int dngn_y_old = dngn_y;
+
+ if (p->type == 'I' && inc != 0)
+ {
+ if (dat == &dngn_x || dat == &dngn_y)
+ {
+ if (inc == 1)
+ inc++;
+ else if (inc == -1)
+ inc--;
+ }
- if (need_resize)
- {
- need_draw_stat = need_draw_msg = true;
+ int olddat = *dat;
+ (*dat)+= inc;
- // crt screen layouts
+ if (*dat > p->max)
+ *dat = p->max;
+ if (*dat < p->min)
+ *dat = p->min;
- // resize msg?
- if (msg_x != msg_x_old || msg_y != msg_y_old)
- {
- upd_msg = true;
- region_msg->resize(msg_x, msg_y);
+ if (olddat == *dat)
+ continue;
+ need_resize = true;
}
- // resize crt?
- if (crt_x != crt_x_old || crt_y != crt_y_old)
- {
- upd_crt = true;
- region_crt->resize(crt_x, crt_y);
- }
- // resize map?
- if (map_px != map_px_old)
+
+ if (need_resize)
{
+ need_draw_stat = need_draw_msg = true;
+
+ // crt screen layouts
+
+ // resize msg?
+ if (msg_x != msg_x_old || msg_y != msg_y_old)
+ {
+ upd_msg = true;
+ region_msg->resize(msg_x, msg_y);
+ }
+ // resize crt?
+ if (crt_x != crt_x_old || crt_y != crt_y_old)
+ {
+ upd_crt = true;
+ region_crt->resize(crt_x, crt_y);
+ }
+ // resize map?
+ if (map_px != map_px_old)
+ {
upd_map = true;
region_map->resize( 0, 0, map_px, map_px);
- }
+ }
- // resize dngn tile screen?
- if (dngn_x != dngn_x_old || dngn_y != dngn_y_old)
- {
+ // resize dngn tile screen?
+ if (dngn_x != dngn_x_old || dngn_y != dngn_y_old)
+ {
clrscr();
upd_dngn = true;
tile_dngn_x = dngn_x;
tile_dngn_y = dngn_y;
region_tile->resize(dngn_x, dngn_y, 0, 0);
- }
+ }
- do_layout();
- win_main->resize();
- win_main->clear();
+ _do_layout();
+ win_main->resize();
+ win_main->clear();
- // Now screens are all black
+ // Now screens are all black
- if (upd_map)
- region_map->resize_backbuf();
- if (upd_dngn)
- {
- region_tile -> resize_backbuf();
- tile_set_force_redraw_tiles(true);
- TileResizeScreen(dngn_x, dngn_y);
- }
- if (region_item)
- region_item->resize_backbuf();
- if (region_item2)
- region_item2->resize_backbuf();
- tile_set_force_redraw_inv(true);
- tile_draw_inv(-1, REGION_INV1);
-
- region_map->force_redraw = true;
- viewwindow(true, true);
- region_tile->redraw();
- region_item->redraw();
- }// need resize
- }//while
+ if (upd_map)
+ region_map->resize_backbuf();
+ if (upd_dngn)
+ {
+ region_tile -> resize_backbuf();
+ tile_set_force_redraw_tiles(true);
+ TileResizeScreen(dngn_x, dngn_y);
+ }
+ if (region_item)
+ region_item->resize_backbuf();
+ if (region_item2)
+ region_item2->resize_backbuf();
+
+ tile_set_force_redraw_inv(true);
+ tile_draw_inv(-1, REGION_INV1);
+
+ region_map->force_redraw = true;
+ viewwindow(true, true);
+ region_tile->redraw();
+ region_item->redraw();
+ } // need resize
+ } // while-loop
+
clrscr();
redraw_screen();
mpr("Done.");
@@ -1078,7 +1103,7 @@ void tip_grid(int gx, int gy, bool do_null = true, int minimap=0)
int tile_cursor_x = -1;
int tile_cursor_y = -1;
-int tile_cursor_flag=0;
+int tile_cursor_flag = 0;
void tile_place_cursor(int x, int y, bool display)
{
@@ -1127,9 +1152,10 @@ int convert_cursor_pos(int mx, int my, int *cx, int *cy)
for (r = w->regions.begin();r != w->regions.end();r++)
{
- if (! (*r)->is_active()) continue;
+ if (! (*r)->is_active())
+ continue;
- if ( (*r)->mouse_pos(mx, my, cx, cy))
+ if ( (*r)->mouse_pos(mx, my, cx, cy) )
{
id = (*r)->id;
mx0 = (*r)->mx;
@@ -1144,13 +1170,14 @@ int convert_cursor_pos(int mx, int my, int *cx, int *cy)
if (id == REGION_TDNGN)
{
x--;
- if (!in_viewport_bounds(x+1,y+1)) return REGION_NONE;
+ if (!in_viewport_bounds(x+1,y+1))
+ return REGION_NONE;
}
if (id == REGION_MAP)
{
- x = x - gmap_ox + region_map->x_margin + 1;
- y = y - gmap_oy + region_map->y_margin + 1;
+ x -= gmap_ox + region_map->x_margin + 1;
+ y -= gmap_oy + region_map->y_margin + 1;
}
if (id == REGION_INV1 || id == REGION_INV2)
@@ -1163,7 +1190,7 @@ int convert_cursor_pos(int mx, int my, int *cx, int *cy)
{
// Out of LOS range
if (!in_viewport_bounds(x+1,y+1))
- return REGION_NONE;
+ return REGION_NONE;
}
*cx = x;
@@ -1172,7 +1199,7 @@ int convert_cursor_pos(int mx, int my, int *cx, int *cy)
return id;
}
-static int handle_mouse_motion(int mouse_x, int mouse_y, bool init)
+static int _handle_mouse_motion(int mouse_x, int mouse_y, bool init)
{
int cx = -1;
int cy = -1;
@@ -1527,8 +1554,8 @@ static int handle_mouse_motion(int mouse_x, int mouse_y, bool init)
return 0;
}
-static int handle_mouse_button(int mx, int my, int button,
- bool shift, bool ctrl)
+static int _handle_mouse_button(int mx, int my, int button,
+ bool shift, bool ctrl)
{
int dir;
const int dx[9]={-1,0,1, -1,0,1, -1,0,1};
@@ -1553,17 +1580,17 @@ static int handle_mouse_button(int mx, int my, int button,
else if (button == 5)
trig = CK_MOUSE_B5;
- if (shift) trig |= 512;
- if (ctrl) trig |= 1024;
+ if (shift)
+ trig |= 512;
+ if (ctrl)
+ trig |= 1024;
- switch(mouse_mode)
+ switch (mouse_mode)
{
case MOUSE_MODE_NORMAL:
return trig;
- break;
case MOUSE_MODE_MORE:
return '\r';
- break;
}
int cx,cy;
@@ -1581,7 +1608,8 @@ static int handle_mouse_button(int mx, int my, int button,
if (mouse_mode==MOUSE_MODE_COMMAND && (button == 4 || button == 5)
&& button == old_button && oldcx == cx && oldcy == cy)
{
- if(!enable_wheel) return 0;
+ if (!enable_wheel)
+ return 0;
if (you.hp < old_hp)
{
mpr("Wheel move aborted (rotate opposite to resume)");
@@ -1722,7 +1750,7 @@ static int handle_mouse_button(int mx, int my, int button,
int adir = -1;
for (dir = 0; dir < 9; dir++)
{
- if (DCX+dx[dir] == cx && DCY+dy[dir]==cy)
+ if (DCX + dx[dir] == cx && DCY + dy[dir] == cy)
{
adir = dir;
break;
@@ -1751,7 +1779,7 @@ static int handle_mouse_button(int mx, int my, int button,
return CK_MOUSE_DONE;
}
- if (mouse_mode==MOUSE_MODE_COMMAND && mode == REGION_MAP)
+ if (mouse_mode == MOUSE_MODE_COMMAND && mode == REGION_MAP)
{
// begin telescope mode
if (button == 2)
@@ -1762,7 +1790,8 @@ static int handle_mouse_button(int mx, int my, int button,
return 0;
}
- if (button != 1) return trig;
+ if (button != 1)
+ return trig;
// L-click: try to travel to the grid
const coord_def gc(cx-1, cy-1);
@@ -1775,7 +1804,7 @@ static int handle_mouse_button(int mx, int my, int button,
}
// target selection
- if((mouse_mode==MOUSE_MODE_TARGET || mouse_mode==MOUSE_MODE_TARGET_DIR)
+ if ((mouse_mode == MOUSE_MODE_TARGET || mouse_mode == MOUSE_MODE_TARGET_DIR)
&& button == 1 && (mode == REGION_DNGN || mode == REGION_TDNGN))
{
gui_set_mouse_view_pos(true, cx+1, cy+1);
@@ -1784,13 +1813,15 @@ static int handle_mouse_button(int mx, int my, int button,
gui_set_mouse_view_pos(false, 0, 0);
- if(mouse_mode==MOUSE_MODE_TARGET_DIR && button == 1 &&
- (mode == REGION_DNGN || mode == REGION_TDNGN))
+ if (mouse_mode == MOUSE_MODE_TARGET_DIR && button == 1
+ && (mode == REGION_DNGN || mode == REGION_TDNGN))
{
- if (cx < DCX-1 || cy < DCY-1 || cx > DCX+1 || cy > DCY+1) return 0;
+ if (cx < DCX-1 || cy < DCY-1 || cx > DCX+1 || cy > DCY+1)
+ return 0;
+
for (dir = 0; dir < 9; dir++)
{
- if( DCX+dx[dir] == cx && DCY+dy[dir]==cy)
+ if (DCX + dx[dir] == cx && DCY + dy[dir] == cy)
return cmd_dir[dir];
}
return 0;
@@ -1799,12 +1830,10 @@ static int handle_mouse_button(int mx, int my, int button,
return trig;
}
-static int handle_mouse_unbutton(int mx, int my, int button)
+static int _handle_mouse_unbutton(int mx, int my, int button)
{
if (toggle_telescope)
- {
TileDrawDungeon(NULL);
- }
toggle_telescope = false;
return 0;
@@ -1812,11 +1841,11 @@ static int handle_mouse_unbutton(int mx, int my, int button)
int getch_ck()
{
- int etype = 0;
- int x1,y1,x2,y2;
- int key;
+ int etype = 0;
+ int x1,y1,x2,y2;
+ int key;
bool sh, ct;
- int k;
+ int k;
while (true)
{
@@ -1825,15 +1854,15 @@ int getch_ck()
switch(etype)
{
case EV_BUTTON:
- k = handle_mouse_button(x1, y1, key, sh, ct);
+ k = _handle_mouse_button(x1, y1, key, sh, ct);
break;
case EV_MOVE:
- k = handle_mouse_motion(x1, y1, false);
+ k = _handle_mouse_motion(x1, y1, false);
break;
case EV_UNBUTTON:
- k = handle_mouse_unbutton(x1, y1, key);
+ k = _handle_mouse_unbutton(x1, y1, key);
break;
case EV_KEYIN:
@@ -1884,7 +1913,7 @@ void mouse_set_mode(int mode)
{
mouse_mode = mode;
// init cursor etc
- handle_mouse_motion(0, 0, true);
+ _handle_mouse_motion(0, 0, true);
}
int mouse_get_mode()
diff --git a/crawl-ref/source/tile1.cc b/crawl-ref/source/tile1.cc
index 9284b1f0bf..20e24e211f 100644
--- a/crawl-ref/source/tile1.cc
+++ b/crawl-ref/source/tile1.cc
@@ -802,6 +802,7 @@ int tileidx_monster_base(int mon_idx, bool detected)
int tileidx_monster(int mon_idx, bool detected)
{
+ ASSERT(mon_idx != -1);
int ch = tileidx_monster_base(mon_idx, detected);
const monsters* mons = &menv[mon_idx];
@@ -1673,7 +1674,7 @@ int tileidx_item(const item_def &item)
the octant boundary slope tan(pi/8)=sqrt(2)-1 = 0.414 is approximated by 2/5
*/
-static int tile_bolt_dir(int dx, int dy)
+static int _tile_bolt_dir(int dx, int dy)
{
int ax = abs(dx);
int ay = abs(dy);
@@ -1693,7 +1694,7 @@ int tileidx_item_throw(const item_def &item, int dx, int dy)
if (item.base_type == OBJ_MISSILES)
{
int ch = -1;
- int dir = tile_bolt_dir(dx, dy);
+ int dir = _tile_bolt_dir(dx, dy);
// Thrown items with multiple directions
switch(item.sub_type)
@@ -1747,7 +1748,7 @@ int tileidx_item_throw(const item_def &item, int dx, int dy)
return tileidx_item(item);
}
-static int tileidx_trap(trap_type type)
+static int _tileidx_trap(trap_type type)
{
switch (type)
{
@@ -1827,7 +1828,7 @@ int tileidx_feature(int object, int gx, int gy)
case DNGN_TRAP_MECHANICAL:
case DNGN_TRAP_MAGICAL:
case DNGN_TRAP_NATURAL:
- return tileidx_trap(trap_type_at_xy(gx, gy));
+ return _tileidx_trap(trap_type_at_xy(gx, gy));
case DNGN_ENTER_SHOP:
return TILE_DNGN_ENTER_SHOP;
case DNGN_ENTER_LABYRINTH:
@@ -2166,33 +2167,34 @@ void tilep_calc_flags(int parts[], int flag[])
{
int i;
- for(i=0;i<TILEP_PARTS_TOTAL;i++) flag[i]=TILEP_FLAG_NORMAL;
+ for (i = 0; i < TILEP_PARTS_TOTAL; i++)
+ flag[i] = TILEP_FLAG_NORMAL;
if (parts[TILEP_PART_HELM]-1 >= TILEP_HELM_HELM_OFS)
- flag[TILEP_PART_HAIR]=TILEP_FLAG_HIDE;
+ flag[TILEP_PART_HAIR] = TILEP_FLAG_HIDE;
if (parts[TILEP_PART_HELM]-1 >= TILEP_HELM_FHELM_OFS)
- flag[TILEP_PART_BEARD]=TILEP_FLAG_HIDE;
+ flag[TILEP_PART_BEARD] = TILEP_FLAG_HIDE;
- if(parts[TILEP_PART_BASE]== TILEP_BASE_NAGA ||
- parts[TILEP_PART_BASE]== TILEP_BASE_NAGA+1)
+ if (parts[TILEP_PART_BASE] == TILEP_BASE_NAGA
+ || parts[TILEP_PART_BASE] == TILEP_BASE_NAGA + 1)
{
- flag[TILEP_PART_BOOTS]=flag[TILEP_PART_LEG]=TILEP_FLAG_HIDE;
- flag[TILEP_PART_BODY] = TILEP_FLAG_CUT_NAGA;
+ flag[TILEP_PART_BOOTS] = flag[TILEP_PART_LEG] = TILEP_FLAG_HIDE;
+ flag[TILEP_PART_BODY] = TILEP_FLAG_CUT_NAGA;
}
- if(parts[TILEP_PART_BASE]== TILEP_BASE_CENTAUR ||
- parts[TILEP_PART_BASE]== TILEP_BASE_CENTAUR+1)
+ if (parts[TILEP_PART_BASE] == TILEP_BASE_CENTAUR
+ || parts[TILEP_PART_BASE] == TILEP_BASE_CENTAUR + 1)
{
- flag[TILEP_PART_BOOTS]=flag[TILEP_PART_LEG]=TILEP_FLAG_HIDE;
- flag[TILEP_PART_BODY] = TILEP_FLAG_CUT_CENTAUR;
+ flag[TILEP_PART_BOOTS] = flag[TILEP_PART_LEG] = TILEP_FLAG_HIDE;
+ flag[TILEP_PART_BODY] = TILEP_FLAG_CUT_CENTAUR;
}
- if (parts[TILEP_PART_BASE] == TILEP_BASE_MERFOLK_WATER ||
- parts[TILEP_PART_BASE] == TILEP_BASE_MERFOLK_WATER +1)
+ if (parts[TILEP_PART_BASE] == TILEP_BASE_MERFOLK_WATER
+ || parts[TILEP_PART_BASE] == TILEP_BASE_MERFOLK_WATER + 1)
{
- flag[TILEP_PART_BOOTS] = TILEP_FLAG_HIDE;
- flag[TILEP_PART_LEG] = TILEP_FLAG_HIDE;
+ flag[TILEP_PART_BOOTS] = TILEP_FLAG_HIDE;
+ flag[TILEP_PART_LEG] = TILEP_FLAG_HIDE;
flag[TILEP_PART_SHADOW] = TILEP_FLAG_HIDE;
}
}
@@ -2690,38 +2692,37 @@ void tilep_scan_parts(char *fbuf, int *parts)
int gcount = 0;
int ccount = 0;
- for(int i = 0; parts_saved[i] != -1; i++)
+ for (int i = 0; parts_saved[i] != -1; i++)
{
- int idx;
- ccount = 0;
- int p = parts_saved[i];
-
- while ( (fbuf[gcount] != ':') && (fbuf[gcount] != '\n')
- && (ccount<4) && (gcount<48) )
- {
- ibuf[ccount] = fbuf[gcount];
- ccount ++;
- gcount ++;
- }
-
- ibuf[ccount] = '\0';
- gcount ++;
-
- idx = tilep_str_to_part(ibuf);
- if (p == TILEP_PART_BASE)
- {
- int p0 = (parts[p]-1) & (0xfe);
- if (((1-idx) & 1) == 1) p0++;
- parts[p] = p0 + 1;
- }
- else if (idx == TILEP_SHOW_EQUIP)
- parts[p] = TILEP_SHOW_EQUIP;
- else if (idx < 0) // no negative value
- parts[p] = 0;
- else if (idx > tilep_parts_total[p]) // bound it
- parts[p] = tilep_parts_total[p];
- else
- parts[p] = idx;
+ int idx;
+ ccount = 0;
+ int p = parts_saved[i];
+
+ while (fbuf[gcount] != ':' && fbuf[gcount] != '\n'
+ && ccount < 4 && gcount < 48)
+ {
+ ibuf[ccount++] = fbuf[gcount++];
+ }
+
+ ibuf[ccount] = '\0';
+ gcount++;
+
+ idx = tilep_str_to_part(ibuf);
+ if (p == TILEP_PART_BASE)
+ {
+ int p0 = (parts[p]-1) & (0xfe);
+ if (((1-idx) & 1) == 1)
+ p0++;
+ parts[p] = p0 + 1;
+ }
+ else if (idx == TILEP_SHOW_EQUIP)
+ parts[p] = TILEP_SHOW_EQUIP;
+ else if (idx < 0) // no negative value
+ parts[p] = 0;
+ else if (idx > tilep_parts_total[p]) // bound it
+ parts[p] = tilep_parts_total[p];
+ else
+ parts[p] = idx;
}
}
@@ -2732,21 +2733,21 @@ void tilep_print_parts(char *fbuf, int *parts)
{
int i;
char *ptr = fbuf;
- for(i = 0; parts_saved[i] != -1; i++)
+ for (i = 0; parts_saved[i] != -1; i++)
{
- int p = parts_saved[i];
- if (p == TILEP_PART_BASE) // 0:female 1:male
- {
- sprintf(ptr, "%03d", parts[p]%2);
- ptr += 3;
- }
- else
- {
- tilep_part_to_str(parts[p], ptr);
- ptr += 3;
- }
- *ptr = ':';
- ptr++;
+ int p = parts_saved[i];
+ if (p == TILEP_PART_BASE) // 0:female 1:male
+ {
+ sprintf(ptr, "%03d", parts[p]%2);
+ ptr += 3;
+ }
+ else
+ {
+ tilep_part_to_str(parts[p], ptr);
+ ptr += 3;
+ }
+ *ptr = ':';
+ ptr++;
}
ptr--; // erase the last ':'
*ptr = 0;
@@ -2760,34 +2761,30 @@ int tilep_equ_weapon(const item_def &item)
if (item.base_type == OBJ_STAVES)
{
if (item_is_rod(item))
- {
return TILEP_HAND1_ROD_BROWN + (item.special / 4) % 10;
- }
else
- {
return TILEP_HAND1_STAFF_LARGE + (item.special / 4) % 10;
- }
}
if (item.base_type == OBJ_MISCELLANY)
{
switch(item.sub_type)
{
- case MISC_BOTTLED_EFREET: return TILEP_HAND1_BOTTLE;
- case MISC_AIR_ELEMENTAL_FAN: return TILEP_HAND1_FAN;
- case MISC_STONE_OF_EARTH_ELEMENTALS: return TILEP_HAND1_STONE;
- case MISC_DISC_OF_STORMS: return TILEP_HAND1_DISC;
+ case MISC_BOTTLED_EFREET: return TILEP_HAND1_BOTTLE;
+ case MISC_AIR_ELEMENTAL_FAN: return TILEP_HAND1_FAN;
+ case MISC_STONE_OF_EARTH_ELEMENTALS: return TILEP_HAND1_STONE;
+ case MISC_DISC_OF_STORMS: return TILEP_HAND1_DISC;
case MISC_CRYSTAL_BALL_OF_SEEING:
case MISC_CRYSTAL_BALL_OF_ENERGY:
- case MISC_CRYSTAL_BALL_OF_FIXATION: return TILEP_HAND1_CRYSTAL;
+ case MISC_CRYSTAL_BALL_OF_FIXATION: return TILEP_HAND1_CRYSTAL;
- case MISC_LAMP_OF_FIRE: return TILEP_HAND1_LANTERN;
- case MISC_LANTERN_OF_SHADOWS: return TILEP_HAND1_BONE_LANTERN;
- case MISC_HORN_OF_GERYON: return TILEP_HAND1_HORN;
+ case MISC_LAMP_OF_FIRE: return TILEP_HAND1_LANTERN;
+ case MISC_LANTERN_OF_SHADOWS: return TILEP_HAND1_BONE_LANTERN;
+ case MISC_HORN_OF_GERYON: return TILEP_HAND1_HORN;
case MISC_BOX_OF_BEASTS:
- case MISC_EMPTY_EBONY_CASKET: return TILEP_HAND1_BOX;
+ case MISC_EMPTY_EBONY_CASKET: return TILEP_HAND1_BOX;
case MISC_DECK_OF_ESCAPE:
case MISC_DECK_OF_DESTRUCTION:
@@ -2797,45 +2794,47 @@ int tilep_equ_weapon(const item_def &item)
case MISC_DECK_OF_PUNISHMENT:
case MISC_DECK_OF_WAR:
case MISC_DECK_OF_CHANGES:
- case MISC_DECK_OF_DEFENCE: return TILEP_HAND1_DECK;
+ case MISC_DECK_OF_DEFENCE: return TILEP_HAND1_DECK;
}
}
- if (item.base_type != OBJ_WEAPONS) return 0;
+ if (item.base_type != OBJ_WEAPONS)
+ return 0;
if (is_fixed_artefact( item ))
{
switch(item.special)
{
- case SPWPN_SINGING_SWORD: return TILEP_HAND1_SINGING_SWORD;
- case SPWPN_WRATH_OF_TROG: return TILEP_HAND1_AXE_TROG;
- case SPWPN_SCYTHE_OF_CURSES: return TILEP_HAND1_FINISHER;
+ case SPWPN_SINGING_SWORD: return TILEP_HAND1_SINGING_SWORD;
+ case SPWPN_WRATH_OF_TROG: return TILEP_HAND1_AXE_TROG;
+ case SPWPN_SCYTHE_OF_CURSES: return TILEP_HAND1_FINISHER;
case SPWPN_MACE_OF_VARIABILITY: return TILEP_HAND1_MACE_OF_VARIABILITY;
- case SPWPN_GLAIVE_OF_PRUNE: return TILEP_HAND1_GLAIVE_OF_PRUNE;
- case SPWPN_SCEPTRE_OF_TORMENT: return TILEP_HAND1_MACE_RUBY;
+ case SPWPN_GLAIVE_OF_PRUNE: return TILEP_HAND1_GLAIVE_OF_PRUNE;
+ case SPWPN_SCEPTRE_OF_TORMENT: return TILEP_HAND1_MACE_RUBY;
case SPWPN_SWORD_OF_ZONGULDROK: return TILEP_HAND1_ZONGULDROK;
- case SPWPN_SWORD_OF_CEREBOV: return TILEP_HAND1_SWORD_TWIST;
- case SPWPN_STAFF_OF_DISPATER: return TILEP_HAND1_DISPATER;
+ case SPWPN_SWORD_OF_CEREBOV: return TILEP_HAND1_SWORD_TWIST;
+ case SPWPN_STAFF_OF_DISPATER: return TILEP_HAND1_DISPATER;
case SPWPN_SCEPTRE_OF_ASMODEUS: return TILEP_HAND1_ASMODEUS;
- case SPWPN_SWORD_OF_POWER: break;
- case SPWPN_KNIFE_OF_ACCURACY: break;
- case SPWPN_STAFF_OF_OLGREB: return TILEP_HAND1_OLGREB;
- case SPWPN_VAMPIRES_TOOTH: break;
- case SPWPN_STAFF_OF_WUCAD_MU: break;
+ case SPWPN_STAFF_OF_OLGREB: return TILEP_HAND1_OLGREB;
+
+ case SPWPN_SWORD_OF_POWER:
+ case SPWPN_KNIFE_OF_ACCURACY:
+ case SPWPN_VAMPIRES_TOOTH:
+ case SPWPN_STAFF_OF_WUCAD_MU:
+ break;
}
}
if (is_unrandom_artefact( item ))
{
- int x = find_unrandart_index(item);
- switch(x+1)
+ switch (find_unrandart_index(item) + 1)
{
// Bloodbane
- case 2: return TILEP_HAND1_BLOODBANE;
+ case 2: return TILEP_HAND1_BLOODBANE;
// Flaming Death
- case 4: return TILEP_HAND1_FLAMING_DEATH;
+ case 4: return TILEP_HAND1_FLAMING_DEATH;
//mace of Brilliance
- case 8: return TILEP_HAND1_MACE_OF_VARIABILITY;
+ case 8: return TILEP_HAND1_MACE_OF_VARIABILITY;
//demon blade Leech
case 12: return TILEP_HAND1_LEECH;
//dagger of Chilly Death
@@ -2881,80 +2880,81 @@ int tilep_equ_weapon(const item_def &item)
switch (item.sub_type)
{
- // Blunt
- case WPN_CLUB: return TILEP_HAND1_CLUB_SLANT;
- case WPN_MACE: return TILEP_HAND1_MACE;
- case WPN_GREAT_MACE: return TILEP_HAND1_GREAT_MACE;
- case WPN_FLAIL: return TILEP_HAND1_FRAIL;
- case WPN_SPIKED_FLAIL: return TILEP_HAND1_SPIKED_FRAIL;
- case WPN_DIRE_FLAIL: return TILEP_HAND1_GREAT_FRAIL;
- case WPN_MORNINGSTAR: return TILEP_HAND1_MORNINGSTAR;
- case WPN_EVENINGSTAR: return TILEP_HAND1_EVENINGSTAR;
- case WPN_GIANT_CLUB: return TILEP_HAND1_GIANT_CLUB_SLANT;
- case WPN_GIANT_SPIKED_CLUB: return TILEP_HAND1_GIANT_CLUB_SPIKE_SLANT;
- case WPN_ANCUS: return TILEP_HAND1_MACE;
- case WPN_WHIP: return TILEP_HAND1_WHIP;
- case WPN_DEMON_WHIP: return TILEP_HAND1_BLACK_WHIP;
-
- // Edge
- case WPN_KNIFE: return TILEP_HAND1_DAGGER_SLANT;
- case WPN_DAGGER: return TILEP_HAND1_DAGGER_SLANT;
- case WPN_SHORT_SWORD: return TILEP_HAND1_SHORT_SWORD_SLANT;
- case WPN_LONG_SWORD: return TILEP_HAND1_LONG_SWORD_SLANT;
- case WPN_GREAT_SWORD: return TILEP_HAND1_GREAT_SWORD_SLANT;
- case WPN_SCIMITAR: return TILEP_HAND1_SCIMITAR;
- case WPN_FALCHION: return TILEP_HAND1_FALCHION;
- case WPN_SABRE: return TILEP_HAND1_SABRE;
- case WPN_DEMON_BLADE: return TILEP_HAND1_SWORD_BLACK;
- case WPN_QUICK_BLADE: return TILEP_HAND1_DAGGER;
- case WPN_KATANA: return TILEP_HAND1_KATANA_SLANT;
- case WPN_DOUBLE_SWORD: return TILEP_HAND1_DOUBLE_SWORD;
- case WPN_TRIPLE_SWORD: return TILEP_HAND1_TRIPLE_SWORD;
- case WPN_BLESSED_BLADE: return TILEP_HAND1_BLESSED_BLADE;
-
- // Axe
- case WPN_HAND_AXE: return TILEP_HAND1_HAND_AXE;
- case WPN_BATTLEAXE: return TILEP_HAND1_BATTLEAXE;
- case WPN_BROAD_AXE: return TILEP_HAND1_BROAD_AXE;
- case WPN_WAR_AXE: return TILEP_HAND1_WAR_AXE;
- case WPN_EXECUTIONERS_AXE: return TILEP_HAND1_EXECUTIONERS_AXE;
- case WPN_BARDICHE: return TILEP_HAND1_GLAIVE3;
-
- //Pole
- case WPN_SPEAR: return TILEP_HAND1_SPEAR;
- case WPN_HALBERD: return TILEP_HAND1_HALBERD;
- case WPN_GLAIVE: return TILEP_HAND1_GLAIVE;
- case WPN_QUARTERSTAFF: return TILEP_HAND1_QUARTERSTAFF1;
- case WPN_SCYTHE: return TILEP_HAND1_SCYTHE;
- case WPN_HAMMER: return TILEP_HAND1_HAMMER;
- case WPN_DEMON_TRIDENT: return TILEP_HAND1_DEMON_TRIDENT;
- case WPN_TRIDENT: return TILEP_HAND1_TRIDENT2;
- case WPN_LAJATANG: return TILEP_HAND1_D_GLAIVE;
-
- //Ranged
- case WPN_SLING: return TILEP_HAND1_SLING;
- case WPN_BOW: return TILEP_HAND1_BOW2;
- case WPN_CROSSBOW: return TILEP_HAND1_CROSSBOW;
- case WPN_HAND_CROSSBOW: return TILEP_HAND1_CROSSBOW;
- case WPN_BLOWGUN: return TILEP_HAND1_BLOWGUN;
- case WPN_LONGBOW: return TILEP_HAND1_BOW3;
- default: return 0;
+ // Blunt
+ case WPN_CLUB: return TILEP_HAND1_CLUB_SLANT;
+ case WPN_MACE: return TILEP_HAND1_MACE;
+ case WPN_GREAT_MACE: return TILEP_HAND1_GREAT_MACE;
+ case WPN_FLAIL: return TILEP_HAND1_FRAIL;
+ case WPN_SPIKED_FLAIL: return TILEP_HAND1_SPIKED_FRAIL;
+ case WPN_DIRE_FLAIL: return TILEP_HAND1_GREAT_FRAIL;
+ case WPN_MORNINGSTAR: return TILEP_HAND1_MORNINGSTAR;
+ case WPN_EVENINGSTAR: return TILEP_HAND1_EVENINGSTAR;
+ case WPN_GIANT_CLUB: return TILEP_HAND1_GIANT_CLUB_SLANT;
+ case WPN_GIANT_SPIKED_CLUB: return TILEP_HAND1_GIANT_CLUB_SPIKE_SLANT;
+ case WPN_ANCUS: return TILEP_HAND1_MACE;
+ case WPN_WHIP: return TILEP_HAND1_WHIP;
+ case WPN_DEMON_WHIP: return TILEP_HAND1_BLACK_WHIP;
+
+ // Edge
+ case WPN_KNIFE: return TILEP_HAND1_DAGGER_SLANT;
+ case WPN_DAGGER: return TILEP_HAND1_DAGGER_SLANT;
+ case WPN_SHORT_SWORD: return TILEP_HAND1_SHORT_SWORD_SLANT;
+ case WPN_LONG_SWORD: return TILEP_HAND1_LONG_SWORD_SLANT;
+ case WPN_GREAT_SWORD: return TILEP_HAND1_GREAT_SWORD_SLANT;
+ case WPN_SCIMITAR: return TILEP_HAND1_SCIMITAR;
+ case WPN_FALCHION: return TILEP_HAND1_FALCHION;
+ case WPN_SABRE: return TILEP_HAND1_SABRE;
+ case WPN_DEMON_BLADE: return TILEP_HAND1_SWORD_BLACK;
+ case WPN_QUICK_BLADE: return TILEP_HAND1_DAGGER;
+ case WPN_KATANA: return TILEP_HAND1_KATANA_SLANT;
+ case WPN_DOUBLE_SWORD: return TILEP_HAND1_DOUBLE_SWORD;
+ case WPN_TRIPLE_SWORD: return TILEP_HAND1_TRIPLE_SWORD;
+ case WPN_BLESSED_BLADE: return TILEP_HAND1_BLESSED_BLADE;
+
+ // Axe
+ case WPN_HAND_AXE: return TILEP_HAND1_HAND_AXE;
+ case WPN_BATTLEAXE: return TILEP_HAND1_BATTLEAXE;
+ case WPN_BROAD_AXE: return TILEP_HAND1_BROAD_AXE;
+ case WPN_WAR_AXE: return TILEP_HAND1_WAR_AXE;
+ case WPN_EXECUTIONERS_AXE: return TILEP_HAND1_EXECUTIONERS_AXE;
+ case WPN_BARDICHE: return TILEP_HAND1_GLAIVE3;
+
+ //Pole
+ case WPN_SPEAR: return TILEP_HAND1_SPEAR;
+ case WPN_HALBERD: return TILEP_HAND1_HALBERD;
+ case WPN_GLAIVE: return TILEP_HAND1_GLAIVE;
+ case WPN_QUARTERSTAFF: return TILEP_HAND1_QUARTERSTAFF1;
+ case WPN_SCYTHE: return TILEP_HAND1_SCYTHE;
+ case WPN_HAMMER: return TILEP_HAND1_HAMMER;
+ case WPN_DEMON_TRIDENT: return TILEP_HAND1_DEMON_TRIDENT;
+ case WPN_TRIDENT: return TILEP_HAND1_TRIDENT2;
+ case WPN_LAJATANG: return TILEP_HAND1_D_GLAIVE;
+
+ //Ranged
+ case WPN_SLING: return TILEP_HAND1_SLING;
+ case WPN_BOW: return TILEP_HAND1_BOW2;
+ case WPN_CROSSBOW: return TILEP_HAND1_CROSSBOW;
+ case WPN_HAND_CROSSBOW: return TILEP_HAND1_CROSSBOW;
+ case WPN_BLOWGUN: return TILEP_HAND1_BLOWGUN;
+ case WPN_LONGBOW: return TILEP_HAND1_BOW3;
+
+ default: return 0;
}
}
int tilep_equ_armour(const item_def &item)
{
- if (item.base_type !=OBJ_ARMOUR) return 0;
+ if (item.base_type != OBJ_ARMOUR)
+ return 0;
if (is_unrandom_artefact( item ))
{
- int x = find_unrandart_index(item);
- switch(x+1)
+ switch (find_unrandart_index(item) + 1)
{
// Holy Armour of Zin
- case 6: return TILEP_BODY_ARMOR_MUMMY;
+ case 6: return TILEP_BODY_ARMOR_MUMMY;
// robe of Augmentation
- case 7: return TILEP_BODY_ROBE_RED2;
+ case 7: return TILEP_BODY_ROBE_RED2;
// robe of Misfortune
case 14: return TILEP_BODY_ARWEN;
// Lear's chain mail
@@ -3000,32 +3000,32 @@ int tilep_equ_armour(const item_def &item)
default: return 0;
}
- case ARM_LEATHER_ARMOUR: return TILEP_BODY_LEATHER_ARMOUR3;
- case ARM_RING_MAIL: return TILEP_BODY_RINGMAIL;
- case ARM_CHAIN_MAIL: return TILEP_BODY_CHAINMAIL;
- case ARM_SCALE_MAIL: return TILEP_BODY_SCALEMAIL;
- case ARM_SPLINT_MAIL: return TILEP_BODY_BANDED;
- case ARM_BANDED_MAIL: return TILEP_BODY_BANDED;
- case ARM_PLATE_MAIL: return TILEP_BODY_PLATE_BLACK;
+ case ARM_LEATHER_ARMOUR: return TILEP_BODY_LEATHER_ARMOUR3;
+ case ARM_RING_MAIL: return TILEP_BODY_RINGMAIL;
+ case ARM_CHAIN_MAIL: return TILEP_BODY_CHAINMAIL;
+ case ARM_SCALE_MAIL: return TILEP_BODY_SCALEMAIL;
+ case ARM_SPLINT_MAIL: return TILEP_BODY_BANDED;
+ case ARM_BANDED_MAIL: return TILEP_BODY_BANDED;
+ case ARM_PLATE_MAIL: return TILEP_BODY_PLATE_BLACK;
case ARM_CRYSTAL_PLATE_MAIL: return TILEP_BODY_CRYSTAL_PLATE;
- case ARM_DRAGON_HIDE: return TILEP_BODY_DRAGONSC_GREEN;
- case ARM_ICE_DRAGON_HIDE: return TILEP_BODY_DRAGONSC_CYAN;
- case ARM_STEAM_DRAGON_HIDE: return TILEP_BODY_DRAGONSC_WHITE;
+ case ARM_DRAGON_HIDE: return TILEP_BODY_DRAGONSC_GREEN;
+ case ARM_ICE_DRAGON_HIDE: return TILEP_BODY_DRAGONSC_CYAN;
+ case ARM_STEAM_DRAGON_HIDE: return TILEP_BODY_DRAGONSC_WHITE;
case ARM_MOTTLED_DRAGON_HIDE: return TILEP_BODY_DRAGONSC_MAGENTA;
- case ARM_STORM_DRAGON_HIDE: return TILEP_BODY_DRAGONSC_BLUE;
- case ARM_GOLD_DRAGON_HIDE: return TILEP_BODY_DRAGONSC_GOLD;
- case ARM_SWAMP_DRAGON_HIDE: return TILEP_BODY_DRAGONSC_BROWN;
+ case ARM_STORM_DRAGON_HIDE: return TILEP_BODY_DRAGONSC_BLUE;
+ case ARM_GOLD_DRAGON_HIDE: return TILEP_BODY_DRAGONSC_GOLD;
+ case ARM_SWAMP_DRAGON_HIDE: return TILEP_BODY_DRAGONSC_BROWN;
- case ARM_DRAGON_ARMOUR: return TILEP_BODY_DRAGONARM_GREEN;
- case ARM_ICE_DRAGON_ARMOUR: return TILEP_BODY_DRAGONARM_CYAN;
- case ARM_STEAM_DRAGON_ARMOUR: return TILEP_BODY_DRAGONARM_WHITE;
+ case ARM_DRAGON_ARMOUR: return TILEP_BODY_DRAGONARM_GREEN;
+ case ARM_ICE_DRAGON_ARMOUR: return TILEP_BODY_DRAGONARM_CYAN;
+ case ARM_STEAM_DRAGON_ARMOUR: return TILEP_BODY_DRAGONARM_WHITE;
case ARM_MOTTLED_DRAGON_ARMOUR: return TILEP_BODY_DRAGONARM_MAGENTA;
- case ARM_STORM_DRAGON_ARMOUR: return TILEP_BODY_DRAGONARM_BLUE;
- case ARM_GOLD_DRAGON_ARMOUR: return TILEP_BODY_DRAGONARM_GOLD;
- case ARM_SWAMP_DRAGON_ARMOUR: return TILEP_BODY_DRAGONARM_BROWN;
+ case ARM_STORM_DRAGON_ARMOUR: return TILEP_BODY_DRAGONARM_BLUE;
+ case ARM_GOLD_DRAGON_ARMOUR: return TILEP_BODY_DRAGONARM_GOLD;
+ case ARM_SWAMP_DRAGON_ARMOUR: return TILEP_BODY_DRAGONARM_BROWN;
- case ARM_ANIMAL_SKIN: return TILEP_BODY_ANIMAL_SKIN;
+ case ARM_ANIMAL_SKIN: return TILEP_BODY_ANIMAL_SKIN;
case ARM_TROLL_HIDE:
case ARM_TROLL_LEATHER_ARMOUR: return TILEP_BODY_TROLL_HIDE;
@@ -3035,16 +3035,18 @@ int tilep_equ_armour(const item_def &item)
int tilep_equ_shield(const item_def &item)
{
- if (you.equip[EQ_SHIELD] == -1) return 0;
- if (item.base_type !=OBJ_ARMOUR) return 0;
+ if (you.equip[EQ_SHIELD] == -1)
+ return 0;
+
+ if (item.base_type != OBJ_ARMOUR)
+ return 0;
if (is_unrandom_artefact( item ))
{
- int x = find_unrandart_index(item);
- switch(x+1)
+ switch (find_unrandart_index(item) + 1)
{
// shield of Ignorance
- case 5: return TILEP_HAND2_SHIELD_SHAMAN;
+ case 5: return TILEP_HAND2_SHIELD_SHAMAN;
// Bullseye
case 10: return TILEP_HAND2_BULLSEYE;
// shield of Resistance
@@ -3054,8 +3056,8 @@ int tilep_equ_shield(const item_def &item)
switch (item.sub_type)
{
- case ARM_SHIELD: return TILEP_HAND2_SHIELD_KNIGHT_BLUE;
- case ARM_BUCKLER: return TILEP_HAND2_SHIELD_ROUND_SMALL;
+ case ARM_SHIELD: return TILEP_HAND2_SHIELD_KNIGHT_BLUE;
+ case ARM_BUCKLER: return TILEP_HAND2_SHIELD_ROUND_SMALL;
case ARM_LARGE_SHIELD: return TILEP_HAND2_SHIELD_LONG_RED;
default: return 0;
}
@@ -3063,9 +3065,12 @@ int tilep_equ_shield(const item_def &item)
int tilep_equ_cloak(const item_def &item)
{
- if (you.equip[EQ_CLOAK] == -1) return 0;
- if (item.base_type !=OBJ_ARMOUR) return 0;
- if (item.sub_type != ARM_CLOAK) return 0;
+ if (you.equip[EQ_CLOAK] == -1)
+ return 0;
+
+ if (item.base_type != OBJ_ARMOUR || item.sub_type != ARM_CLOAK)
+ return 0;
+
switch (item.colour)
{
case BLACK:
@@ -3097,17 +3102,13 @@ int tilep_equ_helm(const item_def &item)
if (is_unrandom_artefact(item))
{
- int idx = find_unrandart_index(item);
- switch (idx + 1)
+ switch (find_unrandart_index(item) + 1)
{
- case 11:
- // crown of Dyrovepreva
+ case 11: // crown of Dyrovepreva
return TILEP_HELM_DYROVEPREVA;
- case 41:
- // mask of the Dragon
+ case 41: // mask of the Dragon
return TILEP_HELM_ART_DRAGONHELM;
- case 50:
- // hat of the Alchemist
+ case 50: // hat of the Alchemist
return TILEP_HELM_TURBAN_PURPLE;
}
@@ -3233,15 +3234,12 @@ int tilep_equ_gloves(const item_def &item)
{
if (you.equip[EQ_GLOVES] == -1)
return 0;
- if (item.base_type != OBJ_ARMOUR)
- return 0;
- if (item.sub_type != ARM_GLOVES)
+ if (item.base_type != OBJ_ARMOUR || item.sub_type != ARM_GLOVES)
return 0;
if (is_unrandom_artefact(item))
{
- int idx = find_unrandart_index(item);
- switch (idx + 1)
+ switch (find_unrandart_index(item) + 1)
{
case 30: // gauntlets of War (thick brown)
return TILEP_ARM_GLOVE_BLACK;
@@ -3250,8 +3248,7 @@ int tilep_equ_gloves(const item_def &item)
}
}
- int etype = get_etype(item);
- switch (etype)
+ switch (get_etype(item))
{
default:
case 0:
@@ -3291,6 +3288,7 @@ int tilep_equ_boots(const item_def &item)
if (item.sub_type == ARM_NAGA_BARDING)
return TILEP_BOOTS_NAGA_BARDING + std::min(etype, 3);
+
if (item.sub_type == ARM_CENTAUR_BARDING)
return TILEP_BOOTS_CENTAUR_BARDING + std::min(etype, 3);
@@ -3299,8 +3297,8 @@ int tilep_equ_boots(const item_def &item)
if (is_unrandom_artefact(item))
{
- int idx = find_unrandart_index(item);
- switch (idx + 1)
+ // in anticipation of more unrandart boots
+ switch (find_unrandart_index(item) + 1)
{
case 23: // boots of the assassin
return TILEP_BOOTS_MIDDLE_GRAY;
@@ -3351,8 +3349,11 @@ int get_ctg_idx(char *name)
{
int i;
- for(i=0;i<TILEP_PARTS_TOTAL;i++)
- if(strcmp(name, tilep_parts_name[i])==0) return i;
+ for (i = 0; i < TILEP_PARTS_TOTAL; i++)
+ {
+ if (strcmp(name, tilep_parts_name[i]) == 0)
+ return i;
+ }
return 0;
}
@@ -3360,8 +3361,11 @@ const char *get_parts_name(int part, int idx)
{
static char tmp[10];
const char *ptr = tilep_comment[ tilep_comment_ofs[part] -1 + idx ];
- if(idx==0) return "";
- if(ptr[0]==0)
+
+ if (idx == 0)
+ return "";
+
+ if (ptr[0] == 0)
{
sprintf(tmp,"%02d",idx);
return tmp;
@@ -3375,9 +3379,11 @@ int get_parts_idx(int part, char *name)
int res = atoi(name);
int i;
- for(i=0;i<tilep_parts_total[part];i++)
- if(strcmp(name, tilep_comment[ tilep_comment_ofs[part]+i])==0)
- return i+1;
+ for (i = 0; i < tilep_parts_total[part]; i++)
+ {
+ if (strcmp(name, tilep_comment[ tilep_comment_ofs[part]+i]) == 0)
+ return i+1;
+ }
return res;
}
#endif /* TILEP_DEBUG */
@@ -3389,14 +3395,14 @@ int get_parts_idx(int part, char *name)
// for clarity
enum SpecialIdx
{
- SPECIAL_N = 0,
- SPECIAL_NE = 1,
- SPECIAL_E = 2,
- SPECIAL_SE = 3,
- SPECIAL_S = 4,
- SPECIAL_SW = 5,
- SPECIAL_W = 6,
- SPECIAL_NW = 7,
+ SPECIAL_N = 0,
+ SPECIAL_NE = 1,
+ SPECIAL_E = 2,
+ SPECIAL_SE = 3,
+ SPECIAL_S = 4,
+ SPECIAL_SW = 5,
+ SPECIAL_W = 6,
+ SPECIAL_NW = 7,
SPECIAL_FULL = 8
};
@@ -4025,64 +4031,49 @@ void tile_draw_dungeon(unsigned int *tileb)
#define swapint(a, b) {int tmp = a; a = b; b = tmp;}
// Item is unided(1) or tried(2) or id'ed (0)
-// Note that Jewellries are never "tried"
-static int item_unid_type(const item_def &item)
+static int _item_unid_type(const item_def &item)
{
- int t = item.base_type;
- int s = item.sub_type;
- int id0 = 0;
-
- id_arr& id = get_typeid_array();
-
- if ((item.flags &ISFLAG_KNOW_TYPE) != 0)
+ if ((item.flags & ISFLAG_KNOW_TYPE) != 0)
return 0;
- switch (t)
+ const int s = item.sub_type;
+ const id_arr& id = get_typeid_array();
+ int id0 = 0;
+
+ switch (item.base_type)
{
- case OBJ_SCROLLS:
- id0 = id[ IDTYPE_SCROLLS ][s];
- if (id0 == ID_TRIED_TYPE)
- return 2;
- else
+ case OBJ_STAVES:
+ id0 = id[ IDTYPE_STAVES ][s];
if (id0 != ID_KNOWN_TYPE)
return 1;
else
return 0;
+
+ case OBJ_SCROLLS:
+ id0 = id[ IDTYPE_SCROLLS ][s];
+ break;
case OBJ_WANDS:
id0 = id[ IDTYPE_WANDS ][s];
- if (id0 == ID_TRIED_TYPE)
- return 2;
- else
- if (id0 != ID_KNOWN_TYPE)
- return 1;
- else
- return 0;
+ break;
case OBJ_POTIONS:
id0 = id[ IDTYPE_POTIONS ][s];
- if (id0 == ID_TRIED_TYPE)
- return 2;
- else
- if (id0 != ID_KNOWN_TYPE)
- return 1;
- else
- return 0;
+ break;
case OBJ_JEWELLERY:
id0 = id[ IDTYPE_JEWELLERY ][s];
- if (id0 != ID_KNOWN_TYPE)
- return 1;
- else
- return 0;
-
- case OBJ_STAVES:
- id0 = id[ IDTYPE_STAVES ][s];
- if (id0 != ID_KNOWN_TYPE)
- return 1;
- else
- return 0;
+ break;
+
+ default:
+ return 0;
}
+
+ if (id0 == ID_TRIED_TYPE)
+ return 2;
+ else if (id0 != ID_KNOWN_TYPE)
+ return 1;
+
return 0;
}
@@ -4155,9 +4146,9 @@ int pack_floor_item(int *idx, int *flag, int *isort, int max)
while (o != NON_ITEM)
{
- int id0 = item_unid_type(mitm[o]);
+ int id0 = _item_unid_type(mitm[o]);
int next = mitm[o].link;
- int typ = mitm[o].base_type;
+ int typ = mitm[o].base_type;
if (n >= max) break;
@@ -4189,7 +4180,7 @@ int pack_floor_item(int *idx, int *flag, int *isort, int max)
// Simple Bubble sort
int k = n;
- while( (k > 0) && (isort[k-1] > isort[k]))
+ while (k > 0 && isort[k-1] > isort[k])
{
swapint(idx[k-1], idx[k]);
swapint(isort[k-1], isort[k]);
@@ -4207,16 +4198,16 @@ void finish_inven_data(int n, int *tiles, int *num, int *idx, int *iflag)
{
int i;
- for(i = 0; i < n; i++)
+ for (i = 0; i < n; i++)
{
int q = -1;
int j = idx[i];
item_def *itm;
- if (j==-1)
+ if (j == -1)
{
- num[i]=-1;
- tiles[i]= 0;
+ num[i] = -1;
+ tiles[i] = 0;
continue;
}
@@ -4266,7 +4257,8 @@ void tile_draw_inv(int item_type, int flag)
if (flag == -1)
{
- flag = (win_main->active_layer == 0) ? REGION_INV1 : REGION_INV2;
+ flag = (win_main->active_layer == 0) ? REGION_INV1
+ : REGION_INV2;
}
TileRegionClass *r = (flag == REGION_INV1) ? region_item:region_item2;
@@ -4308,7 +4300,7 @@ void tile_draw_inv(int item_type, int flag)
empty += 1-eq_flag[j];
}
- for (j=0; j<NUM_EQUIP; j++)
+ for (j = 0; j<NUM_EQUIP; j++)
{
int eq = you.equip[j];
if (eq >= 0 && eq < ENDOFPACK)
@@ -4317,21 +4309,21 @@ void tile_draw_inv(int item_type, int flag)
if (item_type >= 0)
item_chars = syms_table[item_type];
- else
- if (item_type == -2)
+ else if (item_type == -2)
item_chars = obj_syms;
- else
- if (item_type == -3)
+ else if (item_type == -3)
item_chars = ".";
- if (item_chars[0] == 0) return;
+ if (item_chars[0] == 0)
+ return;
for (i=0; i < (int)strlen(item_chars); i++)
{
int top = n;
char ic = item_chars[i];
- if (n >= numInvTiles) break;
+ if (n >= numInvTiles)
+ break;
// Items on the floor
if (ic == '.')
@@ -4354,7 +4346,7 @@ void tile_draw_inv(int item_type, int flag)
// convert item char to item type
int type = -1;
- for (j=0; j < (int)strlen(obj_syms); j++)
+ for (j = 0; j < (int)strlen(obj_syms); j++)
{
if (obj_syms[j] == ic)
{
@@ -4363,7 +4355,8 @@ void tile_draw_inv(int item_type, int flag)
}
}
- if (type == -1) continue;
+ if (type == -1)
+ continue;
for (j = 0; j < ENDOFPACK && n < numInvTiles; j++)
{
@@ -4371,7 +4364,7 @@ void tile_draw_inv(int item_type, int flag)
{
int sval = NUM_EQUIP + you.inv[j].sub_type;
int base = 0;
- int id0 = item_unid_type(you.inv[j]);
+ int id0 = _item_unid_type(you.inv[j]);
idx[n] = j;
iflag[n] = 0;
@@ -4413,7 +4406,7 @@ void tile_draw_inv(int item_type, int flag)
isort[n] = sval;
int k = n;
- while( (k > top) && (isort[k-1] > isort[k]))
+ while (k > top && isort[k-1] > isort[k])
{
swapint(idx[k-1], idx[k]);
swapint(isort[k-1], isort[k]);
@@ -4428,12 +4421,12 @@ void tile_draw_inv(int item_type, int flag)
finish_inven_data(n, tiles, num, idx, iflag);
- for(i = n; i < numInvTiles; i++)
+ for (i = n; i < numInvTiles; i++)
{
- tiles[i] = 0;
- num[i] = 0;
- idx[i] = -1;
- iflag[i] = 0;
+ tiles[i] = 0;
+ num[i] = 0;
+ idx[i] = -1;
+ iflag[i] = 0;
}
TileDrawInvData(n, flag, tiles, num, idx, iflag);
}
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, &current_doll);
+ _draw_doll(DollCacheImg, &current_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, &current_doll))
+ if (!_draw_doll(DollCacheImg, &current_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;
}