summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2013-11-16 10:22:51 +0100
committerAdam Borowski <kilobyte@angband.pl>2013-11-16 19:36:21 +0100
commit97aa533c25deebe96ca4caf538fbac1a845819c1 (patch)
treed348defc4ac438079f410a05505e65ea136c9cec
parent996e7c22911f2ed2cf4764b12213207d3c29c354 (diff)
downloadcrawl-ref-97aa533c25deebe96ca4caf538fbac1a845819c1.tar.gz
crawl-ref-97aa533c25deebe96ca4caf538fbac1a845819c1.zip
Refactor pairs of asserts to ASSERT_RANGE.
More readable, and failures give more informative messages.
-rw-r--r--crawl-ref/source/items.cc3
-rw-r--r--crawl-ref/source/mon-chimera.cc6
-rw-r--r--crawl-ref/source/tileweb-text.cc6
3 files changed, 5 insertions, 10 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index c09401cc77..326a24e374 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -1772,8 +1772,7 @@ 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);
- ASSERT(freeslot < ENDOFPACK);
+ ASSERT_RANGE(freeslot, 0, ENDOFPACK);
ASSERT(!you.inv[freeslot].defined());
coord_def p = it.pos;
diff --git a/crawl-ref/source/mon-chimera.cc b/crawl-ref/source/mon-chimera.cc
index b600dff361..b895f259c0 100644
--- a/crawl-ref/source/mon-chimera.cc
+++ b/crawl-ref/source/mon-chimera.cc
@@ -269,10 +269,8 @@ 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);
- ASSERT(chimtype2 < NUM_MONSTERS);
- ASSERT(chimtype3 > MONS_PROGRAM_BUG);
- ASSERT(chimtype3 < NUM_MONSTERS);
+ ASSERT_RANGE(chimtype2, MONS_PROGRAM_BUG + 1, NUM_MONSTERS);
+ ASSERT_RANGE(chimtype3, MONS_PROGRAM_BUG + 1, NUM_MONSTERS);
ostringstream s;
s << ", " << get_monster_data(chimtype2)->name
diff --git a/crawl-ref/source/tileweb-text.cc b/crawl-ref/source/tileweb-text.cc
index 0d6f28762b..14eb5a991a 100644
--- a/crawl-ref/source/tileweb-text.cc
+++ b/crawl-ref/source/tileweb-text.cc
@@ -77,10 +77,8 @@ void WebTextArea::clear()
void WebTextArea::put_character(ucs_t chr, int fg, int bg, int x, int y)
{
- ASSERT(x < mx);
- ASSERT(y < my);
- ASSERT(x >= 0);
- ASSERT(y >= 0);
+ ASSERT_RANGE(x, 0, mx);
+ ASSERT_RANGE(y, 0, my);
uint8_t col = (fg & 0xf) + (bg << 4);
if ((m_cbuf[x + y * mx] != chr) || (m_abuf[x + y * mx] != col))