summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-14 22:04:34 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-14 22:04:34 +0000
commit39f1638a065766fa67c70871c95a0a8400f044f1 (patch)
tree29de7d191f59b1c55842b25bee2f225e5de1b169 /crawl-ref
parent1c7787b17cee82ed787ff5fed1eea5c943c0cd64 (diff)
downloadcrawl-ref-39f1638a065766fa67c70871c95a0a8400f044f1.tar.gz
crawl-ref-39f1638a065766fa67c70871c95a0a8400f044f1.zip
Apply Horst von Brand's (first) patch 1887488: gcc-4.3 compile failures.
I'm not sure what to do about the rest of that tracker item. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4233 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/abyss.cc31
-rw-r--r--crawl-ref/source/acr.cc155
-rw-r--r--crawl-ref/source/beam.cc1
-rw-r--r--crawl-ref/source/cloud.cc9
-rw-r--r--crawl-ref/source/clua.cc104
-rw-r--r--crawl-ref/source/debug.cc2
-rw-r--r--crawl-ref/source/decks.cc1
-rw-r--r--crawl-ref/source/direct.cc1
-rw-r--r--crawl-ref/source/dungeon.cc355
-rw-r--r--crawl-ref/source/effects.cc1
-rw-r--r--crawl-ref/source/fight.cc1
-rw-r--r--crawl-ref/source/lev-pand.cc4
-rw-r--r--crawl-ref/source/luadgn.cc1
-rw-r--r--crawl-ref/source/makeitem.cc2
-rw-r--r--crawl-ref/source/mapmark.cc17
-rw-r--r--crawl-ref/source/maps.cc58
-rw-r--r--crawl-ref/source/misc.cc2
-rw-r--r--crawl-ref/source/mon-util.cc219
-rw-r--r--crawl-ref/source/monplace.cc45
-rw-r--r--crawl-ref/source/monspeak.cc23
-rw-r--r--crawl-ref/source/monstuff.cc157
-rw-r--r--crawl-ref/source/mstuff2.cc79
-rw-r--r--crawl-ref/source/mtransit.cc9
-rw-r--r--crawl-ref/source/newgame.cc1
-rw-r--r--crawl-ref/source/overmap.cc13
-rw-r--r--crawl-ref/source/spells2.cc23
-rw-r--r--crawl-ref/source/spells3.cc3
-rw-r--r--crawl-ref/source/spells4.cc1
-rw-r--r--crawl-ref/source/stuff.cc77
-rw-r--r--crawl-ref/source/tags.cc47
-rw-r--r--crawl-ref/source/terrain.cc3
-rw-r--r--crawl-ref/source/traps.cc64
-rw-r--r--crawl-ref/source/util/levcomp.lpp19
-rw-r--r--crawl-ref/source/util/levcomp.ypp88
-rw-r--r--crawl-ref/source/view.cc1
-rw-r--r--crawl-ref/source/xom.cc4
36 files changed, 836 insertions, 785 deletions
diff --git a/crawl-ref/source/abyss.cc b/crawl-ref/source/abyss.cc
index ba601bcb38..f75f48aee0 100644
--- a/crawl-ref/source/abyss.cc
+++ b/crawl-ref/source/abyss.cc
@@ -15,6 +15,7 @@
#include "abyss.h"
#include <stdlib.h>
+#include <algorithm>
#include "externs.h"
@@ -164,7 +165,7 @@ static void generate_area(int gx1, int gy1, int gx2, int gy2)
{
if (one_chance_in(200))
{
- thing_created = items(1, OBJ_MISCELLANY,
+ thing_created = items(1, OBJ_MISCELLANY,
MISC_RUNE_OF_ZOT, true, 51, 51);
#if DEBUG_ABYSS
mpr("Placing an Abyssal rune.", MSGCH_DIAGNOSTICS);
@@ -334,7 +335,7 @@ static void abyss_lose_monster(monsters &mons)
{
if (mons.needs_transit())
mons.set_transit( level_id(LEVEL_ABYSS) );
-
+
mons.reset();
}
@@ -350,7 +351,7 @@ void area_shift(void)
for (unsigned int i = 0; i < MAX_MONSTERS; i++)
{
monsters &m = menv[i];
-
+
if (!m.alive())
continue;
@@ -434,7 +435,7 @@ void area_shift(void)
for (unsigned int mcount = 0; mcount < 15; mcount++)
{
- mons_place( RANDOM_MONSTER, BEH_HOSTILE, MHITNOT, false, 1, 1,
+ mons_place( RANDOM_MONSTER, BEH_HOSTILE, MHITNOT, false, 1, 1,
LEVEL_ABYSS, PROX_AWAY_FROM_PLAYER ); // PROX_ANYWHERE?
}
@@ -468,7 +469,7 @@ void abyss_teleport( bool new_area )
x = 16 + random2( GXM - 32 );
y = 16 + random2( GYM - 32 );
- if ((grd[x][y] == DNGN_FLOOR
+ if ((grd[x][y] == DNGN_FLOOR
|| grd[x][y] == DNGN_SHALLOW_WATER)
&& mgrd[x][y] == NON_MONSTER
&& env.cgrid[x][y] == EMPTY_CLOUD)
@@ -502,7 +503,7 @@ void abyss_teleport( bool new_area )
if (menv[i].alive())
abyss_lose_monster(menv[i]);
}
-
+
// Orbs and fixed artefacts are marked as "lost in the abyss"
for (k = 0; k < MAX_ITEMS; k++)
{
@@ -527,7 +528,7 @@ void abyss_teleport( bool new_area )
}
}
- ASSERT( env.cloud_no == 0 );
+ ASSERT( env.cloud_no == 0 );
you.moveto(45, 35);
@@ -647,9 +648,9 @@ static bool is_grid_corruptible(const coord_def &c)
{
if (c == you.pos())
return (false);
-
+
const dungeon_feature_type feat = grd(c);
-
+
// Stairs and portals cannot be corrupted.
if (grid_stair_direction(feat) != CMD_NO_CMD)
return (false);
@@ -662,19 +663,19 @@ static bool is_grid_corruptible(const coord_def &c)
case DNGN_METAL_WALL:
return (one_chance_in(5));
-
+
case DNGN_STONE_WALL:
return (one_chance_in(3));
case DNGN_ROCK_WALL:
return (!one_chance_in(3));
-
+
default:
return (true);
}
}
-// Returns true if the square has <= 4 traversable neighbours.
+// Returns true if the square has <= 4 traversable neighbours.
static bool is_crowded_square(const coord_def &c)
{
int neighbours = 0;
@@ -769,7 +770,7 @@ static void corrupt_level_features(const crawl_environment &oenv)
for (int i = 0, size = corrupt_markers.size(); i < size; ++i)
corrupt_seeds.push_back(corrupt_markers[i]->pos);
-
+
for (int y = MAPGEN_BORDER; y < GYM - MAPGEN_BORDER; ++y)
{
for (int x = MAPGEN_BORDER; x < GXM - MAPGEN_BORDER; ++x)
@@ -837,7 +838,7 @@ bool lugonu_corrupt_level(int power)
you.flash_colour = EC_MUTAGENIC;
viewwindow(true, false);
-
+
initialise_level_corrupt_seeds(power);
std::auto_ptr<crawl_environment> backup(new crawl_environment(env));
@@ -852,7 +853,7 @@ bool lugonu_corrupt_level(int power)
backup.reset(NULL);
dungeon_events.clear();
env.markers.activate_all(false);
-
+
corrupt_level_features(*abyssal);
run_corruption_effects(300);
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 6576ca2794..d4931d6431 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -39,6 +39,7 @@
#include "AppHdr.h"
#include <string>
+#include <algorithm>
// I don't seem to need values.h for VACPP..
#if !defined(__IBMCPP__)
@@ -164,8 +165,8 @@ int stealth; // externed in view.cc
static key_recorder repeat_again_rec;
// Clockwise, around the compass from north (same order as enum RUN_DIR)
-const struct coord_def Compass[8] =
-{
+const struct coord_def Compass[8] =
+{
coord_def(0, -1), coord_def(1, -1), coord_def(1, 0), coord_def(1, 1),
coord_def(0, 1), coord_def(-1, 1), coord_def(-1, 0), coord_def(-1, -1),
};
@@ -223,7 +224,7 @@ int main( int argc, char *argv[] )
// Init monsters up front - needed to handle the mon_glyph option right.
init_monsters(mcolour);
-
+
// Read the init file.
init_file_location = read_init_file();
@@ -264,7 +265,7 @@ int main( int argc, char *argv[] )
// warn player about their weapon, if unsuitable
wield_warning(false);
- if ( game_start )
+ if ( game_start )
{
if (Options.tutorial_left)
_startup_tutorial();
@@ -312,7 +313,7 @@ static void _wanderer_startup_message()
int skill_levels = 0;
for (int i = 0; i < NUM_SKILLS; i++)
skill_levels += you.skills[ i ];
-
+
if (skill_levels <= 2)
{
// Demigods and Demonspawn wanderers stand to not be
@@ -395,12 +396,12 @@ static void _take_starting_note()
static void _startup_tutorial()
{
- // don't allow triggering at game start
+ // don't allow triggering at game start
Options.tut_just_triggered = true;
-
+
// print stats and everything
_prep_input();
-
+
#ifdef USE_TILE
tile_draw_inv(REGION_INV1);
#endif
@@ -408,7 +409,7 @@ static void _startup_tutorial()
msg::streams(MSGCH_TUTORIAL)
<< "Press any key to start the tutorial intro, or Escape to skip it."
<< std::endl;
-
+
const int ch = c_getch();
if (ch != ESCAPE)
tut_starting_screen();
@@ -482,14 +483,14 @@ static void _handle_wizard_command( void )
}
switch (wiz_command)
- {
+ {
case '?':
list_commands(true, 0, true); // tell it to list wizard commands
break;
case CONTROL('G'):
save_ghost(true);
- break;
+ break;
case 'x':
you.experience = 1 + exp_needed( 2 + you.experience_level );
@@ -536,7 +537,7 @@ static void _handle_wizard_command( void )
}
else
{
- mprf("randart val: %d", randart_value(you.inv[i]));
+ mprf("randart val: %d", randart_value(you.inv[i]));
}
break;
@@ -754,7 +755,7 @@ static void _handle_wizard_command( void )
case CONTROL('F'):
debug_fight_statistics(false, true);
break;
-
+
case 'f':
debug_fight_statistics(false);
break;
@@ -835,7 +836,7 @@ static void _handle_wizard_command( void )
{
if (is_valid_item( you.inv[i] ))
{
- set_ident_type( you.inv[i].base_type, you.inv[i].sub_type,
+ set_ident_type( you.inv[i].base_type, you.inv[i].sub_type,
ID_KNOWN_TYPE );
set_ident_flags( you.inv[i], ISFLAG_IDENT_MASK );
@@ -853,7 +854,7 @@ static void _handle_wizard_command( void )
{
if (is_valid_item( you.inv[i] ))
{
- set_ident_type( you.inv[i].base_type, you.inv[i].sub_type,
+ set_ident_type( you.inv[i].base_type, you.inv[i].sub_type,
ID_UNKNOWN_TYPE );
unset_ident_flags( you.inv[i], ISFLAG_IDENT_MASK );
@@ -881,7 +882,7 @@ static void _handle_wizard_command( void )
if (!is_valid_item(item))
continue;
- set_ident_type( item.base_type, item.sub_type,
+ set_ident_type( item.base_type, item.sub_type,
ID_UNKNOWN_TYPE );
unset_ident_flags( item, ISFLAG_IDENT_MASK );
@@ -1041,11 +1042,11 @@ static void _handle_wizard_command( void )
// Rarely, this might result in several gifts during the same round!
do
{
- gain_piety(50);
+ gain_piety(50);
}
while (old_piety < MAX_PIETY && old_piety == you.piety
&& old_penance == you.penance[you.religion]);
-
+
if (old_penance)
{
mprf("Congratulations, your penance was decreased from %d to %d!",
@@ -1060,7 +1061,7 @@ static void _handle_wizard_command( void )
break;
case '=':
- mprf( "Cost level: %d Skill points: %d Next cost level: %d",
+ mprf( "Cost level: %d Skill points: %d Next cost level: %d",
you.skill_cost_level, you.total_skill_points,
skill_cost_needed( you.skill_cost_level + 1 ) );
break;
@@ -1074,12 +1075,12 @@ static void _handle_wizard_command( void )
{
if (mitm[i].link == NON_ITEM)
continue;
-
+
mprf("item:%3d link:%3d cl:%3d ty:%3d pl:%3d pl2:%3d "
"sp:%3ld q:%3d",
- i, mitm[i].link,
+ i, mitm[i].link,
mitm[i].base_type, mitm[i].sub_type,
- mitm[i].plus, mitm[i].plus2, mitm[i].special,
+ mitm[i].plus, mitm[i].plus2, mitm[i].special,
mitm[i].quantity );
}
@@ -1091,10 +1092,10 @@ static void _handle_wizard_command( void )
if (igrd[i][j] != NON_ITEM)
{
mprf("%3d at (%2d,%2d), cl:%3d ty:%3d pl:%3d pl2:%3d "
- "sp:%3ld q:%3d",
+ "sp:%3ld q:%3d",
igrd[i][j], i, j,
mitm[i].base_type, mitm[i].sub_type,
- mitm[i].plus, mitm[i].plus2, mitm[i].special,
+ mitm[i].plus, mitm[i].plus2, mitm[i].special,
mitm[i].quantity );
}
}
@@ -1376,11 +1377,11 @@ static void _input()
{
if (2*you.hp < you.hp_max)
learned_something_new(TUT_RUN_AWAY);
-
+
if (Options.tutorial_type == TUT_MAGIC_CHAR && you.magic_points < 1)
learned_something_new(TUT_RETREAT_CASTER);
}
-
+
if ( you.cannot_act() )
{
crawl_state.cancel_cmd_repeat("Cannot move, cancelling command "
@@ -1389,7 +1390,7 @@ static void _input()
_world_reacts();
return;
}
-
+
if (need_to_autopickup())
autopickup();
@@ -1726,7 +1727,7 @@ static bool _compare_monsters_attitude( const monsters *m1, const monsters *m2 )
{
if (_mons_hostile(m1) && !_mons_hostile(m2))
return (true);
-
+
if (mons_neutral(m1))
{
if (mons_friendly(m2))
@@ -1751,7 +1752,7 @@ void get_visible_monsters(std::vector<std::string>& describe)
if ( ystart < 0 ) ystart = 0;
if ( xend >= GXM ) xend = GXM;
if ( yend >= GYM ) yend = GYM;
-
+
std::vector<const monsters*> mons;
// monster check
for ( int y = ystart; y < yend; ++y )
@@ -1773,9 +1774,9 @@ void get_visible_monsters(std::vector<std::string>& describe)
if (mons.empty())
return;
-
+
std::sort( mons.begin(), mons.end(), _compare_monsters_attitude );
-
+
int count = 0;
int size = mons.size();
for (int i = 0; i < size; ++i)
@@ -1937,7 +1938,7 @@ void process_command( command_type cmd )
case CMD_ENABLE_MORE:
Options.show_more_prompt = true;
break;
-
+
case CMD_REPEAT_KEYS:
ASSERT(crawl_state.is_repeating_cmd());
@@ -1996,7 +1997,7 @@ void process_command( command_type cmd )
else
_toggle_flag( &Options.autoprayer_on, "Autoprayer" );
break;
-
+
case CMD_MAKE_NOTE:
make_user_note();
break;
@@ -2029,7 +2030,7 @@ void process_command( command_type cmd )
if (Options.stash_tracking >= STM_DROPPED)
StashTrack.add_stash();
break;
-
+
case CMD_SEARCH_STASHES:
if (Options.tut_stashes)
Options.tut_stashes = 0;
@@ -2070,7 +2071,7 @@ void process_command( command_type cmd )
case CMD_FULL_VIEW:
_mpr_monsters();
break;
-
+
case CMD_WIELD_WEAPON:
wield_weapon(false);
break;
@@ -2228,7 +2229,7 @@ void process_command( command_type cmd )
case CMD_FIX_WAYPOINT:
travel_cache.add_waypoint();
break;
-
+
case CMD_INTERLEVEL_TRAVEL:
if (Options.tut_travel)
Options.tut_travel = 0;
@@ -2271,7 +2272,7 @@ void process_command( command_type cmd )
show_map(pos, true);
redraw_screen();
-
+
#ifdef USE_TILE
mpr("Returning to the game...");
#endif
@@ -2302,7 +2303,7 @@ void process_command( command_type cmd )
case CMD_SUSPEND_GAME:
// CTRL-Z suspend behaviour is implemented here,
// because we want to have CTRL-Y available...
- // and unfortunately they tend to be stuck together.
+ // and unfortunately they tend to be stuck together.
clrscr();
#ifndef USE_TILE
unixcurses_shutdown();
@@ -2361,7 +2362,7 @@ void process_command( command_type cmd )
case CMD_DISPLAY_CHARACTER_STATUS:
display_char_status();
break;
-
+
case CMD_RESISTS_SCREEN:
print_overview_screen();
break;
@@ -2402,11 +2403,11 @@ void process_command( command_type cmd )
case CMD_LIST_WEAPONS:
list_weapons();
break;
-
+
case CMD_LIST_ARMOUR:
list_armour();
break;
-
+
case CMD_LIST_JEWELLERY:
list_jewellery();
break;
@@ -2418,7 +2419,7 @@ void process_command( command_type cmd )
case CMD_INSCRIBE_ITEM:
inscribe_item();
break;
-
+
#ifdef WIZARD
case CMD_WIZARD:
_handle_wizard_command();
@@ -2562,7 +2563,7 @@ static void _decrement_durations()
you.redraw_armour_class = true;
}
}
-
+
if (_decrement_a_duration(DUR_ICY_ARMOUR, "Your icy armour evaporates."))
you.redraw_armour_class = true;
@@ -2599,7 +2600,7 @@ static void _decrement_durations()
if (--you.duration[DUR_DIVINE_SHIELD] == 1)
mpr("Your divine shield starts to fade.");
}
-
+
if (you.duration[DUR_DIVINE_SHIELD] == 1 && !one_chance_in(3))
{
you.redraw_armour_class = true;
@@ -2610,7 +2611,7 @@ static void _decrement_durations()
}
}
}
-
+
//jmf: more flexible weapon branding code
if (you.duration[DUR_WEAPON_BRAND] > 1)
you.duration[DUR_WEAPON_BRAND]--;
@@ -2752,16 +2753,16 @@ static void _decrement_durations()
_decrement_a_duration(DUR_RESIST_COLD, "Your cold resistance expires.");
_decrement_a_duration(DUR_RESIST_POISON, "Your poison resistance expires.");
_decrement_a_duration(DUR_SLAYING, "You feel less lethal.");
-
+
_decrement_a_duration(DUR_INVIS, "You flicker back into view.",
6, coinflip(), "You flicker for a moment.");
_decrement_a_duration(DUR_BARGAIN, "You feel less charismatic.");
_decrement_a_duration(DUR_CONF, "You feel less confused.");
-
+
if (_decrement_a_duration(DUR_PARALYSIS, "You can move again."))
you.redraw_evasion = true;
-
+
_decrement_a_duration(DUR_EXHAUSTED, "You feel less fatigued.");
_decrement_a_duration( DUR_CONFUSING_TOUCH,
@@ -2792,7 +2793,7 @@ static void _decrement_durations()
// Sometimes berserk leaves us physically drained
//
- // chance of passing out:
+ // chance of passing out:
// - mutation gives a large plus in order to try and
// avoid the mutation being a "death sentence" to
// certain characters.
@@ -2870,15 +2871,15 @@ static void _decrement_durations()
{
you.duration[DUR_PIETY_POOL]--; // decrease even if piety at maximum
gain_piety(1);
-
+
#if DEBUG_DIAGNOSTICS || DEBUG_SACRIFICE || DEBUG_PIETY
mpr("Piety increases by 1 due to piety pool.", MSGCH_DIAGNOSTICS);
-
+
if (!you.duration[DUR_PIETY_POOL])
mpr("Piety pool is now empty.", MSGCH_DIAGNOSTICS);
#endif
}
-
+
if (!you.permanent_levitation())
{
@@ -2898,10 +2899,10 @@ static void _decrement_durations()
if (!you.permanent_flight())
if ( _decrement_a_duration(DUR_CONTROLLED_FLIGHT) && you.airborne() )
mpr("You lose control over your flight.", MSGCH_DURATION);
-
+
if (you.rotting > 0)
{
- // XXX: Mummies have an ability (albeit an expensive one) that
+ // XXX: Mummies have an ability (albeit an expensive one) that
// can fix rotted HPs now... it's probably impossible for them
// to even start rotting right now, but that could be changed. -- bwr
if (you.species == SP_MUMMY)
@@ -3027,7 +3028,7 @@ static void _check_sanctuary()
{
if (env.sanctuary_time <= 0)
return;
-
+
decrease_sanctuary_radius();
}
@@ -3138,7 +3139,7 @@ static void _world_reacts()
Options.stash_tracking == STM_ALL ? StashTracker::ST_AGGRESSIVE
: StashTracker::ST_PASSIVE);
}
-
+
handle_monsters();
_check_banished();
@@ -3231,7 +3232,7 @@ static void _read_each_message()
// Read messages, code borrowed from the SIMPLEMAIL patch.
char line[120];
-
+
if (!lock_file_handle(mf, F_RDLCK))
{
mprf(MSGCH_WARN, "Failed to lock %s: %s", SysEnv.messagefile.c_str(),
@@ -3324,7 +3325,7 @@ static void _check_messages()
SysEnv.have_messages = true;
mfilestat.st_mtime = st.st_mtime;
}
-
+
if (SysEnv.have_messages && !had_messages)
{
_announce_messages();
@@ -3342,16 +3343,16 @@ static command_type _get_next_cmd()
#if DEBUG_DIAGNOSTICS
// save hunger at start of round
// for use with hunger "delta-meter" in output.cc
- you.old_hunger = you.hunger;
+ you.old_hunger = you.hunger;
#endif
-
+
#if DEBUG_ITEM_SCAN
debug_item_scan();
#endif
const time_t before = time(NULL);
keycode_type keyin = _get_next_keycode();
-
+
const time_t after = time(NULL);
// Clamp idle time so that play time is more meaningful.
@@ -3605,8 +3606,8 @@ static void _open_door(int move_x, int move_y, bool check_confused)
return;
}
- }
- else
+ }
+ else
{
mpr("Which direction?", MSGCH_PROMPT);
direction( door_move, DIR_DIR );
@@ -3617,7 +3618,7 @@ static void _open_door(int move_x, int move_y, bool check_confused)
dx = you.x_pos + door_move.dx;
dy = you.y_pos + door_move.dy;
- const dungeon_feature_type feat =
+ const dungeon_feature_type feat =
in_bounds(dx, dy) ? grd[dx][dy] : DNGN_UNSEEN;
if (feat != DNGN_CLOSED_DOOR)
{
@@ -3640,7 +3641,7 @@ static void _open_door(int move_x, int move_y, bool check_confused)
find_connected_identical(coord_def(dx,dy), grd[dx][dy], all_door);
const char *adj, *noun;
get_door_description(all_door.size(), &adj, &noun);
-
+
int skill = you.dex + (you.skills[SK_TRAPS_DOORS] + you.skills[SK_STEALTH]) / 2;
if (you.duration[DUR_BERSERKER])
@@ -3721,9 +3722,9 @@ static void _close_door(int door_x, int door_y)
dx = you.x_pos + door_move.dx;
dy = you.y_pos + door_move.dy;
- const dungeon_feature_type feat =
+ const dungeon_feature_type feat =
in_bounds(dx, dy) ? grd[dx][dy] : DNGN_UNSEEN;
-
+
if (feat == DNGN_OPEN_DOOR)
{
std::set<coord_def> all_door;
@@ -3738,7 +3739,7 @@ static void _close_door(int door_x, int door_y)
const coord_def& dc = *i;
if (mgrd[dc.x][dc.y] != NON_MONSTER)
{
- // Need to make sure that turn_is_over is set if creature is
+ // Need to make sure that turn_is_over is set if creature is
// invisible
if (!player_monster_visible(&menv[mgrd[dc.x][dc.y]]))
{
@@ -3747,7 +3748,7 @@ static void _close_door(int door_x, int door_y)
}
else
mprf("There's a creature in the %sway!", noun);
-
+
door_move.dx = 0;
door_move.dy = 0;
return;
@@ -3829,11 +3830,11 @@ static void _close_door(int door_x, int door_y)
static bool _initialise(void)
{
Options.fixup_options();
-
+
// read the options the player used last time they created a new
// character.
read_startup_prefs();
-
+
you.symbol = '@';
you.colour = LIGHTGREY;
@@ -3867,7 +3868,7 @@ static bool _initialise(void)
// set up the Lua interpreter for the dungeon builder.
init_dungeon_lua();
-
+
// Read special levels and vaults.
read_maps();
@@ -3877,7 +3878,7 @@ static bool _initialise(void)
init_feat_desc_cache();
init_spell_name_cache();
init_item_name_cache();
-
+
cio_init();
// system initialisation stuff:
@@ -3893,7 +3894,7 @@ static bool _initialise(void)
end(0, false);
}
#endif
-
+
// sets up a new game:
const bool newc = new_game();
if (!newc)
@@ -3901,7 +3902,7 @@ static bool _initialise(void)
// Fix the mutation definitions for the species we're playing.
fixup_mutations();
-
+
// Load macros
macro_init();
@@ -4336,7 +4337,7 @@ static void _setup_cmd_repeat()
}
int count = atoi(buf);
-
+
if (crawl_state.doing_prev_cmd_again)
count = crawl_state.prev_cmd_repeat_goal;
@@ -4550,7 +4551,7 @@ static void _update_replay_state()
prev.insert(prev.end(), begin, curr.end());
}
}
-
+
repeat_again_rec.paused = true;
macro_buf_add(KEY_REPEAT_KEYS);
}
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index d074f6b29c..2942a6de1b 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -26,6 +26,7 @@
#include <cstdarg>
#include <iostream>
#include <set>
+#include <algorithm>
#ifdef DOS
#include <dos.h>
diff --git a/crawl-ref/source/cloud.cc b/crawl-ref/source/cloud.cc
index 3aa74613df..f98eabe7aa 100644
--- a/crawl-ref/source/cloud.cc
+++ b/crawl-ref/source/cloud.cc
@@ -13,6 +13,9 @@
*/
#include "AppHdr.h"
+
+#include <algorithm>
+
#include "externs.h"
#include "branch.h"
@@ -89,7 +92,7 @@ static int spread_cloud(const cloud_struct &cloud)
const int x = cloud.x + xi;
const int y = cloud.y + yi;
- if (!in_bounds(x, y)
+ if (!in_bounds(x, y)
|| env.cgrid[x][y] != EMPTY_CLOUD
|| grid_is_solid(grd[x][y]))
continue;
@@ -174,7 +177,7 @@ void delete_cloud( int cloud )
}
// The current use of this function is for shifting in the abyss, so
-// that clouds get moved along with the rest of the map.
+// that clouds get moved along with the rest of the map.
void move_cloud( int cloud, int new_x, int new_y )
{
if (cloud != EMPTY_CLOUD)
@@ -246,7 +249,7 @@ void place_cloud(cloud_type cl_type, int ctarget_x,
unsigned char spread_rate = actual_spread_rate( cl_type, _spread_rate );
// too many clouds
- if (env.cloud_no >= MAX_CLOUDS)
+ if (env.cloud_no >= MAX_CLOUDS)
{
// default to random in case there's no low quality clouds
int cl_del = random2( MAX_CLOUDS );
diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc
index 3b606499d4..2ed6af6dd4 100644
--- a/crawl-ref/source/clua.cc
+++ b/crawl-ref/source/clua.cc
@@ -7,6 +7,8 @@
#include "AppHdr.h"
+#include <algorithm>
+
#include "clua.h"
#include "abl-show.h"
@@ -123,7 +125,7 @@ void CLua::setregistry(const char *name)
lua_settable(state(), LUA_REGISTRYINDEX);
}
-void CLua::getregistry(const char *name)
+void CLua::getregistry(const char *name)
{
lua_pushstring(state(), name);
lua_gettable(state(), LUA_REGISTRYINDEX);
@@ -154,7 +156,7 @@ int CLua::file_write(lua_State *ls)
FILE *f = sf->get_file();
if (!f)
return (0);
-
+
const char *text = luaL_checkstring(ls, 2);
if (text)
fprintf(f, "%s", text);
@@ -169,7 +171,7 @@ FILE *CLua::CLuaSave::get_file()
return (handle);
}
-void CLua::set_error(int err, lua_State *ls)
+void CLua::set_error(int err, lua_State *ls)
{
if (!err)
{
@@ -190,7 +192,7 @@ void CLua::init_throttle()
{
if (!managed_vm)
return;
-
+
if (throttle_unit_lines <= 0)
throttle_unit_lines = 500;
@@ -199,7 +201,7 @@ void CLua::init_throttle()
if (throttle_sleep_end < throttle_sleep_start)
throttle_sleep_end = throttle_sleep_start;
-
+
if (!mixed_call_depth)
{
lua_sethook(_state, clua_throttle_hook,
@@ -226,7 +228,7 @@ int CLua::execstring(const char *s, const char *context, int nresults)
int err = 0;
if ((err = loadstring(s, context)))
return (err);
-
+
lua_State *ls = state();
lua_call_throttle strangler(this);
err = lua_pcall(ls, 0, nresults, 0);
@@ -254,7 +256,7 @@ int CLua::loadfile(lua_State *ls, const char *filename, bool trusted,
make_stringf("invalid filename: %s", filename).c_str());
return (-1);
}
-
+
std::string file = datafile_path(filename, die_on_fail);
if (file.empty())
{
@@ -324,7 +326,7 @@ bool CLua::runhook(const char *hook, const char *params, ...)
void CLua::fnreturns(const char *format, ...)
{
lua_State *ls = _state;
-
+
if (!format || !ls)
return;
@@ -345,7 +347,7 @@ void CLua::vfnreturns(const char *format, va_list args)
format = gs + 1;
else if ((gs = strchr(format, ':')))
format = gs + 1;
-
+
for (const char *run = format; *run; ++run)
{
char argtype = *run;
@@ -456,7 +458,7 @@ int CLua::return_count(lua_State *ls, const char *format)
const char *gs = strchr(format, '>');
if (gs)
return (strlen(gs + 1));
-
+
const char *cs = strchr(format, ':');
if (cs && isdigit(*format))
{
@@ -473,7 +475,7 @@ int CLua::return_count(lua_State *ls, const char *format)
return (0);
}
-bool CLua::calltopfn(lua_State *ls, const char *params, va_list args,
+bool CLua::calltopfn(lua_State *ls, const char *params, va_list args,
int retc, va_list *copyto)
{
// We guarantee to remove the function from the stack
@@ -507,7 +509,7 @@ bool CLua::callbooleanfn(bool def, const char *fn, const char *params, ...)
bool ret = calltopfn(ls, params, args, 1);
if (!ret)
CL_RESETSTACK_RETURN(ls, stacktop, def);
-
+
def = lua_toboolean(ls, -1);
CL_RESETSTACK_RETURN(ls, stacktop, def);
}
@@ -562,7 +564,7 @@ bool CLua::callfn(const char *fn, int nargs, int nret)
lua_settop(ls, -nargs - 2);
return (false);
}
-
+
// Slide the function in front of its args and call it.
if (nargs)
lua_insert(ls, -nargs - 1);
@@ -574,7 +576,7 @@ bool CLua::callfn(const char *fn, int nargs, int nret)
return !err;
}
-// Defined in Kills.cc because the kill bindings refer to Kills.cc local
+// Defined in Kills.cc because the kill bindings refer to Kills.cc local
// structs
extern void luaopen_kills(lua_State *ls);
@@ -627,7 +629,7 @@ void CLua::init_lua()
{
lua_register(_state, "pcall", clua_guarded_pcall);
execfile("clua/userbase.lua", true, true);
- }
+ }
lua_pushboolean(_state, managed_vm);
setregistry("lua_vm_is_managed");
@@ -657,12 +659,12 @@ void CLua::load_cmacro()
/////////////////////////////////////////////////////////////////////
-static void clua_register_metatable(lua_State *ls, const char *tn,
+static void clua_register_metatable(lua_State *ls, const char *tn,
const luaL_reg *lr,
int (*gcfn)(lua_State *ls) = NULL)
{
int top = lua_gettop(ls);
-
+
luaL_newmetatable(ls, tn);
lua_pushstring(ls, "__index");
lua_pushvalue(ls, -2);
@@ -674,7 +676,7 @@ static void clua_register_metatable(lua_State *ls, const char *tn,
lua_pushcfunction(ls, gcfn);
lua_settable(ls, -3);
}
-
+
luaL_openlib(ls, NULL, lr, 0);
lua_settop(ls, top);
@@ -915,7 +917,7 @@ static int l_item_swap_slots(lua_State *ls)
slot2 < 0 || slot2 >= ENDOFPACK ||
slot1 == slot2 || !is_valid_item(you.inv[slot1]))
return (0);
-
+
swap_inv_slots(slot1, slot2, verbose);
return (0);
@@ -983,7 +985,7 @@ static int l_item_remove(lua_State *ls)
mpr("Item is not equipped");
return (0);
}
-
+
bool result = false;
if (eq == EQ_WEAPON)
result = wield_weapon(true, -1);
@@ -1225,7 +1227,7 @@ static int l_item_subtype(lua_State *ls)
else if (item->sub_type == POT_CURE_MUTATION)
s = "cure mutation";
}
-
+
if (s)
lua_pushstring(ls, s);
else
@@ -1306,7 +1308,7 @@ static int l_item_potion_type(lua_State *ls)
static int l_item_cursed(lua_State *ls)
{
LUA_ITEM(item, 1);
- bool cursed = item && item_ident(*item, ISFLAG_KNOW_CURSE)
+ bool cursed = item && item_ident(*item, ISFLAG_KNOW_CURSE)
&& item_cursed(*item);
lua_pushboolean(ls, cursed);
return (1);
@@ -1492,7 +1494,7 @@ static const struct luaL_reg item_lib[] =
{ "equipped_at", l_item_equipped },
{ "equip_type", l_item_equip_type },
{ "weap_skill", l_item_weap_skill },
-
+
{ NULL, NULL },
};
@@ -1624,7 +1626,7 @@ static int food_ischunk(lua_State *ls)
{
LUA_ITEM(item, 1);
lua_pushboolean(ls,
- item && item->base_type == OBJ_FOOD
+ item && item->base_type == OBJ_FOOD
&& item->sub_type == FOOD_CHUNK);
return (1);
}
@@ -1654,7 +1656,7 @@ static int crawl_mpr(lua_State *ls)
{
if (!crawl_state.io_inited)
return (0);
-
+
const char *message = luaL_checkstring(ls, 1);
if (!message)
return (0);
@@ -1683,7 +1685,7 @@ static int crawl_input_line(lua_State *ls)
{
// This is arbitrary, but anybody entering so many characters is psychotic.
char linebuf[500];
-
+
get_input_line(linebuf, sizeof linebuf);
lua_pushstring(ls, linebuf);
return (1);
@@ -1692,7 +1694,7 @@ static int crawl_input_line(lua_State *ls)
static int crawl_c_input_line(lua_State *ls)
{
char linebuf[500];
-
+
bool valid = !cancelable_get_line(linebuf, sizeof linebuf);
if (valid)
lua_pushstring(ls, linebuf);
@@ -1768,7 +1770,7 @@ static int crawl_setopt(lua_State *ls)
{
if (!lua_isstring(ls, 1))
return (0);
-
+
const char *s = lua_tostring(ls, 1);
if (s)
{
@@ -1783,7 +1785,7 @@ static int crawl_read_options(lua_State *ls)
{
if (!lua_isstring(ls, 1))
return (0);
-
+
const char* filename = lua_tostring(ls, 1);
FILE* f = fopen( filename, "r" );
if (f)
@@ -1830,7 +1832,7 @@ static int crawl_msgch_num(lua_State *ls)
int ch = str_to_channel(s);
if (ch == -1)
return (0);
-
+
lua_pushnumber(ls, ch);
return (1);
}
@@ -1852,8 +1854,8 @@ static int crawl_regex(lua_State *ls)
if (!s)
return (0);
-
- text_pattern **tpudata =
+
+ text_pattern **tpudata =
clua_new_userdata< text_pattern* >(ls, REGEX_METATABLE);
if (tpudata)
{
@@ -1865,11 +1867,11 @@ static int crawl_regex(lua_State *ls)
static int crawl_regex_find(lua_State *ls)
{
- text_pattern **pattern =
+ text_pattern **pattern =
clua_get_userdata< text_pattern* >(ls, REGEX_METATABLE);
if (!pattern)
return (0);
-
+
const char *text = luaL_checkstring(ls, -1);
if (!text)
return (0);
@@ -1881,7 +1883,7 @@ static int crawl_regex_find(lua_State *ls)
static int crawl_regex_gc(lua_State *ls)
{
text_pattern **pattern =
- static_cast<text_pattern **>( lua_touserdata(ls, 1) );
+ static_cast<text_pattern **>( lua_touserdata(ls, 1) );
if (pattern)
delete *pattern;
return (0);
@@ -1900,7 +1902,7 @@ static int crawl_message_filter(lua_State *ls)
return (0);
int num = lua_isnumber(ls, 2)? luaL_checkint(ls, 2) : -1;
- message_filter **mf =
+ message_filter **mf =
clua_new_userdata< message_filter* >( ls, MESSF_METATABLE );
if (mf)
{
@@ -1912,11 +1914,11 @@ static int crawl_message_filter(lua_State *ls)
static int crawl_messf_matches(lua_State *ls)
{
- message_filter **mf =
+ message_filter **mf =
clua_get_userdata< message_filter* >(ls, MESSF_METATABLE);
if (!mf)
return (0);
-
+
const char *pattern = luaL_checkstring(ls, 2);
int ch = luaL_checkint(ls, 3);
if (pattern)
@@ -1960,7 +1962,7 @@ static int crawl_split(lua_State *ls)
*token = luaL_checkstring(ls, 2);
if (!s || !token)
return (0);
-
+
std::vector<std::string> segs = split_string(token, s);
lua_newtable(ls);
for (int i = 0, count = segs.size(); i < count; ++i)
@@ -2084,7 +2086,7 @@ struct option_handler
ohandler handler;
};
-static int option_hboolean(lua_State *ls, const char *name, void *data,
+static int option_hboolean(lua_State *ls, const char *name, void *data,
bool get)
{
if (get)
@@ -2125,7 +2127,7 @@ static option_handler handlers[] =
{ "target_zero_exp", &Options.target_zero_exp, option_hboolean },
{ "target_wrap", &Options.target_wrap, option_hboolean },
{ "easy_exit_menu", &Options.easy_exit_menu, option_hboolean },
- { "dos_use_background_intensity", &Options.dos_use_background_intensity,
+ { "dos_use_background_intensity", &Options.dos_use_background_intensity,
option_hboolean },
};
@@ -2157,7 +2159,7 @@ static int option_get(lua_State *ls)
lua_pushstring(ls, ov.c_str());
return (1);
}
-
+
const option_handler *oh = get_handler(opt);
if (oh)
return (oh->handler(ls, opt, oh->data, true));
@@ -2271,14 +2273,14 @@ static int monster_set(lua_State *ls)
return (0);
}
-static int push_activity_interrupt(lua_State *ls, activity_interrupt_data *t)
+static int push_activity_interrupt(lua_State *ls, activity_interrupt_data *t)
{
if (!t->data)
{
lua_pushnil(ls);
return 0;
}
-
+
switch (t->apt)
{
case AIP_HP_LOSS:
@@ -2396,7 +2398,7 @@ struct lua_pat_op
{
const char *token;
const char *luatok;
-
+
bool pretext; // Does this follow a pattern?
bool posttext; // Is this followed by a pattern?
};
@@ -2500,7 +2502,7 @@ bool lua_text_pattern::translate() const
{
return (false);
}
-
+
std::string textp;
std::string luafn;
const lua_pat_op *currop = NULL;
@@ -2519,7 +2521,7 @@ bool lua_text_pattern::translate() const
textp.erase(0, textp.find_first_not_of(" \r\n\t"));
pre_pattern(textp, luafn);
}
-
+
currop = &lop;
luafn += lop.luatok;
@@ -2588,7 +2590,7 @@ static void *clua_allocator(void *ud, void *ptr, size_t osize, size_t nsize)
if (nsize > osize && cl->memory_used >= CLUA_MAX_MEMORY_USE * 1024
&& cl->mixed_call_depth)
return (NULL);
-
+
if (!nsize)
{
free(ptr);
@@ -2606,7 +2608,7 @@ static void clua_throttle_hook(lua_State *ls, lua_Debug *dbg)
// fudge it.
if (!lua)
lua = &clua;
-
+
if (lua)
{
if (!lua->throttle_sleep_ms)
@@ -2655,7 +2657,7 @@ CLua *lua_call_throttle::find_clua(lua_State *ls)
//
// If we did not intercept pcall, the script could do the equivalent
// of this:
-//
+//
// while true do
// pcall(function () while true do end end)
// end
@@ -2676,7 +2678,7 @@ static int clua_guarded_pcall(lua_State *ls)
if (!errs || strstr(errs, BUGGY_SCRIPT_ERROR))
luaL_error(ls, errs? errs : BUGGY_PCALL_ERROR);
}
-
+
lua_pushboolean(ls, !err);
lua_insert(ls, 1);
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index bd1d677599..a9e0ec6f98 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -18,13 +18,13 @@
#include "debug.h"
#include <iostream>
-
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include <ctype.h>
+#include <algorithm>
#ifdef UNIX
#include <errno.h>
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index 1728208b5a..e14fb359e8 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -13,6 +13,7 @@
#include "decks.h"
#include <iostream>
+#include <algorithm>
#include "externs.h"
diff --git a/crawl-ref/source/direct.cc b/crawl-ref/source/direct.cc
index 0ad13a4b28..31bf2c580d 100644
--- a/crawl-ref/source/direct.cc
+++ b/crawl-ref/source/direct.cc
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+#include <algorithm>
#ifdef DOS
#include <conio.h>
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index c2a3424072..1ce6162c22 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -30,6 +30,7 @@
#include <time.h>
#include <set>
#include <sstream>
+#include <algorithm>
#include "AppHdr.h"
#include "abyss.h"
@@ -297,7 +298,7 @@ bool builder(int level_number, int level_type)
{
const std::set<std::string> uniq_tags = you.uniq_map_tags;
const std::set<std::string> uniq_names = you.uniq_map_names;
-
+
// N tries to build the level, after which we bail with a capital B.
int tries = 20;
while (tries-- > 0)
@@ -305,16 +306,16 @@ bool builder(int level_number, int level_type)
#ifdef DEBUG_DIAGNOSTICS
mapgen_report_map_build_start();
#endif
-
+
dgn_level_vetoed = false;
-
+
_reset_level();
// If we're getting low on available retries, disable random vaults
// and minivaults (special levels will still be placed).
if (tries < 5)
use_random_maps = false;
-
+
_build_dungeon_level(level_number, level_type);
_dgn_set_floor_colours();
@@ -495,7 +496,7 @@ static bool _dgn_fill_zone(
bool ret = false;
std::list<coord_def> points[2];
int cur = 0;
-
+
// No bounds checks, assuming the level has at least one layer of
// rock border.
@@ -510,14 +511,14 @@ static bool _dgn_fill_zone(
if (iswanted && iswanted(c))
ret = true;
-
+
for (int yi = -1; yi <= 1; ++yi)
{
for (int xi = -1; xi <= 1; ++xi)
{
if (!xi && !yi)
continue;
-
+
const coord_def cp(c.x + xi, c.y + yi);
if (!map_bounds(cp)
|| travel_point_distance[cp.x][cp.y] || !passable(cp))
@@ -533,7 +534,7 @@ static bool _dgn_fill_zone(
points[cur].clear();
cur = !cur;
}
- return (ret);
+ return (ret);
}
static bool _is_exit_stair(const coord_def &c)
@@ -555,15 +556,15 @@ static bool _is_exit_stair(const coord_def &c)
// vault).
//
// Before:
-//
+//
// xxxxx xxxxx
// x<..x x.2.x
// x.1.x xxxxx 3 isolated zones
// x>..x x.3.x
// xxxxx xxxxx
-//
+//
// After:
-//
+//
// xxxxx xxxxx
// x<1.x x.2.x
// VVVVVVVVVVoooV 3 isolated zones, but the isolated zones are different.
@@ -596,7 +597,7 @@ static int _dgn_count_disconnected_zones(bool choose_stairless)
// If we want only stairless zones, screen out zones that did
// have stairs.
if (choose_stairless && found_exit_stair)
- --nzones;
+ --nzones;
}
return (nzones);
@@ -615,7 +616,7 @@ static void _fixup_pandemonium_stairs()
else
grd[i][j] = DNGN_FLOOR;
}
-
+
if (grd[i][j] >= DNGN_ENTER_LABYRINTH
&& grd[i][j] <= DNGN_ESCAPE_HATCH_DOWN)
{
@@ -637,7 +638,7 @@ static void _mask_vault(const vault_placement &place, unsigned mask)
static void _register_place(const vault_placement &place)
{
_dgn_register_vault(place.map);
-
+
_mask_vault(place, MMT_VAULT | MMT_NO_DOOR);
if (place.map.has_tag("no_monster_gen"))
_mask_vault(place, MMT_NO_MONS);
@@ -665,7 +666,7 @@ static void _register_place(const vault_placement &place)
dgn_Map_Mask[x][y] &= ~((short)spec->map_mask.flags_unset);
}
}
-
+
set_branch_flags(place.map.branch_flags.flags_set, true);
unset_branch_flags(place.map.branch_flags.flags_unset, true);
@@ -734,7 +735,7 @@ static void _reset_level()
dgn_Build_Method.clear();
level_clear_vault_memory();
dgn_colour_grid.reset(NULL);
-
+
vault_chance = 9;
minivault_chance = 3;
use_random_maps = true;
@@ -844,7 +845,7 @@ static int _num_mons_wanted(int level_type)
mon_wanted += roll_dice( 3, 8 );
else if (player_in_branch( BRANCH_HALL_OF_BLADES ))
mon_wanted += roll_dice( 6, 8 );
-
+
if (mon_wanted > 60)
mon_wanted = 60;
@@ -954,7 +955,7 @@ static void _fixup_duplicate_stairs()
for (int y = 1; y < GYM; y++)
{
const coord_def c(x,y);
- if (grd(c) >= DNGN_STONE_STAIRS_DOWN_I &&
+ if (grd(c) >= DNGN_STONE_STAIRS_DOWN_I &&
grd(c) <= DNGN_STONE_STAIRS_DOWN_III &&
num_down_stairs < max_stairs)
{
@@ -1047,12 +1048,12 @@ static void _fixup_duplicate_stairs()
{
int s1 = s % num_stairs;
int s2 = (s1 + 1) % num_stairs;
- ASSERT(grd(stair_list[s2]) >= base &&
+ ASSERT(grd(stair_list[s2]) >= base &&
grd(stair_list[s2]) <= base + 3);
if (grd(stair_list[s1]) == grd(stair_list[s2]))
{
- grd(stair_list[s2]) = (dungeon_feature_type)(base +
+ grd(stair_list[s2]) = (dungeon_feature_type)(base +
(grd(stair_list[s2])-base+1) % 3);
}
}
@@ -1122,7 +1123,7 @@ static void _build_dungeon_level(int level_number, int level_type)
{
return;
}
-
+
// hook up the special room (if there is one, and it hasn't
// been hooked up already in roguey_level())
if (sr.created && !sr.hooked_up)
@@ -1140,7 +1141,7 @@ static void _build_dungeon_level(int level_number, int level_type)
if (dgn_level_vetoed)
return;
-
+
_check_doors();
if (!player_in_branch( BRANCH_DIS ) && !player_in_branch( BRANCH_VAULTS ))
@@ -1154,7 +1155,7 @@ static void _build_dungeon_level(int level_number, int level_type)
// Any further vaults must make sure not to disrupt level layout.
dgn_check_connectivity = true;
-
+
// Try to place minivaults that really badly want to be placed. Still
// no guarantees, seeing this is a minivault.
if (!player_in_branch(BRANCH_SHOALS))
@@ -1169,13 +1170,13 @@ static void _build_dungeon_level(int level_number, int level_type)
// any vault-placement activity must happen before this check.
_dgn_verify_connectivity(nvaults);
-
+
if (dgn_level_vetoed)
return;
-
+
_place_traps(level_number);
_place_fog_machines(level_number);
-
+
// place items
_builder_items(level_number, level_type, _num_items_wanted(level_number));
@@ -1345,7 +1346,7 @@ static int _count_feature_in_box(int x0, int y0, int x1, int y1,
if ( grd[i][j] == feat )
++result;
}
-
+
return result;
}
@@ -1423,18 +1424,18 @@ static void _place_base_islands(int margin, int num_islands, int estradius,
b = std::min(b, (GYM - margin) / 2);
int a = b + roll_dice(2,b)/3; // more wide than tall
- a = std::min(a, (GXM - margin) / 2);
-
+ a = std::min(a, (GXM - margin) / 2);
+
int island_distance = estradius*estradius * (2 + num_islands/3);
-
+
bool centre_ok;
do
{
centre_ok = true;
centres[i].x = a + random2(GXM-2*a-1);
- centres[i].y = b + random2(GYM-2*b-1);
-
+ centres[i].y = b + random2(GYM-2*b-1);
+
for (int j = 0; j < i; ++j)
{
// calculate the distance from the centers of
@@ -1444,13 +1445,13 @@ static void _place_base_islands(int margin, int num_islands, int estradius,
{
centre_ok = false;
break;
- }
+ }
}
if ( random2(num_islands) && island_distance )
--island_distance;
}
while ( !centre_ok );
-
+
// place an ellipse around the new coordinate
_place_ellipse( centres[i].x, centres[i].y, a, b, DNGN_FLOOR, margin);
}
@@ -1466,7 +1467,7 @@ static void _prepare_shoals(int level_number)
const bool at_bottom = (your_branch().depth == player_branch_depth());
int num_islands = player_branch_depth() + 1;
-
+
if ( at_bottom )
num_islands += random2(3);
@@ -1479,16 +1480,16 @@ static void _prepare_shoals(int level_number)
for (int x = margin; x < GXM-margin; ++x)
for (int y = margin; y < GYM-margin; ++y)
grd[x][y] = DNGN_DEEP_WATER;
-
+
_place_base_islands(margin, num_islands, estradius, centres);
}
while ( ++num_tries < 100 && _count_connected(margin) != num_islands );
-
+
#ifdef DEBUG_DIAGNOSTICS
mprf(MSGCH_DIAGNOSTICS, "Num tries: %d Connected components: %d",
num_tries, _count_connected(margin));
#endif
-
+
// Adding shallow water at deep water adjacent to floor.
// Randomisation: place shallow water if at least 1d(1d3) floor neighbours
for ( int i = margin; i < GXM - margin; ++i)
@@ -1503,7 +1504,7 @@ static void _prepare_shoals(int level_number)
for (int banks = 0; banks < 8; ++banks)
{
int xsize = 3+random2(3); // random rectangle
- int ysize = 3+random2(3);
+ int ysize = 3+random2(3);
int xb = random2(GXM - 2 * margin - 10) + margin + 2;
int yb = random2(GYM - 2 * margin - 10) + margin + 2;
@@ -1557,7 +1558,7 @@ static void _prepare_shoals(int level_number)
grd[centres[0].x ][centres[0].y] = DNGN_STONE_STAIRS_UP_I;
grd[centres[0].x+1][centres[0].y] = DNGN_STONE_STAIRS_UP_II;
grd[centres[0].x-1][centres[0].y] = DNGN_STONE_STAIRS_UP_III;
-
+
// Place the rune
int vaultidx;
do
@@ -1579,14 +1580,14 @@ static void _prepare_shoals(int level_number)
}
while ( vaultidx == -1
|| map_by_index(vaultidx)->has_tag("has_rune") );
-
+
_build_minivaults( level_number, vaultidx, true, false, false,
centres[i] );
}
}
else
{
- // Place stairs randomly. No elevators.
+ // Place stairs randomly. No elevators.
for ( int i = 0; i < 3; ++i )
{
int x, y;
@@ -1596,10 +1597,10 @@ static void _prepare_shoals(int level_number)
y = random2(GYM);
}
while ( grd[x][y] != DNGN_FLOOR );
-
+
grd[x][y]
= static_cast<dungeon_feature_type>(DNGN_STONE_STAIRS_DOWN_I + i);
-
+
do
{
x = random2(GXM);
@@ -1654,7 +1655,7 @@ static void _prepare_water( int level_number )
{
if (!unforbidden(coord_def(i, j), MMT_NO_POOL))
continue;
-
+
if (grd[i][j] == DNGN_DEEP_WATER)
{
for (k = -1; k < 2; k++)
@@ -1665,7 +1666,7 @@ static void _prepare_water( int level_number )
// must come first {dlb}
if (which_grid == DNGN_SHALLOW_WATER
- && one_chance_in( 8 + level_number ))
+ && one_chance_in( 8 + level_number ))
{
grd[i][j] = DNGN_SHALLOW_WATER;
}
@@ -1747,7 +1748,7 @@ static builder_rc_type _builder_by_type(int level_number, char level_type)
_portal_vault_level(level_number);
return (BUILD_QUIT);
}
-
+
if (level_type == LEVEL_LABYRINTH)
{
_labyrinth_level(level_number);
@@ -1789,7 +1790,7 @@ static builder_rc_type _builder_by_type(int level_number, char level_type)
"mnoleg", "lom_lobon", "cerebov", "gloorx_vloq"
};
- const int vault =
+ const int vault =
random_map_for_tag(pandemon_level_names[which_demon], false);
ASSERT(vault != -1);
@@ -1807,7 +1808,7 @@ static builder_rc_type _builder_by_type(int level_number, char level_type)
// never output because of above assert
// if (vault == -1)
// end(1, false, "Failed to build Pandemonium minivault!\n");
-
+
_build_minivaults(level_number, vault);
}
@@ -1907,7 +1908,7 @@ static int _dgn_random_map_for_place(bool wantmini)
{
const level_id lid = level_id::current();
int vault = random_map_for_place(lid, wantmini);
-
+
// disallow entry vaults for tutorial (complicates things)
if (vault == -1
&& lid.branch == BRANCH_MAIN_DUNGEON
@@ -1958,7 +1959,7 @@ static void _place_minivaults(const std::string &tag, int lo, int hi, bool force
if (lo == -1)
lo = hi = 1;
-
+
int nvaults = random_range(lo, hi);
if (!tag.empty())
{
@@ -1967,7 +1968,7 @@ static void _place_minivaults(const std::string &tag, int lo, int hi, bool force
const int vault = random_map_for_tag(tag, true);
if (vault == -1)
return;
-
+
_build_minivaults(you.your_level, vault);
}
return;
@@ -1983,7 +1984,7 @@ static void _place_minivaults(const std::string &tag, int lo, int hi, bool force
used.insert(vault);
}
}
-
+
int chance = you.your_level == 0? 50 : 100;
while ((chance && random2(100) < chance) || nvaults-- > 0)
{
@@ -1998,7 +1999,7 @@ static void _place_minivaults(const std::string &tag, int lo, int hi, bool force
{
break;
}
-
+
_build_minivaults(you.your_level, vault);
used.insert(vault);
chance /= 4;
@@ -2029,7 +2030,7 @@ static builder_rc_type _builder_normal(int level_number, char level_type,
// but only ORIENT: encompass primary vaults in other
// branches. Other kinds of vaults can still be placed in
// other branches as secondary vaults.
- //
+ //
if (vault != -1 && !player_in_branch(BRANCH_MAIN_DUNGEON)
&& map_by_index(vault)->orient != MAP_ENCOMPASS)
{
@@ -2231,7 +2232,7 @@ static void _builder_extras( int level_number, int level_type )
= (one_chance_in( 5 + level_number ) ? DNGN_SHALLOW_WATER
: DNGN_DEEP_WATER);
- if (level_number > 11
+ if (level_number > 11
&& (one_chance_in(5) || (level_number > 15 && !one_chance_in(5))))
{
river_type = DNGN_LAVA;
@@ -2243,7 +2244,7 @@ static void _builder_extras( int level_number, int level_type )
if (coinflip())
_build_river( river_type );
- else
+ else
_build_lake( river_type );
}
else if (player_in_branch( BRANCH_COCYTUS ))
@@ -2252,7 +2253,7 @@ static void _builder_extras( int level_number, int level_type )
if (coinflip())
_build_river( river_type );
- else
+ else
_build_lake( river_type );
}
@@ -2262,7 +2263,7 @@ static void _builder_extras( int level_number, int level_type )
{
_build_lake( (river_type != DNGN_SHALLOW_WATER) ? river_type
: DNGN_DEEP_WATER );
- }
+ }
}
static bool _shaft_is_in_corridor(int x, int y)
@@ -2273,7 +2274,7 @@ static bool _shaft_is_in_corridor(int x, int y)
{
return true;
}
-
+
// now check vertical neighbouring squares
if ((!inside_level_bounds(x, y-1) || grd[x][y-1] < DNGN_SHALLOW_WATER)
&& (!inside_level_bounds(x, y+1) || grd[x][y+1] < DNGN_SHALLOW_WATER))
@@ -2312,7 +2313,7 @@ static void _place_traps(int level_number)
trap_type &trap_type = env.trap[i].type;
trap_type = random_trap_for_place(level_number);
-
+
if (trap_type == TRAP_SHAFT && level_number <= 7)
{
// Disallow shaft construction in corridors!
@@ -2320,7 +2321,7 @@ static void _place_traps(int level_number)
{
// choose again!
trap_type = random_trap_for_place(level_number);
-
+
// If we get shaft a second time, turn it into an alarm trap.
if (trap_type == TRAP_SHAFT)
trap_type = TRAP_ALARM;
@@ -2404,7 +2405,7 @@ static void _place_extra_vaults()
// ORIENT: encompass maps are unsuitable as secondary vaults.
if (vault != -1 && map_by_index(vault)->orient == MAP_ENCOMPASS)
vault = -1;
-
+
if (vault != -1 && _build_secondary_vault(you.your_level, vault, -1))
vault_chance = 0;
}
@@ -2460,7 +2461,7 @@ static void _place_branch_entrances(int dlevel, char level_type)
std::string entry_tag = std::string(branches[i].abbrevname);
entry_tag += "_entry";
lowercase(entry_tag);
-
+
_place_specific_stair( branches[i].entry_stairs, entry_tag, dlevel);
}
}
@@ -2479,8 +2480,8 @@ static void _make_trail(int xs, int xr, int ys, int yr, int corrlength,
// temp positions
int dir_x = 0;
- int dir_y = 0;
- int dir_x2, dir_y2;
+ int dir_y = 0;
+ int dir_x2, dir_y2;
do
{
@@ -2493,7 +2494,7 @@ static void _make_trail(int xs, int xr, int ys, int yr, int corrlength,
// assign begin feature
if (begin != DNGN_UNSEEN)
grd[x_start][y_start] = begin;
-
+
x_ps = x_start;
y_ps = y_start;
@@ -2750,7 +2751,7 @@ static int _pick_unique(int lev)
{
which_unique = MONS_POLYPHEMUS;
}
-
+
return (which_unique);
}
@@ -2792,7 +2793,7 @@ static int _place_uniques(int level_number, char level_type)
break;
// note: unique_creatures 40 + used by unique demons
- if (place_monster( not_used, which_unique, level_number,
+ if (place_monster( not_used, which_unique, level_number,
BEH_SLEEP, MHITNOT, false, 1, 1, true,
PROX_ANYWHERE, MONS_PROGRAM_BUG, 0, MMT_NO_MONS ))
{
@@ -2813,16 +2814,16 @@ 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(montypes.size())],
- level_number, BEH_SLEEP, MHITNOT,
+ level_number, BEH_SLEEP, MHITNOT,
false, 1, 1, true, PROX_ANYWHERE,
MONS_PROGRAM_BUG, 0, MMT_NO_MONS ))
{
++result;
}
-
+
return result;
}
-
+
static void _place_aquatic_monsters(int level_number, char level_type)
{
@@ -2844,7 +2845,7 @@ static void _place_aquatic_monsters(int level_number, char level_type)
for (int i = 0; i < 4; i++)
{
swimming_things[i] = MONS_LAVA_WORM + random2(3);
- if (one_chance_in(30))
+ if (one_chance_in(30))
swimming_things[i] = MONS_SALAMANDER;
}
@@ -3105,10 +3106,10 @@ static void _fill_monster_pit( spec_room &sr, FixedVector<pit_mons_def,
#if DEBUG_DIAGNOSTICS
for (i = 0; i < num_types; i++)
{
- const int delta = ((i > 0) ? pit_list[i].rare - pit_list[i - 1].rare
+ const int delta = ((i > 0) ? pit_list[i].rare - pit_list[i - 1].rare
: pit_list[i].rare);
- const float perc = (static_cast<float>( delta ) * 100.0)
+ const float perc = (static_cast<float>( delta ) * 100.0)
/ static_cast<float>( rare_sum );
mprf( MSGCH_DIAGNOSTICS, "%6.2f%%: %s", perc,
@@ -3254,10 +3255,10 @@ static void _special_room(int level_number, spec_room &sr)
if (one_chance_in(4))
continue;
- mons_place( mons_alloc[random2(10)], BEH_SLEEP, MHITNOT,
+ mons_place( mons_alloc[random2(10)], BEH_SLEEP, MHITNOT,
true, x, y );
}
-
+
break;
case SROOM_LAIR_KOBOLD:
@@ -3327,8 +3328,8 @@ static void _special_room(int level_number, spec_room &sr)
}
// place guardian {dlb}:
- mons_place( MONS_GUARDIAN_NAGA, BEH_SLEEP, MHITNOT, true,
- sr.x1 + random2( sr.x2 - sr.x1 ),
+ mons_place( MONS_GUARDIAN_NAGA, BEH_SLEEP, MHITNOT, true,
+ sr.x1 + random2( sr.x2 - sr.x1 ),
sr.y1 + random2( sr.y2 - sr.y1 ) );
break;
@@ -3382,7 +3383,7 @@ static void _beehive(spec_room &sr)
// the hive is chock full of bees!
- mons_place( one_chance_in(7) ? MONS_KILLER_BEE_LARVA
+ mons_place( one_chance_in(7) ? MONS_KILLER_BEE_LARVA
: MONS_KILLER_BEE,
BEH_SLEEP, MHITNOT, true, x, y );
}
@@ -3434,7 +3435,7 @@ static bool _safe_minivault_place(int v1x, int v1y,
{
if (clobber)
return (true);
-
+
const bool water_ok = place.map.has_tag("water_ok");
const std::vector<std::string> &lines = place.map.map.get_lines();
for (int vx = v1x; vx < v1x + place.size.x; vx++)
@@ -3452,12 +3453,12 @@ static bool _safe_minivault_place(int v1x, int v1y,
// nor water, if !water_ok.
if (_may_overwrite_feature(dfeat, water_ok))
return (false);
-
+
// Don't overwrite items or monsters, either!
if (igrd[vx][vy] != NON_ITEM || mgrd[vx][vy] != NON_MONSTER)
return (false);
}
-
+
return (true);
}
@@ -3467,13 +3468,13 @@ static bool _connected_minivault_place(int v1x, int v1y,
/* must not be completely isolated: */
const bool water_ok = place.map.has_tag("water_ok");
const std::vector<std::string> &lines = place.map.map.get_lines();
-
+
for (int vx = v1x; vx < v1x + place.size.x; vx++)
for (int vy = v1y; vy < v1y + place.size.y; vy++)
{
if (lines[vy - v1y][vx - v1x] == ' ')
continue;
-
+
// Overwrite floor, doors or water, but not rock walls.
if (_may_overwrite_feature(grd[vx][vy], water_ok, false))
return (true);
@@ -3521,7 +3522,7 @@ static bool _build_minivaults(int level_number, int force_vault,
if (dgn_check_connectivity && !dgn_zones)
dgn_zones = _dgn_count_disconnected_zones(false);
-
+
map_type vgrid;
vault_placement place;
vault_main(vgrid, place, force_vault);
@@ -3548,12 +3549,12 @@ static bool _build_minivaults(int level_number, int force_vault,
#endif
_register_place(place);
-
+
// these two are throwaways:
int num_runes = 0;
std::vector<coord_def> &target_connections = place.exits;
-
+
// paint the minivault onto the grid
for (int vx = v1x; vx < v1x + place.size.x; vx++)
for (int vy = v1y; vy < v1y + place.size.y; vy++)
@@ -3584,7 +3585,7 @@ static bool _build_minivaults(int level_number, int force_vault,
{
if (target_connections.empty() && place.map.has_tag("mini_float"))
_pick_float_exits(place, target_connections);
-
+
if (!target_connections.empty())
_connect_vault(place);
}
@@ -3630,7 +3631,7 @@ static void _build_rooms(const dgn_region_list &excluded,
if (_join_the_dots(c, myroom.random_edge_point(), MMT_VAULT))
connections.erase( connections.begin() );
}
-
+
if (i > 0 && exclusive)
{
const coord_def end = myroom.end();
@@ -3685,7 +3686,7 @@ static coord_def _dig_away_dir(const vault_placement &place,
const coord_def &pos)
{
// Figure out which way we need to go to dig our way out of the vault.
- bool x_edge =
+ bool x_edge =
pos.x == place.pos.x || pos.x == place.pos.x + place.size.x - 1;
bool y_edge =
pos.y == place.pos.y || pos.y == place.pos.y + place.size.y - 1;
@@ -3713,7 +3714,7 @@ static coord_def _dig_away_dir(const vault_placement &place,
else
y_edge = false;
}
-
+
coord_def dig_dir;
if (x_edge)
{
@@ -3745,11 +3746,11 @@ static void _dig_away_from(vault_placement &place, const coord_def &pos)
coord_def dig_dir = _dig_away_dir(place, pos);
coord_def dig_at = pos;
bool dug = false;
-
+
for (int i = 0; i < GXM; i++)
{
dig_at += dig_dir;
-
+
if (dig_at.x < MAPGEN_BORDER || dig_at.x > (GXM - MAPGEN_BORDER - 1)
|| dig_at.y < MAPGEN_BORDER || dig_at.y > (GYM - MAPGEN_BORDER - 1))
{
@@ -3805,7 +3806,7 @@ static bool _map_grid_is_on_edge(const vault_placement &place,
if (!place.map.in_map(coord_def(xi, yi) - place.pos))
return (true);
}
-
+
return (false);
}
@@ -3840,7 +3841,7 @@ static void _pick_float_exits(vault_placement &place,
{
if (_grid_needs_exit(x, place.pos.y))
possible_exits.push_back( coord_def(x, place.pos.y) );
-
+
if (_grid_needs_exit(x, place.pos.y + place.size.y - 1))
{
possible_exits.push_back(
@@ -3877,7 +3878,7 @@ static std::vector<coord_def> _external_connection_points(
const std::vector<coord_def> &target_connections)
{
std::vector<coord_def> ex_connection_points;
-
+
// Giving target_connections directly to build_rooms causes
// problems with long, skinny vaults where paths to the exit
// tend to cut through the vault. By backing out of the vault
@@ -3925,12 +3926,12 @@ static dungeon_feature_type _dgn_find_rune_subst(const std::string &tag)
{
const std::string suffix("_entry");
const std::string::size_type psuffix = tag.find(suffix);
-
+
if (psuffix == std::string::npos)
return (DNGN_FLOOR);
-
+
const std::string key = tag.substr(0, psuffix);
-
+
if (key == "bzr")
return (DNGN_ENTER_PORTAL_VAULT);
else if (key == "lab")
@@ -3966,14 +3967,14 @@ static dungeon_feature_type _dgn_find_rune_subst_tags(const std::string &tags)
}
// Places a map on the current level (minivault or regular vault).
-//
+//
// You can specify the centre of the map using "where" for floating vaults
// and minivaults. "where" is ignored for other vaults. XXX: it might be
// nice to specify a square that is not the centre, but is identified by
// a marker in the vault to be placed.
//
// NOTE: encompass maps will destroy the existing level!
-//
+//
// generating_level: If true, assumes that this is in the middle of normal
// level generation, and does not link items or handle
// changing terrain.
@@ -3984,7 +3985,7 @@ bool dgn_place_map(int map, bool generating_level, bool clobber,
bool make_no_exits, const coord_def &where)
{
const dgn_colour_override_manager colour_man;
-
+
const map_def *mdef = map_by_index(map);
bool did_map = false;
bool fixup = false;
@@ -4051,7 +4052,7 @@ bool dgn_place_map(int map, bool generating_level, bool clobber,
if (fixup || !generating_level)
setup_environment_effects();
-
+
return (did_map);
}
@@ -4098,14 +4099,14 @@ static bool _build_vaults(int level_number, int force_vault, int rune_subst,
if (dgn_check_connectivity && !dgn_zones)
dgn_zones = _dgn_count_disconnected_zones(false);
-
+
map_type vgrid;
vault_placement place;
std::vector<coord_def> &target_connections = place.exits;
if (map_bounds(where))
place.pos = where;
-
+
const int gluggy = vault_main(vgrid, place, force_vault,
check_collisions, clobber);
@@ -4161,7 +4162,7 @@ static bool _build_vaults(int level_number, int force_vault, int rune_subst,
#ifdef DEBUG_DIAGNOSTICS
if (crawl_state.map_stat_gen)
mapgen_report_map_use(place.map);
-#endif
+#endif
// If the map takes the whole screen or we were only requested to
// build the vault, our work is done.
@@ -4195,7 +4196,7 @@ static bool _build_vaults(int level_number, int force_vault, int rune_subst,
excluded_regions.push_back( dgn_region::absolute(v1x, v1y, v2x, v2y) );
int nrooms = random_range(15, 90);
-
+
// Try harder for floating vaults, which tend to complicate room
// building somewhat.
if (gluggy == MAP_FLOAT)
@@ -4203,7 +4204,7 @@ static bool _build_vaults(int level_number, int force_vault, int rune_subst,
std::vector<coord_def> ex_connection_points =
_external_connection_points(place, target_connections);
-
+
_build_rooms(excluded_regions, ex_connection_points, nrooms);
// Excavate and connect the vault to the rest of the level.
@@ -4244,7 +4245,7 @@ static bool _build_vaults(int level_number, int force_vault, int rune_subst,
j + ((i == 0) ? DNGN_STONE_STAIRS_DOWN_I
: DNGN_STONE_STAIRS_UP_I));
- if (stair_exist[stair - DNGN_STONE_STAIRS_DOWN_I] == 1)
+ if (stair_exist[stair - DNGN_STONE_STAIRS_DOWN_I] == 1)
continue;
do
@@ -4285,9 +4286,9 @@ static void _dgn_place_item_explicit(const item_spec &spec,
}
const int item_made =
- items( spec.allow_uniques, spec.base_type, spec.sub_type, true,
+ items( spec.allow_uniques, spec.base_type, spec.sub_type, true,
level, spec.race, 0, spec.ego );
-
+
if (item_made != NON_ITEM && item_made != -1)
{
mitm[item_made].x = x;
@@ -4311,7 +4312,7 @@ static void _dgn_place_item_explicit(int index, int x, int y,
int level)
{
item_list &sitems = place.map.items;
-
+
if (index < 0 || index >= static_cast<int>(sitems.size()))
{
// Non-fatal, but we warn even in non-debug mode so there's incentive
@@ -4413,7 +4414,7 @@ static void _dgn_give_mon_spec_items(mons_spec &mspec,
}
}
}
-
+
bool dgn_place_monster(mons_spec &mspec,
int monster_level, int vx, int vy,
@@ -4462,7 +4463,7 @@ bool dgn_place_monster(mons_spec &mspec,
}
return (placed);
}
- return (false);
+ return (false);
}
static bool _dgn_place_monster( const vault_placement &place, mons_spec &mspec,
@@ -4470,7 +4471,7 @@ static bool _dgn_place_monster( const vault_placement &place, mons_spec &mspec,
{
const bool generate_awake
= mspec.generate_awake || place.map.has_tag("generate_awake");
-
+
return dgn_place_monster(mspec, monster_level, vx, vy, generate_awake);
}
@@ -4506,7 +4507,7 @@ dungeon_feature_type map_feature(map_def *map, const coord_def &c, int rawfeat)
if (rawfeat == ' ')
return (NUM_FEATURES);
-
+
keyed_mapspec *mapsp = map? map->mapspec_for_key(rawfeat) : NULL;
if (mapsp)
{
@@ -4529,7 +4530,7 @@ dungeon_feature_type map_feature(map_def *map, const coord_def &c, int rawfeat)
(rawfeat == 'v') ? DNGN_METAL_WALL :
(rawfeat == 'b') ? DNGN_GREEN_CRYSTAL_WALL :
(rawfeat == 'a') ? DNGN_WAX_WALL :
- (rawfeat == 'm') ? DNGN_CLEAR_ROCK_WALL :
+ (rawfeat == 'm') ? DNGN_CLEAR_ROCK_WALL :
(rawfeat == 'n') ? DNGN_CLEAR_STONE_WALL :
(rawfeat == 'o') ? DNGN_CLEAR_PERMAROCK_WALL :
(rawfeat == '+') ? DNGN_CLOSED_DOOR :
@@ -4546,7 +4547,7 @@ dungeon_feature_type map_feature(map_def *map, const coord_def &c, int rawfeat)
(rawfeat == ']') ? DNGN_STONE_STAIRS_DOWN_III :
(rawfeat == '[') ? DNGN_STONE_STAIRS_UP_III :
(rawfeat == 'A') ? DNGN_STONE_ARCH :
- (rawfeat == 'B') ? DNGN_ALTAR_ZIN :
+ (rawfeat == 'B') ? DNGN_ALTAR_ZIN :
(rawfeat == 'C') ? _pick_an_altar() : // f(x) elsewhere {dlb}
(rawfeat == 'F') ? DNGN_GRANITE_STATUE :
(rawfeat == 'I') ? DNGN_ORCISH_IDOL :
@@ -4598,7 +4599,7 @@ static int _vault_grid( vault_placement &place,
const trap_type trap
= (f.trap == TRAP_INDEPTH) ? random_trap_for_place(level_number)
: static_cast<trap_type>(f.trap);
-
+
place_specific_trap(vx, vy, trap);
}
else
@@ -4619,7 +4620,7 @@ static int _vault_grid( vault_placement &place,
place_monster( not_used, _random_evil_statue(), 30, BEH_HOSTILE,
MHITNOT, true, vx, vy, false);
}
-
+
// first, set base tile for grids {dlb}:
grd[vx][vy] = ((vgrid == -1) ? grd[vx][vy] :
(vgrid == 'x') ? DNGN_ROCK_WALL :
@@ -4628,7 +4629,7 @@ static int _vault_grid( vault_placement &place,
(vgrid == 'v') ? DNGN_METAL_WALL :
(vgrid == 'b') ? DNGN_GREEN_CRYSTAL_WALL :
(vgrid == 'a') ? DNGN_WAX_WALL :
- (vgrid == 'm') ? DNGN_CLEAR_ROCK_WALL :
+ (vgrid == 'm') ? DNGN_CLEAR_ROCK_WALL :
(vgrid == 'n') ? DNGN_CLEAR_STONE_WALL :
(vgrid == 'o') ? DNGN_CLEAR_PERMAROCK_WALL :
(vgrid == '+') ? DNGN_CLOSED_DOOR :
@@ -4724,7 +4725,7 @@ static int _vault_grid( vault_placement &place,
which_class = OBJ_ORBS;
which_type = ORB_ZOT;
}
- else if (vgrid == '|'
+ else if (vgrid == '|'
|| (vgrid == 'P' && (!possible_rune || num_runes > 0))
|| (vgrid == 'O' && num_runes > 0))
{
@@ -4738,7 +4739,7 @@ static int _vault_grid( vault_placement &place,
grd[vx][vy] = static_cast<dungeon_feature_type>(rune_subst);
break;
}
-
+
which_class = OBJ_MISCELLANY;
which_type = MISC_RUNE_OF_ZOT;
num_runes++;
@@ -4758,7 +4759,7 @@ static int _vault_grid( vault_placement &place,
}
else if (you.level_type == LEVEL_ABYSS)
spec = RUNE_ABYSSAL;
- else
+ else
spec = you.where_are_you;
}
@@ -4767,7 +4768,7 @@ static int _vault_grid( vault_placement &place,
which_depth = MAKE_GOOD_ITEM;
else if (vgrid == '*')
which_depth = 5 + (level_number * 2);
-
+
item_made = items( 1, which_class, which_type, true,
which_depth, spec );
@@ -4870,7 +4871,7 @@ struct coord_comparator
const coord_def del = a - b;
return std::abs(del.x) * GYM + std::abs(del.y);
}
-
+
bool operator () (const coord_def &a, const coord_def &b) const
{
return dist(a, target) < dist(b, target);
@@ -4887,7 +4888,7 @@ static void _jtd_init_surrounds(coord_set &coords, unsigned mapmask,
{
if (!xi == !yi)
continue;
-
+
const coord_def cx(c.x + xi, c.y + yi);
if (!in_bounds(cx) || travel_point_distance[cx.x][cx.y]
|| !unforbidden(cx, mapmask))
@@ -4909,15 +4910,15 @@ static bool _join_the_dots_pathfind(coord_set &coords,
{
int &tpd = travel_point_distance[curr.x][curr.y];
tpd = !tpd? -1000 : -tpd;
-
+
if (curr == to)
break;
-
+
_jtd_init_surrounds(coords, mapmask, curr);
if (coords.empty())
break;
-
+
curr = *coords.begin();
coords.erase(coords.begin());
}
@@ -4929,14 +4930,14 @@ static bool _join_the_dots_pathfind(coord_set &coords,
{
if (unforbidden(curr, mapmask))
grd(curr) = DNGN_FLOOR;
-
+
const int dist = travel_point_distance[curr.x][curr.y];
ASSERT(dist < 0 && dist != -1000);
curr += coord_def(-dist / 4 - 2, (-dist % 4) - 2);
}
if (unforbidden(curr, mapmask))
grd(curr) = DNGN_FLOOR;
-
+
return (true);
}
@@ -5026,7 +5027,7 @@ static void _place_pool(dungeon_feature_type pool_type, unsigned char pool_x1,
unsigned char left_edge, right_edge;
// don't place LAVA pools in crypt.. use shallow water instead.
- if (pool_type == DNGN_LAVA
+ if (pool_type == DNGN_LAVA
&& (player_in_branch(BRANCH_CRYPT) || player_in_branch(BRANCH_TOMB)))
{
pool_type = DNGN_SHALLOW_WATER;
@@ -5103,7 +5104,7 @@ static dungeon_feature_type _pick_an_altar()
dungeon_feature_type altar_type;
int temp_rand; // probability determination {dlb}
- if (player_in_branch( BRANCH_SLIME_PITS )
+ if (player_in_branch( BRANCH_SLIME_PITS )
|| player_in_branch( BRANCH_ECUMENICAL_TEMPLE )
|| you.level_type == LEVEL_LABYRINTH)
{
@@ -5247,7 +5248,7 @@ static void _place_altar()
for (int i = px - 2; i <= px + 2; i++)
for (int j = py - 2; j <= py + 2; j++)
grd[i][j] = DNGN_FLOOR;
-
+
grd[px][py] = _pick_an_altar();
break;
}
@@ -5271,7 +5272,7 @@ static void _place_shops(int level_number, int nshops)
nshops = MAX_SHOPS;
#else
nshops = ((temp_rand > 28) ? 0 : // 76.8%
- (temp_rand > 4) ? 1 // 19.2%
+ (temp_rand > 4) ? 1 // 19.2%
: random_range(1, MAX_RANDOM_SHOPS)); // 0.4%
if (nshops == 0 || level_number < 3)
@@ -5316,7 +5317,7 @@ static bool _need_varied_selection(shop_type shop)
return (shop == SHOP_BOOK);
}
-void place_spec_shop( int level_number,
+void place_spec_shop( int level_number,
int shop_x, int shop_y,
int force_s_type, bool representative )
{
@@ -5341,7 +5342,7 @@ void place_spec_shop( int level_number,
env.shop[i].level = level_number * 2;
env.shop[i].type = static_cast<shop_type>(
- (force_s_type != SHOP_RANDOM) ? force_s_type
+ (force_s_type != SHOP_RANDOM) ? force_s_type
: random2(NUM_SHOPS));
if (env.shop[i].type == SHOP_FOOD)
@@ -5356,7 +5357,7 @@ void place_spec_shop( int level_number,
}
else
env.shop[i].greed = 15 + random2avg(19, 2) + random2(level_number);
-
+
// allow bargains in bazaars, prices randomly between 60% and 95%
if (you.level_type == LEVEL_PORTAL_VAULT && you.level_type_name == "bazaar")
{
@@ -5402,7 +5403,7 @@ void place_spec_shop( int level_number,
{
int help = random2(item_level) + 1;
item_level += help;
-
+
if (item_level > level_number * 5)
item_level = level_number * 5;
}
@@ -5516,7 +5517,7 @@ static object_class_type _item_in_shop(unsigned char shop_type)
static void _spotty_level(bool seeded, int iterations, bool boxy)
{
dgn_Build_Method = "spotty_level";
-
+
// assumes starting with a level full of rock walls (1)
int i, j, k, l;
@@ -5525,7 +5526,7 @@ static void _spotty_level(bool seeded, int iterations, bool boxy)
for (i = DNGN_STONE_STAIRS_DOWN_I; i < DNGN_ESCAPE_HATCH_UP; i++)
{
if (i == DNGN_ESCAPE_HATCH_DOWN
- || (i == DNGN_STONE_STAIRS_UP_I
+ || (i == DNGN_STONE_STAIRS_UP_I
&& !player_in_branch( BRANCH_SLIME_PITS )))
{
continue;
@@ -5610,7 +5611,7 @@ static void _spotty_level(bool seeded, int iterations, bool boxy)
static void _bigger_room()
{
dgn_Build_Method = "bigger_room";
-
+
unsigned char i, j;
for (i = 10; i < (GXM - 10); i++)
@@ -5623,7 +5624,7 @@ static void _bigger_room()
_many_pools(DNGN_DEEP_WATER);
if (one_chance_in(3))
- {
+ {
if (coinflip())
_build_river( DNGN_DEEP_WATER );
else
@@ -5645,7 +5646,7 @@ static void _bigger_room()
static void _plan_main(int level_number, int force_plan)
{
dgn_Build_Method = "plan_main";
-
+
// possible values for do_stairs:
// 0 - stairs already done
// 1 - stairs already done, do spotty
@@ -5691,7 +5692,7 @@ static void _plan_main(int level_number, int force_plan)
static char _plan_1()
{
dgn_Build_Method = "plan_1";
-
+
int temp_rand = 0; // probability determination {dlb}
unsigned char width = (10 - random2(7)); // value range of [4,10] {dlb}
@@ -5761,7 +5762,7 @@ static char _plan_1()
static char _plan_2()
{
dgn_Build_Method = "plan_2";
-
+
char width2 = (5 - random2(5)); // value range of [1,5] {dlb}
_replace_area(10, (35 - width2), (GXM - 10), (35 + width2),
@@ -5775,7 +5776,7 @@ static char _plan_2()
static char _plan_3()
{
dgn_Build_Method = "plan_3";
-
+
/* Draws a room, then another and links them together, then another and etc
Of course, this can easily end up looking just like a make_trail level.
*/
@@ -5867,7 +5868,7 @@ static char _plan_4(char forbid_x1, char forbid_y1, char forbid_x2,
char forbid_y2, dungeon_feature_type force_wall)
{
dgn_Build_Method = "plan_4";
-
+
// a more chaotic version of city level
int temp_rand; // req'd for probability checking
@@ -5972,7 +5973,7 @@ static char _plan_4(char forbid_x1, char forbid_y1, char forbid_x2,
static char _plan_5()
{
dgn_Build_Method = "plan_5";
-
+
unsigned char imax = 5 + random2(20); // value range of [5,24] {dlb}
for (unsigned char i = 0; i < imax; i++)
@@ -5992,7 +5993,7 @@ static char _plan_5()
static char _plan_6(int level_number)
{
dgn_Build_Method = "plan_6";
-
+
spec_room sr;
// circle of standing stones (well, kind of)
@@ -6027,11 +6028,11 @@ static char _plan_6(int level_number)
grd[10][35] = DNGN_STONE_STAIRS_UP_II;
grd[10][36] = DNGN_STONE_STAIRS_UP_III;
- // This "back door" is often one of the easier ways to get out of
- // pandemonium... the easiest is to use the banish spell.
+ // This "back door" is often one of the easier ways to get out of
+ // pandemonium... the easiest is to use the banish spell.
//
- // Note, that although "level_number > 20" will work for most
- // trips to pandemonium (through regular portals), it won't work
+ // Note, that although "level_number > 20" will work for most
+ // trips to pandemonium (through regular portals), it won't work
// for demonspawn who gate themselves there. -- bwr
if (((player_in_branch( BRANCH_MAIN_DUNGEON ) && level_number > 20)
|| you.level_type == LEVEL_PANDEMONIUM)
@@ -6048,7 +6049,7 @@ static bool _octa_room(spec_room &sr, int oblique_max,
dungeon_feature_type type_floor)
{
dgn_Build_Method = "octa_room";
-
+
int x,y;
// hack - avoid lava in the crypt {gdl}
@@ -6112,7 +6113,7 @@ static void _find_maze_neighbours(const coord_def &c,
{
if (!!xi == !!yi)
continue;
-
+
const coord_def cp(c.x + xi, c.y + yi);
if (region.contains(cp))
coords.push_back(cp);
@@ -6138,10 +6139,10 @@ static void _labyrinth_maze_recurse(const coord_def &c, const dgn_region &where)
const coord_def &nc = *i;
if (grd(nc) != DNGN_ROCK_WALL)
continue;
-
+
grd(nc) = DNGN_FLOOR;
grd(c + (nc - c) / 2) = DNGN_FLOOR;
-
+
if (!one_chance_in(5))
_labyrinth_maze_recurse(nc, where);
else
@@ -6182,7 +6183,7 @@ static void _labyrinth_place_items(const coord_def &end)
/* (temp_rand == 8) */ : OBJ_STAVES);
const int treasure_item =
- items( 1, glopop, OBJ_RANDOM, true,
+ items( 1, glopop, OBJ_RANDOM, true,
you.your_level * 3, MAKE_ITEM_RANDOM_RACE );
if (treasure_item != NON_ITEM)
@@ -6256,7 +6257,7 @@ static void _change_walls_from_centre(const dgn_region &region,
...)
{
std::vector<dist_feat> ldist;
-
+
va_list args;
va_start(args, wall);
@@ -6346,14 +6347,14 @@ static void _labyrinth_level(int level_number)
LABYRINTH_BORDER,
GXM - LABYRINTH_BORDER - 1,
GYM - LABYRINTH_BORDER - 1 );
-
+
// First decide if we're going to use a Lab minivault.
int vault = random_map_for_tag("minotaur", true, false);
vault_placement place;
-
+
if (vault != -1)
_init_minivault_placement(vault, place);
-
+
coord_def end;
_labyrinth_build_maze(end, lab);
@@ -6384,7 +6385,7 @@ static void _labyrinth_level(int level_number)
place.pos = rplace.pos;
place.size = rplace.size;
}
-
+
if (vault != -1)
end = place.pos + place.size / 2;
@@ -6397,13 +6398,13 @@ static void _labyrinth_level(int level_number)
0);
_labyrinth_place_entry_point(lab, end);
-
+
// turn rock walls into undiggable stone or metal:
// dungeon_feature_type wall_xform =
// ((random2(50) > 10) ? DNGN_STONE_WALL // 78.0%
// : DNGN_METAL_WALL); // 22.0%
//replace_area(0, 0, GXM - 1, GYM - 1, DNGN_ROCK_WALL, wall_xform, vaults);
-
+
link_items();
} // end labyrinth_level()
@@ -6500,7 +6501,7 @@ static int _box_room_doors( int bx1, int bx2, int by1, int by2, int new_doors)
for (i = 0; i < spot_count; i++)
if (good_doors[i] == 1)
j++;
-
+
if (new_doors > j)
new_doors = j;
@@ -7094,7 +7095,7 @@ static void _jelly_pit(int level_number, spec_room &sr)
pit_list[i].type = MONS_PROGRAM_BUG;
pit_list[i].rare = 0;
}
-
+
#if DEBUG_DIAGNOSTICS
mprf( MSGCH_DIAGNOSTICS, "Build: Jelly Pit" );
#endif
@@ -7365,7 +7366,7 @@ static void _build_river( dungeon_feature_type river_type ) //mv
if (player_in_branch( BRANCH_CRYPT ) || player_in_branch( BRANCH_TOMB ))
return;
- // if (one_chance_in(10))
+ // if (one_chance_in(10))
// _build_river(river_type);
// Made rivers less wide... min width five rivers were too annoying. -- bwr
@@ -7445,7 +7446,7 @@ static void _build_lake(dungeon_feature_type lake_type) //mv
if (j >= 5 && j <= GYM - 5 && i >= 5 && i <= GXM - 5)
{
// Note that vaults might have been created in this area!
- // So we'll avoid the silliness of monsters and items
+ // So we'll avoid the silliness of monsters and items
// on lava and deep water grids. -- bwr
if (!one_chance_in(200) && _may_overwrite_pos(i,j))
grd[i][j] = lake_type;
@@ -7511,7 +7512,7 @@ static coord_def _dgn_find_feature_marker(dungeon_feature_type feat)
}
}
coord_def unfound;
- return (unfound);
+ return (unfound);
}
static coord_def _dgn_find_labyrinth_entry_point()
@@ -7529,7 +7530,7 @@ coord_def dgn_find_nearby_stair(dungeon_feature_type stair_to_find,
stair_to_find,
dungeon_feature_name(stair_to_find));
#endif
-
+
if (stair_to_find == DNGN_ESCAPE_HATCH_UP
|| stair_to_find == DNGN_ESCAPE_HATCH_DOWN)
{
@@ -7557,7 +7558,7 @@ coord_def dgn_find_nearby_stair(dungeon_feature_type stair_to_find,
#endif
stair_to_find = DNGN_FLOOR;
}
-
+
if (stair_to_find == your_branch().exit_stairs)
{
const coord_def pos(_dgn_find_feature_marker(DNGN_STONE_STAIRS_UP_I));
@@ -7720,7 +7721,7 @@ bool dgn_region::overlaps(const dgn_region &other) const
{
// The old overlap check checked only two corners - top-left and
// bottom-right. I'm hoping nothing actually *relied* on that stupid bug.
-
+
return (between(pos.x, other.pos.x, other.pos.x + other.size.x - 1)
|| between(pos.x + size.x - 1, other.pos.x,
other.pos.x + other.size.x - 1))
@@ -7755,7 +7756,7 @@ bool dgn_region::overlaps(const map_mask &mask) const
if (mask[x][y])
return (true);
}
-
+
return (false);
}
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index d77f3c5a5d..15d362ba3d 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -16,6 +16,7 @@
#include <cstdlib>
#include <string.h>
#include <stdio.h>
+#include <algorithm>
#include "externs.h"
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index a2d5dd5802..760a274a25 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -34,6 +34,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
+#include <algorithm>
#ifdef DOS
#include <conio.h>
diff --git a/crawl-ref/source/lev-pand.cc b/crawl-ref/source/lev-pand.cc
index b2cbc1dee3..4e4308de08 100644
--- a/crawl-ref/source/lev-pand.cc
+++ b/crawl-ref/source/lev-pand.cc
@@ -11,10 +11,12 @@
*/
#include "AppHdr.h"
+
+#include <algorithm>
+
#include "lev-pand.h"
#include "externs.h"
-
#include "dungeon.h"
#include "monplace.h"
#include "mon-pick.h"
diff --git a/crawl-ref/source/luadgn.cc b/crawl-ref/source/luadgn.cc
index df3313876e..93324eaaeb 100644
--- a/crawl-ref/source/luadgn.cc
+++ b/crawl-ref/source/luadgn.cc
@@ -9,6 +9,7 @@
#include "AppHdr.h"
#include <sstream>
+#include <algorithm>
#include "branch.h"
#include "clua.h"
diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc
index e16eab55cf..53000eed75 100644
--- a/crawl-ref/source/makeitem.cc
+++ b/crawl-ref/source/makeitem.cc
@@ -8,6 +8,8 @@
#include "AppHdr.h"
+#include <algorithm>
+
#include "enum.h"
#include "externs.h"
#include "makeitem.h"
diff --git a/crawl-ref/source/mapmark.cc b/crawl-ref/source/mapmark.cc
index 4cf22b4057..dfcc66ab34 100644
--- a/crawl-ref/source/mapmark.cc
+++ b/crawl-ref/source/mapmark.cc
@@ -4,10 +4,13 @@
* Created by: dshaligram on Sat Jul 21 12:17:29 2007 UTC
*
* Modified for Crawl Reference by $Author$ on $Date$
- *
+ *
*/
#include "AppHdr.h"
+
+#include <algorithm>
+
#include "mapmark.h"
#include "clua.h"
@@ -234,7 +237,7 @@ bool map_lua_marker::get_table() const
void map_lua_marker::write(writer &outf) const
{
map_marker::write(outf);
-
+
lua_stack_cleaner clean(dlua);
bool init = initialised;
if (!get_table())
@@ -242,7 +245,7 @@ void map_lua_marker::write(writer &outf) const
mprf(MSGCH_WARN, "Couldn't find table.");
init = false;
}
-
+
marshallByte(outf, init);
if (!init)
return;
@@ -275,7 +278,7 @@ void map_lua_marker::write(writer &outf) const
void map_lua_marker::read(reader &inf)
{
map_marker::read(inf);
-
+
if (!(initialised = unmarshallByte(inf)))
return;
@@ -374,7 +377,7 @@ std::string map_lua_marker::property(const std::string &pname) const
std::string result;
if (lua_isstring(dlua, -1))
result = lua_tostring(dlua, -1);
- return (result);
+ return (result);
}
map_marker *map_lua_marker::parse(
@@ -677,7 +680,7 @@ std::vector<map_marker*> map_markers::get_all(map_marker_type mat)
if (mat == MAT_ANY || i->second->get_type() == mat)
rmarkers.push_back(i->second);
}
- return (rmarkers);
+ return (rmarkers);
}
std::vector<map_marker*> map_markers::get_all(const std::string &key,
@@ -695,7 +698,7 @@ std::vector<map_marker*> map_markers::get_all(const std::string &key,
rmarkers.push_back(marker);
}
- return (rmarkers);
+ return (rmarkers);
}
std::vector<map_marker*> map_markers::get_markers_at(const coord_def &c)
diff --git a/crawl-ref/source/maps.cc b/crawl-ref/source/maps.cc
index 05e691ae48..665c8e22ad 100644
--- a/crawl-ref/source/maps.cc
+++ b/crawl-ref/source/maps.cc
@@ -19,6 +19,8 @@
#include <cstring>
#include <cstdlib>
#include <errno.h>
+#include <algorithm>
+
#if !_MSC_VER
#include <unistd.h>
#endif
@@ -33,7 +35,7 @@
#include "stuff.h"
#include "terrain.h"
-static int write_vault(map_def &mdef, map_type mt,
+static int write_vault(map_def &mdef, map_type mt,
vault_placement &,
bool check_place, bool clobber);
static int apply_vault_definition(
@@ -59,15 +61,15 @@ static std::vector<map_def> vdefs;
// make sure that vault_n, where n is a number, is a vault which can be put
// anywhere, while other vault names are for specific level ranges, etc.
-int vault_main(
- map_type vgrid,
+int vault_main(
+ map_type vgrid,
vault_placement &place,
int which_vault,
bool check_place,
bool clobber)
{
#ifdef DEBUG_DIAGNOSTICS
- mprf(MSGCH_DIAGNOSTICS, "Generating level: %s (%d,%d)",
+ mprf(MSGCH_DIAGNOSTICS, "Generating level: %s (%d,%d)",
vdefs[which_vault].name.c_str(),
place.pos.x, place.pos.y);
if (crawl_state.map_stat_gen)
@@ -91,16 +93,16 @@ int vault_main(
check_place, clobber ));
}
-static int write_vault(map_def &mdef, map_type map,
+static int write_vault(map_def &mdef, map_type map,
vault_placement &place,
bool check_place, bool clobber)
{
mdef.load();
-
+
// Copy the map so we can monkey with it.
place.map = mdef;
place.map.original = &mdef;
-
+
// Try so many times to place the map. This will always succeed
// unless there are conflicting map placements in 'avoid', or there
// is a map validate Lua hook that keeps rejecting the map.
@@ -145,7 +147,7 @@ static bool resolve_map(map_def &map, const map_def &original)
if (!map.test_lua_validate(false))
return (false);
-
+
// Mirroring is possible for any map that does not explicitly forbid it.
// Note that mirroring also flips the orientation.
if (coinflip())
@@ -169,7 +171,7 @@ static bool bad_map_place(const map_def &map,
{
if (!check_place || clobber)
return (false);
-
+
const std::vector<std::string> &lines = map.map.get_lines();
for (int y = sy; y < sy + height; ++y)
{
@@ -183,7 +185,7 @@ static bool bad_map_place(const map_def &map,
if (igrd[x][y] != NON_ITEM || mgrd[x][y] != NON_MONSTER)
return (true);
-
+
const dungeon_feature_type grid = grd[x][y];
if (!grid_is_opaque(grid)
@@ -220,7 +222,7 @@ void fit_region_into_map_bounds(coord_def &pos, const coord_def &size)
pos.y = Y_BOUND_2 - size.y + 1;
}
-static bool apply_vault_grid(map_def &def, map_type map,
+static bool apply_vault_grid(map_def &def, map_type map,
vault_placement &place,
bool check_place, bool clobber)
{
@@ -235,7 +237,7 @@ static bool apply_vault_grid(map_def &def, map_type map,
|| orient == MAP_SOUTHWEST)
start.y = GYM - height;
- if (orient == MAP_EAST || orient == MAP_NORTHEAST
+ if (orient == MAP_EAST || orient == MAP_NORTHEAST
|| orient == MAP_SOUTHEAST)
start.x = GXM - width;
@@ -304,7 +306,7 @@ static int apply_vault_definition(
int orient = def.orient;
if (orient == MAP_NONE)
orient = MAP_NORTH;
-
+
return (orient);
}
@@ -338,7 +340,7 @@ int find_map_by_name(const std::string &name)
std::vector<std::string> find_map_matches(const std::string &name)
{
std::vector<std::string> matches;
-
+
for (unsigned i = 0, size = vdefs.size(); i < size; ++i)
if (vdefs[i].name.find(name) != std::string::npos)
matches.push_back(vdefs[i].name);
@@ -370,10 +372,10 @@ int random_map_for_place(const level_id &place, bool want_minivault)
if (mapindex != -1 && vdefs[mapindex].has_tag("dummy"))
mapindex = -1;
-
+
#ifdef DEBUG_DIAGNOSTICS
if (mapindex != -1)
- mprf(MSGCH_DIAGNOSTICS, "Found map %s for %s",
+ mprf(MSGCH_DIAGNOSTICS, "Found map %s for %s",
vdefs[mapindex].name.c_str(), place.describe().c_str());
#endif
@@ -406,7 +408,7 @@ int random_map_in_depth(const level_id &place, bool want_minivault)
if (mapindex != -1 && vdefs[mapindex].has_tag("dummy"))
mapindex = -1;
-
+
return (mapindex);
}
@@ -433,7 +435,7 @@ int random_map_for_tag(const std::string &tag,
if (mapindex != -1 && vdefs[mapindex].has_tag("dummy"))
mapindex = -1;
-
+
#ifdef DEBUG_DIAGNOSTICS
if (mapindex != -1)
mprf(MSGCH_DIAGNOSTICS, "Found map %s tagged '%s'",
@@ -447,7 +449,7 @@ const map_def *map_by_index(int index)
{
if (index < 0 || index >= (int) vdefs.size())
return (NULL);
-
+
return &vdefs[index];
}
@@ -494,7 +496,7 @@ static void check_des_index_dir()
{
if (checked_des_index_dir)
return;
-
+
std::string desdir = get_savedir_path("des");
if (!check_dir("Data file cache", desdir, true))
end(1, true, "Can't create data file cache: %s", desdir.c_str());
@@ -546,7 +548,7 @@ static bool load_map_index(const std::string &base)
global_preludes.push_back( lc_global_prelude );
}
}
-
+
FILE* fp = fopen((base + ".idx").c_str(), "rb");
if (!fp)
end(1, true, "Unable to read %s", (base + ".idx").c_str());
@@ -574,13 +576,13 @@ static bool load_map_cache(const std::string &filename)
{
check_des_index_dir();
const std::string descache_base = get_descache_path(filename, "");
-
+
file_lock deslock(descache_base + ".lk", "rb", false);
if (is_newer(filename, descache_base + ".idx")
|| is_newer(filename, descache_base + ".dsc"))
return (false);
-
+
if (!verify_map_index(descache_base) || !verify_map_full(descache_base))
return (false);
@@ -636,9 +638,9 @@ static void write_map_cache(const std::string &filename, size_t vs, size_t ve)
check_des_index_dir();
const std::string descache_base = get_descache_path(filename, "");
-
+
file_lock deslock(descache_base + ".lk", "wb");
-
+
write_map_prelude(descache_base);
write_map_full(descache_base, vs, ve);
write_map_index(descache_base, vs, ve);
@@ -651,7 +653,7 @@ static void parse_maps(const std::string &s)
end(1, false, "Map file %s has already been read.", base.c_str());
map_files_read.insert(base);
-
+
if (load_map_cache(s))
return;
@@ -731,7 +733,7 @@ static weighted_map_names mg_find_random_vaults(
const level_id &place, bool wantmini)
{
weighted_map_names wms;
-
+
if (!place.is_valid())
return (wms);
@@ -746,7 +748,7 @@ static weighted_map_names mg_find_random_vaults(
&& !vdefs[i].has_tag_suffix("entry")
&& !vdefs[i].has_tag("pan")
&& !vdefs[i].has_tag("unrand")
- && !vdefs[i].has_tag("bazaar"))
+ && !vdefs[i].has_tag("bazaar"))
{
wms.push_back(
weighted_map_name( vdefs[i].name, vdefs[i].chance ) );
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index 2a64821b6d..a069b76a34 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -18,6 +18,8 @@
#include "notes.h"
#include <string.h>
+#include <algorithm>
+
#if !defined(__IBMCPP__) && !defined(_MSC_VER)
#include <unistd.h>
#endif
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index dba02bef07..a7b062381e 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -27,6 +27,7 @@
#include <cstring>
#include <cctype>
#include <sstream>
+#include <algorithm>
#include "externs.h"
@@ -720,7 +721,7 @@ mon_attack_def downscale_zombie_attack(const monsters *mons,
{
attk.flavour = AF_PLAIN;
}
-
+
attk.damage = downscale_zombie_damage(attk.damage);
return (attk);
@@ -730,7 +731,7 @@ mon_attack_def mons_attack_spec(const monsters *mons, int attk_number)
{
int mc = mons->type;
const bool zombified = mons_is_zombified(mons);
-
+
if ((attk_number < 0 || attk_number > 3) || mc == MONS_HYDRA)
attk_number = 0;
@@ -758,7 +759,7 @@ mon_attack_def mons_attack_spec(const monsters *mons, int attk_number)
case 5: attk.flavour = AF_BLINK; break;
}
}
-
+
return (zombified? downscale_zombie_attack(mons, attk) : attk);
}
@@ -792,7 +793,7 @@ int mons_resist_magic( const monsters *mon )
// ego armour resistance
const int armour = mon->inv[MSLOT_ARMOUR];
- if (armour != NON_ITEM
+ if (armour != NON_ITEM
&& get_armour_ego_type( mitm[armour] ) == SPARM_MAGIC_RESISTANCE )
{
u += 30;
@@ -839,7 +840,7 @@ bool check_mons_resist_magic( const monsters *monster, int pow )
#if DEBUG_DIAGNOSTICS
mprf(MSGCH_DIAGNOSTICS,
- "Power: %d, monster's MR: %d, target: %d, roll: %d",
+ "Power: %d, monster's MR: %d, target: %d, roll: %d",
pow, mrs, mrchance, mrch2 );
#endif
@@ -936,7 +937,7 @@ int mons_res_fire( const monsters *mon )
int mc = mon->type;
const mon_resist_def res = get_mons_resists(mon);
-
+
int u = std::min(res.fire + res.hellfire * 3, 3);
if (mons_itemuse(mc) >= MONUSE_STARTING_EQUIPMENT)
@@ -1021,7 +1022,7 @@ int mons_res_negative_energy( const monsters *mon )
}
int u = 0;
-
+
if (mons_itemuse(mc) >= MONUSE_STARTING_EQUIPMENT)
{
@@ -1235,15 +1236,15 @@ int exper_value( const struct monsters *monster )
}
// Monsters who can use equipment (even if only the equipment
- // they are given) can be considerably enhanced because of
+ // they are given) can be considerably enhanced because of
// the way weapons work for monsters. -- bwr
- if (item_usage == MONUSE_STARTING_EQUIPMENT
+ if (item_usage == MONUSE_STARTING_EQUIPMENT
|| item_usage == MONUSE_WEAPONS_ARMOUR)
{
diff += 30;
}
- // Set a reasonable range on the difficulty modifier...
+ // Set a reasonable range on the difficulty modifier...
// Currently 70% - 200% -- bwr
if (diff > 100)
diff = 100;
@@ -1388,7 +1389,7 @@ void define_monster(monsters &mons)
break;
case MONS_DEEP_ELF_CONJURER:
- spells =
+ spells =
(coinflip()? MST_DEEP_ELF_CONJURER_I : MST_DEEP_ELF_CONJURER_II);
break;
@@ -1397,14 +1398,14 @@ void define_monster(monsters &mons)
case MONS_KILLER_KLOWN:
if (col != BLACK) // maybe overwritten by the mon_glyph option
break;
-
+
col = random_colour();
break;
case MONS_GILA_MONSTER:
if (col != BLACK) // maybe overwritten by the mon_glyph option
break;
-
+
temp_rand = random2(7);
col = (temp_rand >= 5 ? LIGHTRED : // 2/7
@@ -1445,16 +1446,16 @@ void define_monster(monsters &mons)
spells = (coinflip() ? MST_HELL_KNIGHT_I : MST_HELL_KNIGHT_II);
else if (temp_rand < 9)
spells = (coinflip() ? MST_NECROMANCER_I : MST_NECROMANCER_II);
- else
- spells = (coinflip() ? MST_DEEP_ELF_CONJURER_I
+ else
+ spells = (coinflip() ? MST_DEEP_ELF_CONJURER_I
: MST_DEEP_ELF_CONJURER_II);
-
+
monnumber = MONS_BLACK_DRACONIAN + random2(8);
break;
}
case MONS_HUMAN:
case MONS_ELF:
- // these are supposed to only be created by polymorph
+ // these are supposed to only be created by polymorph
hd += random2(10);
ac += random2(5);
ev += random2(5);
@@ -1485,11 +1486,11 @@ void define_monster(monsters &mons)
if (mons.number == MONS_PROGRAM_BUG)
mons.number = monnumber;
-
+
mons.flags = 0L;
mons.experience = 0L;
mons.colour = col;
-
+
mons_load_spells( &mons, spells );
// reset monster enchantments
@@ -1506,7 +1507,7 @@ std::string draconian_colour_name(monster_type mtype)
{
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]);
@@ -1516,11 +1517,11 @@ monster_type draconian_colour_by_name(const std::string &name)
{
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);
-
+
return (MONS_PROGRAM_BUG);
}
@@ -1529,10 +1530,10 @@ static std::string _str_monam(const monsters& mon, description_level_type desc,
{
if (desc == DESC_NONE)
return ("");
-
+
// Handle non-visible case first
if ( !force_seen && !player_monster_visible(&mon) )
- {
+ {
switch (desc)
{
case DESC_CAP_THE: case DESC_CAP_A:
@@ -1592,7 +1593,7 @@ static std::string _str_monam(const monsters& mon, description_level_type desc,
// Tack on other prefixes.
switch (mon.type)
{
- case MONS_SPECTRAL_THING:
+ case MONS_SPECTRAL_THING:
result += "spectral ";
nametype = mon.number;
break;
@@ -1616,7 +1617,7 @@ static std::string _str_monam(const monsters& mon, description_level_type desc,
static_cast<monster_type>( mon.number ) ) + " ";
}
break;
-
+
default:
break;
}
@@ -1950,7 +1951,7 @@ bool ms_direct_nasty(spell_type monspell)
&& !spell_typematch(monspell, SPTYP_SUMMONING));
}
-// Spells a monster may want to cast if fleeing from the player, and
+// Spells a monster may want to cast if fleeing from the player, and
// the player is not in sight.
bool ms_useful_fleeing_out_of_sight( const monsters *mon, spell_type monspell )
{
@@ -1980,7 +1981,7 @@ bool ms_low_hitpoint_cast( const monsters *mon, spell_type monspell )
bool ret = false;
bool targ_adj = false;
- if (mon->foe == MHITYOU || mon->foe == MHITNOT)
+ if (mon->foe == MHITYOU || mon->foe == MHITNOT)
{
if (adjacent(you.x_pos, you.y_pos, mon->x, mon->y))
targ_adj = true;
@@ -2129,7 +2130,7 @@ bool ms_waste_of_time( const monsters *mon, spell_type monspell )
case SPELL_SLEEP:
if (monspell == SPELL_SLEEP && (!foe || foe->asleep()))
return (true);
-
+
// occasionally we don't estimate... just fire and see:
if (one_chance_in(5))
return (false);
@@ -2152,9 +2153,9 @@ bool ms_waste_of_time( const monsters *mon, spell_type monspell )
// now randomize (normal intels less accurate than high):
if (intel == I_NORMAL)
- est_magic_resist += random2(80) - 40;
+ est_magic_resist += random2(80) - 40;
else
- est_magic_resist += random2(30) - 15;
+ est_magic_resist += random2(30) - 15;
}
power = 12 * mon->hit_dice * (monspell == SPELL_PAIN ? 2 : 1);
@@ -2163,8 +2164,8 @@ bool ms_waste_of_time( const monsters *mon, spell_type monspell )
// Determine the amount of chance allowed by the benefit from
// the spell. The estimated difficulty is the probability
// of rolling over 100 + diff on 2d100. -- bwr
- diff = (monspell == SPELL_PAIN
- || monspell == SPELL_SLOW
+ diff = (monspell == SPELL_PAIN
+ || monspell == SPELL_SLOW
|| monspell == SPELL_CONFUSE) ? 0 : 50;
if (est_magic_resist - power > diff)
@@ -2175,12 +2176,12 @@ bool ms_waste_of_time( const monsters *mon, spell_type monspell )
case SPELL_NO_SPELL:
ret = true;
break;
-
+
default:
break;
}
- return (ret);
+ return (ret);
}
static bool _ms_ranged_spell( spell_type monspell )
@@ -2243,7 +2244,7 @@ bool mons_has_ranged_attack( const monsters *mon )
if (!missile)
return (false);
-
+
return is_launched(mnc, weapon, *missile);
}
@@ -2467,7 +2468,7 @@ void monsters::init_with(const monsters &mon)
colour = mon.colour;
foe_memory = mon.foe_memory;
god = mon.god;
-
+
if (mon.ghost.get())
ghost.reset(new ghost_demon( *mon.ghost ));
else
@@ -2688,7 +2689,7 @@ int monsters::damage_type(int which_attack)
const mon_attack_def atk = mons_attack_spec(this, which_attack);
return (atk.type == AT_CLAW? DVORP_CLAWING : DVORP_CRUSHING);
}
-
+
return (get_vorpal_type(*mweap));
}
@@ -2698,7 +2699,7 @@ int monsters::damage_brand(int which_attack)
if (!mweap)
return (SPWPN_NORMAL);
-
+
return (!is_range_weapon(*mweap)? get_weapon_brand(*mweap) : SPWPN_NORMAL);
}
@@ -2719,7 +2720,7 @@ item_def *monsters::launcher()
item_def *weap = mslot_item(MSLOT_WEAPON);
if (weap && is_range_weapon(*weap))
return (weap);
-
+
weap = mslot_item(MSLOT_ALT_WEAPON);
return (weap && is_range_weapon(*weap)? weap : NULL);
}
@@ -2728,7 +2729,7 @@ item_def *monsters::weapon(int which_attack)
{
if (which_attack > 1)
which_attack &= 1;
-
+
// This randomly picks one of the wielded weapons for monsters that can use
// two weapons. Not ideal, but better than nothing. fight.cc does it right,
// for various values of right.
@@ -2781,7 +2782,7 @@ bool monsters::can_use_missile(const item_def &item) const
// Blademasters don't want to throw stuff.
if (type == MONS_DEEP_ELF_BLADEMASTER)
return (false);
-
+
if (item.base_type == OBJ_WEAPONS)
return (is_throwable(item));
@@ -2855,7 +2856,7 @@ void monsters::equip_weapon(item_def &item, int near)
}
if (message_given)
set_ident_flags(item, ISFLAG_KNOW_TYPE);
- }
+ }
}
void monsters::equip_armour(item_def &item, int near)
@@ -2937,7 +2938,7 @@ void monsters::unequip_weapon(item_def &item, int near)
}
if (message_given)
set_ident_flags(item, ISFLAG_KNOW_TYPE);
- }
+ }
}
void monsters::unequip_armour(item_def &item, int near)
@@ -2953,10 +2954,10 @@ void monsters::unequip_armour(item_def &item, int near)
const int armour_plus = item.plus;
ASSERT(abs(armour_plus) < 20);
- if (abs(armour_plus) < 20)
+ if (abs(armour_plus) < 20)
ac -= armour_plus;
}
-
+
ev -= property( item, PARM_EVASION ) / 2;
if (ev < 1)
ev = 1; // This *shouldn't* happen.
@@ -3034,7 +3035,7 @@ bool monsters::pickup(item_def &item, int slot, int near, bool force_merge)
dgn_event(DET_ITEM_PICKUP, pos(), 0, item.index(),
monster_index(this)),
pos());
-
+
const int index = item.index();
unlink_item(index);
inv[slot] = index;
@@ -3093,7 +3094,7 @@ bool monsters::pickup_launcher(item_def &launch, int near)
{
if (!is_range_weapon(*elaunch))
continue;
-
+
return (fires_ammo_type(*elaunch) == mt
&& mons_weapon_damage_rating(*elaunch) < mdam_rating
&& drop_item(i, near) && pickup(launch, i, near));
@@ -3125,7 +3126,7 @@ bool monsters::pickup_melee_weapon(item_def &item, int near)
{
if (is_range_weapon(*weap))
continue;
-
+
has_melee = true;
if (mons_weapon_damage_rating(*weap) < mdam_rating)
return (drop_item(i, near) && pickup(item, i, near));
@@ -3145,12 +3146,12 @@ static int _q_adj_damage(int damage, int qty)
{
return (damage * std::min(qty, 8));
}
-
+
bool monsters::pickup_throwable_weapon(item_def &item, int near)
{
if (mslot_item(MSLOT_MISSILE) && pickup(item, MSLOT_MISSILE, near, true))
return (true);
-
+
item_def *launch = NULL;
const int exist_missile = mons_pick_best_missile(this, &launch, true);
if (exist_missile == NON_ITEM
@@ -3222,7 +3223,7 @@ static mon_inv_type _equip_slot_to_mslot(equipment_type eq)
bool monsters::pickup_armour(item_def &item, int near, bool force)
{
ASSERT(item.base_type == OBJ_ARMOUR);
-
+
if (!force && !wants_armour(item))
return (false);
@@ -3253,7 +3254,7 @@ bool monsters::pickup_weapon(item_def &item, int near, bool force)
{
if (!force && !wants_weapon(item))
return (false);
-
+
// Weapon pickup involves:
// - If we have no weapons, always pick this up.
// - If this is a melee weapon and we already have a melee weapon, pick
@@ -3266,7 +3267,7 @@ bool monsters::pickup_weapon(item_def &item, int near, bool force)
if (is_range_weapon(item))
return (pickup_launcher(item, near));
-
+
if (pickup_melee_weapon(item, near))
return (true);
@@ -3278,16 +3279,16 @@ bool monsters::pickup_missile(item_def &item, int near, bool force)
// XXX: Missile pickup could get a lot smarter if we allow monsters to
// drop their existing missiles and pick up new stuff, but that's too
// much work for now.
-
+
const item_def *miss = missiles();
-
+
// monster may not pick up trapping net
if (mons_is_caught(this) && item.sub_type == MI_THROWING_NET
&& item_is_stationary(item))
{
return (false);
}
-
+
if (miss && items_stack(*miss, item))
return (pickup(item, MSLOT_MISSILE, near));
@@ -3345,7 +3346,7 @@ bool monsters::pickup_misc(item_def &item, int near)
// Never pick up runes.
if (item.sub_type == MISC_RUNE_OF_ZOT)
return (false);
-
+
return pickup(item, MSLOT_MISCELLANY, near);
}
@@ -3354,7 +3355,7 @@ bool monsters::pickup_item(item_def &item, int near, bool force)
// Never pick up stuff when we're in battle.
if (!force && (behaviour != BEH_WANDER || attitude == ATT_NEUTRAL))
return (false);
-
+
// Jellies are not handled here.
switch (item.base_type)
{
@@ -3390,7 +3391,7 @@ void monsters::swap_weapons(int near)
{
item_def *weap = mslot_item(MSLOT_WEAPON);
item_def *alt = mslot_item(MSLOT_ALT_WEAPON);
-
+
if (weap && !unequip(*weap, MSLOT_WEAPON, near))
{
// Item was cursed
@@ -3463,10 +3464,10 @@ std::string monsters::conj_verb(const std::string &verb) const
{
if (!verb.empty() && verb[0] == '!')
return (verb.substr(1));
-
+
if (verb == "are")
return ("is");
-
+
return (pluralise(verb));
}
@@ -3594,7 +3595,7 @@ int monsters::shield_bonus() const
// Note that 0 is not quite no-blocking.
if (incapacitated())
return (0);
-
+
int shld_c = property(*shld, PARM_AC);
return (random2avg(shld_c + hit_dice * 2 / 3, 2));
}
@@ -3711,7 +3712,7 @@ int monsters::skill(skill_type sk, bool) const
{
case SK_NECROMANCY:
return (holiness() == MH_UNDEAD? hit_dice / 2 : hit_dice / 3);
-
+
default:
return (0);
}
@@ -3744,10 +3745,10 @@ int monsters::hurt(const actor *agent, int amount)
amount = std::min(amount, hit_points);
hit_points -= amount;
-
+
// Allow the victim to exhibit passive damage behaviour (royal jelly).
react_to_damage(amount);
-
+
if (agent && (hit_points < 1 || hit_dice < 1) && type != -1)
{
if (agent->atype() == ACT_PLAYER)
@@ -3812,7 +3813,7 @@ void monsters::set_ghost(const ghost_demon &g)
{
#ifdef USE_TILE
TileGhostInit(g);
-#endif
+#endif
ghost.reset( new ghost_demon(g) );
}
@@ -3911,7 +3912,7 @@ bool monsters::find_place_near_player()
for (int radius = 1; radius < 7; ++radius)
if (find_home_around(you.pos(), radius))
return (true);
-
+
return (false);
}
@@ -3956,7 +3957,7 @@ void monsters::destroy_inventory()
void monsters::reset()
{
destroy_inventory();
-
+
enchantments.clear();
ench_countdown = 0;
inv.init(NON_ITEM);
@@ -4003,13 +4004,13 @@ void monsters::load_spells(mon_spellbook_type book)
return;
#if DEBUG_DIAGNOSTICS
- mprf( MSGCH_DIAGNOSTICS, "%s: loading spellbook #%d",
+ mprf( MSGCH_DIAGNOSTICS, "%s: loading spellbook #%d",
name(DESC_PLAIN).c_str(), static_cast<int>(book) );
#endif
if (book == MST_GHOST)
spells = ghost->spells;
- else
+ else
{
for (unsigned int i = 0; i < ARRAYSIZE(mspell_list); ++i)
{
@@ -4061,7 +4062,7 @@ mon_enchant monsters::get_ench(enchant_type ench1,
{
mon_enchant_list::const_iterator i =
enchantments.find(static_cast<enchant_type>(e));
-
+
if (i != enchantments.end())
return (i->second);
}
@@ -4586,7 +4587,7 @@ void monsters::apply_enchantment(const mon_enchant &me)
// the more corroded it gets, the more easily it will break
const int hold = mitm[net].plus; // this will usually be negative
const int mon_size = body_size(PSIZE_BODY);
-
+
// smaller monsters can escape more quickly
if (mon_size < random2(SIZE_BIG) // BIG = 5
&& !has_ench(ENCH_BERSERK) && type != MONS_DANCING_WEAPON)
@@ -4601,14 +4602,14 @@ void monsters::apply_enchantment(const mon_enchant &me)
break;
decay_enchantment(me, 2*(NUM_SIZE_LEVELS - mon_size) - hold);
-
+
// frayed nets are easier to escape
if (mon_size <= -(hold-1)/2)
decay_enchantment(me, (NUM_SIZE_LEVELS - mon_size));
}
else // large (and above) monsters always thrash the net and destroy it
{ // e.g. ogre, large zombie (large); centaur, nage, hydra (big)
-
+
if (mons_near(this) && !player_monster_visible(this))
mpr("Something wriggles in the net.");
else
@@ -4621,7 +4622,7 @@ void monsters::apply_enchantment(const mon_enchant &me)
// nets get destroyed more quickly for larger monsters
// and if already strongly frayed
int damage = 0;
-
+
// tiny: 1/6, little: 2/5, small: 3/4, medium and above: always
if (random2(SIZE_GIANT - mon_size) <= mon_size)
damage++;
@@ -4634,8 +4635,8 @@ void monsters::apply_enchantment(const mon_enchant &me)
if (can_cut_meat(mitm[inv[MSLOT_WEAPON]]))
damage++;
}
-
-
+
+
// extra damage for large (50%) and big (always)
if (mon_size == SIZE_BIG || mon_size == SIZE_LARGE && coinflip())
damage++;
@@ -4753,7 +4754,7 @@ void monsters::apply_enchantment(const mon_enchant &me)
#if DEBUG_DIAGNOSTICS
// for debugging, we don't have this silent.
- simple_monster_message( this, " takes poison damage.",
+ simple_monster_message( this, " takes poison damage.",
MSGCH_DIAGNOSTICS );
mprf(MSGCH_DIAGNOSTICS, "poison damage: %d", dam );
#endif
@@ -4860,7 +4861,7 @@ void monsters::apply_enchantments()
{
if (enchantments.empty())
return;
-
+
const mon_enchant_list ec = enchantments;
for (mon_enchant_list::const_iterator i = ec.begin(); i != ec.end(); ++i)
{
@@ -4874,7 +4875,7 @@ void monsters::scale_hp(int num, int den)
{
hit_points = hit_points * num / den;
max_hit_points = max_hit_points * num / den;
-
+
if (hit_points < 1)
hit_points = 1;
if (max_hit_points < 1)
@@ -4957,9 +4958,9 @@ void monsters::check_speed()
speed, speed_increment, hit_dice,
describe_enchantments().c_str());
#endif
-
+
fix_speed();
-
+
#ifdef DEBUG_DIAGNOSTICS
mprf(MSGCH_DIAGNOSTICS, "Fixed speed for %s to %d",
name(DESC_PLAIN).c_str(), speed);
@@ -5268,12 +5269,12 @@ void monsters::react_to_damage(int damage)
coord_def jpos = find_newmons_square_contiguous(jelly, pos());
if (!in_bounds(jpos))
continue;
-
+
const int nmons =
mons_place( jelly, sbehaviour, foe, true, jpos.x, jpos.y,
you.level_type, PROX_ANYWHERE, MONS_PROGRAM_BUG,
0, false );
-
+
if (nmons != -1 && nmons != NON_MONSTER)
{
// Don't allow milking the royal jelly.
@@ -5284,7 +5285,7 @@ void monsters::react_to_damage(int damage)
const bool needs_message =
spawned && mons_near(this) && player_monster_visible(this);
-
+
if (needs_message)
{
const std::string mname = name(DESC_CAP_THE);
@@ -5305,7 +5306,7 @@ void monsters::react_to_damage(int damage)
/////////////////////////////////////////////////////////////////////////
// mon_enchant
-static const char *enchant_names[] =
+static const char *enchant_names[] =
{
"none", "slow", "haste", "fear", "conf", "inv", "pois", "bers",
"rot", "summon", "abj", "backlit", "charm", "fire",
@@ -5317,7 +5318,7 @@ static const char *enchant_names[] =
const char *mons_enchantment_name(enchant_type ench)
{
COMPILE_CHECK(ARRAYSIZE(enchant_names) == NUM_ENCHANTMENTS+1, c1);
-
+
if (ench > NUM_ENCHANTMENTS)
ench = NUM_ENCHANTMENTS;
@@ -5355,7 +5356,7 @@ void mon_enchant::cap_degree()
// Sickness is not capped.
if (ench == ENCH_SICK)
return;
-
+
// Hard cap to simulate old enum behaviour, we should really throw this
// out entirely.
const int max = ench == ENCH_ABJ? 6 : 4;
@@ -5403,7 +5404,7 @@ int mon_enchant::calc_duration(const monsters *mons,
const mon_enchant *added) const
{
int cturn = 0;
-
+
const int newdegree = added? added->degree : degree;
const int deg = newdegree? newdegree : 1;
@@ -5470,7 +5471,7 @@ int mon_enchant::calc_duration(const monsters *mons,
default:
break;
}
-
+
if (cturn < 2)
cturn = 2;
@@ -5510,7 +5511,7 @@ static std::string _replace_god_name(bool need_verb = false, bool capital = fals
result +=
(you.religion == GOD_NO_GOD? " are" : " is");
}
-
+
return (result);
}
@@ -5521,7 +5522,7 @@ static std::string _get_species_insult(const std::string type)
lookup += species_name(you.species, 1, true);
lookup += " ";
lookup += type;
-
+
std::string insult = getSpeakString(lowercase(lookup));
if (insult.empty()) // species too specific?
{
@@ -5648,7 +5649,7 @@ std::string do_mon_str_replacements(const std::string &in_msg,
// replace with "you are" for atheists
msg = replace_all(msg, "@god_is@", _replace_god_name(true, false));
msg = replace_all(msg, "@God_is@", _replace_god_name(true, true));
-
+
// no verb needed
msg = replace_all(msg, "@player_god@", _replace_god_name(false, false));
msg = replace_all(msg, "@Player_god@", _replace_god_name(false, true));
@@ -5664,20 +5665,20 @@ std::string do_mon_str_replacements(const std::string &in_msg,
_get_species_insult("noun"));
}
- static const char * sound_list[] =
+ static const char * sound_list[] =
{
"says", // actually S_SILENT
- "shouts",
- "barks",
- "shouts",
- "roars",
- "screams",
- "bellows",
- "screeches",
- "buzzes",
- "moans",
- "whines",
- "croaks",
+ "shouts",
+ "barks",
+ "shouts",
+ "roars",
+ "screams",
+ "bellows",
+ "screeches",
+ "buzzes",
+ "moans",
+ "whines",
+ "croaks",
"growls",
"hisses",
"breathes", // S_VERY_SOFT
@@ -6014,18 +6015,18 @@ mon_resist_def::mon_resist_def(int flags, short level)
case MR_RES_COLD: cold = nl; break;
case MR_RES_ASPHYX: asphyx = nl; break;
case MR_RES_ACID: acid = nl; break;
-
+
// vulnerabilities
case MR_VUL_ELEC: elec = -nl; break;
case MR_VUL_POISON: poison = -nl; break;
case MR_VUL_FIRE: fire = -nl; break;
case MR_VUL_COLD: cold = -nl; break;
-
+
// resistance to certain damage types
case MR_RES_PIERCE: pierce = nl; break;
case MR_RES_SLICE: slice = nl; break;
case MR_RES_BLUDGEON: bludgeon = nl; break;
-
+
// vulnerability to certain damage types
case MR_VUL_PIERCE: pierce = -nl; break;
case MR_VUL_SLICE: slice = -nl; break;
diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc
index e0aa3b0d3d..01611ef586 100644
--- a/crawl-ref/source/monplace.cc
+++ b/crawl-ref/source/monplace.cc
@@ -11,6 +11,9 @@
*/
#include "AppHdr.h"
+
+#include <algorithm>
+
#include "monplace.h"
#include "branch.h"
@@ -47,7 +50,7 @@ static int place_monster_aux(int mon_type, beh_type behaviour, int target,
int px, int py, int power, int extra, bool first_band_member,
int dur = 0);
-// Returns whether actual_grid is compatible with grid_wanted for monster
+// Returns whether actual_grid is compatible with grid_wanted for monster
// movement (or for monster generation, if generation is true).
bool grid_compatible(dungeon_feature_type grid_wanted,
dungeon_feature_type actual_grid, bool generation)
@@ -55,8 +58,8 @@ bool grid_compatible(dungeon_feature_type grid_wanted,
// XXX What in Xom's name is DNGN_WATER_STUCK? It looks like an artificial
// device to slow down fiery monsters flying over water.
if (grid_wanted == DNGN_FLOOR)
- return actual_grid >= DNGN_FLOOR
- || (!generation
+ return actual_grid >= DNGN_FLOOR
+ || (!generation
&& actual_grid == DNGN_SHALLOW_WATER);
if (grid_wanted >= DNGN_ROCK_WALL
@@ -230,7 +233,7 @@ monster_type pick_random_monster(const level_id &place,
{
if (place.level_type == LEVEL_LABYRINTH)
return (MONS_PROGRAM_BUG);
-
+
monster_type mon_type = MONS_PROGRAM_BUG;
lev_mons = power;
@@ -365,7 +368,7 @@ static int resolve_monster_type(int mon_type, proximity_type proximity,
mon_type = random_range(MONS_BLACK_DRACONIAN, MONS_PALE_DRACONIAN);
else if (mon_type == RANDOM_NONBASE_DRACONIAN)
mon_type = random_range(MONS_DRACONIAN_CALLER, MONS_DRACONIAN_SCORCHER);
-
+
// (2) take care of random monsters
if (mon_type == RANDOM_MONSTER)
{
@@ -453,7 +456,7 @@ bool place_monster(int &id, int mon_type, int power, beh_type behaviour,
int band_monsters[BIG_BAND]; // band monster types
int lev_mons = power; // final 'power'
int i;
-
+
int tries = 0;
int pval = 0;
dungeon_char_type stair_type = NUM_DCHAR_TYPES;
@@ -507,7 +510,7 @@ bool place_monster(int &id, int mon_type, int power, beh_type behaviour,
if (!summoned)
{
tries = 0;
-
+
// try to pick px, py that is
// a) not occupied
// b) compatible
@@ -527,16 +530,16 @@ bool place_monster(int &id, int mon_type, int power, beh_type behaviour,
return (false);
tries ++;
-
+
// placement already decided for PROX_NEAR_STAIRS
if (proximity != PROX_NEAR_STAIRS)
{
px = 5 + random2(GXM - 10);
py = 5 + random2(GYM - 10);
}
-
+
// Let's recheck these even for PROX_NEAR_STAIRS, just in case
-
+
// occupied?
if (mgrd[px][py] != NON_MONSTER
|| (px == you.x_pos && py == you.y_pos))
@@ -620,7 +623,7 @@ bool place_monster(int &id, int mon_type, int power, beh_type behaviour,
} // end while.. place first monster
}
- id = place_monster_aux( mon_type, behaviour, target, px, py, lev_mons,
+ id = place_monster_aux( mon_type, behaviour, target, px, py, lev_mons,
extra, true);
// now, forget about banding if the first placement failed, or there's too
@@ -796,7 +799,7 @@ static int place_monster_aux( int mon_type, beh_type behaviour, int target,
if (monster_can_submerge(&menv[id], grd[fx][fy])
&& !one_chance_in(5))
menv[id].add_ench(ENCH_SUBMERGED);
-
+
menv[id].flags |= MF_JUST_SUMMONED;
if (mon_type == MONS_DANCING_WEAPON && extra != 1) // ie not from spell
@@ -862,7 +865,7 @@ static int place_monster_aux( int mon_type, beh_type behaviour, int target,
}
mark_interesting_monst(&menv[id], behaviour);
-
+
if (player_monster_visible(&menv[id]) && mons_near(&menv[id]))
seen_monster(&menv[id]);
@@ -1116,7 +1119,7 @@ static band_type choose_band( int mon_type, int power, int &band_size )
band_size = 3 + random2(3);
break;
- // Journey -- Added Draconian Packs
+ // Journey -- Added Draconian Packs
case MONS_WHITE_DRACONIAN:
case MONS_RED_DRACONIAN:
case MONS_PURPLE_DRACONIAN:
@@ -1125,7 +1128,7 @@ static band_type choose_band( int mon_type, int power, int &band_size )
case MONS_BLACK_DRACONIAN:
case MONS_GREEN_DRACONIAN:
case MONS_PALE_DRACONIAN:
- if (power > 18 && one_chance_in(3) && you.level_type == LEVEL_DUNGEON)
+ if (power > 18 && one_chance_in(3) && you.level_type == LEVEL_DUNGEON)
{
band = BAND_DRACONIAN;
band_size = random_range(2, 4);
@@ -1404,7 +1407,7 @@ static int band_member(band_type band, int power)
case BAND_DRACONIAN:
{
temp_rand = random2( (power < 24) ? 24 : 37 );
- mon_type =
+ mon_type =
((temp_rand > 35) ? MONS_DRACONIAN_CALLER : // 1 in 34
(temp_rand > 33) ? MONS_DRACONIAN_KNIGHT : // 2 in 34
(temp_rand > 31) ? MONS_DRACONIAN_MONK : // 2 in 34
@@ -1436,7 +1439,7 @@ static int ood_limit() {
void mark_interesting_monst(struct monsters* monster, beh_type behaviour)
{
bool interesting = false;
-
+
// Unique monsters are always intersting
if ( mons_is_unique(monster->type) )
interesting = true;
@@ -1445,7 +1448,7 @@ void mark_interesting_monst(struct monsters* monster, beh_type behaviour)
interesting = false;
// Don't waste time on moname() if user isn't using this option
else if ( Options.note_monsters.size() > 0 )
- {
+ {
const std::string iname = mons_type_name(monster->type, DESC_NOCAP_A);
for (unsigned i = 0; i < Options.note_monsters.size(); ++i)
{
@@ -1611,12 +1614,12 @@ public:
set_floodseed(start);
return travel_pathfind::pathfind(RMODE_EXPLORE);
}
-
+
bool path_flood(const coord_def &c, const coord_def &dc)
{
if (best_distance && traveled_distance > best_distance)
return (true);
-
+
if (!in_bounds(dc)
|| (maxdistance > 0 && traveled_distance > maxdistance))
{
@@ -1903,7 +1906,7 @@ monster_type rand_dragon( dragon_class_type type )
case DRAGON_LIZARD:
temp_rand = random2(100);
summoned = ((temp_rand > 80) ? MONS_SWAMP_DRAKE :
- (temp_rand > 59) ? MONS_KOMODO_DRAGON :
+ (temp_rand > 59) ? MONS_KOMODO_DRAGON :
(temp_rand > 34) ? MONS_FIREDRAKE :
(temp_rand > 11) ? MONS_DEATH_DRAKE :
MONS_DRAGON);
diff --git a/crawl-ref/source/monspeak.cc b/crawl-ref/source/monspeak.cc
index da4fba4f4e..06910e7c50 100644
--- a/crawl-ref/source/monspeak.cc
+++ b/crawl-ref/source/monspeak.cc
@@ -15,6 +15,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+#include <algorithm>
#ifdef DOS
#include <conio.h>
@@ -118,10 +119,10 @@ static std::string _get_speak_string(const std::vector<std::string> prefixes,
const monsters *monster)
{
std::string msg = _try_exact_string(prefixes, key);
-
+
if (!msg.empty())
return msg;
-
+
// Combinations of prefixes by threes
const int size = prefixes.size();
std::string prefix = "";
@@ -136,7 +137,7 @@ static std::string _get_speak_string(const std::vector<std::string> prefixes,
prefix += prefixes[k] + " ";
msg = getSpeakString("default " + prefix + key);
-
+
if (!msg.empty())
return msg;
}
@@ -152,7 +153,7 @@ static std::string _get_speak_string(const std::vector<std::string> prefixes,
prefix += prefixes[j] + " ";
msg = getSpeakString("default " + prefix + key);
-
+
if (!msg.empty())
return msg;
}
@@ -166,7 +167,7 @@ static std::string _get_speak_string(const std::vector<std::string> prefixes,
prefix = prefixes[i] + " ";
msg = getSpeakString("default " + prefix + key);
-
+
if (!msg.empty())
return msg;
}
@@ -235,14 +236,14 @@ bool mons_speaks(const monsters *monster)
// charmed monsters aren't too expressive
if (monster->has_ench(ENCH_CHARM) && !one_chance_in(3))
return false;
-
+
std::vector<std::string> prefixes;
if (mons_neutral(monster))
{
if (coinflip()) // neutrals speak half as often
return false;
-
+
prefixes.push_back("neutral");
}
else if (mons_friendly(monster))
@@ -358,7 +359,7 @@ bool mons_speaks(const monsters *monster)
key += "'";
msg = _get_speak_string(prefixes, key, monster);
}
-
+
if (msg == "__NONE")
{
#ifdef DEBUG_MONSPEAK
@@ -410,7 +411,7 @@ bool mons_speaks(const monsters *monster)
if (msg.empty() || msg == "__NEXT")
msg = _get_speak_string(prefixes, get_mon_shape_str(shape), monster);
-
+
if (msg == "__NONE")
{
#ifdef DEBUG_MONSPEAK
@@ -442,7 +443,7 @@ bool mons_speaks(const monsters *monster)
msg2 = _get_speak_string(prefixes,
get_mon_shape_str(shape),
monster);
-
+
if (msg == "__NONE" && msg2 == "__NONE")
{
#ifdef DEBUG_MONSPEAK
@@ -490,7 +491,7 @@ bool mons_speaks(const monsters *monster)
for (int i = 0, size = lines.size(); i < size; i++)
{
std::string line = lines[i];
-
+
// This function is a little bit of a problem for the message
// channels since some of the messages it generates are "fake"
// warning to scare the player. In order to accomidate this
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 031ca713e5..035bc36f73 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+#include <algorithm>
#ifdef DOS
#include <conio.h>
@@ -663,7 +664,7 @@ static bool _slime_pit_unlock(bool silent)
mpr("You feel a strange vibration for a moment.",
MSGCH_MONSTER_ENCHANT);
}
-
+
return (true);
}
@@ -1797,7 +1798,7 @@ bool swap_places(monsters *monster)
int loc_y = you.y_pos;
const int mgrid = grd[monster->x][monster->y];
-
+
if (monster->has_ench(ENCH_HELD))
{
simple_monster_message(monster, " is held in a net!");
@@ -2638,7 +2639,7 @@ static void _handle_movement(monsters *monster)
if (random2(5) > 2)
monster->del_ench(ENCH_FEAR);
}
-
+
// some calculations
if (monster->type == MONS_BORING_BEETLE && monster->foe == MHITYOU)
{
@@ -2822,7 +2823,7 @@ static void _handle_nearby_ability(monsters *monster)
if (monster->ghost->cycle_colours)
monster->colour = random_colour();
break;
-
+
default: break;
}
} // end handle_nearby_ability()
@@ -2840,8 +2841,8 @@ static bool _handle_special_ability(monsters *monster, bolt & beem)
FixedArray < unsigned int, 19, 19 > show;
- const monster_type mclass = (mons_genus( monster->type ) == MONS_DRACONIAN)
- ? draco_subspecies( monster )
+ const monster_type mclass = (mons_genus( monster->type ) == MONS_DRACONIAN)
+ ? draco_subspecies( monster )
: static_cast<monster_type>( monster->type );
if (!mons_near( monster )
@@ -2857,10 +2858,10 @@ static bool _handle_special_ability(monsters *monster, bolt & beem)
case MONS_ORC_WARLORD:
if (is_sanctuary(monster->x, monster->y))
break;
-
+
used = orc_battle_cry(monster);
break;
-
+
case MONS_ORANGE_STATUE:
if (is_sanctuary(you.x_pos, you.y_pos)
|| is_sanctuary(monster->x, monster->y))
@@ -2882,7 +2883,7 @@ static bool _handle_special_ability(monsters *monster, bolt & beem)
case MONS_BALL_LIGHTNING:
if (is_sanctuary(monster->x, monster->y))
break;
-
+
if (monster->attitude == ATT_HOSTILE
&& distance( you.x_pos, you.y_pos, monster->x, monster->y ) <= 5)
{
@@ -3027,7 +3028,7 @@ static bool _handle_special_ability(monsters *monster, bolt & beem)
if (one_chance_in(3))
used = moth_incite_monsters(monster);
break;
-
+
case MONS_PIT_FIEND:
if (one_chance_in(3))
break;
@@ -3072,7 +3073,7 @@ static bool _handle_special_ability(monsters *monster, bolt & beem)
// good idea?
if (mons_should_fire(beem))
{
- simple_monster_message( monster, " makes a gesture!",
+ simple_monster_message( monster, " makes a gesture!",
MSGCH_MONSTER_SPELL );
mons_cast(monster, beem, spell_cast);
@@ -3242,7 +3243,7 @@ static bool _handle_special_ability(monsters *monster, bolt & beem)
}
bool already_beheld = player_beheld_by(monster);
-
+
if (one_chance_in(5)
|| monster->foe == MHITYOU && !already_beheld && coinflip())
{
@@ -3267,13 +3268,13 @@ static bool _handle_special_ability(monsters *monster, bolt & beem)
mpr("You hear a haunting song.", MSGCH_SOUND);
else
mpr("You hear an eerie melody.", MSGCH_SOUND);
-
+
canned_msg(MSG_YOU_RESIST); // flavour only
}
break;
}
}
-
+
// once beheld by a particular monster, cannot resist anymore
if (!already_beheld
&& (you.species == SP_MERFOLK || you_resist_magic(100)))
@@ -3484,7 +3485,7 @@ static bool _handle_reaching(monsters *monster)
static bool _handle_scroll(monsters *monster)
{
// yes, there is a logic to this ordering {dlb}:
- if (monster->has_ench(ENCH_CONFUSION)
+ if (monster->has_ench(ENCH_CONFUSION)
|| monster->behaviour == BEH_SLEEP
|| monster->has_ench(ENCH_SUBMERGED))
{
@@ -3671,7 +3672,7 @@ static bool _handle_wand(monsters *monster, bolt &beem)
return (false);
case WAND_INVISIBILITY:
- if (!monster->has_ench(ENCH_INVIS)
+ if (!monster->has_ench(ENCH_INVIS)
&& !monster->has_ench(ENCH_SUBMERGED)
&& (!mons_friendly(monster) || player_see_invis(false)))
{
@@ -3790,9 +3791,9 @@ static spell_type _get_draconian_breath_spell( const monsters *monster )
// [ds] Check line-of-fire here. It won't happen elsewhere.
bolt beem;
setup_mons_cast(monster, beem, draco_breath);
-
+
fire_tracer(monster, beem);
-
+
if (!mons_should_fire(beem))
draco_breath = SPELL_NO_SPELL;
}
@@ -3839,7 +3840,7 @@ static bool _mons_announce_cast(monsters *monster, bool nearby,
}
else if (mons_is_demon( monster->type ))
{
- simple_monster_message( monster, " gestures.",
+ simple_monster_message( monster, " gestures.",
MSGCH_MONSTER_SPELL );
}
else
@@ -3869,18 +3870,18 @@ static bool _mons_announce_cast(monsters *monster, bool nearby,
switch (random2(3))
{
case 0:
- simple_monster_message( monster,
+ simple_monster_message( monster,
" prays.",
MSGCH_MONSTER_SPELL );
break;
case 1:
- simple_monster_message( monster,
+ simple_monster_message( monster,
" mumbles some strange prayers.",
MSGCH_MONSTER_SPELL );
break;
case 2:
default:
- simple_monster_message( monster,
+ simple_monster_message( monster,
" utters an invocation.",
MSGCH_MONSTER_SPELL );
break;
@@ -3892,21 +3893,21 @@ static bool _mons_announce_cast(monsters *monster, bool nearby,
{
case 0:
// XXX: could be better, chosen to match the
- // ones in monspeak.cc... has the problem
+ // ones in monspeak.cc... has the problem
// that it doesn't suggest a vocal component. -- bwr
if (player_monster_visible(monster))
- simple_monster_message( monster,
+ simple_monster_message( monster,
" gestures wildly.",
MSGCH_MONSTER_SPELL );
break;
case 1:
- simple_monster_message( monster,
+ simple_monster_message( monster,
" mumbles some strange words.",
MSGCH_MONSTER_SPELL );
break;
case 2:
default:
- simple_monster_message( monster,
+ simple_monster_message( monster,
" casts a spell.",
MSGCH_MONSTER_SPELL );
break;
@@ -4025,12 +4026,12 @@ static bool _handle_spell( monsters *monster, bolt & beem )
return (false); //jmf: shapeshifters don't get spells, just
// physical powers.
}
- else if (monster->has_ench(ENCH_CONFUSION)
+ else if (monster->has_ench(ENCH_CONFUSION)
&& !mons_class_flag(monster->type, M_CONFUSED))
{
return (false);
}
- else if (monster->type == MONS_PANDEMONIUM_DEMON
+ else if (monster->type == MONS_PANDEMONIUM_DEMON
&& !monster->ghost->spellcaster)
{
return (false);
@@ -4058,7 +4059,7 @@ static bool _handle_spell( monsters *monster, bolt & beem )
|| monster->has_spell(SPELL_GREATER_HEALING))
&& monster->hit_points < monster->max_hit_points)
{
- // The player's out of sight!
+ // The player's out of sight!
// Quick, let's take a turn to heal ourselves. -- bwr
spell_cast =
monster->has_spell(SPELL_GREATER_HEALING)?
@@ -4102,13 +4103,13 @@ static bool _handle_spell( monsters *monster, bolt & beem )
}
// Promote the casting of useful spells for low-HP monsters.
- if (!finalAnswer
+ if (!finalAnswer
&& monster->hit_points < monster->max_hit_points / 4
&& !one_chance_in(4))
{
// Note: There should always be at least some chance we don't
// get here... even if the monster is on its last HP. That
- // way we don't have to worry about monsters infinitely casting
+ // way we don't have to worry about monsters infinitely casting
// Healing on themselves (e.g. orc high priests).
if (monster->behaviour == BEH_FLEE
&& ms_low_hitpoint_cast( monster, hspell_pass[5] ))
@@ -4140,14 +4141,14 @@ static bool _handle_spell( monsters *monster, bolt & beem )
{
return (false);
}
-
+
// remove healing/invis/haste if we don't need them
int num_no_spell = 0;
for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; i++)
{
if (hspell_pass[i] == SPELL_NO_SPELL)
- num_no_spell++;
+ num_no_spell++;
else if (ms_waste_of_time( monster, hspell_pass[i] )
// should monster not have selected dig by now, it never will:
|| hspell_pass[i] == SPELL_DIG)
@@ -4169,11 +4170,11 @@ static bool _handle_spell( monsters *monster, bolt & beem )
{
bool spellOK = false;
- // setup spell - fleeing monsters will always try to
+ // setup spell - fleeing monsters will always try to
// choose their emergency spell.
if (monster->behaviour == BEH_FLEE)
{
- spell_cast = (one_chance_in(5) ? SPELL_NO_SPELL
+ spell_cast = (one_chance_in(5) ? SPELL_NO_SPELL
: hspell_pass[5]);
}
else if (is_sanctuary(you.x_pos, you.y_pos)
@@ -4223,7 +4224,7 @@ static bool _handle_spell( monsters *monster, bolt & beem )
// a measure of time instead of peeking to see
// if the player is still there). -- bwr
if (!mons_player_visible( monster )
- && (monster->target_x != you.x_pos
+ && (monster->target_x != you.x_pos
|| monster->target_y != you.y_pos
|| coinflip()))
{
@@ -4255,8 +4256,8 @@ static bool _handle_spell( monsters *monster, bolt & beem )
// If there's otherwise no ranged attack use the breath weapon.
// The breath weapon is also occasionally used.
- if (draco_breath != SPELL_NO_SPELL
- && (spell_cast == SPELL_NO_SPELL
+ if (draco_breath != SPELL_NO_SPELL
+ && (spell_cast == SPELL_NO_SPELL
|| (!_is_emergency_spell(hspell_pass, spell_cast)
&& one_chance_in(4)))
&& !is_sanctuary(you.x_pos, you.y_pos)
@@ -4281,7 +4282,7 @@ static bool _handle_spell( monsters *monster, bolt & beem )
if (!_mons_announce_cast(monster, monsterNearby,
spell_cast, draco_breath))
return (false);
-
+
// FINALLY! determine primary spell effects {dlb}:
if (spell_cast == SPELL_BLINK)
{
@@ -4337,7 +4338,7 @@ int mons_weapon_damage_rating(const item_def &launcher)
// which may be NULL), works out whether using missiles or throwing the
// main weapon (with returning brand) is better. If using missiles that
// need a launcher, sets *launcher to the launcher.
-//
+//
// If the monster has no ranged weapon attack, returns NON_ITEM.
//
int mons_pick_best_missile(monsters *mons, item_def **launcher,
@@ -4355,7 +4356,7 @@ int mons_pick_best_missile(monsters *mons, item_def **launcher,
melee = item;
}
}
-
+
const item_def *missiles = mons->missiles();
if (launch && missiles && !missiles->launched_by(*launch))
launch = NULL;
@@ -4448,7 +4449,7 @@ static bool _handle_throw(monsters *monster, bolt & beem)
// set fake damage for the tracer.
beem.damage = dice_def(10, 10);
-
+
// fire tracer
fire_tracer( monster, beem );
@@ -4460,7 +4461,7 @@ static bool _handle_throw(monsters *monster, bolt & beem)
{
if (launcher && launcher != weapon)
monster->swap_weapons();
-
+
beem.name.clear();
return (mons_throw( monster, beem, mon_item ));
}
@@ -4596,7 +4597,7 @@ static void _handle_monster_move(int i, monsters *monster)
_monster_add_energy(monster);
// Handle clouds on nonmoving monsters:
- if (monster->speed == 0)
+ if (monster->speed == 0)
{
if (env.cgrid[monster->x][monster->y] != EMPTY_CLOUD
&& !monster->has_ench(ENCH_SUBMERGED))
@@ -4636,15 +4637,15 @@ static void _handle_monster_move(int i, monsters *monster)
if (monster->type == MONS_SHAPESHIFTER)
monster->add_ench(ENCH_SHAPESHIFTER);
- // We reset batty monsters from wander to seek here, instead
+ // We reset batty monsters from wander to seek here, instead
// of in handle_behaviour() since that will be called with
- // every single movement, and we want these monsters to
+ // every single movement, and we want these monsters to
// hit and run. -- bwr
- if (monster->foe != MHITNOT
+ if (monster->foe != MHITNOT
&& monster->behaviour == BEH_WANDER
&& testbits( monster->flags, MF_BATTY ))
{
- monster->behaviour = BEH_SEEK;
+ monster->behaviour = BEH_SEEK;
}
monster->check_speed();
@@ -4717,7 +4718,7 @@ static void _handle_monster_move(int i, monsters *monster)
monster->speed_increment -= non_move_energy;
continue;
}
-
+
_handle_behaviour(monster);
// submerging monsters will hide from clouds
@@ -4753,7 +4754,7 @@ static void _handle_monster_move(int i, monsters *monster)
DEBUG_ENERGY_USE("handle_pickup()");
continue;
}
- }
+ }
}
if (mons_is_caught(monster))
@@ -4972,7 +4973,7 @@ static void _handle_monster_move(int i, monsters *monster)
monster->speed_increment -= non_move_energy;
}
update_beholders(monster);
-
+
// reevaluate behaviour, since the monster's
// surroundings have changed (it may have moved,
// or died for that matter. Don't bother for
@@ -4990,7 +4991,7 @@ static void _handle_monster_move(int i, monsters *monster)
// detach monster from the grid first, so it
// doesn't get hit by its own explosion (GDL)
mgrd[monster->x][monster->y] = NON_MONSTER;
-
+
spore_goes_pop( monster );
monster_cleanup( monster );
return;
@@ -5022,11 +5023,11 @@ void handle_monsters(void)
if (monster->type == -1 || immobile_monster[i])
continue;
- const int mx = monster->x,
+ const int mx = monster->x,
my = monster->y;
_handle_monster_move(i, monster);
- if (!invalid_monster(monster)
+ if (!invalid_monster(monster)
&& (monster->x != mx || monster->y != my))
{
immobile_monster[i] = true;
@@ -5045,7 +5046,7 @@ void handle_monsters(void)
}
} // end of for loop
- // Clear any summoning flags so that lower indiced
+ // Clear any summoning flags so that lower indiced
// monsters get their actions in the next round.
for (int i = 0; i < MAX_MONSTERS; i++)
{
@@ -5069,7 +5070,7 @@ static bool _is_item_jelly_edible(const item_def &item)
// don't eat special game items
if (item.base_type == OBJ_ORBS
- || (item.base_type == OBJ_MISCELLANY
+ || (item.base_type == OBJ_MISCELLANY
&& (item.sub_type == MISC_RUNE_OF_ZOT
|| item.sub_type == MISC_HORN_OF_GERYON)))
{
@@ -5106,7 +5107,7 @@ static bool _handle_pickup(monsters *monster)
int eaten = 0;
bool eaten_net = false;
- for (item = igrd[monster->x][monster->y];
+ for (item = igrd[monster->x][monster->y];
item != NON_ITEM && eaten < max_eat && hps_gained < 50;
item = mitm[item].link)
{
@@ -5114,7 +5115,7 @@ static bool _handle_pickup(monsters *monster)
if (!_is_item_jelly_edible(mitm[item]))
continue;
-
+
if (mitm[igrd[monster->x][monster->y]].base_type != OBJ_GOLD)
{
if (quant > max_eat - eaten)
@@ -5122,7 +5123,7 @@ static bool _handle_pickup(monsters *monster)
hps_gained += (quant * item_mass( mitm[item] )) / 20 + quant;
eaten += quant;
-
+
if (mons_is_caught(monster)
&& mitm[item].base_type == OBJ_MISSILES
&& mitm[item].sub_type == MI_THROWING_NET
@@ -5185,7 +5186,7 @@ static bool _handle_pickup(monsters *monster)
} // end "if jellies"
// Note: Monsters only look at stuff near the top of stacks.
-
+
for (item = igrd[monster->x][monster->y]; item != NON_ITEM; )
{
item_def &topickup = mitm[item];
@@ -5216,7 +5217,7 @@ static void _jelly_grows(monsters *monster)
if (mons_class_flag( monster->type, M_SPLITS ))
{
// and here is where the jelly might divide {dlb}
- const int reqd = (monster->hit_dice < 6) ? 50
+ const int reqd = (monster->hit_dice < 6) ? 50
: monster->hit_dice * 8;
if (monster->hit_points >= reqd)
@@ -5371,13 +5372,13 @@ void mons_check_pool(monsters *mons, killer_type killer, int killnum)
// Levitating/flying monsters don't make contact with the terrain.
if (mons->airborne())
return;
-
+
dungeon_feature_type grid = grd(mons->pos());
if ((grid == DNGN_LAVA || grid == DNGN_DEEP_WATER)
&& !monster_habitable_grid(mons, grid))
{
const bool message = mons_near(mons);
-
+
// don't worry about invisibility - you should be able to
// see if something has fallen into the lava
if (message)
@@ -5512,7 +5513,7 @@ static bool _is_trap_safe(const monsters *monster, const int trap_x,
return (true);
return (false);
}
-
+
// Monsters are not afraid of non-mechanical traps. XXX: If we add
// any non-mechanical traps that can damage monsters, must add
// check here.
@@ -5575,7 +5576,7 @@ static bool _is_trap_safe(const monsters *monster, const int trap_x,
{
return (false);
}
-
+
// Healthy monsters don't mind a little pain.
if (mechanical && monster->hit_points >= monster->max_hit_points / 2
&& (intel == I_ANIMAL
@@ -5583,7 +5584,7 @@ static bool _is_trap_safe(const monsters *monster, const int trap_x,
{
return (true);
}
-
+
// Friendly monsters don't enjoy Zot trap perks, handle accordingly.
if (mons_friendly(monster))
return (mechanical? mons_flies(monster) : trap.type != TRAP_ZOT);
@@ -5805,7 +5806,7 @@ bool _mon_can_move_to_pos(const monsters *monster, const int count_x,
case CLOUD_MIASMA:
// Even the dumbest monsters will avoid miasma if they can.
return (mons_res_miasma(monster) > 0);
-
+
case CLOUD_FIRE:
if (mons_res_fire(monster) > 1)
return true;
@@ -5850,7 +5851,7 @@ bool _mon_can_move_to_pos(const monsters *monster, const int count_x,
if (monster->hit_points >= random2avg(19, 2))
return true;
break;
-
+
default:
return true; // harmless clouds
}
@@ -5860,7 +5861,7 @@ bool _mon_can_move_to_pos(const monsters *monster, const int count_x,
if (mons_intel(monster->type) != I_PLANT)
return false;
}
-
+
// if we end up here the monster can safely move
return true;
}
@@ -6021,8 +6022,8 @@ static bool _monster_move(monsters *monster)
if (one_chance_in( count ))
{
- mmov_x = count_x - 1;
- mmov_y = count_y - 1;
+ mmov_x = count_x - 1;
+ mmov_y = count_y - 1;
}
}
}
@@ -6036,7 +6037,7 @@ static bool _monster_move(monsters *monster)
if (good_move[mmov_x + 1][mmov_y + 1] == false)
{
int current_distance = grid_distance( monster->x, monster->y,
- monster->target_x,
+ monster->target_x,
monster->target_y );
int dir = -1;
@@ -6080,7 +6081,7 @@ static bool _monster_move(monsters *monster)
{
dist[i] = grid_distance( monster->x + compass_x[newdir],
monster->y + compass_y[newdir],
- monster->target_x,
+ monster->target_x,
monster->target_y );
}
else
@@ -6137,7 +6138,7 @@ forget_it:
// take care of beetle burrowing
if (monster->type == MONS_BORING_BEETLE)
{
- dungeon_feature_type feat =
+ dungeon_feature_type feat =
grd[monster->x + mmov_x][monster->y + mmov_y];
if ((feat == DNGN_ROCK_WALL || feat == DNGN_ROCK_WALL)
&& good_move[mmov_x + 1][mmov_y + 1] == true)
@@ -6212,21 +6213,21 @@ forget_it:
if (monster->type == MONS_EFREET
|| monster->type == MONS_FIRE_ELEMENTAL)
{
- place_cloud( CLOUD_FIRE, monster->x, monster->y,
+ place_cloud( CLOUD_FIRE, monster->x, monster->y,
2 + random2(4), monster->kill_alignment() );
}
- if (monster->type == MONS_ROTTING_DEVIL
+ if (monster->type == MONS_ROTTING_DEVIL
|| monster->type == MONS_CURSE_TOE)
{
- place_cloud( CLOUD_MIASMA, monster->x, monster->y,
+ place_cloud( CLOUD_MIASMA, monster->x, monster->y,
2 + random2(3), monster->kill_alignment() );
}
}
else
{
mmov_x = mmov_y = 0;
-
+
// fleeing monsters that can't move will panic and possibly
// turn to face their attacker
if (monster->behaviour == BEH_FLEE)
diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc
index 5313dd04f8..08705851d7 100644
--- a/crawl-ref/source/mstuff2.cc
+++ b/crawl-ref/source/mstuff2.cc
@@ -22,6 +22,7 @@
#include <string>
#include <string.h>
#include <stdio.h>
+#include <algorithm>
#include "externs.h"
@@ -391,7 +392,7 @@ void mons_trap(struct monsters *monster)
if (monsterNearby)
{
mprf("A%s %s %s%s!",
- beem.name.c_str(),
+ beem.name.c_str(),
(damage_taken >= 0) ? "hits" : "misses",
monster->name(DESC_NOCAP_THE).c_str(),
(damage_taken == 0) ? ", but does no damage" : "");
@@ -413,7 +414,7 @@ void mons_trap(struct monsters *monster)
// reveal undiscovered traps, where appropriate: {dlb}
if (monsterNearby && !trapKnown && revealTrap)
{
- grd[env.trap[which_trap].x][env.trap[which_trap].y]
+ grd[env.trap[which_trap].x][env.trap[which_trap].y]
= trap_category(env.trap[which_trap].type);
}
@@ -537,11 +538,11 @@ void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast)
simple_monster_message(monster, " is healed.");
}
return;
-
+
case SPELL_BERSERKER_RAGE:
monster->go_berserk(true);
return;
-
+
case SPELL_SUMMON_SMALL_MAMMAL:
case SPELL_VAMPIRE_SUMMON:
if ( spell_cast == SPELL_SUMMON_SMALL_MAMMAL )
@@ -724,7 +725,7 @@ void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast)
for (sumcount = 0; sumcount < sumcount2; sumcount++)
{
create_monster( summon_any_demon(DEMON_GREATER), duration,
- SAME_ATTITUDE(monster), monster->x, monster->y,
+ SAME_ATTITUDE(monster), monster->x, monster->y,
monster->foe, MONS_PROGRAM_BUG );
}
return;
@@ -756,7 +757,7 @@ void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast)
for (int i = 0, size = monsters.size(); i < size; ++i)
{
create_monster( monsters[i], duration,
- SAME_ATTITUDE(monster),
+ SAME_ATTITUDE(monster),
monster->x, monster->y, monster->foe,
MONS_PROGRAM_BUG );
}
@@ -767,7 +768,7 @@ void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast)
{
const bool friendly = mons_friendly(monster);
bool need_friendly_stub = false;
- // Monster spell of uselessness, just prints a message.
+ // Monster spell of uselessness, just prints a message.
// This spell exists so that some monsters with really strong
// spells (ie orc priest) can be toned down a bit. -- bwr
//
@@ -791,7 +792,7 @@ void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast)
mpr( "You feel a wave of unholy energy pass over you." );
break;
case 3:
- simple_monster_message( monster, " looks stronger.",
+ simple_monster_message( monster, " looks stronger.",
MSGCH_MONSTER_ENCHANT );
break;
case 4:
@@ -816,7 +817,7 @@ void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast)
if (need_friendly_stub)
simple_monster_message(monster, " shimmers for a moment.",
MSGCH_MONSTER_ENCHANT);
-
+
return;
}
}
@@ -916,12 +917,12 @@ void setup_mons_cast(const monsters *monster, struct bolt &pbolt, int spell_cast
pbolt.is_beam = theBeam.is_beam;
pbolt.source_x = monster->x;
pbolt.source_y = monster->y;
- pbolt.is_tracer = false;
+ pbolt.is_tracer = false;
pbolt.is_explosion = theBeam.is_explosion;
if (pbolt.name.length() && pbolt.name[0] != '0')
pbolt.aux_source = pbolt.name;
- else
+ else
pbolt.aux_source.clear();
if (spell_cast == SPELL_HASTE
@@ -1034,7 +1035,7 @@ void monster_teleport(struct monsters *monster, bool instan, bool silent)
void setup_dragon(struct monsters *monster, struct bolt &pbolt)
{
- const int type = (mons_genus( monster->type ) == MONS_DRACONIAN)
+ const int type = (mons_genus( monster->type ) == MONS_DRACONIAN)
? draco_subspecies( monster ) : monster->type;
int scaling = 100;
@@ -1088,7 +1089,7 @@ void setup_dragon(struct monsters *monster, struct bolt &pbolt)
pbolt.aux_source = "blast of draining breath";
scaling = 65;
break;
-
+
default:
DEBUGSTR("Bad monster class in setup_dragon()");
break;
@@ -1103,7 +1104,7 @@ void setup_dragon(struct monsters *monster, struct bolt &pbolt)
pbolt.beam_source = monster_index(monster);
pbolt.thrower = KILL_MON;
pbolt.is_beam = true;
-
+
// accuracy is halved if the dragon is attacking a target that's
// wielding a weapon of dragon slaying (which makes the
// dragon/draconian avoid looking at the foe).
@@ -1227,7 +1228,7 @@ bool mons_throw(struct monsters *monster, struct bolt &pbolt, int hand_used)
// ammo damage needs adjusting here - OBJ_MISSILES
// don't get separate tohit/damage bonuses!
ammoDamBonus = ammoHitBonus;
-
+
// [dshaligram] Thrown stones/darts do only half the damage of
// launched stones/darts. This matches 4.0 behaviour.
if (wepType == MI_DART || wepType == MI_STONE
@@ -1292,10 +1293,10 @@ bool mons_throw(struct monsters *monster, struct bolt &pbolt, int hand_used)
exHitBonus = (hitMult * monster->hit_dice) / 10 + 1;
exDamBonus = (damMult * monster->hit_dice) / 10 + 1;
- // monsters no longer gain unfair advantages with weapons of fire/ice
+ // monsters no longer gain unfair advantages with weapons of fire/ice
// and incorrect ammo. They now have same restriction as players.
- const int bow_brand =
+ const int bow_brand =
get_weapon_brand(mitm[monster->inv[MSLOT_WEAPON]]);
const int ammo_brand = get_ammo_brand( item );
@@ -1410,18 +1411,18 @@ bool mons_throw(struct monsters *monster, struct bolt &pbolt, int hand_used)
if (monster->visible())
mpr(msg.c_str());
- // [dshaligram] When changing bolt names here, you must edit
+ // [dshaligram] When changing bolt names here, you must edit
// hiscores.cc (scorefile_entry::terse_missile_cause()) to match.
- if (projected == LRET_LAUNCHED)
+ if (projected == LRET_LAUNCHED)
{
snprintf( throw_buff, sizeof(throw_buff), "Shot with a%s %s by %s",
- (is_vowel(pbolt.name[0]) ? "n" : ""), pbolt.name.c_str(),
+ (is_vowel(pbolt.name[0]) ? "n" : ""), pbolt.name.c_str(),
monster->name(DESC_NOCAP_A).c_str() );
}
else
{
snprintf( throw_buff, sizeof(throw_buff), "Hit by a%s %s thrown by %s",
- (is_vowel(pbolt.name[0]) ? "n" : ""), pbolt.name.c_str(),
+ (is_vowel(pbolt.name[0]) ? "n" : ""), pbolt.name.c_str(),
monster->name(DESC_NOCAP_A).c_str() );
}
@@ -1442,13 +1443,13 @@ bool mons_throw(struct monsters *monster, struct bolt &pbolt, int hand_used)
if (monster->has_ench(ENCH_BATTLE_FRENZY))
{
const mon_enchant ench = monster->get_ench(ENCH_BATTLE_FRENZY);
-
+
#ifdef DEBUG_DIAGNOSTICS
const dice_def orig_damage = pbolt.damage;
#endif
-
+
pbolt.damage.size = pbolt.damage.size * (115 + ench.degree * 15) / 100;
-
+
#ifdef DEBUG_DIAGNOSTICS
mprf(MSGCH_DIAGNOSTICS, "%s frenzy damage: %dd%d -> %dd%d",
monster->name(DESC_PLAIN).c_str(),
@@ -1456,7 +1457,7 @@ bool mons_throw(struct monsters *monster, struct bolt &pbolt, int hand_used)
pbolt.damage.num, pbolt.damage.size);
#endif
}
-
+
// Skilled archers get better to-hit and damage.
if (skilled)
{
@@ -1578,7 +1579,7 @@ void spore_goes_pop(struct monsters *monster)
}
bool nearby = mons_near(monster);
-
+
if (nearby)
{
viewwindow(true, false);
@@ -1664,8 +1665,8 @@ bolt mons_spells( int spell_cast, int power )
beam.rangeMax = 9;
beam.damage = dice_def( 3, std::min(6 + power / 7, 40) );
beam.is_beam = true;
- break;
-
+ break;
+
case SPELL_PARALYSE:
beam.name = "0";
beam.range = 5;
@@ -1705,7 +1706,7 @@ bolt mons_spells( int spell_cast, int power )
beam.thrower = KILL_MON_MISSILE;
beam.is_beam = true;
break;
-
+
case SPELL_CONFUSE:
beam.name = "0";
beam.range = 5;
@@ -1772,7 +1773,7 @@ bolt mons_spells( int spell_cast, int power )
beam.hit = 17 + power / 25;
beam.is_beam = true;
break;
-
+
case SPELL_BOLT_OF_FIRE:
beam.name = "bolt of fire";
beam.range = 5;
@@ -1798,7 +1799,7 @@ bolt mons_spells( int spell_cast, int power )
beam.hit = 17 + power / 25;
beam.is_beam = true;
break;
-
+
case SPELL_BOLT_OF_COLD:
beam.name = "bolt of cold";
beam.range = 5;
@@ -1838,7 +1839,7 @@ bolt mons_spells( int spell_cast, int power )
beam.hit = 17 + power / 20;
beam.is_beam = true;
break;
-
+
case SPELL_LIGHTNING_BOLT:
beam.name = "bolt of lightning";
beam.range = 7;
@@ -2126,7 +2127,7 @@ bolt mons_spells( int spell_cast, int power )
beam.is_big_cloud = true;
beam.range = beam.rangeMax = 8;
break;
-
+
case SPELL_QUICKSILVER_BOLT: // Quicksilver dragon
beam.colour = random_colour();
beam.name = "bolt of energy";
@@ -2203,7 +2204,7 @@ static int monster_abjure_square(const coord_def &pos,
const int mindex = mgrd(pos);
if (mindex == NON_MONSTER)
return (0);
-
+
monsters *target = &menv[mindex];
if (!target->alive() || ((bool)friendly == mons_friendly(target)))
return (0);
@@ -2276,14 +2277,14 @@ static int monster_abjuration(const monsters *caster, bool test)
maffected += number_hit;
// Each affected monster drops power.
- //
+ //
// We could further tune this by the actual amount of abjuration
// damage done to each summon, but the player will probably never
// notice. :-)
//
while (number_hit-- > 0)
pow = pow * 90 / 100;
-
+
pow /= 2;
}
return (maffected);
@@ -2352,7 +2353,7 @@ bool orc_battle_cry(monsters *chief)
{
const int dur =
random_range(12, 20) * speed_to_duration(mons->speed);
-
+
if (ench.ench != ENCH_NONE)
{
ench.degree = level;
@@ -2374,7 +2375,7 @@ bool orc_battle_cry(monsters *chief)
}
}
}
-
+
if (!affected.empty())
{
if (you.can_see(chief) && player_can_hear(chief->x, chief->y))
@@ -2442,7 +2443,7 @@ static bool make_monster_angry(const monsters *mon, monsters *targ)
if (need_message)
mprf("%s goads %s on!", mon->name(DESC_CAP_THE).c_str(),
targ->name(DESC_NOCAP_THE).c_str());
-
+
targ->go_berserk(false);
return (true);
diff --git a/crawl-ref/source/mtransit.cc b/crawl-ref/source/mtransit.cc
index 417a24d585..2a9edda813 100644
--- a/crawl-ref/source/mtransit.cc
+++ b/crawl-ref/source/mtransit.cc
@@ -7,6 +7,9 @@
*/
#include "AppHdr.h"
+
+#include <algorithm>
+
#include "mtransit.h"
#include "dungeon.h"
@@ -141,7 +144,7 @@ static bool place_lost_monster(follower &f)
#ifdef DEBUG_DIAGNOSTICS
mprf(MSGCH_DIAGNOSTICS, "Placing lost one: %s",
f.mons.name(DESC_PLAIN).c_str());
-#endif
+#endif
return (f.place(false));
}
@@ -209,7 +212,7 @@ void place_transiting_items()
pos.x = random_range(X_BOUND_1 + 1, X_BOUND_2 - 1);
pos.y = random_range(Y_BOUND_1 + 1, Y_BOUND_2 - 1);
}
-
+
const coord_def where_to_go
= dgn_find_nearby_stair(DNGN_ESCAPE_HATCH_DOWN, pos, true);
@@ -294,7 +297,7 @@ bool follower::place(bool near_player)
m.reset();
break;
}
-
+
return (false);
}
diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc
index 51138dd2a1..6d09c966e1 100644
--- a/crawl-ref/source/newgame.cc
+++ b/crawl-ref/source/newgame.cc
@@ -55,6 +55,7 @@
#include <string.h>
#include <ctype.h>
#include <time.h>
+#include <algorithm>
#ifdef DOS
#include <conio.h>
diff --git a/crawl-ref/source/overmap.cc b/crawl-ref/source/overmap.cc
index 0deb980903..cf02458678 100644
--- a/crawl-ref/source/overmap.cc
+++ b/crawl-ref/source/overmap.cc
@@ -22,6 +22,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
+#include <algorithm>
#include "externs.h"
@@ -62,11 +63,11 @@ void seen_notable_thing( dungeon_feature_type which_thing, int x, int y )
{
// Tell the world first.
dungeon_events.fire_position_event(DET_PLAYER_IN_LOS, coord_def(x, y));
-
+
// Don't record in temporary terrain
if (you.level_type != LEVEL_DUNGEON)
return;
-
+
const coord_def pos(x, y);
const god_type god = grid_altar_god(which_thing);
if (god != GOD_NO_GOD)
@@ -205,7 +206,7 @@ std::string overview_description_string()
disp += EOL;
seen_anything = true;
}
-
+
++branchcount;
snprintf(buffer, sizeof buffer, "<yellow>%-6s</yellow>: %-7s",
@@ -224,7 +225,7 @@ std::string overview_description_string()
// remove unworthy altars from the list we show the user. Yeah,
// one more round of map iteration.
const altar_map_type notable_altars = get_notable_altars(altars_present);
-
+
// print altars
// we loop through everything a dozen times, oh well
if ( !notable_altars.empty() )
@@ -237,7 +238,7 @@ std::string overview_description_string()
}
level_id last_id;
- std::map<level_pos, god_type>::const_iterator ci_altar;
+ std::map<level_pos, god_type>::const_iterator ci_altar;
for ( int cur_god = GOD_NO_GOD; cur_god < NUM_GODS; ++cur_god )
{
last_id.depth = 10000; // fake depth to be sure we don't match
@@ -517,7 +518,7 @@ void seen_altar( god_type god, const coord_def& pos )
// can't record in abyss or pan.
if ( you.level_type != LEVEL_DUNGEON )
return;
-
+
level_pos where(level_id::current(), pos);
altars_present[where] = god;
}
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index c6ce14f552..bb52c64d4f 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <string.h>
#include <sstream>
+#include <algorithm>
#include "externs.h"
@@ -233,7 +234,7 @@ int detect_creatures( int pow, bool telepathic )
if (mons_intel( mon->type ) == I_HIGH
&& mons_class_flag( mon->type, M_SPELLCASTER ))
{
- behaviour_event( mon, ME_DISTURB, MHITYOU,
+ behaviour_event( mon, ME_DISTURB, MHITYOU,
you.x_pos, you.y_pos );
}
}
@@ -402,7 +403,7 @@ int animate_dead( actor *caster, int power, beh_type corps_beh,
int animate_a_corpse( int axps, int ayps, beh_type corps_beh, int corps_hit,
int class_allowed )
-{
+{
int rc = 0;
int objl = igrd[axps][ayps];
// This searches all the items on the ground for a corpse
@@ -505,10 +506,10 @@ void cast_twisted(int power, beh_type corps_beh, int corps_hit)
mprf(MSGCH_DIAGNOSTICS, "Mass for abomination: %d", total_mass);
#endif
- // This is what the old statement pretty much boils down to,
+ // This is what the old statement pretty much boils down to,
// the average will be approximately 10 * power (or about 1000
// at the practical maximum). That's the same as the mass
- // of a hippogriff, a spiny frog, or a steam dragon. Thus,
+ // of a hippogriff, a spiny frog, or a steam dragon. Thus,
// material components are far more important to this spell. -- bwr
total_mass += roll_dice( 20, power );
@@ -549,7 +550,7 @@ void cast_twisted(int power, beh_type corps_beh, int corps_hit)
if (type_resurr == MONS_ABOMINATION_LARGE)
{
menv[mon].hit_dice = 8 + total_mass / ((colour == LIGHTRED) ? 500 :
- (colour == RED) ? 1000
+ (colour == RED) ? 1000
: 2500);
if (menv[mon].hit_dice > 30)
@@ -650,7 +651,7 @@ bool brand_weapon(brand_type which_brand, int power)
// [dshaligram] At level 7 it's costly enough to experiment
// with removing the miscast effect. We may need to revise the spell
// to level 8 or 9. XXX.
- // miscast_effect(SPTYP_TRANSLOCATION,
+ // miscast_effect(SPTYP_TRANSLOCATION,
// 9, 90, 100, "distortion branding");
break;
@@ -789,7 +790,7 @@ void turn_undead(int pow)
simple_monster_message( monster, " is repelled!" );
//mv: must be here to work
- behaviour_event( monster, ME_SCARE, MHITYOU );
+ behaviour_event( monster, ME_SCARE, MHITYOU );
// reduce power based on monster turned
pow -= monster->hit_dice * 3;
@@ -952,8 +953,8 @@ void cast_refrigeration(int pow)
mpr("You feel very cold.");
ouch( hurted, 0, KILLED_BY_FREEZING );
- // Note: this used to be 12!... and it was also applied even if
- // the player didn't take damage from the cold, so we're being
+ // Note: this used to be 12!... and it was also applied even if
+ // the player didn't take damage from the cold, so we're being
// a lot nicer now. -- bwr
expose_player_to_element(BEAM_COLD, 5);
}
@@ -1269,7 +1270,7 @@ int summon_elemental(int pow, int restricted_type,
}
else if (dir_x == 0 && dir_y == 0)
mpr("You can't summon an elemental from yourself!");
- else
+ else
break;
}
@@ -1473,7 +1474,7 @@ void summon_scorpions(int pow)
else
{
if (create_monster( MONS_SCORPION, 3, BEH_FRIENDLY,
- you.x_pos, you.y_pos,
+ you.x_pos, you.y_pos,
you.pet_target, MONS_PROGRAM_BUG,
false, false, false, true) != -1)
{
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index 019d2f81d8..50ca506833 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <string.h>
#include <iostream>
+#include <algorithm>
#include "externs.h"
@@ -1103,7 +1104,7 @@ void cast_poison_ammo(void)
{
mprf("%s %s covered in a thin film of poison.", old_desc,
(you.inv[ammo].quantity == 1) ? "is" : "are");
-
+
if (ammo == you.equip[EQ_WEAPON])
you.wield_change = true;
}
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc
index 248ba9422d..1e52124d7c 100644
--- a/crawl-ref/source/spells4.cc
+++ b/crawl-ref/source/spells4.cc
@@ -17,6 +17,7 @@
#include <string>
#include <iostream>
#include <stdio.h>
+#include <algorithm>
#include "externs.h"
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc
index 0b3b6212c1..b8f862365c 100644
--- a/crawl-ref/source/stuff.cc
+++ b/crawl-ref/source/stuff.cc
@@ -27,6 +27,7 @@
#include <cstdarg>
#include <sstream>
#include <iomanip>
+#include <algorithm>
#include <errno.h>
#include <stdlib.h>
@@ -84,7 +85,7 @@ radius_iterator::radius_iterator( const coord_def& _center, int _radius,
{
location.x = center.x - radius;
location.y = center.y - radius;
-
+
if ( !this->on_valid_square() )
++(*this);
}
@@ -392,7 +393,7 @@ int random_choose(int first, ...)
}
ASSERT(nargs > 0);
-
+
va_end(args);
return (chosen);
}
@@ -417,7 +418,7 @@ const char* random_choose_string(const char* first, ...)
}
ASSERT(nargs > 0);
-
+
va_end(args);
return (chosen);
}
@@ -441,7 +442,7 @@ int random_choose_weighted(int weight, int first, ...)
}
ASSERT(nargs > 0);
-
+
va_end(args);
return (chosen);
}
@@ -515,8 +516,8 @@ int roll_dice( int num, int size )
int ret = 0;
int i;
- // If num <= 0 or size <= 0, then we'll just return the default
- // value of zero. This is good behaviour in that it will be
+ // If num <= 0 or size <= 0, then we'll just return the default
+ // value of zero. This is good behaviour in that it will be
// appropriate for calculated values that might be passed in.
if (num > 0 && size > 0)
{
@@ -571,7 +572,7 @@ void cio_init()
#ifdef DOS
init_libdos();
#endif
-
+
crawl_view.init_geometry();
if (Options.char_set == CSET_UNICODE && !crawl_state.unicode_ok)
@@ -605,7 +606,7 @@ void cio_cleanup()
void end(int exit_code, bool print_error, const char *format, ...)
{
std::string error = print_error? strerror(errno) : "";
-
+
cio_cleanup();
databaseSystemShutdown();
if (format)
@@ -615,7 +616,7 @@ void end(int exit_code, bool print_error, const char *format, ...)
char buffer[100];
vsnprintf(buffer, sizeof buffer, format, arg);
va_end(arg);
-
+
if (error.empty())
error = std::string(buffer);
else
@@ -637,7 +638,7 @@ void end(int exit_code, bool print_error, const char *format, ...)
getchar();
}
#endif
-
+
exit(exit_code);
}
@@ -737,7 +738,7 @@ int stepdown_value(int base_value, int stepping, int first_step,
} // end stepdown_value()
int skill_bump( int skill )
-{
+{
return ((you.skills[skill] < 3) ? you.skills[skill] * 2
: you.skills[skill] + 3);
}
@@ -944,19 +945,19 @@ static std::string _list_alternative_yes(char yes1, char yes2,
help += yes1;
print_yes = true;
}
-
+
if (yes2 != 'Y' && yes2 != yes1)
{
if (print_yes)
help += "/";
-
+
if (lowered)
help += tolower(yes2);
else
help += yes2;
print_yes = true;
}
-
+
if (print_yes)
{
if (brackets)
@@ -964,7 +965,7 @@ static std::string _list_alternative_yes(char yes1, char yes2,
else
help = "/" + help;
}
-
+
return help;
}
@@ -1000,7 +1001,7 @@ int yesnoquit( const char* str, bool safe, int safeanswer,
if ( tmp == CK_ESCAPE || tmp == 'q' || tmp == 'Q' )
return -1;
-
+
if ((tmp == ' ' || tmp == '\r' || tmp == '\n') && safeanswer)
tmp = safeanswer;
@@ -1111,8 +1112,8 @@ void random_in_bounds( int &x_pos, int &y_pos, int terr,
else if (terr == DNGN_DEEP_WATER
&& grd[x_pos][y_pos] == DNGN_SHALLOW_WATER)
done = true;
- else if (empty
- && mgrd[x_pos][y_pos] != NON_MONSTER
+ else if (empty
+ && mgrd[x_pos][y_pos] != NON_MONSTER
&& (x_pos != you.x_pos || y_pos != you.y_pos))
{
done = true;
@@ -1145,7 +1146,7 @@ bool is_element_colour( int col )
int element_colour( int element, bool no_random )
{
- // Doing this so that we don't have to do recursion here at all
+ // Doing this so that we don't have to do recursion here at all
// (these were the only cases which had possible double evaluation):
if (element == EC_FLOOR)
element = env.floor_colour;
@@ -1159,7 +1160,7 @@ int element_colour( int element, bool no_random )
int ret = BLACK;
// Setting no_random to true will get the first colour in the cases
- // below. This is potentially useful for calls to this function
+ // below. This is potentially useful for calls to this function
// which might want a consistent result.
int tmp_rand = (no_random ? 0 : random2(120));
@@ -1167,13 +1168,13 @@ int element_colour( int element, bool no_random )
{
case EC_FIRE:
ret = (tmp_rand < 40) ? RED :
- (tmp_rand < 80) ? YELLOW
+ (tmp_rand < 80) ? YELLOW
: LIGHTRED;
break;
case EC_ICE:
ret = (tmp_rand < 40) ? LIGHTBLUE :
- (tmp_rand < 80) ? BLUE
+ (tmp_rand < 80) ? BLUE
: WHITE;
break;
@@ -1187,7 +1188,7 @@ int element_colour( int element, bool no_random )
case EC_ELECTRICITY:
ret = (tmp_rand < 40) ? LIGHTCYAN :
- (tmp_rand < 80) ? LIGHTBLUE
+ (tmp_rand < 80) ? LIGHTBLUE
: CYAN;
break;
@@ -1202,7 +1203,7 @@ int element_colour( int element, bool no_random )
case EC_MAGIC:
ret = (tmp_rand < 30) ? LIGHTMAGENTA :
(tmp_rand < 60) ? LIGHTBLUE :
- (tmp_rand < 90) ? MAGENTA
+ (tmp_rand < 90) ? MAGENTA
: BLUE;
break;
@@ -1242,7 +1243,7 @@ int element_colour( int element, bool no_random )
case EC_VEHUMET:
ret = (tmp_rand < 40) ? LIGHTRED :
- (tmp_rand < 80) ? LIGHTMAGENTA
+ (tmp_rand < 80) ? LIGHTMAGENTA
: LIGHTBLUE;
break;
@@ -1253,20 +1254,20 @@ int element_colour( int element, bool no_random )
case EC_CRYSTAL:
ret = (tmp_rand < 40) ? LIGHTGREY :
- (tmp_rand < 80) ? GREEN
+ (tmp_rand < 80) ? GREEN
: LIGHTRED;
break;
case EC_SLIME:
ret = (tmp_rand < 40) ? GREEN :
- (tmp_rand < 80) ? BROWN
+ (tmp_rand < 80) ? BROWN
: LIGHTGREEN;
break;
case EC_SMOKE:
ret = (tmp_rand < 30) ? LIGHTGREY :
(tmp_rand < 60) ? DARKGREY :
- (tmp_rand < 90) ? LIGHTBLUE
+ (tmp_rand < 90) ? LIGHTBLUE
: MAGENTA;
break;
@@ -1279,36 +1280,36 @@ int element_colour( int element, bool no_random )
(tmp_rand < 72) ? LIGHTBLUE :
(tmp_rand < 84) ? MAGENTA :
(tmp_rand < 96) ? RED :
- (tmp_rand < 108) ? GREEN
+ (tmp_rand < 108) ? GREEN
: BLUE;
break;
case EC_ELVEN:
ret = (tmp_rand < 40) ? LIGHTGREEN :
(tmp_rand < 80) ? GREEN :
- (tmp_rand < 100) ? LIGHTBLUE
+ (tmp_rand < 100) ? LIGHTBLUE
: BLUE;
break;
case EC_DWARVEN:
ret = (tmp_rand < 40) ? BROWN :
(tmp_rand < 80) ? LIGHTRED :
- (tmp_rand < 100) ? LIGHTGREY
+ (tmp_rand < 100) ? LIGHTGREY
: CYAN;
break;
case EC_ORCISH:
ret = (tmp_rand < 40) ? DARKGREY :
(tmp_rand < 80) ? RED :
- (tmp_rand < 100) ? BROWN
+ (tmp_rand < 100) ? BROWN
: MAGENTA;
break;
case EC_GILA:
ret = (tmp_rand < 30) ? LIGHTMAGENTA :
(tmp_rand < 60) ? MAGENTA :
- (tmp_rand < 90) ? YELLOW :
- (tmp_rand < 105) ? LIGHTRED
+ (tmp_rand < 90) ? YELLOW :
+ (tmp_rand < 105) ? LIGHTRED
: RED;
break;
@@ -1414,7 +1415,7 @@ int near_stairs(const coord_def &p, int max_dist,
continue;
stair_type = get_feature_dchar(feat);
-
+
// is it a branch stair?
for (int i = 0; i < NUM_BRANCHES; ++i)
{
@@ -1466,12 +1467,12 @@ void zap_los_monsters()
continue;
int imon = mgrd[gx][gy];
-
+
// at tutorial beginning disallow items in line of sight
if (Options.tutorial_events[TUT_SEEN_FIRST_OBJECT])
{
int item = igrd[gx][gy];
-
+
if (item != NON_ITEM && is_valid_item(mitm[item]) )
destroy_item(item);
}
@@ -1485,7 +1486,7 @@ void zap_los_monsters()
if (mons_class_flag( mon->type, M_NO_EXP_GAIN ))
continue;
-
+
#ifdef DEBUG_DIAGNOSTICS
mprf(MSGCH_DIAGNOSTICS, "Dismissing %s",
mon->name(DESC_PLAIN, true).c_str() );
diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc
index 6c956e1f6c..78a74fd8b7 100644
--- a/crawl-ref/source/tags.cc
+++ b/crawl-ref/source/tags.cc
@@ -55,6 +55,7 @@
#include <stdio.h>
#include <string.h> // for memcpy
#include <iterator>
+#include <algorithm>
#ifdef UNIX
#include <sys/types.h>
@@ -575,7 +576,7 @@ bool unmarshallBoolean(reader &th)
std::string make_date_string( time_t in_date )
{
char buff[20];
-
+
if (in_date <= 0)
{
buff[0] = 0;
@@ -584,7 +585,7 @@ std::string make_date_string( time_t in_date )
struct tm *date = localtime( &in_date );
- snprintf( buff, sizeof buff,
+ snprintf( buff, sizeof buff,
"%4d%02d%02d%02d%02d%02d%s",
date->tm_year + 1900, date->tm_mon, date->tm_mday,
date->tm_hour, date->tm_min, date->tm_sec,
@@ -685,7 +686,7 @@ void tag_write(tag_type tagID, FILE* outf)
// Read a single tagged chunk of data from fp into memory.
// TAG_NO_TAG is returned if there's nothing left to read in the file
// (or on an error).
-//
+//
// minorVersion is available for any sub-readers that need it
// (like TAG_LEVEL_MONSTERS)
tag_type tag_read(FILE *fp, char minorVersion)
@@ -773,7 +774,7 @@ void tag_missing(int tag, char minorVersion)
case TAG_LEVEL_TILES:
tag_missing_level_tiles();
break;
- default:
+ default:
perror("Tag is missing; file is likely corrupt.");
end(-1);
}
@@ -993,7 +994,7 @@ static void tag_construct_you(writer &th)
marshallShort(th, you.transit_stair);
marshallByte(th, you.entering_level);
-
+
// list of currently beholding monsters (usually empty)
marshallByte(th, you.beheld_by.size());
for (unsigned int k = 0; k < you.beheld_by.size(); k++)
@@ -1133,7 +1134,7 @@ static void marshall_follower(writer &th, const follower &f)
{
marshall_monster(th, f.mons);
for (int i = 0; i < NUM_MONSTER_SLOTS; ++i)
- marshallItem(th, f.items[i]);
+ marshallItem(th, f.items[i]);
}
static void unmarshall_follower(reader &th, follower &f)
@@ -1146,7 +1147,7 @@ static void unmarshall_follower(reader &th, follower &f)
static void marshall_follower_list(writer &th, const m_transit_list &mlist)
{
marshallShort( th, mlist.size() );
-
+
for (m_transit_list::const_iterator mi = mlist.begin();
mi != mlist.end(); ++mi)
{
@@ -1157,7 +1158,7 @@ static void marshall_follower_list(writer &th, const m_transit_list &mlist)
static void marshall_item_list(writer &th, const i_transit_list &ilist)
{
marshallShort( th, ilist.size() );
-
+
for (i_transit_list::const_iterator ii = ilist.begin();
ii != ilist.end(); ++ii)
{
@@ -1168,7 +1169,7 @@ static void marshall_item_list(writer &th, const i_transit_list &ilist)
static m_transit_list unmarshall_follower_list(reader &th)
{
m_transit_list mlist;
-
+
const int size = unmarshallShort(th);
for (int i = 0; i < size; ++i)
@@ -1184,7 +1185,7 @@ static m_transit_list unmarshall_follower_list(reader &th)
static i_transit_list unmarshall_item_list(reader &th)
{
i_transit_list ilist;
-
+
const int size = unmarshallShort(th);
for (int i = 0; i < size; ++i)
@@ -1295,7 +1296,7 @@ static void tag_read_you(reader &th, char minorVersion)
count_c = unmarshallByte(th);
for (i = 0; i < count_c; i++)
you.spell_letter_table[i] = unmarshallByte(th);
-
+
count_c = unmarshallByte(th);
for (i = 0; i < count_c; i++)
you.ability_letter_table[i] =
@@ -1352,7 +1353,7 @@ static void tag_read_you(reader &th, char minorVersion)
count_c = unmarshallByte(th);
for (i = 0; i < count_c; i++)
you.worshipped[i] = unmarshallByte(th);
-
+
for (i = 0; i < count_c; i++)
you.num_gifts[i] = unmarshallShort(th);
@@ -1378,7 +1379,7 @@ static void tag_read_you(reader &th, char minorVersion)
you.transit_stair = static_cast<dungeon_feature_type>(unmarshallShort(th));
you.entering_level = unmarshallByte(th);
-
+
// list of currently beholding monsters (usually empty)
count_c = unmarshallByte(th);
for (i = 0; i < count_c; i++)
@@ -1534,7 +1535,7 @@ static void tag_read_you_dungeon(reader &th)
for (j = 0; j < count_c; ++j)
tmp_file_pairs[i][j] = unmarshallBoolean(th);
}
-
+
unmarshallMap(th, stair_level,
unmarshall_long_as<branch_type>,
unmarshall_level_id);
@@ -1579,7 +1580,7 @@ static void tag_read_you_dungeon(reader &th)
static void tag_read_lost_monsters(reader &th, int minorVersion)
{
the_lost_ones.clear();
-
+
unmarshallMap(th, the_lost_ones,
unmarshall_level_id, unmarshall_follower_list);
}
@@ -1587,7 +1588,7 @@ static void tag_read_lost_monsters(reader &th, int minorVersion)
static void tag_read_lost_items(reader &th, int minorVersion)
{
transiting_items.clear();
-
+
unmarshallMap(th, transiting_items,
unmarshall_level_id, unmarshall_item_list);
}
@@ -1617,7 +1618,7 @@ static void tag_construct_level(writer &th)
{
marshallByte(th, grd[count_x][count_y]);
marshallShort(th, env.map[count_x][count_y].object);
- marshallShort(th, env.map[count_x][count_y].colour);
+ marshallShort(th, env.map[count_x][count_y].colour);
marshallShort(th, env.map[count_x][count_y].flags);
marshallShort(th, env.map[count_x][count_y].property);
marshallShort(th, env.cgrid[count_x][count_y]);
@@ -1701,14 +1702,14 @@ void unmarshallItem(reader &th, item_def &item)
item.x = unmarshallShort(th);
item.y = unmarshallShort(th);
item.flags = (unsigned long) unmarshallLong(th);
-
+
unmarshallShort(th); // mitm[].link -- unused
unmarshallShort(th); // igrd[item.x][item.y] -- unused
item.slot = unmarshallByte(th);
item.orig_place = unmarshallShort(th);
- item.orig_monnum = unmarshallShort(th);
+ item.orig_monnum = unmarshallShort(th);
item.inscription = unmarshallString(th, 80);
item.props.clear();
@@ -1873,7 +1874,7 @@ void tag_construct_level_tiles(writer &th)
marshallShort(th, tile);
marshallByte(th, rle_count);
- // fg
+ // fg
tile = env.tile_bk_fg[0][0];
rle_count = 0;
for (int count_x = 0; count_x < GXM; count_x++)
@@ -1932,7 +1933,7 @@ static void tag_read_level( reader &th, char minorVersion )
const int gy = unmarshallShort(th);
env.turns_on_level = unmarshallLong(th);
-
+
for (int i = 0; i < gx; i++)
{
for (int j = 0; j < gy; j++)
@@ -2303,7 +2304,7 @@ static void marshallGhost(writer &th, const ghost_demon &ghost)
static ghost_demon unmarshallGhost( reader &th )
{
ghost_demon ghost;
-
+
ghost.name = unmarshallString(th, 20);
ghost.species = static_cast<species_type>( unmarshallShort(th) );
@@ -2326,7 +2327,7 @@ static ghost_demon unmarshallGhost( reader &th )
ghost.fly = static_cast<flight_type>( unmarshallShort(th) );
unmarshallSpells(th, ghost.spells);
-
+
return (ghost);
}
diff --git a/crawl-ref/source/terrain.cc b/crawl-ref/source/terrain.cc
index d414c19c58..7ed006e988 100644
--- a/crawl-ref/source/terrain.cc
+++ b/crawl-ref/source/terrain.cc
@@ -11,10 +11,11 @@
*/
#include "AppHdr.h"
-
#include "externs.h"
#include "terrain.h"
+#include <algorithm>
+
#include "dgnevent.h"
#include "direct.h"
#include "itemprop.h"
diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc
index 50473e468b..0301a3082e 100644
--- a/crawl-ref/source/traps.cc
+++ b/crawl-ref/source/traps.cc
@@ -15,6 +15,8 @@
#include "externs.h"
#include "traps.h"
+#include <algorithm>
+
#include "beam.h"
#include "branch.h"
#include "delay.h"
@@ -172,7 +174,7 @@ void player_caught_in_net()
mpr("You fall like a stone!");
fall_into_a_pool(you.x_pos, you.y_pos, false, grd(you.pos()));
}
-
+
stop_delay(true); // even stair delays
}
}
@@ -193,7 +195,7 @@ static void dart_trap(bool trap_known, int trapped, bolt &pbolt, bool poison)
std::string msg = "A" + pbolt.name + " shoots out and ";
- if (random2( 20 + 5 * you.shield_blocks * you.shield_blocks )
+ if (random2( 20 + 5 * you.shield_blocks * you.shield_blocks )
< player_shield_class())
{
you.shield_blocks++;
@@ -208,21 +210,21 @@ static void dart_trap(bool trap_known, int trapped, bolt &pbolt, bool poison)
your_dodge = player_evasion() + random2(you.dex) / 3
- 2 + (you.duration[DUR_REPEL_MISSILES] * 10);
-
+
if (trap_hit >= your_dodge && you.duration[DUR_DEFLECT_MISSILES] == 0)
{
msg += "hits you!";
mpr(msg.c_str());
-
+
if (poison && random2(100) < 50 - (3 * player_AC()) / 2
&& !player_res_poison())
{
poison_player( 1 + random2(3) );
}
-
+
damage_taken = roll_dice( pbolt.damage );
damage_taken -= random2( player_AC() + 1 );
-
+
if (damage_taken > 0)
ouch( damage_taken, 0, KILLED_BY_TRAP, pbolt.name.c_str() );
}
@@ -294,7 +296,7 @@ void itrap( struct bolt &pbolt, int trapped )
void handle_traps(trap_type trt, int i, bool trap_known)
{
struct bolt beam;
-
+
bool branchtype = false;
if (trap_category(trt) == DNGN_TRAP_MECHANICAL && trt != TRAP_NET
&& trt != TRAP_BLADE)
@@ -456,7 +458,7 @@ void handle_traps(trap_type trt, int i, bool trap_known)
break;
}
-
+
case TRAP_ZOT:
default:
mpr((trap_known) ? "You enter the Zot trap."
@@ -466,7 +468,7 @@ void handle_traps(trap_type trt, int i, bool trap_known)
break;
}
learned_something_new(TUT_SEEN_TRAP, you.x_pos, you.y_pos);
-
+
if (!trap_known) // Now you know...
exercise(SK_TRAPS_DOORS, ((coinflip()) ? 2 : 1));
} // end handle_traps()
@@ -559,7 +561,7 @@ void disarm_trap( struct dist &disa )
{
const int num_to_make = 10 + random2(you.skills[SK_TRAPS_DOORS]);
for (j = 0; j < num_to_make; j++)
- {
+ {
// places items (eg darts), which will automatically stack
itrap(beam, i);
}
@@ -579,7 +581,7 @@ void disarm_trap( struct dist &disa )
void remove_net_from(monsters *mon)
{
you.turn_is_over = true;
-
+
int net = get_trapping_net(mon->x, mon->y);
if (net == NON_ITEM)
@@ -592,7 +594,7 @@ void remove_net_from(monsters *mon)
int paralys = 0;
if (mons_is_paralysed(mon)) // makes this easier
paralys = random2(5);
-
+
int invis = 0;
if (!player_monster_visible(mon)) // makes this harder
invis = 3 + random2(5);
@@ -629,10 +631,10 @@ void remove_net_from(monsters *mon)
exercise(SK_TRAPS_DOORS, 1 + random2(mon->body_size(PSIZE_BODY)/2));
return;
}
-
+
mon->del_ench(ENCH_HELD, true);
remove_item_stationary(mitm[net]);
-
+
if (player_monster_visible(mon))
mprf("You free %s.", mon->name(DESC_NOCAP_THE).c_str());
else
@@ -652,7 +654,7 @@ static int damage_or_escape_net(int hold)
// Ogre, Troll, Centaur, Naga: large (-1)
// transformations: spider, bat: tiny (+3); ice beast: large (-1)
int escape = SIZE_MEDIUM - you.body_size(PSIZE_BODY);
-
+
int damage = -escape;
// your weapon may damage the net, max. bonus of 2
@@ -660,7 +662,7 @@ static int damage_or_escape_net(int hold)
{
if (can_cut_meat(you.inv[you.equip[EQ_WEAPON]]))
damage++;
-
+
int brand = get_weapon_brand( you.inv[you.equip[EQ_WEAPON]] );
if (brand == SPWPN_FLAMING || brand == SPWPN_VORPAL)
damage++;
@@ -675,7 +677,7 @@ static int damage_or_escape_net(int hold)
else
damage += level - 1;
}
-
+
// Berserkers get a fighting bonus
if (you.duration[DUR_BERSERKER])
damage += 2;
@@ -704,12 +706,12 @@ static int damage_or_escape_net(int hold)
else if (damage >= 2)
damage -= 2;
}
-
+
// damaged nets are easier to destroy
if (hold < 0)
{
- damage += random2(-hold/3 + 1);
-
+ damage += random2(-hold/3 + 1);
+
// ... and easier to slip out of (but only if escape looks feasible)
if (you.attribute[ATTR_HELD] < 5 || escape >= damage)
escape += random2(-hold/2) + 1;
@@ -743,14 +745,14 @@ void free_self_from_net()
#endif
if (do_what <= 0) // you try to destroy the net
- { // for previously undamaged nets this takes at least 2
+ { // for previously undamaged nets this takes at least 2
// and at most 8 turns
bool can_slice = you.attribute[ATTR_TRANSFORMATION] == TRAN_BLADE_HANDS
|| you.equip[EQ_WEAPON] != -1
&& can_cut_meat(you.inv[you.equip[EQ_WEAPON]]);
int damage = -do_what;
-
+
if (damage < 1)
damage = 1;
@@ -763,7 +765,7 @@ void free_self_from_net()
if (damage > 5)
damage = 5;
-
+
hold -= damage;
mitm[net].plus = hold;
@@ -772,13 +774,13 @@ void free_self_from_net()
mprf("You %s the net and break free!",
can_slice ? (damage >= 4? "slice" : "cut") :
(damage >= 4? "shred" : "rip"));
-
+
destroy_item(net);
you.attribute[ATTR_HELD] = 0;
return;
}
-
+
if (damage >= 4)
{
mprf("You %s into the net.",
@@ -792,7 +794,7 @@ void free_self_from_net()
if (you.attribute[ATTR_HELD] > 1 && coinflip())
{
you.attribute[ATTR_HELD]--;
-
+
if (you.attribute[ATTR_HELD] > 1 && hold < -random2(5))
you.attribute[ATTR_HELD]--;
}
@@ -803,26 +805,26 @@ void free_self_from_net()
if (you.duration[DUR_HASTE]) // extra bonus, also Berserk
escape++;
-
+
// medium sized characters are at disadvantage and sometimes get a bonus
if (you.body_size(PSIZE_BODY) == SIZE_MEDIUM)
escape += coinflip();
if (escape > 4)
escape = 4;
-
+
if (escape >= you.attribute[ATTR_HELD])
{
if (escape >= 3)
mpr("You slip out of the net!");
else
mpr("You break free from the net!");
-
+
you.attribute[ATTR_HELD] = 0;
remove_item_stationary(mitm[net]);
return;
}
-
+
if (escape >= 3)
mpr("You try to slip out of the net.");
else
@@ -1131,7 +1133,7 @@ static trap_type random_trap_default(int level_number, const level_id &place)
{
type = TRAP_ARROW;
}
-
+
if ((type == TRAP_DART || type == TRAP_ARROW) && one_chance_in(15))
type = TRAP_NET;
diff --git a/crawl-ref/source/util/levcomp.lpp b/crawl-ref/source/util/levcomp.lpp
index 8812326257..6247c611ca 100644
--- a/crawl-ref/source/util/levcomp.lpp
+++ b/crawl-ref/source/util/levcomp.lpp
@@ -2,14 +2,15 @@
// levcomp.lpp:
// Level compiler lexer for Dungeon Crawl Stone Soup.
-//
+//
// Based loosely on NetHack's lev_comp.l
+#include <algorithm>
+#include <cstring>
+#include <queue>
#include "AppHdr.h"
#include "mapdef.h"
#include "levcomp.tab.h"
-#include <cstring>
-#include <queue>
static bool alloced = false;
@@ -127,7 +128,7 @@ NSPACE [^\ \t\r\n]
<KEYWORDS>[ \t]+ ;
<KEYWORDS>[ \t]*\r?\n { BEGIN(INITIAL); }
-<ITEM_LIST>[^, \t\r\n][^,\r\n]*[^, \t\r\n] {
+<ITEM_LIST>[^, \t\r\n][^,\r\n]*[^, \t\r\n] {
settext();
return ITEM_INFO;
}
@@ -143,18 +144,18 @@ NSPACE [^\ \t\r\n]
<MNAME>[\ \t\r]*\n { BEGIN(INITIAL); }
-<MNAME>[^,\ \t\r\n][^,\r\n]+[^,\ \t\r\n] {
+<MNAME>[^,\ \t\r\n][^,\r\n]+[^,\ \t\r\n] {
settext();
- return MONSTER_NAME;
+ return MONSTER_NAME;
}
<MNAME>, return COMMA;
<MNAME>[ \t\r]+ ;
-<ARGUMENT>{NSPACE}.*{NSPACE} {
+<ARGUMENT>{NSPACE}.*{NSPACE} {
BEGIN(INITIAL);
settext();
- return STRING;
+ return STRING;
}
<ARGUMENT>\r?\n { BEGIN(INITIAL); }
@@ -177,7 +178,7 @@ NSPACE [^\ \t\r\n]
^[ \t]*: { BEGIN(LUA_ONELINER); return MAIN; }
-^[ \t]*prelude[ \t]*\{\{ { BEGIN(LUA); return PRELUDE; }
+^[ \t]*prelude[ \t]*\{\{ { BEGIN(LUA); return PRELUDE; }
^[ \t]*lua[ \t]*\{\{ { BEGIN(LUA); return MAIN; }
^[ \t]*\{\{ { BEGIN(LUA); return MAIN; }
^[ \t]*validate[ \t]*\{\{ { BEGIN(LUA); return VALIDATE; }
diff --git a/crawl-ref/source/util/levcomp.ypp b/crawl-ref/source/util/levcomp.ypp
index 614a357bbc..fc75c4a53b 100644
--- a/crawl-ref/source/util/levcomp.ypp
+++ b/crawl-ref/source/util/levcomp.ypp
@@ -1,5 +1,8 @@
%{
+#include <map>
+#include <algorithm>
+
#include "AppHdr.h"
#include "clua.h"
#include "libutil.h"
@@ -7,7 +10,6 @@
#include "mapdef.h"
#include "maps.h"
#include "stuff.h"
-#include <map>
#define YYERROR_VERBOSE 1
@@ -80,9 +82,9 @@ error_seq : CHARACTER
yyerror("Unexpected character sequence.");
}
;
-
+
def : defdepth {}
- | global_lua {}
+ | global_lua {}
;
defdepth : DEFAULT_DEPTH STRING
@@ -98,7 +100,7 @@ defdepth : DEFAULT_DEPTH STRING
level : name map_specs
{
lc_map.set_file(lc_desfile);
-
+
if (lc_run_global_prelude && !lc_global_prelude.empty())
{
lc_global_prelude.set_file(lc_desfile);
@@ -130,7 +132,7 @@ name : NAME STRING
lc_map.init();
lc_map.name = $2;
- map_load_info_t::const_iterator i =
+ map_load_info_t::const_iterator i =
lc_loaded_maps.find($2);
if (i != lc_loaded_maps.end())
@@ -219,8 +221,8 @@ veto_lua_lines : /* empty */ { }
veto_lua_line : LUA_LINE
{
lc_map.veto.add(yylineno, $1);
- }
-
+ }
+
prelude_lua : PRELUDE prelude_lua_lines { }
prelude_lua_lines : /* empty */ { }
@@ -236,8 +238,8 @@ kfeat : KFEAT { }
| KFEAT STRING
{
lc_map.main.add(
- yylineno,
- make_stringf("kfeat(\"%s\")",
+ yylineno,
+ make_stringf("kfeat(\"%s\")",
quote_lua_string($2).c_str()));
}
@@ -245,8 +247,8 @@ kmons : KMONS { }
| KMONS STRING
{
lc_map.main.add(
- yylineno,
- make_stringf("kmons(\"%s\")",
+ yylineno,
+ make_stringf("kmons(\"%s\")",
quote_lua_string($2).c_str()));
}
@@ -254,8 +256,8 @@ kitem : KITEM { }
| KITEM STRING
{
lc_map.main.add(
- yylineno,
- make_stringf("kitem(\"%s\")",
+ yylineno,
+ make_stringf("kitem(\"%s\")",
quote_lua_string($2).c_str()));
}
@@ -263,12 +265,12 @@ kmask : KMASK { }
| KMASK STRING
{
lc_map.main.add(
- yylineno,
- make_stringf("kmask(\"%s\")",
+ yylineno,
+ make_stringf("kmask(\"%s\")",
quote_lua_string($2).c_str()));
}
-shuffle : SHUFFLE shuffle_specifiers {}
+shuffle : SHUFFLE shuffle_specifiers {}
;
shuffle_specifiers : shuffle_spec
@@ -278,8 +280,8 @@ shuffle_specifiers : shuffle_spec
shuffle_spec : ITEM_INFO
{
lc_map.main.add(
- yylineno,
- make_stringf("shuffle(\"%s\")",
+ yylineno,
+ make_stringf("shuffle(\"%s\")",
quote_lua_string($1).c_str()));
}
@@ -293,8 +295,8 @@ tagstrings : /* empty */
tagstring : STRING
{
lc_map.main.add(
- yylineno,
- make_stringf("tags(\"%s\")",
+ yylineno,
+ make_stringf("tags(\"%s\")",
quote_lua_string($1).c_str()));
}
;
@@ -317,7 +319,7 @@ bflags : BFLAGS STRING
}
;
-marker : MARKER
+marker : MARKER
{
lc_map.main.add(yylineno, "marker(");
start_marker_segment = true;
@@ -337,7 +339,7 @@ mspec_segments : /* nothing */
mspec_segment : STRING
{
lc_map.main.add(
- yylineno,
+ yylineno,
make_stringf(
"%s\"%s\"",
start_marker_segment? "" : " .. ",
@@ -379,7 +381,7 @@ colour_specifier : ITEM_INFO
quote_lua_string($1).c_str()));
}
;
-
+
nsubst : NSUBST nsubst_specifiers { }
;
@@ -390,12 +392,12 @@ nsubst_specifiers : nsubst_spec { }
nsubst_spec : ITEM_INFO
{
lc_map.main.add(
- yylineno,
- make_stringf("nsubst(\"%s\")",
+ yylineno,
+ make_stringf("nsubst(\"%s\")",
quote_lua_string($1).c_str()));
}
;
-
+
subst : SUBST subst_specifiers { }
;
@@ -406,8 +408,8 @@ subst_specifiers : subst_spec
subst_spec : ITEM_INFO
{
lc_map.main.add(
- yylineno,
- make_stringf("subst(\"%s\")",
+ yylineno,
+ make_stringf("subst(\"%s\")",
quote_lua_string($1).c_str()));
}
;
@@ -423,11 +425,11 @@ item_specifiers : item_specifiers COMMA item_specifier
item_specifier : ITEM_INFO
{
lc_map.main.add(
- yylineno,
- make_stringf("item(\"%s\")",
+ yylineno,
+ make_stringf("item(\"%s\")",
quote_lua_string($1).c_str()));
}
-
+
mons : MONS {}
| MONS mnames {}
;
@@ -439,8 +441,8 @@ mnames : mname COMMA mnames
mname : MONSTER_NAME
{
lc_map.main.add(
- yylineno,
- make_stringf("mons(\"%s\")",
+ yylineno,
+ make_stringf("mons(\"%s\")",
quote_lua_string($1).c_str()));
}
;
@@ -448,18 +450,18 @@ mname : MONSTER_NAME
place : PLACE STRING
{
lc_map.main.add(
- yylineno,
- make_stringf("place(\"%s\")",
+ yylineno,
+ make_stringf("place(\"%s\")",
quote_lua_string($2).c_str()));
}
;
depth : DEPTH {}
- | DEPTH STRING
+ | DEPTH STRING
{
lc_map.main.add(
- yylineno,
- make_stringf("depth(\"%s\")",
+ yylineno,
+ make_stringf("depth(\"%s\")",
quote_lua_string($2).c_str()));
}
;
@@ -467,7 +469,7 @@ depth : DEPTH {}
chance : CHANCE INTEGER
{
lc_map.main.add(
- yylineno,
+ yylineno,
make_stringf("chance(\"%d\")", $2));
}
;
@@ -476,8 +478,8 @@ orientation : ORIENT {}
| ORIENT STRING
{
lc_map.main.add(
- yylineno,
- make_stringf("orient(\"%s\")",
+ yylineno,
+ make_stringf("orient(\"%s\")",
quote_lua_string($2).c_str()));
}
;
@@ -501,8 +503,8 @@ map_lines : map_lines map_line
map_line : MAP_LINE
{
lc_map.main.add(
- yylineno,
- make_stringf("map(\"%s\")",
+ yylineno,
+ make_stringf("map(\"%s\")",
quote_lua_string($1).c_str()));
}
;
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index ca921d3126..eb301e6f91 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -29,6 +29,7 @@
#include <string.h>
#include <cmath>
#include <sstream>
+#include <algorithm>
#ifdef DOS
#include <conio.h>
diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc
index d5eaa1880e..fc7cb320c8 100644
--- a/crawl-ref/source/xom.cc
+++ b/crawl-ref/source/xom.cc
@@ -8,6 +8,8 @@
#include "AppHdr.h"
+#include <algorithm>
+
#include "beam.h"
#include "branch.h"
#include "database.h"
@@ -839,7 +841,7 @@ static bool xom_is_bad(int sever)
else if (random2(sever) <= 10)
{
god_speaks(GOD_XOM, _get_xom_speech("major miscast effect"));
-
+
miscast_effect( SPTYP_RANDOM, 0, 0, random2(4),
"the severe capriciousness of Xom" );