summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-05-01 14:47:53 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-05-01 14:47:53 +0000
commit106fb6de1cf3523c10197dc8e02ec44e94523f18 (patch)
treebe6eba2338470be1467fc89131f20d80878a4906 /crawl-ref/source
parent83043ea070b1f45c5cad9c7ad1f1844a01079809 (diff)
downloadcrawl-ref-106fb6de1cf3523c10197dc8e02ec44e94523f18.tar.gz
crawl-ref-106fb6de1cf3523c10197dc8e02ec44e94523f18.zip
Type safety, cast cleanups, etc.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1401 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/abl-show.cc19
-rw-r--r--crawl-ref/source/beam.cc47
-rw-r--r--crawl-ref/source/chardump.cc16
-rw-r--r--crawl-ref/source/cloud.cc20
-rw-r--r--crawl-ref/source/cloud.h8
-rw-r--r--crawl-ref/source/command.cc8
-rw-r--r--crawl-ref/source/debug.cc2
-rw-r--r--crawl-ref/source/decks.cc75
-rw-r--r--crawl-ref/source/decks.h3
-rw-r--r--crawl-ref/source/describe.cc3
-rw-r--r--crawl-ref/source/dungeon.cc4
-rw-r--r--crawl-ref/source/externs.h6
-rw-r--r--crawl-ref/source/files.cc6
-rw-r--r--crawl-ref/source/hiscores.cc5
-rw-r--r--crawl-ref/source/initfile.cc4
-rw-r--r--crawl-ref/source/invent.cc13
-rw-r--r--crawl-ref/source/it_use3.cc3
-rw-r--r--crawl-ref/source/items.cc12
-rw-r--r--crawl-ref/source/makeitem.cc7
-rw-r--r--crawl-ref/source/mapdef.cc4
-rw-r--r--crawl-ref/source/menu.cc2
-rw-r--r--crawl-ref/source/misc.cc6
-rw-r--r--crawl-ref/source/mon-util.cc2
-rw-r--r--crawl-ref/source/monstuff.cc8
-rw-r--r--crawl-ref/source/mstuff2.cc4
-rw-r--r--crawl-ref/source/newgame.cc2
-rw-r--r--crawl-ref/source/notes.cc5
-rw-r--r--crawl-ref/source/religion.cc8
-rw-r--r--crawl-ref/source/spells1.cc6
-rw-r--r--crawl-ref/source/spells1.h4
-rw-r--r--crawl-ref/source/spells3.cc6
-rw-r--r--crawl-ref/source/spells4.cc9
-rw-r--r--crawl-ref/source/spells4.h3
-rw-r--r--crawl-ref/source/spl-cast.cc6
-rw-r--r--crawl-ref/source/spl-util.cc17
-rw-r--r--crawl-ref/source/spl-util.h4
-rw-r--r--crawl-ref/source/stash.h4
-rw-r--r--crawl-ref/source/stuff.cc4
-rw-r--r--crawl-ref/source/tags.cc2
-rw-r--r--crawl-ref/source/travel.cc4
-rw-r--r--crawl-ref/source/view.cc10
41 files changed, 196 insertions, 185 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc
index c0650fd859..ea7e619a8d 100644
--- a/crawl-ref/source/abl-show.cc
+++ b/crawl-ref/source/abl-show.cc
@@ -435,15 +435,12 @@ bool activate_ability(void)
/*************************/
{
unsigned char keyin = 0;
- unsigned char spc, spc2;
int power;
struct dist abild;
struct bolt beam;
struct dist spd;
- unsigned char abil_used;
-
if (you.berserker)
{
canned_msg(MSG_TOO_BERSERK);
@@ -505,24 +502,20 @@ bool activate_ability(void)
}
}
- spc = (int) keyin;
-
- if (!isalpha( spc ))
+ if (!isalpha( keyin ))
{
mpr("You can't do that.");
return (false);
}
- spc2 = letter_to_index(spc);
+ const int abil_used = letter_to_index(keyin);
- if (Curr_abil[spc2].which == -1)
+ if (Curr_abil[abil_used].which == -1)
{
mpr("You can't do that.");
return (false);
}
- abil_used = spc2;
-
// some abilities don't need a hunger check
bool hungerCheck = true;
switch (Curr_abil[abil_used].which)
@@ -1609,7 +1602,7 @@ bool generate_abilities( bool check_confused )
{
if ( you.piety >= piety_breakpoint(i) )
{
- ability_type abil = god_abilities[(int)you.religion][i];
+ ability_type abil = god_abilities[you.religion][i];
if ( abil != ABIL_NON_ABILITY )
insert_ability(abil, check_confused);
}
@@ -1752,9 +1745,9 @@ void set_god_ability_slots( void )
int num = 0;
for ( i = 0; i < MAX_GOD_ABILITIES; ++i )
{
- if ( god_abilities[(int)you.religion][i] != ABIL_NON_ABILITY )
+ if ( god_abilities[you.religion][i] != ABIL_NON_ABILITY )
{
- set_god_ability_helper(god_abilities[(int)you.religion][i],
+ set_god_ability_helper(god_abilities[you.religion][i],
(Options.lowercase_invocations ? 'a' : 'A') + num);
++num;
}
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index f3d16f8c68..32d73c56bc 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -2195,7 +2195,7 @@ static bool isBouncy(struct bolt &beam, unsigned char gridtype)
static void beam_explodes(struct bolt &beam, int x, int y)
{
- int cloud_type;
+ cloud_type cl_type;
// this will be the last thing this beam does.. set target_x
// and target_y to hold explosion co'ords.
@@ -2272,8 +2272,8 @@ static void beam_explodes(struct bolt &beam, int x, int y)
// cloud producer -- FOUL VAPOR (SWAMP DRAKE?)
if (beam.name == "foul vapour")
{
- cloud_type = beam.flavour == BEAM_MIASMA? CLOUD_MIASMA : CLOUD_STINK;
- big_cloud( cloud_type, whose_kill(beam), x, y, 0, 9 );
+ cl_type = beam.flavour == BEAM_MIASMA? CLOUD_MIASMA : CLOUD_STINK;
+ big_cloud( cl_type, whose_kill(beam), x, y, 0, 9 );
return;
}
@@ -2630,7 +2630,8 @@ static int affect_place_clouds(struct bolt &beam, int x, int y)
{
// polymorph randomly changes clouds in its path
if (beam.flavour == BEAM_POLYMORPH)
- env.cloud[ env.cgrid[x][y] ].type = 1 + random2(8);
+ env.cloud[ env.cgrid[x][y] ].type =
+ static_cast<cloud_type>(1 + random2(8));
// now exit (all enchantments)
if (beam.name[0] == '0')
@@ -2709,7 +2710,7 @@ static int affect_place_clouds(struct bolt &beam, int x, int y)
// following two functions used with explosions:
static void affect_place_explosion_clouds(struct bolt &beam, int x, int y)
{
- int cloud_type;
+ cloud_type cl_type;
int duration;
// first check: FIRE/COLD over water/lava
@@ -2729,58 +2730,58 @@ static void affect_place_explosion_clouds(struct bolt &beam, int x, int y)
switch (beam.flavour)
{
case BEAM_POTION_STINKING_CLOUD:
- cloud_type = CLOUD_STINK;
+ cl_type = CLOUD_STINK;
break;
case BEAM_POTION_POISON:
- cloud_type = CLOUD_POISON;
+ cl_type = CLOUD_POISON;
break;
case BEAM_POTION_MIASMA:
- cloud_type = CLOUD_MIASMA;
+ cl_type = CLOUD_MIASMA;
break;
case BEAM_POTION_BLACK_SMOKE:
- cloud_type = CLOUD_BLACK_SMOKE;
+ cl_type = CLOUD_BLACK_SMOKE;
break;
case BEAM_POTION_FIRE:
- cloud_type = CLOUD_FIRE;
+ cl_type = CLOUD_FIRE;
break;
case BEAM_POTION_COLD:
- cloud_type = CLOUD_COLD;
+ cl_type = CLOUD_COLD;
break;
case BEAM_POTION_BLUE_SMOKE:
- cloud_type = CLOUD_BLUE_SMOKE;
+ cl_type = CLOUD_BLUE_SMOKE;
break;
case BEAM_POTION_PURP_SMOKE:
- cloud_type = CLOUD_PURP_SMOKE;
+ cl_type = CLOUD_PURP_SMOKE;
break;
case BEAM_POTION_RANDOM:
switch (random2(10))
{
- case 0: cloud_type = CLOUD_FIRE; break;
- case 1: cloud_type = CLOUD_STINK; break;
- case 2: cloud_type = CLOUD_COLD; break;
- case 3: cloud_type = CLOUD_POISON; break;
- case 4: cloud_type = CLOUD_BLACK_SMOKE; break;
- case 5: cloud_type = CLOUD_BLUE_SMOKE; break;
- case 6: cloud_type = CLOUD_PURP_SMOKE; break;
- default: cloud_type = CLOUD_STEAM; break;
+ case 0: cl_type = CLOUD_FIRE; break;
+ case 1: cl_type = CLOUD_STINK; break;
+ case 2: cl_type = CLOUD_COLD; break;
+ case 3: cl_type = CLOUD_POISON; break;
+ case 4: cl_type = CLOUD_BLACK_SMOKE; break;
+ case 5: cl_type = CLOUD_BLUE_SMOKE; break;
+ case 6: cl_type = CLOUD_PURP_SMOKE; break;
+ default: cl_type = CLOUD_STEAM; break;
}
break;
case BEAM_POTION_STEAM:
default:
- cloud_type = CLOUD_STEAM;
+ cl_type = CLOUD_STEAM;
break;
}
- place_cloud( cloud_type, x, y, duration, whose_kill(beam) );
+ place_cloud( cl_type, x, y, duration, whose_kill(beam) );
}
// then check for more specific explosion cloud types.
diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc
index 2f7793ae84..0458a9a594 100644
--- a/crawl-ref/source/chardump.cc
+++ b/crawl-ref/source/chardump.cc
@@ -269,16 +269,16 @@ std::string munge_description(const std::string & inStr)
outStr.reserve(inStr.length() + 32);
- const long kIndent = 3;
- long lineLen = kIndent;
+ const int kIndent = 3;
+ int lineLen = kIndent;
- long i = 0;
+ unsigned int i = 0;
outStr += std::string(kIndent, ' ');
- while (i < (long) inStr.length())
+ while (i < inStr.length())
{
- char ch = inStr[i];
+ const char ch = inStr[i];
if (ch == '$')
{
@@ -310,8 +310,8 @@ std::string munge_description(const std::string & inStr)
{
std::string word;
- while (i < (long) inStr.length()
- && lineLen + (long) word.length() < 79
+ while (i < inStr.length()
+ && lineLen + word.length() < 79
&& !isspace(inStr[i]) && inStr[i] != '$')
{
word += inStr[i++];
@@ -884,7 +884,7 @@ static void sdump_spells(const std::string &, std::string & text)
for (int i = spell_line.length(); i < 68; i++)
spell_line += ' ';
- itoa((int) spell_difficulty( spell ), tmp_quant, 10 );
+ itoa(spell_difficulty(spell), tmp_quant, 10 );
spell_line += tmp_quant;
spell_line += "\n";
diff --git a/crawl-ref/source/cloud.cc b/crawl-ref/source/cloud.cc
index 8ecfa7b158..1f542523fc 100644
--- a/crawl-ref/source/cloud.cc
+++ b/crawl-ref/source/cloud.cc
@@ -33,7 +33,7 @@ static bool cloud_spreads(const cloud_struct &cloud)
}
}
-static void new_cloud( int cloud, int type, int x, int y, int decay,
+static void new_cloud( int cloud, cloud_type type, int x, int y, int decay,
kill_category whose )
{
ASSERT( env.cloud[ cloud ].type == CLOUD_NONE );
@@ -47,7 +47,7 @@ static void new_cloud( int cloud, int type, int x, int y, int decay,
env.cloud_no++;
}
-static void place_new_cloud(int cltype, int x, int y, int decay,
+static void place_new_cloud(cloud_type cltype, int x, int y, int decay,
kill_category whose)
{
if (env.cloud_no >= MAX_CLOUDS)
@@ -182,7 +182,7 @@ void move_cloud( int cloud, int new_x, int new_y )
// Places a cloud with the given stats assuming one doesn't already
// exist at that point.
-void check_place_cloud( int cl_type, int x, int y, int lifetime,
+void check_place_cloud( cloud_type cl_type, int x, int y, int lifetime,
kill_category whose )
{
if (!in_bounds(x, y) || env.cgrid[x][y] != EMPTY_CLOUD)
@@ -194,7 +194,7 @@ void check_place_cloud( int cl_type, int x, int y, int lifetime,
// Places a cloud with the given stats. May delete old clouds to
// make way if there are too many on level. Will overwrite an old
// cloud under some circumstances.
-void place_cloud(int cl_type, int ctarget_x,
+void place_cloud(cloud_type cl_type, int ctarget_x,
int ctarget_y, int cl_range,
kill_category whose)
{
@@ -273,3 +273,15 @@ bool is_opaque_cloud(unsigned char cloud_idx)
return ( ctype == CLOUD_BLACK_SMOKE ||
(ctype >= CLOUD_GREY_SMOKE && ctype <= CLOUD_STEAM) );
}
+
+cloud_type random_smoke_type()
+{
+ // excludes black (reproducing existing behaviour)
+ switch ( random2(3) )
+ {
+ case 0: return CLOUD_GREY_SMOKE;
+ case 1: return CLOUD_BLUE_SMOKE;
+ case 2: return CLOUD_PURP_SMOKE;
+ }
+ return CLOUD_DEBUGGING;
+}
diff --git a/crawl-ref/source/cloud.h b/crawl-ref/source/cloud.h
index 94b25834c6..e94c7d83b5 100644
--- a/crawl-ref/source/cloud.h
+++ b/crawl-ref/source/cloud.h
@@ -14,13 +14,15 @@
#include "externs.h"
+cloud_type random_smoke_type();
+
void delete_cloud( int cloud );
void move_cloud( int cloud, int new_x, int new_y );
-void check_place_cloud( int cl_type, int x, int y, int lifetime,
+void check_place_cloud( cloud_type cl_type, int x, int y, int lifetime,
kill_category whose );
-void place_cloud(int cl_type, int ctarget_x, int ctarget_y, int cl_range,
- kill_category whose);
+void place_cloud(cloud_type cl_type, int ctarget_x, int ctarget_y,
+ int cl_range, kill_category whose);
void manage_clouds(void);
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc
index 865d1148d1..2fd4f54892 100644
--- a/crawl-ref/source/command.cc
+++ b/crawl-ref/source/command.cc
@@ -215,7 +215,7 @@ static void adjust_spells(void)
return;
}
- int input_1 = (int) keyin;
+ int input_1 = keyin;
if (!isalpha( input_1 ))
{
@@ -265,7 +265,7 @@ static void adjust_spells(void)
return;
}
- int input_2 = (int) keyin;
+ int input_2 = keyin;
if (!isalpha( input_2 ))
{
@@ -335,7 +335,7 @@ static void adjust_ability(void)
return;
}
- int input_1 = (int) keyin;
+ int input_1 = keyin;
if (!isalpha( input_1 ))
{
@@ -384,7 +384,7 @@ static void adjust_ability(void)
return;
}
- int input_2 = (int) keyin;
+ int input_2 = keyin;
if (!isalpha( input_2 ))
{
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index 2af2c160e6..dd93f536d3 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -1463,7 +1463,7 @@ static void fsim_item(FILE *out,
int maxdam, unsigned long time)
{
double hitdam = hits? double(damage) / hits : 0.0;
- int avspeed = (int) (time / iterations);
+ int avspeed = static_cast<int>(time / iterations);
fprintf(out,
" %-5s| %3ld%% | %5.2f | %5.2f |"
" %5.2f | %3d | %2ld\n",
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index 9db98525e2..6cf199ff9a 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -31,14 +31,7 @@
#include "spl-cast.h"
#include "stuff.h"
-// array sizes -- see notes below {dlb}
-#define DECK_WONDERS_SIZE 27
-#define DECK_SUMMONING_SIZE 11
-#define DECK_TRICKS_SIZE 11
-#define DECK_POWER_SIZE 17
-#define DECK_PUNISHMENT_SIZE 23
-
-enum CARDS // (unsigned char) deck_of_foo[]
+enum card_type
{
CARD_BLANK = 0, // 0
CARD_BUTTERFLY,
@@ -99,7 +92,7 @@ enum CARDS // (unsigned char) deck_of_foo[]
CARD_RANDOM = 255 // must remain final member {dlb}
};
-static unsigned char deck_of_wonders[] =
+static card_type deck_of_wonders[] =
{
CARD_BLANK,
CARD_BUTTERFLY,
@@ -130,7 +123,7 @@ static unsigned char deck_of_wonders[] =
CARD_PANDEMONIUM
};
-static unsigned char deck_of_summoning[] =
+static card_type deck_of_summoning[] =
{
CARD_STATUE,
CARD_DEMON_LESSER,
@@ -145,7 +138,7 @@ static unsigned char deck_of_summoning[] =
CARD_HORROR_UNSEEN
};
-static unsigned char deck_of_tricks[] =
+static card_type deck_of_tricks[] =
{
CARD_BLANK,
CARD_BUTTERFLY,
@@ -160,7 +153,7 @@ static unsigned char deck_of_tricks[] =
CARD_HASTEN
};
-static unsigned char deck_of_power[] =
+static card_type deck_of_power[] =
{
CARD_BLANK,
CARD_DEMON_COMMON,
@@ -183,7 +176,7 @@ static unsigned char deck_of_power[] =
// Supposed to be bad, small chance of OK... Nemelex wouldn't like a game
// that didn't have some chance of "losing".
-static unsigned char deck_of_punishment[] =
+static card_type deck_of_punishment[] =
{
CARD_BLANK,
CARD_BUTTERFLY,
@@ -210,22 +203,20 @@ static unsigned char deck_of_punishment[] =
CARD_PANDEMONIUM
};
-static void cards(unsigned char which_card);
+// array sizes -- see notes below {dlb}
+#define ARRAYSIZE(x) (sizeof(x) / sizeof(x[0]))
+#define DECK_WONDERS_SIZE ARRAYSIZE(deck_of_wonders)
+#define DECK_SUMMONING_SIZE ARRAYSIZE(deck_of_summoning)
+#define DECK_TRICKS_SIZE ARRAYSIZE(deck_of_tricks)
+#define DECK_POWER_SIZE ARRAYSIZE(deck_of_power)
+#define DECK_PUNISHMENT_SIZE ARRAYSIZE(deck_of_punishment)
-void deck_of_cards(unsigned char which_deck)
-{
+static void cards(card_type which_card);
- // I really am not fond of how all of this works, the
- // decks ought to be stored (possibly) in an array of
- // pointers to int or as discrete arrays of int using
- // the sizeof operator to determine upper bounds, and
- // not defines, which is a bit clumsy given that you
- // have to update two things presently (the array and
- // the corresponding define) in order to add things to
- // decks ... someone fix this, or I will {dlb}
- unsigned char *card = deck_of_wonders;
- unsigned char max_card = 0;
- int i = 0;
+void deck_of_cards(deck_type which_deck)
+{
+ card_type *deck = deck_of_wonders;
+ int max_card = 0;
int brownie_points = 0; // for passing to did_god_conduct() {dlb}
mpr("You draw a card...");
@@ -233,39 +224,41 @@ void deck_of_cards(unsigned char which_deck)
switch (which_deck)
{
case DECK_OF_WONDERS:
- card = deck_of_wonders;
+ deck = deck_of_wonders;
max_card = DECK_WONDERS_SIZE;
break;
case DECK_OF_SUMMONING:
- card = deck_of_summoning;
+ deck = deck_of_summoning;
max_card = DECK_SUMMONING_SIZE;
break;
case DECK_OF_TRICKS:
- card = deck_of_tricks;
+ deck = deck_of_tricks;
max_card = DECK_TRICKS_SIZE;
break;
case DECK_OF_POWER:
- card = deck_of_power;
+ deck = deck_of_power;
max_card = DECK_POWER_SIZE;
break;
case DECK_OF_PUNISHMENT:
- card = deck_of_punishment;
+ deck = deck_of_punishment;
max_card = DECK_PUNISHMENT_SIZE;
break;
}
- i = (int) card[random2(max_card)];
+ card_type chosen = deck[random2(max_card)];
if (one_chance_in(250))
{
mpr("This card doesn't seem to belong here.");
- i = random2(NUM_CARDS);
+ chosen = static_cast<card_type>(random2(NUM_CARDS));
}
- if (i == CARD_BLANK && you.skills[SK_EVOCATIONS] > random2(30))
- i = (int) card[random2(max_card)];
+ // High Evocations gives you another shot (but not at being punished...)
+ if (which_deck != DECK_OF_PUNISHMENT && chosen == CARD_BLANK &&
+ you.skills[SK_EVOCATIONS] > random2(30))
+ chosen = deck[random2(max_card)];
- cards(i);
+ cards(chosen);
// Decks of punishment aren't objects in the game,
// its just Nemelex's form of punishment -- bwr
@@ -300,7 +293,7 @@ void deck_of_cards(unsigned char which_deck)
return;
} // end deck_of_cards()
-static void cards(unsigned char which_card)
+static void cards(card_type which_card)
{
FixedVector < int, 5 > dvar;
FixedVector < int, 5 > mvar;
@@ -315,7 +308,6 @@ static void cards(unsigned char which_card)
switch (which_card)
{
- default:
case CARD_BLANK:
mpr("It is blank.");
break;
@@ -863,6 +855,11 @@ static void cards(unsigned char which_card)
mpr("You have drawn the Prison!");
entomb();
break;
+
+ case NUM_CARDS:
+ case CARD_RANDOM:
+ mpr("You have drawn a buggy card!");
+ break;
}
return;
diff --git a/crawl-ref/source/decks.h b/crawl-ref/source/decks.h
index 43f41e0395..6124aa14db 100644
--- a/crawl-ref/source/decks.h
+++ b/crawl-ref/source/decks.h
@@ -13,12 +13,13 @@
#ifndef DECKS_H
#define DECKS_H
+#include "enum.h"
// last updated 12may2000 {dlb}
/* ***********************************************************************
* called from: it_use_3 - religion
* *********************************************************************** */
-void deck_of_cards(unsigned char which_deck);
+void deck_of_cards(deck_type which_deck);
#endif
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index acf5dc147d..f7b2e7d8ca 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -3121,7 +3121,8 @@ std::string get_item_description( const item_def &item, bool verbose,
<< "x: " << item.x << " y: " << item.y
<< " link: " << item.link
<< " ident_type: "
- << get_ident_type(item.base_type, item.sub_type)
+ << static_cast<int>(get_ident_type(item.base_type,
+ item.sub_type))
<< "$$";
}
#endif
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 9bdc1021ec..1772b2ce0a 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -1949,7 +1949,7 @@ static int place_monster_vector(std::vector<int> montypes,
int not_used = 0;
for (int i = 0; i < num_to_place; i++)
{
- if (place_monster( not_used, montypes[random2((int)montypes.size())],
+ if (place_monster( not_used, montypes[random2(montypes.size())],
level_number, BEH_SLEEP, MHITNOT,
false, 1, 1, true, PROX_ANYWHERE, 250, 0,
no_monster_zones ))
@@ -3186,7 +3186,7 @@ static void dngn_place_item_explicit(int index, int x, int y,
{
item_list &sitems = place.map.items;
- if (index < 0 || index >= (int) sitems.size())
+ if (index < 0 || index >= static_cast<int>(sitems.size()))
{
// Non-fatal, but we warn even in non-debug mode so there's incentive
// to fix the problem.
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index 3ac39950f6..7eaad6c76a 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -304,8 +304,8 @@ struct ray_def
int quadrant;
int fullray_idx; // for cycling: where did we come from?
- int x() const { return (int)(accx); }
- int y() const { return (int)(accy); }
+ int x() const { return static_cast<int>(accx); }
+ int y() const { return static_cast<int>(accy); }
int advance(); // returns the direction taken (0,1,2)
void advance_and_bounce();
void regress();
@@ -1056,7 +1056,7 @@ struct cloud_struct
{
int x;
int y;
- int type;
+ cloud_type type;
int decay;
kill_category whose;
};
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index a778ca42fa..26f716d6ac 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -129,7 +129,7 @@ static std::string uid_as_string()
{
#ifdef MULTIUSER
char struid[20];
- snprintf( struid, sizeof struid, "-%d", (int)getuid() );
+ snprintf( struid, sizeof struid, "-%d", static_cast<int>(getuid()) );
return std::string(struid);
#else
return std::string();
@@ -1532,8 +1532,8 @@ void writeShort(FILE *file, short s)
{
char data[2];
// High byte first - network order
- data[0] = (char)((s >> 8) & 0xFF);
- data[1] = (char)(s & 0xFF);
+ data[0] = static_cast<char>((s >> 8) & 0xFF);
+ data[1] = static_cast<char>(s & 0xFF);
write2(file, data, sizeof(data));
}
diff --git a/crawl-ref/source/hiscores.cc b/crawl-ref/source/hiscores.cc
index 47b1f9d68b..db78f5d592 100644
--- a/crawl-ref/source/hiscores.cc
+++ b/crawl-ref/source/hiscores.cc
@@ -414,7 +414,8 @@ static void hs_nextstring(const char *&inbuf, char *dest, size_t destsize)
if (*inbuf == ':')
inbuf++;
- while (*inbuf && *inbuf != ':' && (p - dest) < (int) destsize - 1)
+ while (*inbuf && *inbuf != ':' &&
+ (p - dest) < static_cast<int>(destsize) - 1)
*p++ = *inbuf++;
// If we ran out of buffer, discard the rest of the field.
@@ -1051,7 +1052,7 @@ void scorefile_entry::init()
name = you.your_name;
#ifdef MULTIUSER
- uid = (int) getuid();
+ uid = static_cast<int>(getuid());
#else
uid = 0;
#endif
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index 1502266f0b..a41adc1d74 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -115,7 +115,7 @@ int str_to_colour( const std::string &str, int default_colour )
// Check if we have a direct colour index
const char *s = str.c_str();
char *es = NULL;
- int ci = (int) strtol(s, &es, 10);
+ const int ci = static_cast<int>(strtol(s, &es, 10));
if (s != (const char *) es && es && ci >= 0 && ci < 16)
ret = ci;
}
@@ -1786,7 +1786,7 @@ void game_options::read_option_line(const std::string &str, bool runscript)
// We shouldn't bother to allocate this a second time
// if the user puts two crawl_dir lines in the init file.
if (!SysEnv.crawl_dir)
- SysEnv.crawl_dir = (char *) calloc(kPathLen, sizeof(char));
+ SysEnv.crawl_dir = (char*)calloc(kPathLen, sizeof(char));
if (SysEnv.crawl_dir)
{
diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc
index 5096365115..a570e9e625 100644
--- a/crawl-ref/source/invent.cc
+++ b/crawl-ref/source/invent.cc
@@ -722,15 +722,13 @@ std::vector<SelItem> prompt_invent_items(
static int digit_to_index( char digit, operation_types oper ) {
- int i;
- unsigned int j;
- char iletter = (char)(oper);
+ const char iletter = static_cast<char>(oper);
- for ( i = 0; i < ENDOFPACK; ++i ) {
+ for ( int i = 0; i < ENDOFPACK; ++i ) {
if (is_valid_item(you.inv[i])) {
const std::string& r(you.inv[i].inscription);
/* note that r.size() is unsigned */
- for ( j = 0; j + 2 < r.size(); ++j ) {
+ for ( unsigned int j = 0; j + 2 < r.size(); ++j ) {
if ( r[j] == '@' &&
(r[j+1] == iletter || r[j+1] == '*') &&
r[j+2] == digit ) {
@@ -745,11 +743,10 @@ static int digit_to_index( char digit, operation_types oper ) {
static bool has_warning_inscription(const item_def& item,
operation_types oper)
{
- char iletter = (char)(oper);
- unsigned int i;
+ const char iletter = static_cast<char>(oper);
const std::string& r(item.inscription);
- for ( i = 0; i + 1 < r.size(); ++i )
+ for ( unsigned int i = 0; i + 1 < r.size(); ++i )
if (r[i] == '!' && (r[i+1] == iletter || r[i+1] == '*'))
return true;
return false;
diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc
index 3ced683d07..3b936bedda 100644
--- a/crawl-ref/source/it_use3.cc
+++ b/crawl-ref/source/it_use3.cc
@@ -22,6 +22,7 @@
#include "externs.h"
#include "beam.h"
+#include "cloud.h"
#include "decks.h"
#include "direct.h"
#include "effects.h"
@@ -849,7 +850,7 @@ void tome_of_power(char sc_read_2)
case 8:
case 9:
mpr("A cloud of weird smoke pours from the book's pages!");
- big_cloud( CLOUD_GREY_SMOKE + random2(3), KC_YOU,
+ big_cloud( random_smoke_type(), KC_YOU,
you.x_pos, you.y_pos, 20, 10 + random2(8) );
return;
case 1:
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index 2922877e12..1d9075b82c 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -1507,10 +1507,10 @@ int move_item_to_player( int obj, int quant_got, bool quiet )
// multiply both constants * 10
- if ((int) you.burden + imass > carrying_capacity())
+ if (you.burden + imass > carrying_capacity())
{
// calculate quantity we can actually pick up
- int part = (carrying_capacity() - (int)you.burden) / unit_mass;
+ int part = (carrying_capacity() - you.burden) / unit_mass;
if (part < 1)
return (0);
@@ -2010,7 +2010,7 @@ void update_corpses(double elapsedTime)
if (elapsedTime <= 0.0)
return;
- const long rot_time = (long) (elapsedTime / 20.0);
+ const long rot_time = static_cast<long>(elapsedTime / 20.0);
for (int c = 0; c < MAX_ITEMS; c++)
{
@@ -2063,8 +2063,8 @@ void update_corpses(double elapsedTime)
}
}
- int fountain_checks = (int)(elapsedTime / 1000.0);
- if (random2(1000) < (int)(elapsedTime) % 1000)
+ int fountain_checks = static_cast<int>(elapsedTime / 1000.0);
+ if (random2(1000) < static_cast<int>(elapsedTime) % 1000)
fountain_checks += 1;
// dry fountains may start flowing again
@@ -2101,7 +2101,7 @@ void update_corpses(double elapsedTime)
void update_level( double elapsedTime )
{
int m, i;
- int turns = (int) (elapsedTime / 10.0);
+ const int turns = static_cast<int>(elapsedTime / 10.0);
#if DEBUG_DIAGNOSTICS
int mons_total = 0;
diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc
index 05ff224432..0e790622f9 100644
--- a/crawl-ref/source/makeitem.cc
+++ b/crawl-ref/source/makeitem.cc
@@ -846,7 +846,6 @@ int items( int allow_uniques, // not just true-false,
{
int temp_rand = 0; // probability determination {dlb}
int range_charges = 0; // for OBJ_WANDS charge count {dlb}
- int temp_value = 0; // temporary value storage {dlb}
int loopy = 0; // just another loop variable {dlb}
int count = 0; // just another loop variable {dlb}
@@ -956,11 +955,11 @@ int items( int allow_uniques, // not just true-false,
// pick a weapon based on rarity
for (;;)
{
- temp_value = (unsigned char) random2(NUM_WEAPONS);
+ const int wpntype = random2(NUM_WEAPONS);
- if (weapon_rarity(temp_value) >= random2(10) + 1)
+ if (weapon_rarity(wpntype) >= random2(10) + 1)
{
- mitm[p].sub_type = temp_value;
+ mitm[p].sub_type = static_cast<unsigned char>(wpntype);
break;
}
}
diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc
index 4ef6f3217a..3cf3ad9b41 100644
--- a/crawl-ref/source/mapdef.cc
+++ b/crawl-ref/source/mapdef.cc
@@ -222,7 +222,7 @@ const std::vector<std::string> &map_lines::get_lines() const
void map_lines::add_line(const std::string &s)
{
lines.push_back(s);
- if ((int) s.length() > map_width)
+ if (static_cast<int>(s.length()) > map_width)
map_width = s.length();
}
@@ -478,7 +478,7 @@ void map_lines::normalise(char fillch)
for (int i = 0, size = lines.size(); i < size; ++i)
{
std::string &s = lines[i];
- if ((int) s.length() < map_width)
+ if (static_cast<int>(s.length()) < map_width)
s += std::string( map_width - s.length(), fillch );
}
}
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index 23e5df6e79..da948d09cc 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -331,7 +331,7 @@ void Menu::deselect_all(bool update_view)
bool Menu::is_hotkey(int i, int key)
{
int end = first_entry + pagesize;
- if (end > (int) items.size()) end = items.size();
+ if (end > static_cast<int>(items.size())) end = items.size();
bool ishotkey = is_set(MF_SINGLESELECT)?
items[i]->is_primary_hotkey(key)
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index f742e073da..316f8e1c90 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -314,7 +314,7 @@ void search_around( bool only_adjacent )
return;
} // end search_around()
-void in_a_cloud(void)
+void in_a_cloud()
{
int cl = env.cgrid[you.x_pos][you.y_pos];
int hurted = 0;
@@ -463,6 +463,8 @@ void in_a_cloud(void)
rot_hp(1);
break;
+ default:
+ break;
}
return;
@@ -1847,7 +1849,7 @@ bool i_feel_safe(bool announce)
if (in_bounds(you.x_pos, you.y_pos)
&& env.cgrid[you.x_pos][you.y_pos] != EMPTY_CLOUD)
{
- const cloud_type type = (cloud_type)
+ const cloud_type type =
env.cloud[ env.cgrid[you.x_pos][you.y_pos] ].type;
if (is_damaging_cloud(type))
{
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index b92ead92b9..9ffe0030ef 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -514,7 +514,7 @@ bool mons_player_visible( struct monsters *mon )
unsigned char mons_char(int mc)
{
- return (unsigned char) smc->showchar;
+ return static_cast<unsigned char>(smc->showchar);
} // end mons_char()
char mons_itemuse(int mc)
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 2d77ae7c63..746fba0a52 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -493,7 +493,7 @@ void monster_die(monsters *monster, char killer, int i, bool silent)
}
if (hard_reset)
- place_cloud( CLOUD_GREY_SMOKE + random2(3),
+ place_cloud( random_smoke_type(),
monster->x, monster->y, 1 + random2(3),
monster->kill_alignment() );
@@ -731,8 +731,8 @@ void monster_die(monsters *monster, char killer, int i, bool silent)
simple_monster_message( monster,
" disappears in a puff of smoke!" );
- place_cloud( CLOUD_GREY_SMOKE + random2(3), monster->x,
- monster->y, 1 + random2(3),
+ place_cloud( random_smoke_type(),
+ monster->x, monster->y, 1 + random2(3),
monster->kill_alignment() );
if (monster->needs_transit())
@@ -820,7 +820,7 @@ void monster_die(monsters *monster, char killer, int i, bool silent)
simple_monster_message(monster,
"'s corpse disappears in a puff of smoke!");
- place_cloud( CLOUD_GREY_SMOKE + random2(3),
+ place_cloud( random_smoke_type(),
monster->x, monster->y, 1 + random2(3),
monster->kill_alignment() );
}
diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc
index 186d1f9ce7..d7bc219c55 100644
--- a/crawl-ref/source/mstuff2.cc
+++ b/crawl-ref/source/mstuff2.cc
@@ -974,8 +974,8 @@ void throw_type( int lnchClass, int lnchType, int wepClass, int wepType,
{
if (wepClass == OBJ_MISSILES
&& lnchClass == OBJ_WEAPONS
- && is_range_weapon_type((weapon_type) lnchType)
- && wepType == fires_ammo_type((weapon_type) lnchType))
+ && is_range_weapon_type(static_cast<weapon_type>(lnchType))
+ && wepType == fires_ammo_type(static_cast<weapon_type>(lnchType)))
{
launched = true;
}
diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc
index 753a44a1bf..ac6fd3f3d9 100644
--- a/crawl-ref/source/newgame.cc
+++ b/crawl-ref/source/newgame.cc
@@ -342,7 +342,7 @@ static unsigned char random_potion_description()
|| desc == PDESCS(PDC_CLEAR)
|| desc == PDESCQ(PDQ_GLUGGY, PDC_WHITE));
- return (unsigned char) desc;
+ return static_cast<unsigned char>(desc);
}
// Determine starting depths of branches
diff --git a/crawl-ref/source/notes.cc b/crawl-ref/source/notes.cc
index 99e797b78b..9fe1b9e0b3 100644
--- a/crawl-ref/source/notes.cc
+++ b/crawl-ref/source/notes.cc
@@ -74,7 +74,8 @@ static int dungeon_branch_depth( unsigned char branch )
static bool is_noteworthy_dlevel( unsigned short place )
{
- const unsigned char branch = (unsigned char) ((place >> 8) & 0xFF);
+ const unsigned char branch =
+ static_cast<unsigned char>((place >> 8) & 0xFF);
const int lev = (place & 0xFF);
/* Special levels (Abyss, etc.) are always interesting */
@@ -372,7 +373,7 @@ void Note::save( FILE* fp ) const {
void Note::load( FILE* fp )
{
- type = (NOTE_TYPES)(readLong( fp ));
+ type = static_cast<NOTE_TYPES>(readLong( fp ));
turn = readLong( fp );
packed_place = readShort( fp );
first = readLong( fp );
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 3235fd749a..85152b1991 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -292,7 +292,7 @@ void dec_penance(int val)
void inc_penance(int god, int val)
{
- if ((int) you.penance[god] + val > 200)
+ if (you.penance[god] + val > 200)
you.penance[god] = 200;
else
you.penance[god] += val;
@@ -305,7 +305,7 @@ void inc_penance(int val)
static void inc_gift_timeout(int val)
{
- if ((int) you.gift_timeout + val > 200)
+ if (you.gift_timeout + val > 200)
you.gift_timeout = 200;
else
you.gift_timeout += val;
@@ -1694,7 +1694,7 @@ void gain_piety(char pgn)
old_piety < piety_breakpoint(i) )
{
take_note(Note(NOTE_GOD_POWER, you.religion, i));
- const char* pmsg = god_gain_power_messages[(int)you.religion][i];
+ const char* pmsg = god_gain_power_messages[you.religion][i];
const char first = pmsg[0];
if ( first )
{
@@ -1743,7 +1743,7 @@ void lose_piety(char pgn)
if ( you.piety < piety_breakpoint(i) &&
old_piety >= piety_breakpoint(i) )
{
- const char* pmsg=god_lose_power_messages[(int)you.religion][i];
+ const char* pmsg = god_lose_power_messages[you.religion][i];
const char first = pmsg[0];
if ( first )
{
diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc
index 76c3ca13a1..03351e2ff0 100644
--- a/crawl-ref/source/spells1.cc
+++ b/crawl-ref/source/spells1.cc
@@ -473,18 +473,18 @@ int stinking_cloud( int pow, bolt &beem )
return (1);
} // end stinking_cloud()
-int cast_big_c(int pow, int cty, kill_category whose, bolt &beam)
+int cast_big_c(int pow, cloud_type cty, kill_category whose, bolt &beam)
{
big_cloud( cty, whose,
beam.target_x, beam.target_y, pow, 8 + random2(3) );
return (1);
} // end cast_big_c()
-void big_cloud(int cloud_type, kill_category whose,
+void big_cloud(cloud_type cl_type, kill_category whose,
int cl_x, int cl_y, int pow, int size)
{
apply_area_cloud(make_a_normal_cloud, cl_x, cl_y, pow, size,
- cloud_type, whose);
+ cl_type, whose);
} // end big_cloud()
static int healing_spell( int healed )
diff --git a/crawl-ref/source/spells1.h b/crawl-ref/source/spells1.h
index 2cf9deee53..62f9ae37cb 100644
--- a/crawl-ref/source/spells1.h
+++ b/crawl-ref/source/spells1.h
@@ -56,7 +56,7 @@ int cast_healing(int power);
/* ***********************************************************************
* called from: beam - it_use3 - spells - spells1
* *********************************************************************** */
-void big_cloud(int clouds, kill_category whose, int cl_x, int cl_y,
+void big_cloud(cloud_type cl_type, kill_category whose, int cl_x, int cl_y,
int pow, int size);
@@ -70,7 +70,7 @@ int blink(void);
/* ***********************************************************************
* called from: spell
* *********************************************************************** */
-int cast_big_c(int pow, int cty, kill_category whose, bolt &beam);
+int cast_big_c(int pow, cloud_type cty, kill_category whose, bolt &beam);
void cast_confusing_touch(int power);
void cast_cure_poison(int mabil);
int allowed_deaths_door_hp(void);
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index 5ef969ccd9..6043c1a759 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -62,7 +62,7 @@ bool cast_selective_amnesia(bool force)
{
mpr( "Forget which spell ([?*] list [ESC] exit)? ", MSGCH_PROMPT );
- keyin = (unsigned char) get_ch();
+ keyin = get_ch();
if (keyin == ESCAPE)
return (false); // early return {dlb}
@@ -977,7 +977,7 @@ int portal(void)
for (;;)
{
- keyi = (unsigned char) get_ch();
+ keyi = get_ch();
if (keyi == '<')
{
@@ -1013,7 +1013,7 @@ int portal(void)
for (;;)
{
- keyi = (unsigned char) get_ch();
+ keyi = get_ch();
if (keyi == 'x')
{
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc
index 11e4cead85..dbd82557fa 100644
--- a/crawl-ref/source/spells4.cc
+++ b/crawl-ref/source/spells4.cc
@@ -62,7 +62,7 @@ enum DEBRIS // jmf: add for shatter, dig, and Giants to throw
}; // jmf: ...and I'll actually implement the items Real Soon Now...
// static int make_a_random_cloud(int x, int y, int pow, int ctype);
-static int make_a_rot_cloud(int x, int y, int pow, int ctype);
+static int make_a_rot_cloud(int x, int y, int pow, cloud_type ctype);
static int quadrant_blink(int x, int y, int pow, int garbage);
//void cast_animate_golem(int pow); // see actual function for reasoning {dlb}
@@ -990,7 +990,7 @@ static int ignite_poison_clouds( int x, int y, int pow, int garbage )
}
}
- return ((int) did_anything);
+ return did_anything;
} // end ignite_poison_clouds()
static int ignite_poison_monsters(int x, int y, int pow, int garbage)
@@ -1501,7 +1501,7 @@ void cast_swap(int pow)
apply_one_neighbouring_square( spell_swap_func, pow );
}
-static int make_a_rot_cloud(int x, int y, int pow, int ctype)
+static int make_a_rot_cloud(int x, int y, int pow, cloud_type ctype)
{
int next = 0, obj = mgrd[x][y];
@@ -1537,7 +1537,8 @@ static int make_a_rot_cloud(int x, int y, int pow, int ctype)
return 0;
} // end make_a_rot_cloud()
-int make_a_normal_cloud(int x, int y, int pow, int ctype, kill_category whose)
+int make_a_normal_cloud(int x, int y, int pow, cloud_type ctype,
+ kill_category whose)
{
place_cloud( ctype, x, y,
(3 + random2(pow / 4) + random2(pow / 4) + random2(pow / 4)),
diff --git a/crawl-ref/source/spells4.h b/crawl-ref/source/spells4.h
index d76921f82a..004ce8085f 100644
--- a/crawl-ref/source/spells4.h
+++ b/crawl-ref/source/spells4.h
@@ -18,7 +18,8 @@
const char *your_hand(bool plural);
bool backlight_monsters(int x, int y, int pow, int garbage);
-int make_a_normal_cloud(int x, int y, int pow, int ctype, kill_category);
+int make_a_normal_cloud(int x, int y, int pow, cloud_type ctype,
+ kill_category);
int disperse_monsters(int x, int y, int pow, int message);
void cast_bend(int pow);
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc
index 197c1abb0c..cfe6a670da 100644
--- a/crawl-ref/source/spl-cast.cc
+++ b/crawl-ref/source/spl-cast.cc
@@ -216,7 +216,7 @@ char list_spells(void)
gotoxy(77, wherey());
- itoa( (int) spell_difficulty( spell ), sval, 10 );
+ itoa( spell_difficulty( spell ), sval, 10 );
cprintf(sval);
}
} // end of j loop
@@ -569,7 +569,7 @@ int spell_enhancement( unsigned int typeflags )
} // end spell_enhancement()
// returns false if spell failed, and true otherwise
-bool cast_a_spell(void)
+bool cast_a_spell()
{
char spc = 0;
char spc2 = 0;
@@ -2941,7 +2941,7 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail,
{
case 0:
mprf("Smoke pours from your %s!", your_hand(true) );
- big_cloud( CLOUD_GREY_SMOKE + random2(3), KC_YOU,
+ big_cloud( random_smoke_type(), KC_YOU,
you.x_pos, you.y_pos, 20, 7 + random2(7) );
break;
diff --git a/crawl-ref/source/spl-util.cc b/crawl-ref/source/spl-util.cc
index 05458c1ba5..40eb6f662d 100644
--- a/crawl-ref/source/spl-util.cc
+++ b/crawl-ref/source/spl-util.cc
@@ -50,9 +50,9 @@ static int spell_list[NUM_SPELLS];
#define SPELLDATASIZE (sizeof(spelldata)/sizeof(struct spell_desc))
static struct spell_desc *seekspell(int spellid);
-static bool cloud_helper( int (*func) (int, int, int, int, kill_category),
- int x, int y,
- int pow, int ctype, kill_category );
+static bool cloud_helper(int (*func)(int, int, int, cloud_type, kill_category),
+ int x, int y,
+ int pow, cloud_type ctype, kill_category );
/*
* BEGIN PUBLIC FUNCTIONS
@@ -523,9 +523,10 @@ int apply_area_within_radius( int (*func) (int, int, int, int),
// We really need some sort of a queue structure, since ideally I'd like
// to do a (shallow) breadth-first-search of the dungeon floor.
// This ought to work okay for small clouds.
-void apply_area_cloud( int (*func) (int, int, int, int, kill_category),
+void apply_area_cloud( int (*func) (int, int, int, cloud_type, kill_category),
int x, int y,
- int pow, int number, int ctype, kill_category whose )
+ int pow, int number, cloud_type ctype,
+ kill_category whose )
{
int spread, clouds_left = number;
int good_squares = 0, neighbours[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
@@ -811,9 +812,9 @@ static struct spell_desc *seekspell(int spell)
return (&spelldata[spell_list[spell]]);
}
-static bool cloud_helper( int (*func) (int, int, int, int, kill_category),
- int x, int y,
- int pow, int ctype, kill_category whose )
+static bool cloud_helper(int (*func)(int, int, int, cloud_type, kill_category),
+ int x, int y,
+ int pow, cloud_type ctype, kill_category whose )
{
if (!grid_is_solid(grd[x][y]) && env.cgrid[x][y] == EMPTY_CLOUD)
{
diff --git a/crawl-ref/source/spl-util.h b/crawl-ref/source/spl-util.h
index 25e98a5933..25335d0530 100644
--- a/crawl-ref/source/spl-util.h
+++ b/crawl-ref/source/spl-util.h
@@ -96,8 +96,8 @@ char spell_direction( struct dist &spelld, struct bolt &pbolt,
int mode = TARG_ENEMY,
const char *prompt = NULL );
-void apply_area_cloud(int (*func) (int, int, int, int, kill_category),
- int x, int y, int pow, int number, int ctype,
+void apply_area_cloud(int (*func) (int, int, int, cloud_type, kill_category),
+ int x, int y, int pow, int number, cloud_type ctype,
kill_category);
const char *spelltype_name(unsigned int which_spelltype);
diff --git a/crawl-ref/source/stash.h b/crawl-ref/source/stash.h
index af11c6389e..a6bc8746da 100644
--- a/crawl-ref/source/stash.h
+++ b/crawl-ref/source/stash.h
@@ -72,8 +72,8 @@ public:
bool isAt(int xp, int yp) const { return x == xp && y == yp; }
int abs_pos() const { return abspos; }
- int getX() const { return (int) x; }
- int getY() const { return (int) y; }
+ int getX() const { return x; }
+ int getY() const { return y; }
bool is_verified() const { return verified; }
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc
index f53b07a184..0a0fbbe1d8 100644
--- a/crawl-ref/source/stuff.cc
+++ b/crawl-ref/source/stuff.cc
@@ -608,7 +608,7 @@ void canned_msg(canned_message_type which_message)
bool yesno( const char *str, bool safe, int safeanswer, bool clear_after,
bool interrupt_delays, bool noprompt )
{
- unsigned char tmp;
+ int tmp;
if (interrupt_delays)
interrupt_activity( AI_FORCE_INTERRUPT );
@@ -617,7 +617,7 @@ bool yesno( const char *str, bool safe, int safeanswer, bool clear_after,
if ( !noprompt )
mpr(str, MSGCH_PROMPT);
- tmp = (unsigned char) getch();
+ tmp = getch();
if ((tmp == ' ' || tmp == 27 || tmp == '\r' || tmp == '\n')
&& safeanswer)
diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc
index 695f602437..ab9a12043f 100644
--- a/crawl-ref/source/tags.cc
+++ b/crawl-ref/source/tags.cc
@@ -1544,7 +1544,7 @@ static void tag_read_level( struct tagHeader &th, char minorVersion )
{
env.cloud[i].x = unmarshallByte(th);
env.cloud[i].y = unmarshallByte(th);
- env.cloud[i].type = unmarshallByte(th);
+ env.cloud[i].type = static_cast<cloud_type>(unmarshallByte(th));
env.cloud[i].decay = unmarshallShort(th);
env.cloud[i].whose = static_cast<kill_category>(unmarshallShort(th));
}
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index d7e665402f..da371a7b8d 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -423,7 +423,7 @@ static bool is_safe_move(int x, int y)
return (true);
// We can also safely run through smoke.
- const cloud_type ctype = (cloud_type) env.cloud[ cloud ].type;
+ const cloud_type ctype = env.cloud[ cloud ].type;
return (!is_damaging_cloud(ctype));
}
@@ -2837,7 +2837,7 @@ void LevelInfo::get_stairs(std::vector<coord_def> &st)
for (int x = 0; x < GXM - 1; ++x)
{
int grid = grd[x + 1][y + 1];
- int envc = (unsigned char) env.map[x][y];
+ int envc = env.map[x][y];
if ((x + 1 == you.x_pos && y + 1 == you.y_pos)
|| (envc
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index 74d871bf9c..8b64b837a9 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -1064,8 +1064,8 @@ static int find_next_intercept(double* accx, double* accy, const double slope)
return 1;
}
- const double xtarget = (double)((int)(*accx) + 1);
- const double ytarget = (double)((int)(*accy) + 1);
+ const double xtarget = (static_cast<int>(*accx) + 1);
+ const double ytarget = (static_cast<int>(*accy) + 1);
const double xdistance = xtarget - *accx;
const double ydistance = ytarget - *accy;
const double distdiff = (xdistance * slope - ydistance);
@@ -1191,8 +1191,8 @@ static int shoot_ray( double accx, double accy, const double slope,
for ( cellnum = 0; true; ++cellnum )
{
find_next_intercept( &accx, &accy, slope );
- curx = (int)(accx);
- cury = (int)(accy);
+ curx = static_cast<int>(accx);
+ cury = static_cast<int>(accy);
if ( curx > maxrange || cury > maxrange )
break;
@@ -1264,7 +1264,7 @@ static std::vector<int> find_nonduped_cellrays()
std::vector<int> result;
for (curidx=0, raynum=0;
- raynum < (int)raylengths.size();
+ raynum < static_cast<int>(raylengths.size());
curidx += raylengths[raynum++])
{
for (cellnum = 0; cellnum < raylengths[raynum]; ++cellnum)