summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorpauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-02 05:14:31 +0000
committerpauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-02 05:14:31 +0000
commit9ddee55cb06790b2d7ddf07666390614c92bc71d (patch)
tree93b4528b40167b3aeed13ee210e65b5637a3007a /crawl-ref
parent26302842887cde2a029061396d4f9a4df9e312ce (diff)
downloadcrawl-ref-9ddee55cb06790b2d7ddf07666390614c92bc71d.tar.gz
crawl-ref-9ddee55cb06790b2d7ddf07666390614c92bc71d.zip
Fix [ 1902141 ] Documentation wrong
- changed number comments on a few enums - added a few COMPILE_CHECKs so they'll get caught Other: - Fix COMPILE_CHECK macro so it doesn't cause a warning in gcc. - Replace ASSERT(...) with COMPILE_CHECK(...) where possible. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3501 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/acr.cc20
-rw-r--r--crawl-ref/source/debug.h4
-rw-r--r--crawl-ref/source/enum.h74
-rw-r--r--crawl-ref/source/item_use.cc2
-rw-r--r--crawl-ref/source/itemname.cc6
-rw-r--r--crawl-ref/source/luadgn.cc4
-rw-r--r--crawl-ref/source/mon-util.cc11
-rw-r--r--crawl-ref/source/mutation.cc3
-rw-r--r--crawl-ref/source/newgame.cc4
-rw-r--r--crawl-ref/source/religion.cc4
10 files changed, 78 insertions, 54 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 4023971c9a..d3c9e1bf70 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -189,6 +189,8 @@ static void startup_tutorial();
static void read_messages();
#endif
+static void compile_time_asserts();
+
/*
It all starts here. Some initialisations are run first, then straight to
new_game and then input.
@@ -199,6 +201,7 @@ int old_main( int argc, char *argv[] )
int main( int argc, char *argv[] )
#endif
{
+ compile_time_asserts(); // just to quiet "unused static function" warning
// Load in the system environment variables
get_system_environment();
@@ -4360,3 +4363,20 @@ static void update_replay_state()
if (!is_processing_macro())
repeat_again_rec.clear();
}
+
+
+void compile_time_asserts()
+{
+ // Check that the numbering comments in enum.h haven't been
+ // disturbed accidentally.
+ COMPILE_CHECK(SK_UNARMED_COMBAT == 19 , c1);
+ COMPILE_CHECK(SK_EVOCATIONS == 39 , c2);
+ COMPILE_CHECK(SP_MERFOLK == 35 , c3);
+ COMPILE_CHECK(SPELL_BOLT_OF_MAGMA == 18 , c4);
+ COMPILE_CHECK(SPELL_POISON_ARROW == 94 , c5);
+ COMPILE_CHECK(SPELL_SUMMON_MUSHROOMS == 221 , c6);
+
+ //jmf: NEW ASSERTS: we ought to do a *lot* of these
+ COMPILE_CHECK(NUM_SPELLS < SPELL_NO_SPELL , c7);
+ COMPILE_CHECK(NUM_JOBS < JOB_UNKNOWN , c8);
+}
diff --git a/crawl-ref/source/debug.h b/crawl-ref/source/debug.h
index a051922bb7..631113a4c0 100644
--- a/crawl-ref/source/debug.h
+++ b/crawl-ref/source/debug.h
@@ -36,9 +36,9 @@
#ifndef _lint
-#define COMPILE_CHECK(p) {struct _CC {char a[(p) ? 1 : -1];};} 0
+#define COMPILE_CHECK(expr, tag) typedef char compile_check_ ## tag[(expr) ? 1 : -1]
#else
-#define COMPILE_CHECK(p)
+#define COMPILE_CHECK(expr, tag)
#endif
#if DEBUG
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index 4b003358e2..b68dde3cfe 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -1508,6 +1508,14 @@ enum monster_type // (int) menv[].type
MONS_BLUE_DEVIL,
MONS_BEAST,
MONS_IRON_DEVIL, // 89
+ // 90
+ //
+ //
+ //
+ //
+ // 95
+ //
+ //
MONS_GLOWING_SHAPESHIFTER = 98, // 98
MONS_SHAPESHIFTER,
MONS_GIANT_MITE, // 100
@@ -1585,15 +1593,15 @@ enum monster_type // (int) menv[].type
MONS_SWAMP_DRAKE,
MONS_DEATH_DRAKE,
MONS_SOLDIER_ANT,
- MONS_HILL_GIANT,
- MONS_QUEEN_ANT, // 175
+ MONS_HILL_GIANT, // 175
+ MONS_QUEEN_ANT,
MONS_ANT_LARVA,
MONS_GIANT_FROG,
MONS_GIANT_BROWN_FROG,
- MONS_SPINY_FROG,
- MONS_BLINK_FROG, // 180
+ MONS_SPINY_FROG, // 180
+ MONS_BLINK_FROG,
MONS_GIANT_COCKROACH,
- MONS_SMALL_SNAKE, // 182
+ MONS_SMALL_SNAKE,
//jmf: new monsters
MONS_SHUGGOTH, //jmf: added for evil spells
MONS_WOLF, //jmf: added
@@ -1601,11 +1609,11 @@ enum monster_type // (int) menv[].type
MONS_BEAR, //jmf: added bears!
MONS_GRIZZLY_BEAR,
MONS_POLAR_BEAR,
- MONS_BLACK_BEAR, // 189
+ MONS_BLACK_BEAR, // 190
MONS_SIMULACRUM_SMALL,
MONS_SIMULACRUM_LARGE,
MONS_MERFOLK,
- MONS_MERMAID, // 193
+ MONS_MERMAID, // 194
//jmf: end new monsters
MONS_WHITE_IMP = 220, // 220
MONS_LEMURE,
@@ -1706,26 +1714,26 @@ enum monster_type // (int) menv[].type
// mon-util.cc.
MONS_BLACK_DRACONIAN, // Should always be first colour.
MONS_MOTTLED_DRACONIAN,
- MONS_YELLOW_DRACONIAN,
- MONS_GREEN_DRACONIAN, // 315
+ MONS_YELLOW_DRACONIAN, // 315
+ MONS_GREEN_DRACONIAN,
MONS_PURPLE_DRACONIAN,
MONS_RED_DRACONIAN,
MONS_WHITE_DRACONIAN,
- MONS_PALE_DRACONIAN, // Should always be last colour.
+ MONS_PALE_DRACONIAN, // 320 Should always be last colour.
// Sync up with monplace.cc's draconian selection if adding more.
MONS_DRACONIAN_CALLER,
MONS_DRACONIAN_MONK,
MONS_DRACONIAN_ZEALOT,
MONS_DRACONIAN_SHIFTER,
- MONS_DRACONIAN_ANNIHILATOR,
- MONS_DRACONIAN_KNIGHT, // 325
+ MONS_DRACONIAN_ANNIHILATOR, // 325
+ MONS_DRACONIAN_KNIGHT,
MONS_DRACONIAN_SCORCHER,
MONS_MURRAY,
MONS_TIAMAT,
- MONS_DEEP_ELF_BLADEMASTER,
+ MONS_DEEP_ELF_BLADEMASTER, // 330
MONS_DEEP_ELF_MASTER_ARCHER,
// The Lords of Hell:
@@ -1758,11 +1766,11 @@ enum monster_type // (int) menv[].type
MONS_YAKTAUR_CAPTAIN,
MONS_KILLER_KLOWN,
MONS_ELECTRIC_GOLEM, // replacing the guardian robot -- bwr
- MONS_BALL_LIGHTNING, // replacing the dorgi -- bwr
+ MONS_BALL_LIGHTNING, // replacing the dorgi -- bwr 380
MONS_ORB_OF_FIRE, // Swords renamed to fit -- bwr
MONS_QUOKKA, // Quokka are a type of wallaby, returned -- bwr 382
-
-
+ // 383
+ // 384
MONS_EYE_OF_DEVASTATION = 385, // 385
MONS_MOTH_OF_WRATH,
MONS_DEATH_COB,
@@ -2311,38 +2319,38 @@ enum species_type
SP_HUMAN = 1, // 1
SP_HIGH_ELF,
SP_GREY_ELF,
- SP_DEEP_ELF, // 5
- SP_SLUDGE_ELF,
+ SP_DEEP_ELF,
+ SP_SLUDGE_ELF, // 5
SP_MOUNTAIN_DWARF,
SP_HALFLING,
- SP_HILL_ORC, // 10
+ SP_HILL_ORC,
SP_KOBOLD,
- SP_MUMMY,
+ SP_MUMMY, // 10
SP_NAGA,
SP_GNOME,
- SP_OGRE, // 15
+ SP_OGRE,
SP_TROLL,
SP_OGRE_MAGE,
SP_RED_DRACONIAN,
SP_WHITE_DRACONIAN,
- SP_GREEN_DRACONIAN, // 20
+ SP_GREEN_DRACONIAN,
SP_GOLDEN_DRACONIAN,
- SP_GREY_DRACONIAN,
+ SP_GREY_DRACONIAN, // 20
SP_BLACK_DRACONIAN,
SP_PURPLE_DRACONIAN,
- SP_MOTTLED_DRACONIAN, // 25
+ SP_MOTTLED_DRACONIAN,
SP_PALE_DRACONIAN,
SP_UNK0_DRACONIAN,
SP_UNK1_DRACONIAN,
SP_BASE_DRACONIAN,
- SP_CENTAUR, // 30
+ SP_CENTAUR,
SP_DEMIGOD,
- SP_SPRIGGAN,
+ SP_SPRIGGAN, // 30
SP_MINOTAUR,
SP_DEMONSPAWN,
- SP_GHOUL, // 35
+ SP_GHOUL,
SP_KENKU,
- SP_MERFOLK,
+ SP_MERFOLK, // 35
SP_VAMPIRE,
SP_ELF, // (placeholder)
SP_HILL_DWARF, // (placeholder)
@@ -2372,6 +2380,7 @@ enum spell_type
SPELL_BOLT_OF_COLD,
SPELL_LIGHTNING_BOLT,
SPELL_BOLT_OF_MAGMA, // 18
+ // 19
SPELL_POLYMORPH_OTHER = 20, // 20
SPELL_SLOW,
SPELL_HASTE,
@@ -2447,6 +2456,7 @@ enum spell_type
SPELL_ABJURATION_II,
SPELL_FULSOME_DISTILLATION, // 93
SPELL_POISON_ARROW, // 94
+
SPELL_TWISTED_RESURRECTION = 110, // 110
SPELL_REGENERATION,
SPELL_BONE_SHARDS,
@@ -2528,17 +2538,17 @@ enum spell_type
SPELL_BEND,
SPELL_BACKLIGHT,
SPELL_INTOXICATE, // confusion but only "smart" creatures
- SPELL_EVAPORATE, // turn a potion into a cloud
+ SPELL_EVAPORATE, // turn a potion into a cloud 190
SPELL_ERINGYAS_SURPRISING_BOUQUET, // turn sticks into herbivore food
SPELL_FRAGMENTATION, // replacement for "orb of frag"
SPELL_AIR_WALK, // "dematerialize" (air/transmigration)
- SPELL_SANDBLAST, // mini-frag; can use stones for material comp 195
+ SPELL_SANDBLAST, // mini-frag; can use stones for material comp
SPELL_ROTTING, // evil god power or necromantic transmigration
SPELL_MAXWELLS_SILVER_HAMMER, // vorpal-brand maces etc.
SPELL_CONDENSATION_SHIELD, // "shield" of icy vapour
SPELL_SEMI_CONTROLLED_BLINK, //jmf: to test effect
- SPELL_STONESKIN, // 200
- SPELL_SIMULACRUM,
+ SPELL_STONESKIN,
+ SPELL_SIMULACRUM, // 200
SPELL_CONJURE_BALL_LIGHTNING,
SPELL_CHAIN_LIGHTNING,
SPELL_EXCRUCIATING_WOUNDS,
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 55c97c9a37..2e2628a836 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -3653,7 +3653,7 @@ bool drink_fountain()
20, 20,
4, 4, 4 };
- ASSERT( ARRAYSIZE(weights) == ARRAYSIZE(effects) );
+ COMPILE_CHECK( ARRAYSIZE(weights) == ARRAYSIZE(effects), c1 );
fountain_effect =
effects[choose_random_weighted(weights,
weights + ARRAYSIZE(weights))];
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index 74b30e88d2..2696f6e5b9 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -1294,16 +1294,14 @@ std::string item_def::name_aux( description_level_type desc,
"smoky ", "glowing ", "sedimented ", "metallic ", "murky ",
"gluggy ", "oily ", "slimy ", "emulsified "
};
- ASSERT( sizeof(potion_qualifiers) / sizeof(*potion_qualifiers)
- == PDQ_NQUALS );
+ COMPILE_CHECK( ARRAYSIZE(potion_qualifiers) == PDQ_NQUALS, c1 );
static const char *potion_colours[] = {
"clear", "blue", "black", "silvery", "cyan", "purple",
"orange", "inky", "red", "yellow", "green", "brown", "pink",
"white"
};
- ASSERT( sizeof(potion_colours) / sizeof(*potion_colours)
- == PDC_NCOLOURS );
+ COMPILE_CHECK( ARRAYSIZE(potion_colours) == PDC_NCOLOURS, c1 );
const char *qualifier =
(pqual < 0 || pqual >= PDQ_NQUALS)? "bug-filled "
diff --git a/crawl-ref/source/luadgn.cc b/crawl-ref/source/luadgn.cc
index 3e41a0b07c..7cff5edd3d 100644
--- a/crawl-ref/source/luadgn.cc
+++ b/crawl-ref/source/luadgn.cc
@@ -1112,7 +1112,7 @@ const char *dngn_feature_names[] =
dungeon_feature_type dungeon_feature_by_name(const std::string &name)
{
- ASSERT(ARRAYSIZE(dngn_feature_names) == NUM_REAL_FEATURES);
+ COMPILE_CHECK(ARRAYSIZE(dngn_feature_names) == NUM_REAL_FEATURES, c1);
if (name.empty())
return (DNGN_UNSEEN);
@@ -1127,7 +1127,7 @@ std::vector<std::string> dungeon_feature_matches(const std::string &name)
{
std::vector<std::string> matches;
- ASSERT(ARRAYSIZE(dngn_feature_names) == NUM_REAL_FEATURES);
+ COMPILE_CHECK(ARRAYSIZE(dngn_feature_names) == NUM_REAL_FEATURES, c1);
if (name.empty())
return (matches);
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 6a85bd55cb..95f0d98b83 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -1496,8 +1496,8 @@ static const char *drac_colour_names[] = {
std::string draconian_colour_name(monster_type mtype)
{
- ASSERT(ARRAYSIZE(drac_colour_names) ==
- MONS_PALE_DRACONIAN - MONS_DRACONIAN);
+ COMPILE_CHECK(ARRAYSIZE(drac_colour_names) ==
+ MONS_PALE_DRACONIAN - MONS_DRACONIAN, c1);
if (mtype < MONS_BLACK_DRACONIAN || mtype > MONS_PALE_DRACONIAN)
return "buggy";
return (drac_colour_names[mtype - MONS_BLACK_DRACONIAN]);
@@ -1505,8 +1505,8 @@ std::string draconian_colour_name(monster_type mtype)
monster_type draconian_colour_by_name(const std::string &name)
{
- ASSERT(ARRAYSIZE(drac_colour_names) ==
- MONS_PALE_DRACONIAN - MONS_DRACONIAN);
+ COMPILE_CHECK(ARRAYSIZE(drac_colour_names) ==
+ MONS_PALE_DRACONIAN - MONS_DRACONIAN, c1);
for (unsigned i = 0; i < ARRAYSIZE(drac_colour_names); ++i)
if (name == drac_colour_names[i])
return static_cast<monster_type>(i + MONS_BLACK_DRACONIAN);
@@ -5201,8 +5201,7 @@ static const char *enchant_names[] =
const char *mons_enchantment_name(enchant_type ench)
{
- ASSERT(NUM_ENCHANTMENTS ==
- (sizeof(enchant_names) / sizeof(*enchant_names)) - 1);
+ COMPILE_CHECK(ARRAYSIZE(enchant_names) == NUM_ENCHANTMENTS+1, c1);
if (ench > NUM_ENCHANTMENTS)
ench = NUM_ENCHANTMENTS;
diff --git a/crawl-ref/source/mutation.cc b/crawl-ref/source/mutation.cc
index 51324a8a83..35f3c22a78 100644
--- a/crawl-ref/source/mutation.cc
+++ b/crawl-ref/source/mutation.cc
@@ -990,10 +990,11 @@ static mutation_def mutation_defs[] = {
{ MUT_PATTERNED_SCALES, 1, 3, false }
};
+COMPILE_CHECK(ARRAYSIZE(mutation_defs) == NUM_MUTATIONS, c1);
+
#ifdef DEBUG_DIAGNOSTICS
void sanity_check_mutation_defs()
{
- ASSERT(ARRAYSIZE(mutation_defs) == NUM_MUTATIONS);
for (unsigned i = 0; i < ARRAYSIZE(mutation_defs); ++i)
{
diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc
index cbb8f70a2c..89e722f486 100644
--- a/crawl-ref/source/newgame.cc
+++ b/crawl-ref/source/newgame.cc
@@ -728,10 +728,6 @@ static void give_species_bonus_mp()
bool new_game(void)
{
- //jmf: NEW ASSERTS: we ought to do a *lot* of these
- ASSERT(NUM_SPELLS < SPELL_NO_SPELL);
- ASSERT(NUM_JOBS < JOB_UNKNOWN);
-
init_player();
if (!crawl_state.startup_errors.empty()
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index b2c7dba780..2672d6a23d 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -1665,14 +1665,14 @@ bool did_god_conduct( conduct_type thing_done, int level, bool known,
"Kill Living", "Kill Undead", "Kill Demon", "Kill Natural Evil",
"Kill Mutator Or Rotter", "Kill Wizard", "Kill Priest",
"Kill Angel", "Kill Neutral", "Undead Slave Kill Living",
- "Servant Kill Living", "Servant Kill Undead", "Servant Kill Demon",
+ "Servant Kill Living", "Servant Kill Undead", "Servant Kill Demon",
"Servant Kill Natural Evil", "Servant Kill Angel",
"Spell Memorise", "Spell Cast", "Spell Practise", "Spell Nonutility",
"Cards", "Stimulants", "Drink Blood", "Cannibalism", "Eat Meat",
"Eat Souled Beings", "Create Life", "Deliberate Mutation"
};
- ASSERT(ARRAYSIZE(conducts) == NUM_CONDUCTS);
+ COMPILE_CHECK(ARRAYSIZE(conducts) == NUM_CONDUCTS, c1);
mprf( MSGCH_DIAGNOSTICS,
"conduct: %s; piety: %d (%+d); penance: %d (%+d)",
conducts[thing_done],