summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/delay.cc3
-rw-r--r--crawl-ref/source/dungeon.cc1
-rw-r--r--crawl-ref/source/libgui.cc257
-rw-r--r--crawl-ref/source/mon-util.cc7
-rw-r--r--crawl-ref/source/monstuff.cc199
-rw-r--r--crawl-ref/source/spells3.cc12
-rw-r--r--crawl-ref/source/travel.cc6
-rw-r--r--crawl-ref/source/view.cc30
-rw-r--r--crawl-ref/source/view.h3
9 files changed, 270 insertions, 248 deletions
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index 71a65cbd5c..458a2bb6a5 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -526,8 +526,7 @@ delay_type current_delay_action( void )
bool is_run_delay(int delay)
{
- return (delay == DELAY_RUN || delay == DELAY_REST
- || delay == DELAY_TRAVEL);
+ return (delay == DELAY_RUN || delay == DELAY_REST || delay == DELAY_TRAVEL);
}
bool is_being_butchered(const item_def &item)
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 01589b1c8f..7855e3db40 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -7384,6 +7384,7 @@ static coord_def _dgn_find_closest_to_stone_stairs(coord_def base_pos)
if (!travel_point_distance[x][y] && grid_is_stone_stair(grd[x][y]))
_dgn_fill_zone(coord_def(x, y), 1, np, _dgn_square_travel_ok);
}
+
return (np.nearest);
}
diff --git a/crawl-ref/source/libgui.cc b/crawl-ref/source/libgui.cc
index 517e14f059..c45013a798 100644
--- a/crawl-ref/source/libgui.cc
+++ b/crawl-ref/source/libgui.cc
@@ -163,7 +163,7 @@ static void _libgui_save_prefs();
//Internal variables
static int mouse_mode = MOUSE_MODE_NORMAL;
-// hack: prevent clrscr for some region
+// Hack: prevent clrscr for some region.
static bool region_lock[NUM_REGIONS];
static bool toggle_telescope;
@@ -177,7 +177,7 @@ static int gmap_min_x, gmap_max_x;
static int gmap_min_y, gmap_max_y;
static int gmap_ox, gmap_oy;
-// redefine color constants with shorter name to save space
+// Redefine color constants with shorter names to save space.
#define PX_0 0
#define PX_F 1
#define PX_W 2
@@ -473,7 +473,8 @@ void GmapDisplay(int linex, int liney)
bool show_mark = false;
int mark_x = 0;
int mark_y = 0;
- if ((you.level_type != LEVEL_LABYRINTH) && (you.level_type != LEVEL_ABYSS))
+ // Unmappables...
+ if (you.level_type != LEVEL_LABYRINTH && you.level_type != LEVEL_ABYSS)
{
ox += linex - gmap_min_x;
oy += liney - gmap_min_y;
@@ -482,7 +483,7 @@ void GmapDisplay(int linex, int liney)
mark_y = oy;
show_mark = true;
- // highlight centre of the map
+ // Highlight centre of the map.
// [enne] Maybe we need another colour for the highlight?
buf2[ox + oy * GXM] = Options.tile_player_col;
}
@@ -491,7 +492,7 @@ void GmapDisplay(int linex, int liney)
region_map->draw_data(buf2, show_mark, mark_x, mark_y);
}
-/* initialize routines */
+// Initialize routines.
static void _do_layout()
{
// buffer between map region and stat region
@@ -585,7 +586,7 @@ void libgui_init()
_libgui_load_prefs();
- // Adjust sizes
+ // Adjust sizes.
if (dngn_x & 1 == 0) dngn_x++;
if (dngn_y & 1 == 0) dngn_y++;
if (font_size & 1 == 1) font_size--;
@@ -635,10 +636,12 @@ void libgui_init()
region_tile->id = REGION_DNGN;
#if DEBUG_DIAGNOSTICS
- // one more line for debug GPS
- region_stat = new TextRegionClass(crawl_view.hudsz.x, crawl_view.hudsz.y + 1, 0, 0);
+ // One more line for debug GPS.
+ region_stat = new TextRegionClass(crawl_view.hudsz.x,
+ crawl_view.hudsz.y + 1, 0, 0);
#else
- region_stat = new TextRegionClass(crawl_view.hudsz.x, crawl_view.hudsz.y, 0, 0);
+ region_stat = new TextRegionClass(crawl_view.hudsz.x,
+ crawl_view.hudsz.y, 0, 0);
#endif
region_stat->id = REGION_STAT;
region_msg = new TextRegionClass(msg_x, msg_y, 0, 0);
@@ -686,7 +689,7 @@ void libgui_shutdown()
if (WallImg)
ImgDestroy(WallImg);
- // do this before delete win_main
+ // Do this before delete win_main.
_libgui_save_prefs();
std::vector<RegionClass *>::iterator r;
@@ -701,7 +704,7 @@ void libgui_shutdown()
libgui_shutdown_sys();
}
-/*** Save, Load, and Edit window prefs ***/
+// Save, Load, and Edit window prefs.
static void _libgui_load_prefs()
{
int i, mode;
@@ -725,8 +728,8 @@ static void _libgui_load_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, "r")) != NULL )
{
@@ -735,7 +738,9 @@ static void _libgui_load_prefs()
fgets(buf, 250, fp);
i = 0;
while (buf[i] >= 32 && i < 120)
+ {
i++;
+ }
buf[i] = 0;
for (i = 0; i < MAX_PREFS; i++)
@@ -754,22 +759,24 @@ static void _libgui_load_prefs()
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;
}
- if (p->type == 'S')
+ else if (p->type == 'S')
{
strncpy(dummy_str[mode][p->dummy_idx], dat,
MAX_PREF_CHAR);
+
if (mode == pref_mode)
strncpy((char *)p->ptr, dat, MAX_PREF_CHAR);
}
break;
- }// tag match
+ }
}
}
- }// while
+ } // while (!end of file)
}
}
@@ -789,12 +796,12 @@ static void _libgui_save_prefs()
for (i = 0; i < MAX_PREFS; i++)
{
- struct prefs *p = &pref_data[i];
- int idx = p->dummy_idx;
- if (p->type == 'I')
- dummy_int[pref_mode][idx] = *(int *)p->ptr;
- else if (p->type == 'S')
- strncpy(dummy_str[pref_mode][idx], (char *)p->ptr, MAX_PREF_CHAR);
+ struct prefs *p = &pref_data[i];
+ int idx = p->dummy_idx;
+ if (p->type == 'I')
+ dummy_int[pref_mode][idx] = *(int *)p->ptr;
+ else if (p->type == 'S')
+ strncpy(dummy_str[pref_mode][idx], (char *)p->ptr, MAX_PREF_CHAR);
}
const char *baseTxt = "wininit.txt";
@@ -806,21 +813,21 @@ static void _libgui_save_prefs()
{
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]);
- }
- else 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");
}
@@ -899,23 +906,23 @@ void edit_prefs()
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)
- {
- 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);
+ 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);
@@ -974,11 +981,11 @@ void edit_prefs()
case 'H': inc = -10; break;
}
- int crt_x_old = crt_x;
- int crt_y_old = crt_y;
+ 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 msg_x_old = msg_x;
+ int msg_y_old = msg_y;
int dngn_x_old = dngn_x;
int dngn_y_old = dngn_y;
@@ -1011,26 +1018,26 @@ void edit_prefs()
// crt screen layouts
- // resize msg?
+ // 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?
+ // 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?
+ // Resize map?
if (map_px != map_px_old)
{
upd_map = true;
region_map->resize( 0, 0, map_px, map_px);
}
- // resize dngn tile screen?
+ // Resize dngn tile screen?
if (dngn_x != dngn_x_old || dngn_y != dngn_y_old)
{
clrscr();
@@ -1044,16 +1051,18 @@ void edit_prefs()
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)
@@ -1443,7 +1452,8 @@ static int _handle_mouse_motion(int mouse_x, int mouse_y, bool init)
&& player_knows_spell(
SPELL_STICKS_TO_SNAKES) )
{
- // For Sandblast and Sticks to Snakes, respectively.
+ // For Sandblast and Sticks to Snakes,
+ // respectively.
desc += EOL "[Ctrl-L-Click] Wield (w)";
}
break;
@@ -1510,7 +1520,7 @@ static int _handle_mouse_motion(int mouse_x, int mouse_y, bool init)
}
// For Boneshards.
- // special handling since skeletons have no primary action
+ // Special handling since skeletons have no primary action.
if (item.base_type == OBJ_CORPSES
&& item.sub_type == CORPSE_SKELETON)
{
@@ -1521,7 +1531,7 @@ static int _handle_mouse_motion(int mouse_x, int mouse_y, bool init)
}
desc += EOL "[R-Click] Info";
- // has to be non-equipped or non-cursed to drop
+ // Has to be non-equipped or non-cursed to drop.
if (!equipped || !_is_true_equipped_item(you.inv[ix])
|| !item_cursed(you.inv[ix]))
{
@@ -1591,10 +1601,10 @@ static int _handle_mouse_motion(int mouse_x, int mouse_y, bool init)
if (grid_stair_direction( grd[gx][gy] ) != CMD_NO_CMD)
desc += EOL "[Shift-L-Click] use stairs (</>)";
- // character overview
+ // Character overview.
desc += EOL "[R-Click] Overview (%)";
- // Religion
+ // Religion.
if (you.religion != GOD_NO_GOD)
desc += EOL "[Shift-R-Click] Religion (^)";
@@ -1633,6 +1643,7 @@ static int _handle_mouse_motion(int mouse_x, int mouse_y, bool init)
{
if (oldmode != REGION_STAT)
update_tip_text("[L-Click] Rest / Search for a while");
+
oldmode = mode;
oldcx = cx;
oldcy = cy;
@@ -1646,8 +1657,13 @@ 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};
- const int dy[9] = {1,1,1,0,0,0,-1,-1,-1};
+ const int dx[9] = {-1, 0, 1,
+ -1, 0, 1,
+ -1, 0, 1};
+
+ const int dy[9] = { 1, 1, 1,
+ 0, 0, 0,
+ -1,-1,-1};
const int cmd_n[9] = {'b', 'j', 'n', 'h', '.', 'l', 'y', 'k', 'u'};
const int cmd_s[9] = {'B', 'J', 'N', 'H', '5', 'L', 'Y', 'K', 'U'};
@@ -1659,14 +1675,14 @@ static int _handle_mouse_button(int mx, int my, int button,
const int cmd_dir[9] = {'1','2','3','4','5','6','7','8','9'};
int trig = CK_MOUSE_B1;
- if (button == 2)
- trig = CK_MOUSE_B2;
- else if (button == 3)
- trig = CK_MOUSE_B3;
- else if (button == 4)
- trig = CK_MOUSE_B4;
- else if (button == 5)
- trig = CK_MOUSE_B5;
+ switch (button)
+ {
+ case 2: trig = CK_MOUSE_B2; break;
+ case 3: trig = CK_MOUSE_B3; break;
+ case 4: trig = CK_MOUSE_B4; break;
+ case 5: trig = CK_MOUSE_B5; break;
+ default: break;
+ }
if (shift)
trig |= 512;
@@ -1687,12 +1703,12 @@ static int _handle_mouse_button(int mx, int my, int button,
static int oldcy = -1;
static bool enable_wheel = true;
- static int old_button = 0;
- static int old_hp = 0;
+ static int old_button = 0;
+ static int old_hp = 0;
mode = convert_cursor_pos(mx, my, &cx, &cy);
- // prevent accidental wheel slip and subsequent char death
+ // Prevent accidental wheel slip and subsequent char death.
if (mouse_mode == MOUSE_MODE_COMMAND && (button == 4 || button == 5)
&& button == old_button && oldcx == cx && oldcy == cy)
{
@@ -1713,7 +1729,7 @@ static int _handle_mouse_button(int mx, int my, int button,
if (toggle_telescope)
{
- // quit telescope mode
+ // Quit telescope mode.
TileDrawDungeon(NULL);
toggle_telescope = false;
}
@@ -1728,7 +1744,7 @@ static int _handle_mouse_button(int mx, int my, int button,
return 0;
}
- // item clicked
+ // Clicked on item.
if (mode == REGION_INV1)
{
int ix = TileInvIdx(cx);
@@ -1736,7 +1752,7 @@ static int _handle_mouse_button(int mx, int my, int button,
{
if (button == 2)
{
- // describe item
+ // Describe item.
if (itemlist_iflag[cx] & TILEI_FLAG_FLOOR)
{
if (shift)
@@ -1758,7 +1774,7 @@ static int _handle_mouse_button(int mx, int my, int button,
// Floor item
if (itemlist_iflag[cx] & TILEI_FLAG_FLOOR)
{
- // try pick up one item
+ // Try to pick up one item.
if (!shift)
_gui_set_mouse_inv(ix, INV_PICKUP);
else
@@ -1767,7 +1783,7 @@ static int _handle_mouse_button(int mx, int my, int button,
return CK_MOUSE_B1ITEM;
}
- // use item
+ // Use item.
if (shift)
_gui_set_mouse_inv(ix, INV_DROP);
else if (ctrl)
@@ -1796,11 +1812,11 @@ static int _handle_mouse_button(int mx, int my, int button,
{
if (button == 1 && cx == DCX && cy == DCY)
{
- // pick up items
+ // Pick up items.
if (!shift)
return 'g';
- // else attempt to use stairs on square
+ // Else attempt to use stairs on square.
const int gx = view2gridX(cx) + 1;
const int gy = view2gridY(cy) + 1;
switch (grid_stair_direction( grd[gx][gy] ))
@@ -1816,22 +1832,21 @@ static int _handle_mouse_button(int mx, int my, int button,
if (button == 2)
{
- // describe yourself
+ // Describe yourself.
if (cx == DCX && cy == DCY)
{
if (!shift)
- return '%'; // character overview
+ return '%'; // Character overview.
if (you.religion != GOD_NO_GOD)
- return '^'; // religion screen
+ return '^'; // Religion screen.
}
// trigger
if (mouse_mode == MOUSE_MODE_MACRO)
return trig;
- // Right Click: try to describe grid
- // otherwise return trigger key
+ // R-Click: try to describe grid; otherwise return trigger key.
if (!in_los_bounds(cx+1,cy+1))
return CK_MOUSE_B2;
@@ -1842,8 +1857,8 @@ static int _handle_mouse_button(int mx, int my, int button,
}
// button = 1 or 4, 5
- // first, check if 3x3 grid around @ is clicked.
- // if so, return equivalent numpad key
+ // First check if 3x3 grid around @ is clicked.
+ // If so, return equivalent numpad key.
int adir = -1;
for (dir = 0; dir < 9; dir++)
{
@@ -1866,19 +1881,19 @@ static int _handle_mouse_button(int mx, int my, int button,
if (button != 1)
return trig;
- // otherwise travel to that grid
+ // Otherwise travel to that grid.
const coord_def gc = view2grid(coord_def(cx+1, cy+1));
if (!map_bounds(gc))
return 0;
- // Activate travel
+ // Activate travel.
start_travel(gc.x, gc.y);
return CK_MOUSE_DONE;
}
if (mouse_mode == MOUSE_MODE_COMMAND && mode == REGION_MAP)
{
- // begin telescope mode
+ // Begin telescope mode.
if (button == 2)
{
toggle_telescope = true;
@@ -1890,12 +1905,12 @@ static int _handle_mouse_button(int mx, int my, int button,
if (button != 1)
return trig;
- // L-click: try to travel to the grid
+ // L-click: try to travel to the grid.
const coord_def gc(cx-1, cy-1);
if (!map_bounds(gc))
return 0;
- // Activate travel
+ // Activate travel.
start_travel(gc.x, gc.y);
return CK_MOUSE_DONE;
}
@@ -1917,10 +1932,9 @@ static int _handle_mouse_button(int mx, int my, int button,
return 0;
for (dir = 0; dir < 9; dir++)
- {
if (DCX + dx[dir] == cx && DCY + dy[dir] == cy)
return cmd_dir[dir];
- }
+
return 0;
}
@@ -1983,7 +1997,7 @@ int getch()
{
'k', 'j', 'h', 'l', '.', 'y', 'b', '.', 'u', 'n',
'K', 'J', 'H', 'L', '5', 'Y', 'B', '5', 'U', 'N',
- 11, 10, 8, 12, '0', 25, 2, 'C', 21, 14
+ 11, 10, 8, 12, '0', 25, 2, 'C', 21, 14
};
int keyin = getch_ck();
@@ -2009,7 +2023,7 @@ void set_mouse_enabled(bool enabled)
void mouse_set_mode(int mode)
{
mouse_mode = mode;
- // init cursor etc
+ // Init cursor etc.
_handle_mouse_motion(0, 0, true);
}
@@ -2084,7 +2098,7 @@ void clrscr()
win_main->clear();
TextRegionClass::cursor_region = NULL;
- // clear Text regions
+ // Clear Text regions.
if (!region_lock[REGION_CRT])
region_crt->clear();
@@ -2100,7 +2114,7 @@ void clrscr()
if (region_tip && !region_lock[REGION_TIP])
region_tip->clear();
- // Hack: Do not erase the backbuffer. Instead just hide it.
+ // Hack: Do not erase the backbuffer; instead just hide it.
if (region_map)
{
if (region_lock[REGION_MAP])
@@ -2175,31 +2189,34 @@ void get_input_line_gui(char *const buff, int len)
if (!r->flag)
return;
- /* Locate the cursor */
+ // Locate the cursor.
x = wherex();
y = wherey();
- /* Paranoia -- check len */
- if (len < 1) len = 1;
+ // Paranoia -- check len.
+ if (len < 1)
+ len = 1;
- /* Restrict the length */
- if (x + len > r->mx) len = r->mx - x;
- if (len > 40) len = 40;
+ // Restrict the length.
+ if (x + len > r->mx)
+ len = r->mx - x;
+ if (len > 40)
+ len = 40;
- /* Paranoia -- Clip the default entry */
+ // Paranoia -- Clip the default entry.
buff[len] = '\0';
- buff[0] = '\0';
+ buff[0] = '\0';
r->cgotoxy(x, y);
putch('_');
- /* Process input */
+ // Process input.
while (!done)
{
- /* Get a key */
+ // Get a key.
kin = getch_ck();
- /* Analyze the key */
+ // Analyze the key.
switch (kin)
{
case 0x1B:
@@ -2243,10 +2260,10 @@ void get_input_line_gui(char *const buff, int len)
}
break;
}
- /* Terminate */
+ // Terminate.
buff[k] = '\0';
- /* Update the entry */
+ // Update the entry.
r->cgotoxy(x, y);
int i;
@@ -2272,7 +2289,7 @@ void get_input_line_gui(char *const buff, int len)
}
r->addstr((char *)"_ ");
r->cgotoxy(x+k, y);
- }/* while */
+ } // while (!done)
}
void cprintf(const char *format,...)
@@ -2440,7 +2457,7 @@ void ViewTextFile(const char *name)
// Hack
#define MAXTEXTLINES 100
-#define DELIMITER_END "-------------------------------------------------------------------------------"
+#define DELIMITER_END "-------------------------------------------------------------------------------"
#define DELIMITER_MORE "...(more)... "
unsigned char buf[80*MAXTEXTLINES], buf2[84];
int nlines = 0;
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 8790c9ff9f..428747f977 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -3990,8 +3990,8 @@ item_def *monsters::slot_item(equipment_type eq)
item_def *monsters::mslot_item(mon_inv_type mslot) const
{
- const int mindex = mslot == NUM_MONSTER_SLOTS? NON_ITEM : inv[mslot];
- return (mindex == NON_ITEM? NULL: &mitm[mindex]);
+ const int mindex = (mslot == NUM_MONSTER_SLOTS) ? NON_ITEM : inv[mslot];
+ return (mindex == NON_ITEM ? NULL : &mitm[mindex]);
}
item_def *monsters::shield()
@@ -5673,7 +5673,8 @@ bool monsters::mon_see_grid(int tx, int ty, bool reach) const
max_disallowed = DNGN_MAX_NONREACH;
// XXX: Ignoring clouds for now.
- return (num_feats_between(x, y, tx, ty, DNGN_UNSEEN, max_disallowed) == 0);
+ return (!num_feats_between(x, y, tx, ty, DNGN_UNSEEN, max_disallowed,
+ true, true));
}
bool monsters::can_see(const actor *target) const
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 74cf8b2fdf..ca7c5115e2 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -230,18 +230,18 @@ bool curse_an_item( bool decay_potions, bool quiet )
continue;
}
- // item is valid for cursing, so we'll give it a chance
+ // Item is valid for cursing, so we'll give it a chance.
count++;
if (one_chance_in( count ))
item = i;
}
}
- // any item to curse?
+ // Any item to curse?
if (item == ENDOFPACK)
return (false);
- // curse item:
+ // Curse item.
if (decay_potions && !quiet) // just for mummies
mpr("You feel nervous for a moment...", MSGCH_MONSTER_SPELL);
@@ -602,8 +602,7 @@ static bool _monster_avoided_death(monsters *monster, killer_type killer, int i)
// Orcs may convert to Beogh under threat of death, either from you
// or, less often, your followers. In both cases, the checks are
- // made against your stats. You're the potential messiah, after
- // all.
+ // made against your stats. You're the potential messiah, after all.
if (convert)
{
#ifdef DEBUG_DIAGNOSTICS
@@ -1110,7 +1109,7 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent)
{
// Vehumet - only for non-undead servants (coding
// convenience, no real reason except that Vehumet
- // prefers demons)
+ // prefers demons).
if (you.magic_points < you.max_magic_points)
{
mpr("You feel your power returning.");
@@ -1155,7 +1154,7 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent)
}
break;
- // Monster killed by trap/inanimate thing/itself/poison not from you
+ // Monster killed by trap/inanimate thing/itself/poison not from you.
case KILL_MISC:
if (!silent)
{
@@ -1290,7 +1289,7 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent)
}
else
{
- // have to add case for disintegration effect here? {dlb}
+ // Have to add case for disintegration effect here? {dlb}
_place_monster_corpse(monster);
}
}
@@ -1357,7 +1356,7 @@ static bool _jelly_divide(monsters * parent)
int k = 0; // must remain outside loop that follows {dlb}
- // now that we have a spot, find a monster slot {dlb}:
+ // Now that we have a spot, find a monster slot {dlb}:
for (k = 0; k < MAX_MONSTERS; k++)
{
child = &menv[k];
@@ -1418,13 +1417,13 @@ void alert_nearby_monsters(void)
behaviour_event( monster, ME_ALERT, MHITYOU );
}
}
-} // end alert_nearby_monsters()
+}
static bool _valid_morph( monsters *monster, int new_mclass )
{
const dungeon_feature_type current_tile = grd[monster->x][monster->y];
- // morph targets are _always_ "base" classes, not derived ones.
+ // 'morph targets are _always_ "base" classes, not derived ones.
new_mclass = mons_species(new_mclass);
// [ds] Non-base draconians are much more trouble than their HD
@@ -1437,10 +1436,10 @@ static bool _valid_morph( monsters *monster, int new_mclass )
return (false);
}
- // various inappropriate polymorph targets
+ // Various inappropriate polymorph targets.
if (mons_class_holiness( new_mclass ) != mons_holiness( monster )
- || mons_class_flag( new_mclass, M_NO_EXP_GAIN ) // not helpless
- || new_mclass == mons_species( monster->type ) // must be different
+ || mons_class_flag( new_mclass, M_NO_EXP_GAIN ) // not helpless
+ || new_mclass == mons_species( monster->type ) // must be different
|| new_mclass == MONS_PROGRAM_BUG
|| new_mclass == MONS_SHAPESHIFTER
|| new_mclass == MONS_GLOWING_SHAPESHIFTER
@@ -1455,20 +1454,20 @@ static bool _valid_morph( monsters *monster, int new_mclass )
|| new_mclass == MONS_PLAYER_GHOST
|| new_mclass == MONS_PANDEMONIUM_DEMON
- // Other poly-unsuitable things
+ // Other poly-unsuitable things.
|| new_mclass == MONS_ROYAL_JELLY
|| new_mclass == MONS_ORB_GUARDIAN
|| new_mclass == MONS_ORANGE_STATUE
|| new_mclass == MONS_SILVER_STATUE
|| new_mclass == MONS_ICE_STATUE
- || (new_mclass >= MONS_GERYON && new_mclass <= MONS_ERESHKIGAL))
+ || new_mclass >= MONS_GERYON && new_mclass <= MONS_ERESHKIGAL)
{
return (false);
}
- // Determine if the monster is happy on current tile
+ // Determine if the monster is happy on current tile.
return (monster_habitable_grid(new_mclass, current_tile));
-} // end valid_morph()
+}
static bool _is_poly_power_unsuitable(
poly_power_type power,
@@ -1480,14 +1479,14 @@ static bool _is_poly_power_unsuitable(
{
case PPT_LESS:
return (tgt_pow > src_pow - 3 + (relax * 3) / 2)
- || (power == PPT_LESS && (tgt_pow < src_pow - (relax / 2)));
+ || (power == PPT_LESS && (tgt_pow < src_pow - (relax / 2)));
case PPT_MORE:
return (tgt_pow < src_pow + 2 - relax)
- || (power == PPT_MORE && (tgt_pow > src_pow + relax));
+ || (power == PPT_MORE && (tgt_pow > src_pow + relax));
default:
case PPT_SAME:
return (tgt_pow < src_pow - relax)
- || (tgt_pow > src_pow + (relax * 3) / 2);
+ || (tgt_pow > src_pow + (relax * 3) / 2);
}
}
@@ -1513,11 +1512,11 @@ bool monster_polymorph( monsters *monster, monster_type targetc,
{
do
{
- // Pick a monster that's guaranteed happy at this grid
+ // Pick a monster that's guaranteed happy at this grid.
targetc = random_monster_at_grid(monster->x, monster->y);
- // valid targets are always base classes ([ds] which is unfortunate
- // in that well-populated monster classes will dominate polymorphs)
+ // Valid targets are always base classes ([ds] which is unfortunate
+ // in that well-populated monster classes will dominate polymorphs).
targetc = mons_species( targetc );
target_power = mons_power( targetc );
@@ -1545,7 +1544,7 @@ bool monster_polymorph( monsters *monster, monster_type targetc,
monster->name(DESC_CAP_A, true).c_str()));
}
- // messaging: {dlb}
+ // Messaging.
bool invis = (!player_see_invis() && (mons_class_flag( targetc, M_INVIS )
|| monster->invisible()));
@@ -1578,8 +1577,8 @@ bool monster_polymorph( monsters *monster, monster_type targetc,
update_beholders(monster, true);
// the actual polymorphing:
- const int old_hp = monster->hit_points;
- const int old_hp_max = monster->max_hit_points;
+ const int old_hp = monster->hit_points;
+ const int old_hp_max = monster->max_hit_points;
const bool old_mon_caught = mons_is_caught(monster);
const char old_ench_countdown = monster->ench_countdown;
@@ -1625,10 +1624,10 @@ bool monster_polymorph( monsters *monster, monster_type targetc,
_monster_drop_ething(monster);
- // New monster type might be interesting
+ // New monster type might be interesting.
mark_interesting_monst(monster);
- // If new monster is visible to player, then we've seen it
+ // If new monster is visible to player, then we've seen it.
if (player_monster_visible(monster) && mons_near(monster))
seen_monster(monster);
@@ -1713,8 +1712,8 @@ bool monster_blink(monsters *monster)
return (true);
}
-// allow_adjacent: allow target to be adjacent to origin
-// restrict_LOS: restict target to be within PLAYER line of sight
+// allow_adjacent: allow target to be adjacent to origin.
+// restrict_LOS: restict target to be within PLAYER line of sight.
bool random_near_space(int ox, int oy, int &tx, int &ty, bool allow_adjacent,
bool restrict_LOS)
{
@@ -1791,7 +1790,8 @@ bool random_near_space(int ox, int oy, int &tx, int &ty, bool allow_adjacent,
int walls_passed = num_feats_between(tx, ty, ox, oy,
DNGN_CLEAR_ROCK_WALL,
- DNGN_CLEAR_PERMAROCK_WALL);
+ DNGN_CLEAR_PERMAROCK_WALL,
+ true, true);
if (walls_passed == 0)
return (true);
@@ -1918,9 +1918,8 @@ bool swap_places(monsters *monster)
return (swap);
} // end swap_places()
-void mons_get_damage_level(
- const monsters* monster,
- std::string& desc, mon_dam_level_type& dam_level)
+void mons_get_damage_level( const monsters* monster, std::string& desc,
+ mon_dam_level_type& dam_level )
{
if (monster->hit_points <= monster->max_hit_points / 6)
{
@@ -1979,8 +1978,9 @@ void print_wounds(const monsters *monster)
desc.insert(0, " is ");
desc += ".";
- simple_monster_message(monster, desc.c_str(), MSGCH_MONSTER_DAMAGE, dam_level);
-} // end print_wounds()
+ simple_monster_message(monster, desc.c_str(), MSGCH_MONSTER_DAMAGE,
+ dam_level);
+}
// (true == 'damaged') [constructs, undead, etc.]
// and (false == 'wounded') [living creatures, etc.] {dlb}
@@ -3088,7 +3088,7 @@ static bool _handle_special_ability(monsters *monster, bolt & beem)
if (monster->attitude == targ->attitude)
continue;
- // faking LOS by checking the neighbouring square
+ // Faking LOS by checking the neighbouring square.
int dx = sgn(targ->x - monster->x);
int dy = sgn(targ->y - monster->y);
@@ -3123,7 +3123,7 @@ static bool _handle_special_ability(monsters *monster, bolt & beem)
if (coinflip())
break;
- // setup tracer
+ // Setup tracer.
beem.name = "glob of lava";
beem.aux_source = "glob of lava";
beem.range = 4;
@@ -3136,10 +3136,10 @@ static bool _handle_special_ability(monsters *monster, bolt & beem)
beem.beam_source = monster_index(monster);
beem.thrower = KILL_MON;
- // fire tracer
+ // Fire tracer.
fire_tracer(monster, beem);
- // good idea?
+ // Good idea?
if (mons_should_fire(beem))
{
_make_mons_stop_fleeing(monster);
@@ -3165,7 +3165,7 @@ static bool _handle_special_ability(monsters *monster, bolt & beem)
if (coinflip())
break;
- // setup tracer
+ // Setup tracer.
beem.name = "bolt of electricity";
beem.aux_source = "bolt of electricity";
beem.range = 4;
@@ -3179,10 +3179,10 @@ static bool _handle_special_ability(monsters *monster, bolt & beem)
beem.thrower = KILL_MON;
beem.is_beam = true;
- // fire tracer
+ // Fire tracer.
fire_tracer(monster, beem);
- // good idea?
+ // Good idea?
if (mons_should_fire(beem))
{
_make_mons_stop_fleeing(monster);
@@ -3258,10 +3258,10 @@ static bool _handle_special_ability(monsters *monster, bolt & beem)
spell_cast = SPELL_HELLFIRE;
setup_mons_cast(monster, beem, spell_cast);
- // fire tracer
+ // Fire tracer.
fire_tracer(monster, beem);
- // good idea?
+ // Good idea?
if (mons_should_fire(beem))
{
_make_mons_stop_fleeing(monster);
@@ -3314,7 +3314,7 @@ static bool _handle_special_ability(monsters *monster, bolt & beem)
// Do the throwing right here, since the beam is so
// easy to set up and doesn't involve inventory.
- // set up the beam
+ // Set up the beam.
beem.name = "volley of spikes";
beem.aux_source = "volley of spikes";
beem.range = 9;
@@ -3328,17 +3328,17 @@ static bool _handle_special_ability(monsters *monster, bolt & beem)
beem.thrower = KILL_MON;
beem.is_beam = false;
- // fire tracer
+ // Fire tracer.
fire_tracer(monster, beem);
- // good idea?
+ // Good idea?
if (mons_should_fire(beem))
{
_make_mons_stop_fleeing(monster);
simple_monster_message(monster, " flicks its tail!");
fire_beam(beem);
used = true;
- // decrement # of volleys left
+ // Decrement # of volleys left.
monster->number--;
}
break;
@@ -3356,7 +3356,8 @@ static bool _handle_special_ability(monsters *monster, bolt & beem)
break;
}
}
- // dragon breath weapon:
+
+ // Dragon breath weapons:
case MONS_DRAGON:
case MONS_HELL_HOUND:
case MONS_ICE_DRAGON:
@@ -3382,10 +3383,10 @@ static bool _handle_special_ability(monsters *monster, bolt & beem)
{
setup_dragon(monster, beem);
- // fire tracer
+ // Fire tracer.
fire_tracer(monster, beem);
- // good idea?
+ // Good idea?
if (mons_should_fire(beem))
{
_make_mons_stop_fleeing(monster);
@@ -3400,7 +3401,7 @@ static bool _handle_special_ability(monsters *monster, bolt & beem)
case MONS_MERMAID:
{
- // Don't behold player already half down or up the stairs
+ // Don't behold player already half down or up the stairs.
if (!you.delay_queue.empty())
{
delay_queue_item delay = you.delay_queue.front();
@@ -3518,7 +3519,7 @@ static bool _handle_special_ability(monsters *monster, bolt & beem)
static bool _handle_potion(monsters *monster, bolt & beem)
{
- // yes, there is a logic to this ordering {dlb}:
+ // Yes, there is a logic to this ordering {dlb}:
if (monster->behaviour == BEH_SLEEP)
return (false);
else if (monster->inv[MSLOT_POTION] == NON_ITEM)
@@ -3588,7 +3589,7 @@ static bool _handle_potion(monsters *monster, bolt & beem)
break;
case POT_SPEED:
- // notice that these are the same odd colours used in
+ // Notice that these are the same odd colours used in
// mons_ench_f2() {dlb}
if (monster->has_ench(ENCH_HASTE))
break;
@@ -3702,7 +3703,7 @@ static bool _handle_reaching(monsters *monster)
//---------------------------------------------------------------
static bool _handle_scroll(monsters *monster)
{
- // yes, there is a logic to this ordering {dlb}:
+ // Yes, there is a logic to this ordering {dlb}:
if (monster->has_ench(ENCH_CONFUSION)
|| monster->behaviour == BEH_SLEEP
|| monster->has_ench(ENCH_SUBMERGED))
@@ -3789,7 +3790,7 @@ static bool _handle_scroll(monsters *monster)
//---------------------------------------------------------------
static bool _handle_wand(monsters *monster, bolt &beem)
{
- // yes, there is a logic to this ordering {dlb}:
+ // Yes, there is a logic to this ordering {dlb}:
if (monster->behaviour == BEH_SLEEP)
return (false);
else if (!mons_near(monster))
@@ -3853,7 +3854,7 @@ static bool _handle_wand(monsters *monster, bolt &beem)
beem.damage.size = beem.damage.size * 2 / 3;
break;
- // these have been deemed "too tricky" at this time {dlb}:
+ // These have been deemed "too tricky" at this time {dlb}:
case WAND_ENSLAVEMENT:
case WAND_DIGGING:
case WAND_RANDOM_EFFECTS:
@@ -3866,7 +3867,7 @@ static bool _handle_wand(monsters *monster, bolt &beem)
return false;
break;
- // these are wands that monsters will aim at themselves {dlb}:
+ // These are wands that monsters will aim at themselves {dlb}:
case WAND_HASTING:
if (!monster->has_ench(ENCH_HASTE))
{
@@ -3926,7 +3927,7 @@ static bool _handle_wand(monsters *monster, bolt &beem)
{
fire_tracer( monster, beem );
- // good idea?
+ // Good idea?
zap = mons_should_fire( beem );
}
@@ -4050,8 +4051,9 @@ static bool _mons_announce_cast(monsters *monster, bool nearby,
const msg_channel_type spl = (mons_friendly(monster) ? MSGCH_FRIEND_SPELL
: MSGCH_MONSTER_SPELL);
- if (nearby) // handle monsters within range of player
+ if (nearby)
{
+ // Handle monsters within range of player.
if (monster->type == MONS_GERYON)
{
if (silenced(monster->x, monster->y))
@@ -4188,8 +4190,9 @@ static bool _mons_announce_cast(monsters *monster, bool nearby,
}
}
}
- else // handle far-away monsters
+ else
{
+ // Handle far-away monsters.
if (monster->type == MONS_GERYON
&& !silenced(you.x_pos, you.y_pos))
{
@@ -4214,7 +4217,7 @@ static bool _handle_spell( monsters *monster, bolt & beem )
bool finalAnswer = false; // as in: "Is that your...?" {dlb}
const spell_type draco_breath = _get_draconian_breath_spell(monster);
- // yes, there is a logic to this ordering {dlb}:
+ // Yes, there is a logic to this ordering {dlb}:
if (monster->behaviour == BEH_SLEEP
|| !mons_class_flag(monster->type, M_SPELLCASTER)
&& draco_breath == SPELL_NO_SPELL
@@ -4265,9 +4268,8 @@ static bool _handle_spell( monsters *monster, bolt & beem )
{
// The player's out of sight!
// Quick, let's take a turn to heal ourselves. -- bwr
- spell_cast =
- monster->has_spell(SPELL_GREATER_HEALING)?
- SPELL_GREATER_HEALING : SPELL_LESSER_HEALING;
+ spell_cast = monster->has_spell(SPELL_GREATER_HEALING)?
+ SPELL_GREATER_HEALING : SPELL_LESSER_HEALING;
finalAnswer = true;
}
else if (monster->behaviour == BEH_FLEE)
@@ -4396,20 +4398,20 @@ static bool _handle_spell( monsters *monster, bolt & beem )
if (spell_cast == SPELL_NO_SPELL)
continue;
- // setup the spell
+ // Setup the spell.
setup_mons_cast(monster, beem, spell_cast);
// beam-type spells requiring tracers
if (spell_needs_tracer(spell_cast))
{
fire_tracer(monster, beem);
- // good idea?
+ // Good idea?
if (mons_should_fire(beem))
spellOK = true;
}
else
{
- // all direct-effect/summoning/self-enchantments/etc.
+ // All direct-effect/summoning/self-enchantments/etc.
spellOK = true;
if (is_sanctuary(you.x_pos, you.y_pos)
@@ -4496,7 +4498,7 @@ static bool _handle_spell( monsters *monster, bolt & beem )
// FINALLY! determine primary spell effects {dlb}:
if (spell_cast == SPELL_BLINK)
{
- // why only cast blink if nearby? {dlb}
+ // Why only cast blink if nearby? {dlb}
if (monsterNearby)
{
simple_monster_message(monster, " blinks!");
@@ -4511,6 +4513,7 @@ static bool _handle_spell( monsters *monster, bolt & beem )
{
if (spell_needs_foe(spell_cast))
_make_mons_stop_fleeing(monster);
+
mons_cast(monster, beem, spell_cast);
mmov_x = 0;
mmov_y = 0;
@@ -4665,13 +4668,13 @@ static bool _handle_throw(monsters *monster, bolt & beem)
// Set fake damage for the tracer.
beem.damage = dice_def(10, 10);
- // fire tracer
+ // Fire tracer.
fire_tracer( monster, beem );
// Clear fake damage (will be set correctly in mons_throw).
beem.damage = 0;
- // good idea?
+ // Good idea?
if (mons_should_fire( beem ))
{
if (launcher && launcher != weapon)
@@ -4686,7 +4689,7 @@ static bool _handle_throw(monsters *monster, bolt & beem)
static bool _handle_monster_spell(monsters *monster, bolt &beem)
{
- // shapeshifters don't get spells
+ // Shapeshifters don't get spells.
if (!monster->has_ench( ENCH_GLOWING_SHAPESHIFTER,
ENCH_SHAPESHIFTER )
|| !mons_class_flag( monster->type, M_ACTUAL_SPELLS ))
@@ -4705,7 +4708,7 @@ static void _monster_add_energy(monsters *monster)
// Slow monsters might get 0 here. Maybe we should factor in
// *how* slow it is...but a 10-to-1 move ratio seems more than
// enough.
- if ( energy_gained == 0 && monster->speed != 0 )
+ if (energy_gained == 0 && monster->speed != 0)
energy_gained = 1;
monster->speed_increment += energy_gained;
@@ -4942,7 +4945,7 @@ static void _handle_monster_move(int i, monsters *monster)
_handle_behaviour(monster);
- // submerging monsters will hide from clouds
+ // Submerging monsters will hide from clouds.
if (monster_can_submerge(monster, grd[monster->x][monster->y])
&& env.cgrid[monster->x][monster->y] != EMPTY_CLOUD)
{
@@ -5052,17 +5055,6 @@ static void _handle_monster_move(int i, monsters *monster)
monster->y + mmov_y);
}
break;
-/*
- if (monster->foe == enemy || mons_friendly(monster)
- && monster->foe == MHITYOU)
- {
- monster->foe = MHITNOT;
- monster->behaviour = BEH_WANDER;
- }
-
- monster->target_x = 10 + random2(GXM - 10);
- monster->target_y = 10 + random2(GYM - 10);
-*/
}
}
}
@@ -5428,6 +5420,8 @@ static bool _handle_pickup(monsters *monster)
// Note: Monsters only look at stuff near the top of stacks.
// XXX: Need to put in something so that monster picks up multiple items
// (eg ammunition) identical to those it's carrying.
+ // Monsters may now pick up several items in the same turn, though with
+ // reducing chances. (jpeg)
bool success = false;
for (item = igrd[monster->x][monster->y]; item != NON_ITEM; )
{
@@ -5797,11 +5791,13 @@ static bool _is_trap_safe(const monsters *monster, const int trap_x,
// What we do is check whether the squares with the relative
// positions (-1,0)/(+1,0) or (0,-1)/(0,+1) form a "corridor"
// (relative to the _current_ monster position rather than the
- // trap one) form a corridor-like environment. If they don't
- // the trap square is marked as "unsafe", otherwise the decision
- // will be made according to later tests (monster hp, trap type, ...)
+ // trap one).
+ // If they don't, the trap square is marked as "unsafe" (because
+ // there's good alternative move for the monster to take),
+ // otherwise the decision will be made according to later tests
+ // (monster hp, trap type, ...)
// If a monster still gets stuck in a corridor it will usually be
- // because it has less than half its maximum hp
+ // because it has less than half its maximum hp.
if ((_mon_can_move_to_pos(monster, x-1, y, true)
|| _mon_can_move_to_pos(monster, x+1,y, true))
@@ -6142,8 +6138,11 @@ static bool _monster_move(monsters *monster)
{
handle_monster_shouts(monster, true);
}
- else // just be noisy without messaging the player
+ else
+ {
+ // Just be noisy without messaging the player
noisy( noise_level, monster->x, monster->y );
+ }
}
}
@@ -6258,7 +6257,6 @@ static bool _monster_move(monsters *monster)
count = 0;
for (count_x = 0; count_x < 3; count_x++)
- {
for (count_y = 0; count_y < 3; count_y++)
{
if (good_move[count_x][count_y]
@@ -6274,12 +6272,11 @@ static bool _monster_move(monsters *monster)
}
}
}
- }
}
- // now, if a monster can't move in its intended direction, try
+ // Now, if a monster can't move in its intended direction, try
// either side. If they're both good, move in whichever dir
- // gets it closer(farther for fleeing monsters) to its target.
+ // gets it closer (farther for fleeing monsters) to its target.
// If neither does, do nothing.
if (good_move[mmov_x + 1][mmov_y + 1] == false)
{
@@ -6304,7 +6301,7 @@ static bool _monster_move(monsters *monster)
int dist[2];
- // first 1 away, then 2 (3 is silly)
+ // First 1 away, then 2 (3 is silly).
for (int j = 1; j <= 2; j++)
{
int sdir, inc;
@@ -6320,7 +6317,7 @@ static bool _monster_move(monsters *monster)
inc = -2*j;
}
- // try both directions
+ // Try both directions.
for (mod = sdir, i = 0; i < 2; mod += inc, i++)
{
newdir = (dir + 8 + mod) % 8;
@@ -6338,7 +6335,7 @@ static bool _monster_move(monsters *monster)
}
}
- // now choose
+ // Now choose.
if (dist[0] == dist[1] && abs(dist[0]) == FAR_AWAY)
continue;
@@ -6510,7 +6507,7 @@ static bool _plant_spit(monsters *monster, bolt &pbolt)
_setup_plant_spit(monster, pbolt);
- // fire tracer
+ // Fire tracer.
fire_tracer(monster, pbolt);
if (mons_should_fire(pbolt))
@@ -6528,7 +6525,7 @@ static bool _plant_spit(monsters *monster, bolt &pbolt)
}
return (did_spit);
-} // end plant_spit()
+}
static void _mons_in_cloud(monsters *monster)
{
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index af6c347b07..08b6d3e9bf 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -753,12 +753,11 @@ bool entomb(int powc)
};
for (int srx = you.x_pos - 1; srx < you.x_pos + 2; srx++)
- {
for (int sry = you.y_pos - 1; sry < you.y_pos + 2; sry++)
{
- // tile already occupied by monster or yourself {dlb}:
+ // Tile already occupied by monster or yourself {dlb}:
if (mgrd[srx][sry] != NON_MONSTER
- || (srx == you.x_pos && sry == you.y_pos))
+ || srx == you.x_pos && sry == you.y_pos)
{
continue;
}
@@ -827,11 +826,10 @@ bool entomb(int powc)
}
}
- // finally, place the wall {dlb}:
+ // Finally, place the wall {dlb}:
grd[srx][sry] = DNGN_ROCK_WALL;
number_built++;
- } // end "for srx,sry"
- }
+ }
if (number_built > 0)
{
@@ -843,7 +841,7 @@ bool entomb(int powc)
const coord_def pos = mon->pos();
int walls = num_feats_between(you.x_pos, you.y_pos,
pos.x, pos.y, DNGN_UNSEEN,
- DNGN_MAXWALL);
+ DNGN_MAXWALL, true, true);
if (walls > 0)
{
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index c4bfe6686b..50ad0e67a7 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -1025,7 +1025,7 @@ command_type travel()
if (you.running.is_explore())
{
- // Exploring
+ // Exploring.
if (grd[you.x_pos][you.y_pos] == DNGN_ENTER_SHOP
&& you.running == RMODE_EXPLORE_GREEDY)
{
@@ -1058,8 +1058,8 @@ command_type travel()
if (you.running < 0)
{
- // Remember what run-mode we were in so that we can resume explore/
- // interlevel travel correctly.
+ // Remember what run-mode we were in so that we can resume
+ // explore/interlevel travel correctly.
int runmode = you.running;
// Get the next step to make. If the travel command can't find a route,
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index 019ea1605f..86e18f81bf 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -2439,10 +2439,12 @@ bool find_ray( int sourcex, int sourcey, int targetx, int targety,
// Count the number of matching features between two points along
// a beam-like path; the path will pass through solid features.
// By default, it excludes end points from the count.
+// If just_check is true, the function will return early once one
+// such feature is encountered.
int num_feats_between(int sourcex, int sourcey, int targetx, int targety,
dungeon_feature_type min_feat,
dungeon_feature_type max_feat,
- bool exclude_endpoints)
+ bool exclude_endpoints, bool just_check)
{
ray_def ray;
int count = 0;
@@ -2458,24 +2460,30 @@ int num_feats_between(int sourcex, int sourcey, int targetx, int targety,
}
int dist = 0;
+ bool reached_target = false;
while (dist++ <= max_dist)
{
dungeon_feature_type feat = grd[ray.x()][ray.y()];
- if (feat >= min_feat && feat <= max_feat)
- count++;
-
if (ray.x() == targetx && ray.y() == targety)
+ reached_target = true;
+
+ if (feat >= min_feat && feat <= max_feat
+ && (!exclude_endpoints || !reached_target))
{
- if (exclude_endpoints && feat >= min_feat && feat <= max_feat)
- count--;
+ count++;
- break;
+ if (just_check) // Only needs to be > 0.
+ return (count);
}
+
+ if (reached_target)
+ break;
+
ray.advance(true);
}
- return count;
+ return (count);
}
// The rule behind LOS is:
@@ -2989,7 +2997,7 @@ static void _draw_level_map(int start_x, int start_y, bool travel_mode)
static void _reset_travel_colours(std::vector<coord_def> &features)
{
- // We now need to redo travel colours
+ // We now need to redo travel colours.
features.clear();
find_travel_pos(you.x_pos, you.y_pos, NULL, NULL, &features);
// Sort features into the order the player is likely to prefer.
@@ -3660,8 +3668,8 @@ bool grid_see_grid(int posx_1, int posy_1, int posx_2, int posy_2,
max_disallowed = static_cast<dungeon_feature_type>(allowed - 1);
// XXX: Ignoring clouds for now.
- return (num_feats_between(posx_1, posy_1, posx_2, posy_2, DNGN_UNSEEN,
- max_disallowed) == 0);
+ return (!num_feats_between(posx_1, posy_1, posx_2, posy_2, DNGN_UNSEEN,
+ max_disallowed, true, true));
}
static const unsigned dchar_table[ NUM_CSET ][ NUM_DCHAR_TYPES ] =
diff --git a/crawl-ref/source/view.h b/crawl-ref/source/view.h
index 135314223f..357cfbf597 100644
--- a/crawl-ref/source/view.h
+++ b/crawl-ref/source/view.h
@@ -232,7 +232,8 @@ bool find_ray( int sourcex, int sourcey, int targetx, int targety,
int num_feats_between(int sourcex, int sourcey, int targetx, int targety,
dungeon_feature_type min_feat,
dungeon_feature_type max_feat,
- bool exclude_endpoints = true);
+ bool exclude_endpoints = true,
+ bool just_check = false);
dungeon_char_type dchar_by_name(const std::string &name);