From 997a4469a2022461f5fe011bd7d0843d6dd6c5de Mon Sep 17 00:00:00 2001 From: Steven Noonan Date: Tue, 13 Oct 2009 03:05:10 -0700 Subject: fix 'DEBUG' macro usage consistency Sometimes we were doing #if DEBUG and others we were doing #ifdef DEBUG. If we mix both, we have problems: If the DEBUG macro isn't defined, the statement '#if DEBUG' doesn't really make sense logically, because 'DEBUG' has no value. And if we '#define DEBUG 0', then the '#ifdef DEBUG's become true statements. The easiest fix is to swap out the #ifs with #ifdefs. Signed-off-by: Steven Noonan --- crawl-ref/source/AppHdr.h | 2 +- crawl-ref/source/acr.cc | 2 +- crawl-ref/source/beam.cc | 2 +- crawl-ref/source/debug.cc | 8 ++++---- crawl-ref/source/debug.h | 6 +++--- crawl-ref/source/describe.cc | 2 +- crawl-ref/source/items.cc | 2 +- crawl-ref/source/monstuff.cc | 4 ++-- crawl-ref/source/newgame.cc | 2 +- crawl-ref/source/player.cc | 6 +++--- crawl-ref/source/religion.cc | 2 +- crawl-ref/source/spl-util.cc | 2 +- crawl-ref/source/store.cc | 10 +++++----- crawl-ref/source/stuff.h | 6 +++--- crawl-ref/source/tilebuf.cc | 2 +- 15 files changed, 29 insertions(+), 29 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/AppHdr.h b/crawl-ref/source/AppHdr.h index 4014edab30..7864d87abe 100644 --- a/crawl-ref/source/AppHdr.h +++ b/crawl-ref/source/AppHdr.h @@ -333,7 +333,7 @@ // #define DEBUG 0 // leave this undefined for those lamers who use #ifdef #endif -#if DEBUG +#ifdef DEBUG #if __MWERKS__ #define MSIPL_DEBUG_MODE #endif diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index b20c9794f1..3b02f32750 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -15,7 +15,7 @@ REVISION("$Rev$"); #include #endif -#if DEBUG +#ifdef DEBUG // this contains the DBL_MAX constant #include #endif diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index e2815833cc..98379be9c2 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -1494,7 +1494,7 @@ void bolt::initialise_fire() if (range == -1) { -#if DEBUG +#ifdef DEBUG if (is_tracer) { mpr("Tracer with range == -1, skipping.", MSGCH_ERROR); diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 0fa8f1b7f0..6cef944a8c 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -99,7 +99,7 @@ static void _dump_levgen(); //--------------------------------------------------------------- // BreakStrToDebugger //--------------------------------------------------------------- -#if DEBUG +#ifdef DEBUG static void _BreakStrToDebugger(const char *mesg) { #if defined(TARGET_OS_MACOSX) || defined(TARGET_COMPILER_MINGW) @@ -124,7 +124,7 @@ static void _BreakStrToDebugger(const char *mesg) // AssertFailed // //--------------------------------------------------------------- -#if DEBUG +#ifdef DEBUG static std::string _assert_msg; void AssertFailed(const char *expr, const char *file, int line) @@ -151,7 +151,7 @@ void AssertFailed(const char *expr, const char *file, int line) // DEBUGSTR // //--------------------------------------------------------------- -#if DEBUG +#ifdef DEBUG void DEBUGSTR(const char *format, ...) { char mesg[2048]; @@ -6568,7 +6568,7 @@ void do_crash_dump() set_msg_dump_file(file); -#if DEBUG +#ifdef DEBUG if (!_assert_msg.empty()) fprintf(file, "%s" EOL EOL, _assert_msg.c_str()); #endif diff --git a/crawl-ref/source/debug.h b/crawl-ref/source/debug.h index e75903c81f..44571a1891 100644 --- a/crawl-ref/source/debug.h +++ b/crawl-ref/source/debug.h @@ -11,11 +11,11 @@ #include "enum.h" // Synch with ANSI definitions. -#if DEBUG && defined(NDEBUG) +#if defined(DEBUG) && defined(NDEBUG) #error DEBUG and NDEBUG are out of sync! #endif -#if !DEBUG && !defined(NDEBUG) +#if !defined(DEBUG) && !defined(NDEBUG) #error DEBUG and NDEBUG are out of sync! #endif @@ -36,7 +36,7 @@ #define COMPILE_CHECK(expr, tag) #endif -#if DEBUG +#ifdef DEBUG void AssertFailed(const char *expr, const char *file, int line); diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index aff6afc172..0c490ea618 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -2398,7 +2398,7 @@ bool _get_spell_description(const spell_type spell, std::string &description, { description += "This spell has no description. " "Casting it may therefore be unwise. " -#if DEBUG +#ifdef DEBUG "Instead, go fix it. "; #else "Please file a bug report."; diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 2e0d7a7015..e5e52e82fd 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -410,7 +410,7 @@ void unlink_item( int dest ) } } -#if DEBUG +#ifdef DEBUG // Okay, the sane ways are gone... let's warn the player: mprf(MSGCH_ERROR, "BUG WARNING: Problems unlinking item '%s', (%d, %d)!!!", mitm[dest].name(DESC_PLAIN).c_str(), diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index e2c53a68a7..42df85b2e0 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -7528,7 +7528,7 @@ static void _khufu_drop_tomb(monsters *monster) monster->lose_energy(EUT_SPELL); } -#if DEBUG +#ifdef DEBUG # define DEBUG_ENERGY_USE(problem) \ if (monster->speed_increment == old_energy && monster->alive()) \ mprf(MSGCH_DIAGNOSTICS, \ @@ -7649,7 +7649,7 @@ static void _handle_monster_move(monsters *monster) if (monster->speed_increment >= old_energy) { -#if DEBUG +#ifdef DEBUG if (monster->speed_increment == old_energy) { mprf(MSGCH_DIAGNOSTICS, "'%s' has same energy as last loop", diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc index e8219cb908..3c2b5413c7 100644 --- a/crawl-ref/source/newgame.cc +++ b/crawl-ref/source/newgame.cc @@ -1094,7 +1094,7 @@ static void _give_species_bonus_mp() } } -#if DEBUG +#ifdef DEBUG static bool _species_is_undead( const species_type speci ) { return (speci == SP_MUMMY || speci == SP_GHOUL || speci == SP_VAMPIRE); diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index d5591ef803..b0bdc8cbaf 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -2818,7 +2818,7 @@ void check_beholders() if (!mon->alive() || mons_genus(mon->type) != MONS_MERMAID || mons_is_submerged(mon)) { -#if DEBUG +#ifdef DEBUG if (!mon->alive()) mpr("Dead mermaid/siren still mesmerising?", MSGCH_DIAGNOSTICS); else if (mons_genus(mon->type) != MONS_MERMAID) @@ -2843,7 +2843,7 @@ void check_beholders() if (walls > 0) { -#if DEBUG +#ifdef DEBUG mprf(MSGCH_DIAGNOSTICS, "%d walls between mesmerising '%s' " "and player", walls, mon->name(DESC_PLAIN, true).c_str()); #endif @@ -2860,7 +2860,7 @@ void check_beholders() if (you.duration[DUR_MESMERISED] > 0 && you.mesmerised_by.empty()) { -#if DEBUG +#ifdef DEBUG mpr("Mesmerised with no mermaids/sirens left?", MSGCH_DIAGNOSTICS); #endif diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 1efd7f2d49..5fc5a51949 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -1427,7 +1427,7 @@ void mons_make_god_gift(monsters *mon, god_type god) mon->god = god; -#if DEBUG +#ifdef DEBUG if (mon->flags & MF_GOD_GIFT) mprf(MSGCH_DIAGNOSTICS, "Monster '%s' is already a gift of god '%s'", mon->name(DESC_PLAIN, true).c_str(), god_name(god).c_str()); diff --git a/crawl-ref/source/spl-util.cc b/crawl-ref/source/spl-util.cc index b727117eb8..c3097b0e53 100644 --- a/crawl-ref/source/spl-util.cc +++ b/crawl-ref/source/spl-util.cc @@ -92,7 +92,7 @@ void init_spell_descs(void) { spell_desc &data = spelldata[i]; -#if DEBUG +#ifdef DEBUG if (data.id < SPELL_NO_SPELL || data.id >= NUM_SPELLS) end(1, false, "spell #%d has invalid id %d", i, data.id); diff --git a/crawl-ref/source/store.cc b/crawl-ref/source/store.cc index 7ace5e40d9..8d74d75cca 100644 --- a/crawl-ref/source/store.cc +++ b/crawl-ref/source/store.cc @@ -518,7 +518,7 @@ CrawlHashTable &CrawlStoreValue::new_table(store_flags _flags) CrawlHashTable &CrawlStoreValue::new_table(store_val_type _type, store_flags _flags) { -#if DEBUG +#ifdef DEBUG CrawlHashTable* old_table = static_cast(val.ptr); ASSERT(flags & SFLAG_UNSET); @@ -553,7 +553,7 @@ CrawlVector &CrawlStoreValue::new_vector(store_val_type _type, store_flags _flags, vec_size _max_size) { -#if DEBUG +#ifdef DEBUG CrawlVector* old_vector = static_cast(val.ptr); ASSERT(flags & SFLAG_UNSET); @@ -1139,7 +1139,7 @@ bool CrawlHashTable::exists(const std::string &key) const void CrawlHashTable::assert_validity() const { -#if DEBUG +#ifdef DEBUG ASSERT(!(default_flags & SFLAG_UNSET)); hash_map_type::const_iterator i = hash_map.begin(); @@ -1255,7 +1255,7 @@ void CrawlHashTable::erase(const std::string key) if (i != hash_map.end()) { -#if DEBUG +#ifdef DEBUG CrawlStoreValue &val = i->second; ASSERT(!(val.flags & SFLAG_NO_ERASE)); #endif @@ -1422,7 +1422,7 @@ store_val_type CrawlVector::get_type() const void CrawlVector::assert_validity() const { -#if DEBUG +#ifdef DEBUG ASSERT(!(default_flags & SFLAG_UNSET)); ASSERT(max_size > 0); ASSERT(max_size >= size()); diff --git a/crawl-ref/source/stuff.h b/crawl-ref/source/stuff.h index 84554a47af..0591c07688 100644 --- a/crawl-ref/source/stuff.h +++ b/crawl-ref/source/stuff.h @@ -230,7 +230,7 @@ int choose_random_weighted(Iterator beg, const Iterator end) { ASSERT(beg < end); -#if DEBUG +#ifdef DEBUG int times_set = 0; #endif @@ -242,14 +242,14 @@ int choose_random_weighted(Iterator beg, const Iterator end) if (random2(totalweight) < *beg) { result = count; -#if DEBUG +#ifdef DEBUG times_set++; #endif } ++count; ++beg; } -#if DEBUG +#ifdef DEBUG ASSERT(times_set > 0); #endif return result; diff --git a/crawl-ref/source/tilebuf.cc b/crawl-ref/source/tilebuf.cc index 2699502717..f27671a517 100644 --- a/crawl-ref/source/tilebuf.cc +++ b/crawl-ref/source/tilebuf.cc @@ -27,7 +27,7 @@ VColour VColour::transparent(0, 0, 0, 0); ///////////////////////////////////////////////////////////////////////////// // VertBuffer -#if DEBUG +#ifdef DEBUG static bool _valid(int num_verts, int prim) { switch (prim) -- cgit v1.2.3-54-g00ecf