summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrendan Hickey <brendan@bhickey.net>2013-11-15 22:09:48 -0800
committerBrendan Hickey <brendan@bhickey.net>2013-11-15 22:23:40 -0800
commit88d061b7451307158b7e9cf8c83cd09e2ee3c283 (patch)
treef115d2b8bb33c44136bb0f8fdb6df03e5a499758
parent02d7e00d420071eed54ccd5a13dff0137a22ee52 (diff)
downloadcrawl-ref-88d061b7451307158b7e9cf8c83cd09e2ee3c283.tar.gz
crawl-ref-88d061b7451307158b7e9cf8c83cd09e2ee3c283.zip
Refactor ASSERT(a && b) again
This commit converts ASSERT(a && b) to ASSERT(a); ASSERT(b); Assertions of the form !(a && b) are left intact, since there isn't an obvious readability gain over (!a || !b).
-rw-r--r--crawl-ref/source/arena.cc3
-rw-r--r--crawl-ref/source/item_use.cc3
-rw-r--r--crawl-ref/source/items.cc3
-rw-r--r--crawl-ref/source/los.cc6
-rw-r--r--crawl-ref/source/main.cc6
-rw-r--r--crawl-ref/source/maps.cc3
-rw-r--r--crawl-ref/source/mon-behv.cc2
-rw-r--r--crawl-ref/source/mon-chimera.cc6
-rw-r--r--crawl-ref/source/random-var.cc3
-rw-r--r--crawl-ref/source/ray.cc3
-rw-r--r--crawl-ref/source/spl-book.cc3
-rw-r--r--crawl-ref/source/tileweb-text.cc5
12 files changed, 31 insertions, 15 deletions
diff --git a/crawl-ref/source/arena.cc b/crawl-ref/source/arena.cc
index dbef7263af..24a5b1fa0a 100644
--- a/crawl-ref/source/arena.cc
+++ b/crawl-ref/source/arena.cc
@@ -804,7 +804,8 @@ namespace arena
{
const int ch = getchm();
handle_keypress(ch);
- ASSERT(crawl_state.game_is_arena() && !crawl_state.arena_suspended);
+ ASSERT(crawl_state.game_is_arena());
+ ASSERT(!crawl_state.arena_suspended);
if (contest_cancelled)
return;
}
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index f08014c503..859d3e36ef 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -2629,7 +2629,8 @@ static void _handle_enchant_weapon(int acc, int dam, const char *colour)
bool enchant_armour(int &ac_change, bool quiet, item_def &arm)
{
- ASSERT(arm.defined() && arm.base_type == OBJ_ARMOUR);
+ ASSERT(arm.defined());
+ ASSERT(arm.base_type == OBJ_ARMOUR);
ac_change = 0;
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index dc57483332..c09401cc77 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -1772,7 +1772,8 @@ int move_item_to_player(int obj, int quant_got, bool quiet,
_fish(it, quant_got);
int freeslot = find_free_slot(it);
- ASSERT(freeslot >= 0 && freeslot < ENDOFPACK);
+ ASSERT(freeslot >= 0);
+ ASSERT(freeslot < ENDOFPACK);
ASSERT(!you.inv[freeslot].defined());
coord_def p = it.pos;
diff --git a/crawl-ref/source/los.cc b/crawl-ref/source/los.cc
index 3541df5884..ce0ec37867 100644
--- a/crawl-ref/source/los.cc
+++ b/crawl-ref/source/los.cc
@@ -556,7 +556,8 @@ static bool _find_ray_se(const coord_def& target, ray_def& ray,
const opacity_func& opc, const circle_def& bds,
bool cycle)
{
- ASSERT(target.x >= 0 && target.y >= 0);
+ ASSERT(target.x >= 0);
+ ASSERT(target.y >= 0);
ASSERT(!target.origin());
if (!bds.contains(target))
return false;
@@ -717,7 +718,8 @@ int num_feats_between(const coord_def& source, const coord_def& target,
int count = 0;
int max_dist = grid_distance(source, target);
- ASSERT(map_bounds(source) && map_bounds(target));
+ ASSERT(map_bounds(source));
+ ASSERT(map_bounds(target));
if (source == target)
return 0; // XXX: might want to count the cell.
diff --git a/crawl-ref/source/main.cc b/crawl-ref/source/main.cc
index 36b641b4ef..78c401ddd8 100644
--- a/crawl-ref/source/main.cc
+++ b/crawl-ref/source/main.cc
@@ -1569,7 +1569,8 @@ static bool _prompt_stairs(dungeon_feature_type ygrd, bool down)
static void _take_stairs(bool down)
{
- ASSERT(!crawl_state.game_is_arena() && !crawl_state.arena_suspended);
+ ASSERT(!crawl_state.game_is_arena());
+ ASSERT(!crawl_state.arena_suspended);
const dungeon_feature_type ygrd = grd(you.pos());
@@ -3762,7 +3763,8 @@ static bool _untrap_target(const coord_def move, bool check_confused)
// direction for the door to be opened (eg if you type ctrl + dir).
static void _open_door(coord_def move, bool check_confused)
{
- ASSERT(!crawl_state.game_is_arena() && !crawl_state.arena_suspended);
+ ASSERT(!crawl_state.game_is_arena());
+ ASSERT(!crawl_state.arena_suspended);
if (you.attribute[ATTR_HELD])
{
diff --git a/crawl-ref/source/maps.cc b/crawl-ref/source/maps.cc
index ca3c33a17d..62b4a496af 100644
--- a/crawl-ref/source/maps.cc
+++ b/crawl-ref/source/maps.cc
@@ -346,7 +346,8 @@ static void _fit_region_into_map_bounds(coord_def &pos, const coord_def &size,
const int Y_1(Y_BOUND_1 + margin);
const int Y_2(Y_BOUND_2 - margin);
- ASSERT(size.x <= (X_2 - X_1 + 1) && size.y <= (Y_2 - Y_1 + 1));
+ ASSERT(size.x <= (X_2 - X_1 + 1));
+ ASSERT(size.y <= (Y_2 - Y_1 + 1));
if (pos.x < X_1)
pos.x = X_1;
diff --git a/crawl-ref/source/mon-behv.cc b/crawl-ref/source/mon-behv.cc
index b2e28d4c45..f8b9470c9f 100644
--- a/crawl-ref/source/mon-behv.cc
+++ b/crawl-ref/source/mon-behv.cc
@@ -361,7 +361,7 @@ void handle_behaviour(monster* mon)
}
// Make sure monsters are not targetting the player in arena mode.
- ASSERT(!(crawl_state.game_is_arena() && mon->foe == MHITYOU));
+ ASSERT(!crawl_state.game_is_arena() || mon->foe != MHITYOU);
if (mons_wall_shielded(mon) && cell_is_solid(mon->pos()))
{
diff --git a/crawl-ref/source/mon-chimera.cc b/crawl-ref/source/mon-chimera.cc
index 283295ac05..b600dff361 100644
--- a/crawl-ref/source/mon-chimera.cc
+++ b/crawl-ref/source/mon-chimera.cc
@@ -269,8 +269,10 @@ string monster_info::chimera_part_names() const
monster_type chimtype2 = static_cast<monster_type>(props["chimera_part_2"].get_int());
monster_type chimtype3 = static_cast<monster_type>(props["chimera_part_3"].get_int());
- ASSERT(chimtype2 > MONS_PROGRAM_BUG && chimtype2 < NUM_MONSTERS);
- ASSERT(chimtype3 > MONS_PROGRAM_BUG && chimtype3 < NUM_MONSTERS);
+ ASSERT(chimtype2 > MONS_PROGRAM_BUG);
+ ASSERT(chimtype2 < NUM_MONSTERS);
+ ASSERT(chimtype3 > MONS_PROGRAM_BUG);
+ ASSERT(chimtype3 < NUM_MONSTERS);
ostringstream s;
s << ", " << get_monster_data(chimtype2)->name
diff --git a/crawl-ref/source/random-var.cc b/crawl-ref/source/random-var.cc
index 3daf178fc0..cf06461409 100644
--- a/crawl-ref/source/random-var.cc
+++ b/crawl-ref/source/random-var.cc
@@ -54,7 +54,8 @@ void random_var::init()
for (int v = start; v < end; ++v)
total += weight(v);
ASSERT(total > 0);
- ASSERT(weight(start) > 0 && weight(end - 1) > 0);
+ ASSERT(weight(start) > 0);
+ ASSERT(weight(end - 1) > 0);
}
int random_var::roll2val(int r) const
diff --git a/crawl-ref/source/ray.cc b/crawl-ref/source/ray.cc
index 92fbfac797..c297cde658 100644
--- a/crawl-ref/source/ray.cc
+++ b/crawl-ref/source/ray.cc
@@ -413,7 +413,8 @@ static geom::form _corner_wall(const coord_def &side, const reflect_grid &rg)
e = coord_def(1, 0);
else
e = coord_def(0, 1);
- ASSERT(!rg(coord_def(0,0)) && rg(side));
+ ASSERT(!rg(coord_def(0,0)));
+ ASSERT(rg(side));
// Reflect back by an orthogonal wall...
coord_def wall = e;
// unless the wall is clearly diagonal:
diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc
index dd72c1f721..0785d18f83 100644
--- a/crawl-ref/source/spl-book.cc
+++ b/crawl-ref/source/spl-book.cc
@@ -2128,7 +2128,8 @@ bool make_book_theme_randart(item_def &book,
ASSERT(disc1 < (1 << (SPTYP_LAST_EXPONENT + 1)));
ASSERT(disc2 < (1 << (SPTYP_LAST_EXPONENT + 1)));
- ASSERT(count_bits(disc1) == 1 && count_bits(disc2) == 1);
+ ASSERT(count_bits(disc1) == 1);
+ ASSERT(count_bits(disc2) == 1);
int disc1_pos = 0, disc2_pos = 0;
for (int i = 0; i <= SPTYP_LAST_EXPONENT; i++)
diff --git a/crawl-ref/source/tileweb-text.cc b/crawl-ref/source/tileweb-text.cc
index 3dcd349184..0d6f28762b 100644
--- a/crawl-ref/source/tileweb-text.cc
+++ b/crawl-ref/source/tileweb-text.cc
@@ -77,7 +77,10 @@ void WebTextArea::clear()
void WebTextArea::put_character(ucs_t chr, int fg, int bg, int x, int y)
{
- ASSERT((x < mx) && (y < my) && (x >= 0) && (y >= 0));
+ ASSERT(x < mx);
+ ASSERT(y < my);
+ ASSERT(x >= 0);
+ ASSERT(y >= 0);
uint8_t col = (fg & 0xf) + (bg << 4);
if ((m_cbuf[x + y * mx] != chr) || (m_abuf[x + y * mx] != col))