diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-06-26 21:30:33 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-06-26 21:30:33 +0000 |
commit | 80f31bee412fa01db4611cdd27862db6a34d419c (patch) | |
tree | 1f032864acceb947e4d50df291d8ebafe22c6324 /crawl-ref/source | |
parent | c42e7efab8779a54b7e3e486ae83f4af72b15fb9 (diff) | |
download | crawl-ref-80f31bee412fa01db4611cdd27862db6a34d419c.tar.gz crawl-ref-80f31bee412fa01db4611cdd27862db6a34d419c.zip |
Fix another two instances of monster placement returning false
instead of -1.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6155 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/enum.h | 4 | ||||
-rw-r--r-- | crawl-ref/source/monplace.cc | 38 | ||||
-rw-r--r-- | crawl-ref/source/player.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/spells2.cc | 109 | ||||
-rw-r--r-- | crawl-ref/source/tags.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/tile1.cc | 26 |
6 files changed, 90 insertions, 93 deletions
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index f9b3878b13..aba77bf568 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -1687,6 +1687,10 @@ enum monster_type // (int) menv[].type MONS_CEREBOV, MONS_GLOORX_VLOQ, // 254 MONS_MOLLUSC_LORD, // 255 - deprecated, but still referenced in code {dlb} + // 256 + // 257 + // 258 + // 259 // BCR - End first batch of uniques. MONS_NAGA_MAGE = 260, // 260 MONS_NAGA_WARRIOR, diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc index 40ab8e00a8..e93032e008 100644 --- a/crawl-ref/source/monplace.cc +++ b/crawl-ref/source/monplace.cc @@ -220,17 +220,19 @@ static void _hell_spawn_random_monsters() void spawn_random_monsters() { + mpr("in spawn_random_monsters()", MSGCH_DIAGNOSTICS); if (player_in_branch(BRANCH_VESTIBULE_OF_HELL)) { _hell_spawn_random_monsters(); return; } - // place normal dungeon monsters, but not in player LOS + // Place normal dungeon monsters, but not in player LOS. if (you.level_type == LEVEL_DUNGEON && !player_in_branch( BRANCH_ECUMENICAL_TEMPLE ) && one_chance_in((you.char_direction == GDT_DESCENDING) ? 240 : 8)) { + mpr("Create wandering monster...", MSGCH_DIAGNOSTICS); proximity_type prox = (one_chance_in(10) ? PROX_NEAR_STAIRS : PROX_AWAY_FROM_PLAYER); @@ -242,16 +244,18 @@ void spawn_random_monsters() mg.proximity = prox; mons_place( mg ); viewwindow(true, false); + return; } - // place Abyss monsters. + // Place Abyss monsters. if (you.level_type == LEVEL_ABYSS && one_chance_in(5)) { mons_place(mgen_data(WANDERING_MONSTER)); viewwindow(true, false); + return; } - // place Pandemonium monsters + // Place Pandemonium monsters. if (you.level_type == LEVEL_PANDEMONIUM && one_chance_in(50)) { pandemonium_mons(); @@ -302,7 +306,7 @@ monster_type pick_random_monster(const level_id &place, int power, } // Abyss or Pandemonium. Almost never called from Pan; probably only - // if a random demon gets summon anything spell + // if a random demon gets summon anything spell. if (lev_mons == 51 || place.level_type == LEVEL_PANDEMONIUM || place.level_type == LEVEL_ABYSS) @@ -424,7 +428,7 @@ static monster_type _resolve_monster_type(monster_type mon_type, } // (2) Take care of non-draconian random monsters. - if (mon_type == RANDOM_MONSTER) + else if (mon_type == RANDOM_MONSTER) { level_id place = level_id::current(); @@ -534,6 +538,7 @@ static int _is_near_stairs(coord_def &p) int place_monster(mgen_data mg, bool force_pos) { + mpr("in place_monster()", MSGCH_DIAGNOSTICS); int band_size = 0; monster_type band_monsters[BIG_BAND]; // band monster types @@ -543,7 +548,7 @@ int place_monster(mgen_data mg, bool force_pos) // (1) Early out (summoned to occupied grid). if (mg.use_position() && mgrd(mg.pos) != NON_MONSTER) - return (false); + return (-1); mg.cls = _resolve_monster_type(mg.cls, mg.proximity, mg.base_type, mg.pos, mg.map_mask, @@ -558,8 +563,9 @@ int place_monster(mgen_data mg, bool force_pos) if (mg.permit_bands()) { + mpr("Choose band members...", MSGCH_DIAGNOSTICS); const band_type band = _choose_band(mg.cls, mg.power, band_size); - band_size ++; + band_size++; for (int i = 1; i < band_size; i++) band_monsters[i] = _band_member( band, mg.power ); } @@ -603,7 +609,7 @@ int place_monster(mgen_data mg, bool force_pos) { // Dropped number of tries from 60. if (tries++ >= 45) - return (false); + return (-1); // Placement already decided for PROX_NEAR_STAIRS. // Else choose a random point on the map. @@ -695,7 +701,7 @@ int place_monster(mgen_data mg, bool force_pos) // Bail out now if we failed. if (id == -1) - return (id); + return (-1); monsters *mon = &menv[id]; if (mg.needs_patrol_point()) @@ -1187,6 +1193,7 @@ static void _define_zombie( int mid, monster_type ztype, static band_type _choose_band( int mon_type, int power, int &band_size ) { + mpr("in choose_band()", MSGCH_DIAGNOSTICS); // init band_size = 0; band_type band = BAND_NO_BAND; @@ -1427,7 +1434,7 @@ static band_type _choose_band( int mon_type, int power, int &band_size ) band_size = 2 + random2(3); break; case MONS_CYCLOPS: - if ( one_chance_in(5) || player_in_branch(BRANCH_SHOALS) ) + if (one_chance_in(5) || player_in_branch(BRANCH_SHOALS)) { band = BAND_SHEEP; // Odyssey reference band_size = 2 + random2(3); @@ -1477,7 +1484,7 @@ static band_type _choose_band( int mon_type, int power, int &band_size ) band = BAND_NO_BAND; if (band_size >= BIG_BAND) - band_size = BIG_BAND-1; + band_size = BIG_BAND - 1; return (band); } @@ -1816,7 +1823,10 @@ void mark_interesting_monst(struct monsters* monster, beh_type behaviour) static monster_type _pick_zot_exit_defender() { if (one_chance_in(11)) + { + mpr("Create a pandemonium demon!", MSGCH_DIAGNOSTICS); return (MONS_PANDEMONIUM_DEMON); + } const int temp_rand = random2(276); const int mon_type = @@ -1836,6 +1846,7 @@ int mons_place( mgen_data mg ) // int px, int py, int level_type, proximity_type proximity, // int extra, int dur, bool permit_bands ) { + mpr("in mons_place()", MSGCH_DIAGNOSTICS); int mon_count = 0; for (int il = 0; il < MAX_MONSTERS; il++) if (menv[il].type != -1) @@ -1846,6 +1857,7 @@ int mons_place( mgen_data mg ) if (mon_count > MAX_MONSTERS - 50) return (-1); + mpr("Set class RANDOM_MONSTER", MSGCH_DIAGNOSTICS); mg.cls = RANDOM_MONSTER; } @@ -1858,11 +1870,11 @@ int mons_place( mgen_data mg ) if (you.char_direction == GDT_ASCENDING && mg.cls == RANDOM_MONSTER && you.level_type == LEVEL_DUNGEON && !mg.summoned()) { + mpr("Call _pick_zot_exit_defender()", MSGCH_DIAGNOSTICS); mg.cls = _pick_zot_exit_defender(); mg.flags |= MG_PERMIT_BANDS; } - - if (mg.cls == RANDOM_MONSTER || mg.level_type == LEVEL_PANDEMONIUM) + else if (mg.cls == RANDOM_MONSTER || mg.level_type == LEVEL_PANDEMONIUM) mg.flags |= MG_PERMIT_BANDS; // Translate level_type. diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 2990c6a726..a0acffc7c2 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -189,6 +189,7 @@ bool move_player_to_grid( int x, int y, bool stepped, bool allow_shift, if (!yes_or_no("Do you really want to step into the Zot trap")) { canned_msg(MSG_OK); + stop_running(); you.turn_is_over = false; return (false); } @@ -215,6 +216,7 @@ bool move_player_to_grid( int x, int y, bool stepped, bool allow_shift, if (!yesno(prompt.c_str(), true, 'n')) { canned_msg(MSG_OK); + stop_running(); you.turn_is_over = false; return (false); } diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index 11f9aeb63a..7e078290c0 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -186,7 +186,7 @@ static bool _mark_detected_creature(int gridx, int gridy, const monsters *mon, tile_place_monster(gridx, gridy, idx, false, true); #endif - return found_good; + return (found_good); } int detect_creatures( int pow, bool telepathic ) @@ -1110,8 +1110,7 @@ bool cast_sticks_to_snakes(int pow, god_type god) if (wpn == -1) { - msg::stream << "Your " << your_hand(true) << " feel slithery!" - << std::endl; + mprf("Your %s feel slithery!", your_hand(true).c_str()); return (false); } @@ -1139,8 +1138,8 @@ bool cast_sticks_to_snakes(int pow, god_type god) int count = 0; - if ((you.inv[wpn].base_type == OBJ_MISSILES - && (you.inv[wpn].sub_type == MI_ARROW))) + if (you.inv[wpn].base_type == OBJ_MISSILES + && you.inv[wpn].sub_type == MI_ARROW) { if (you.inv[wpn].quantity < how_many_max) how_many_max = you.inv[wpn].quantity; @@ -1224,8 +1223,7 @@ bool cast_sticks_to_snakes(int pow, god_type god) return (true); } - msg::stream << "Your " << your_hand(true) << " feel slithery!" - << std::endl; + mprf("Your %s feel slithery!", your_hand(true).c_str()); return (false); } @@ -1550,8 +1548,6 @@ bool cast_summon_elemental(int pow, god_type god, bool cast_summon_ice_beast(int pow, god_type god) { - bool success = false; - monster_type mon = MONS_ICE_BEAST; const int dur = std::min(2 + (random2(pow) / 4), 6); @@ -1561,20 +1557,16 @@ bool cast_summon_ice_beast(int pow, god_type god) you.pet_target, 0, god)) != -1) { - success = true; - mpr("A chill wind blows around you."); + return (true); } - else - canned_msg(MSG_NOTHING_HAPPENS); - return (success); + canned_msg(MSG_NOTHING_HAPPENS); + return (false); } bool cast_summon_ugly_thing(int pow, god_type god) { - bool success = false; - const int chance = std::max(6 - (pow / 12), 1); monster_type mon = (one_chance_in(chance)) ? MONS_VERY_UGLY_THING : MONS_UGLY_THING; @@ -1590,18 +1582,17 @@ bool cast_summon_ugly_thing(int pow, god_type god) friendly ? you.pet_target : MHITYOU, 0, god)) != -1) { - success = true; - mpr((mon == MONS_VERY_UGLY_THING) ? "A very ugly thing appears." : "An ugly thing appears."); if (!friendly) mpr("It doesn't look very happy."); + + return (true); } - else - canned_msg(MSG_NOTHING_HAPPENS); - return (success); + canned_msg(MSG_NOTHING_HAPPENS); + return (false); } bool cast_summon_dragon(int pow, god_type god) @@ -1611,8 +1602,6 @@ bool cast_summon_dragon(int pow, god_type god) // especially since these aren't on the Abjuration plan... they'll // last until they die (maybe that should be changed, but this is // a very high level spell so it might be okay). -- bwr - bool success = false; - const bool friendly = (random2(pow) > 5); if (create_monster( @@ -1622,24 +1611,21 @@ bool cast_summon_dragon(int pow, god_type god) friendly ? you.pet_target : MHITYOU, 0, god)) != -1) { - success = true; - mpr("A dragon appears."); if (!friendly) mpr("It doesn't look very happy."); + + return (true); } - else - canned_msg(MSG_NOTHING_HAPPENS); - return (success); + canned_msg(MSG_NOTHING_HAPPENS); + return (false); } // Trog sends a fighting buddy (or enemy) for a follower. bool summon_berserker(int pow, god_type god, bool force_hostile) { - bool success = false; - monster_type mon = MONS_PROGRAM_BUG; int dur = std::min(2 + (random2(pow) / 4), 6); @@ -1692,34 +1678,29 @@ bool summon_berserker(int pow, god_type god, bool force_hostile) !force_hostile ? you.pet_target : MHITYOU, 0, god)); - if (monster != -1) - { - success = true; + if (monster == -1) + return (false); - monsters *summon = &menv[monster]; + monsters *summon = &menv[monster]; - summon->go_berserk(false); - mon_enchant berserk = summon->get_ench(ENCH_BERSERK); - mon_enchant abj = summon->get_ench(ENCH_ABJ); + summon->go_berserk(false); + mon_enchant berserk = summon->get_ench(ENCH_BERSERK); + mon_enchant abj = summon->get_ench(ENCH_ABJ); - // Let Trog's gifts berserk longer, and set the abjuration - // timeout to the berserk timeout. - berserk.duration = berserk.duration * 3 / 2; - berserk.maxduration = berserk.duration; - abj.duration = abj.maxduration = berserk.duration; - summon->update_ench(berserk); - summon->update_ench(abj); - } + // Let Trog's gifts berserk longer, and set the abjuration + // timeout to the berserk timeout. + berserk.duration = berserk.duration * 3 / 2; + berserk.maxduration = berserk.duration; + abj.duration = abj.maxduration = berserk.duration; + summon->update_ench(berserk); + summon->update_ench(abj); - return (success); + return (true); } static bool _summon_holy_being_wrapper(int pow, god_type god, monster_type mon, bool quiet) -{ - bool success = false; - - const int dur = std::min(2 + (random2(pow) / 4), 6); +{ const int dur = std::min(2 + (random2(pow) / 4), 6); const int monster = create_monster( @@ -1727,24 +1708,21 @@ static bool _summon_holy_being_wrapper(int pow, god_type god, you.pos(), you.pet_target, MG_FORCE_BEH, god)); - if (monster != -1) - { - success = true; - - monsters *summon = &menv[monster]; - summon->flags |= MF_ATT_CHANGE_ATTEMPT; + if (monster == -1) + return (false); - if (!quiet) - { - mprf("You are momentarily dazzled by a brilliant %s light.", - (mon == MONS_DAEVA) ? "golden" - : "white"); - } + monsters *summon = &menv[monster]; + summon->flags |= MF_ATT_CHANGE_ATTEMPT; - player_angers_monster(&menv[monster]); + if (!quiet) + { + mprf("You are momentarily dazzled by a brilliant %s light.", + (mon == MONS_DAEVA) ? "golden" + : "white"); } + player_angers_monster(&menv[monster]); - return (success); + return (true); } // Zin sends an angel for a follower. @@ -1812,8 +1790,7 @@ bool cast_tukimas_dance(int pow, god_type god, you.inv[wpn].name(DESC_CAP_YOUR).c_str()); } else - msg::stream << "Your " << your_hand(true) << " twitch." - << std::endl; + mprf("Your %s twitch.", your_hand(true).c_str()); return (false); } diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc index d9e574c477..ea38dd05b1 100644 --- a/crawl-ref/source/tags.cc +++ b/crawl-ref/source/tags.cc @@ -1217,7 +1217,7 @@ static void tag_construct_lost_items(writer &th) static void tag_read_you(reader &th, char minorVersion) { - char buff[20]; // For birth date + char buff[20]; // For birth date. int i,j; char count_c; short count_s; @@ -1248,7 +1248,7 @@ static void tag_read_you(reader &th, char minorVersion) you.hp = unmarshallShort(th); you.hunger = unmarshallShort(th); - // how many you.equip? + // How many you.equip? count_c = unmarshallByte(th); for (i = 0; i < count_c; ++i) you.equip[i] = unmarshallByte(th); diff --git a/crawl-ref/source/tile1.cc b/crawl-ref/source/tile1.cc index 2f0c3f9aae..ed2c3bf65a 100644 --- a/crawl-ref/source/tile1.cc +++ b/crawl-ref/source/tile1.cc @@ -2354,18 +2354,20 @@ static void _finalize_tile(unsigned int *tile, bool is_special, // Hack: Swap rock/stone in crypt and tomb, because there are // only stone walls. if ((you.where_are_you == BRANCH_CRYPT || you.where_are_you == BRANCH_TOMB) - && orig == TILE_DNGN_STONE_WALL) - orig = TILE_DNGN_ROCK_WALL_OFS; + && orig == TILE_DNGN_STONE_WALL) + { + orig = TILE_DNGN_ROCK_WALL_OFS; + } // If there are special tiles for this level, then use them. // Otherwise, we'll fall through to the next case and replace // special tiles with normal floor. - if (orig == TILE_DNGN_FLOOR && is_special && - get_num_floor_special_flavors() > 0) + if (orig == TILE_DNGN_FLOOR && is_special + && get_num_floor_special_flavors() > 0) { (*tile) = get_floor_special_tile_idx() + special_flv; - ASSERT(special_flv >= 0 && - special_flv < get_num_floor_special_flavors()); + ASSERT(special_flv >= 0 + && special_flv < get_num_floor_special_flavors()); } else if (orig == TILE_DNGN_FLOOR || orig == TILE_DNGN_FLOOR_SPECIAL) { @@ -2375,10 +2377,10 @@ static void _finalize_tile(unsigned int *tile, bool is_special, { (*tile) = get_wall_tile_idx() + wall_flv; } - else if (orig == TILE_DNGN_SHALLOW_WATER || - orig == TILE_DNGN_DEEP_WATER || - orig == TILE_DNGN_LAVA || - orig == TILE_DNGN_STONE_WALL) + else if (orig == TILE_DNGN_SHALLOW_WATER + || orig == TILE_DNGN_DEEP_WATER + || orig == TILE_DNGN_LAVA + || orig == TILE_DNGN_STONE_WALL) { // These types always have four flavors... (*tile) = orig + (floor_flv % 4); @@ -2861,14 +2863,14 @@ void tilep_job_default(int job, int gender, int *parts) } /* - * Patrs index to string + * Parts index to string */ void tilep_part_to_str(int number, char *buf) { //special if (number == TILEP_SHOW_EQUIP) { - buf[0] = buf[1] = buf[2] ='*'; + buf[0] = buf[1] = buf[2] = '*'; } else { |