From bf8210ed870bd1cccb470f2a9a699e8d79e07f60 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Thu, 24 Jul 2008 06:09:36 +0000 Subject: Trunk->0.4 merge r6659-6660: [2026251] Elf arrival vault fix, debug_mons_scan. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.4@6661 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/AppHdr.h | 1 + crawl-ref/source/acr.cc | 3 +++ crawl-ref/source/debug.cc | 40 ++++++++++++++++++++++++++++++++++++++++ crawl-ref/source/debug.h | 1 + crawl-ref/source/dungeon.cc | 2 +- crawl-ref/source/monplace.cc | 21 ++++++++++++++------- 6 files changed, 60 insertions(+), 8 deletions(-) diff --git a/crawl-ref/source/AppHdr.h b/crawl-ref/source/AppHdr.h index 700bfc2c0c..1316e75ffb 100644 --- a/crawl-ref/source/AppHdr.h +++ b/crawl-ref/source/AppHdr.h @@ -299,6 +299,7 @@ // against the name. Still, it is nice to know the // turn in which "bad" items appear. #define DEBUG_ITEM_SCAN 1 + #define DEBUG_MONS_SCAN 1 #endif #ifdef _DEBUG // this is how MSVC signals a debug build diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 4ee02b279d..4f312b8e0f 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -3387,6 +3387,9 @@ static command_type _get_next_cmd() #if DEBUG_ITEM_SCAN debug_item_scan(); #endif +#if DEBUG_MONS_SCAN + debug_mons_scan(); +#endif const time_t before = time(NULL); keycode_type keyin = _get_next_keycode(); diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 4ce700daa2..731664a7b6 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -1978,8 +1978,48 @@ void debug_item_scan( void ) } } } + +#endif + +#if DEBUG_MONS_SCAN +void debug_mons_scan() +{ + bool warned = false; + for (int y = 0; y < GYM; ++y) + for (int x = 0; x < GXM; ++x) + { + const int mons = mgrd[x][y]; + if (mons != NON_MONSTER && + menv[mons].pos() != coord_def(x, y)) + { + const monsters *m = &menv[mons]; + mprf(MSGCH_WARN, + "Bogosity: mgrd at %d,%d points at %s, " + "but monster is at %d,%d", + x, y, m->name(DESC_PLAIN).c_str(), m->x, m->y); + warned = true; + } + } + + for (int i = 0; i < MAX_MONSTERS; ++i) + { + const monsters *m = &menv[i]; + if (!m->alive()) + continue; + if (mgrd(m->pos()) != i) + { + mprf(MSGCH_WARN, "Floating monster: %s at (%d,%d)", + m->name(DESC_PLAIN).c_str(), m->x, m->y); + warned = true; + } + } + // If there are warnings, force the dev to notice. :P + if (warned) + more(); +} #endif + //--------------------------------------------------------------- // // debug_item_statistics diff --git a/crawl-ref/source/debug.h b/crawl-ref/source/debug.h index 27c1272eba..7703b5b25b 100644 --- a/crawl-ref/source/debug.h +++ b/crawl-ref/source/debug.h @@ -95,6 +95,7 @@ void debug_make_shop( void ); void debug_place_map(); // Honest debugging functions. void debug_item_scan( void ); +void debug_mons_scan(); void debug_item_statistics( void ); void debug_fight_statistics( bool use_init_defaults, bool defence = false ); void debug_list_monsters(); diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 622f97ef5d..9276ba9218 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -4303,7 +4303,7 @@ static bool _build_vaults(int level_number, int force_vault, int rune_subst, place.map.map.apply_overlays(place.pos); _register_place(place); - if (gluggy == MAP_FLOAT && target_connections.empty()) + if (target_connections.empty()) _pick_float_exits(place, target_connections); if (make_no_exits) diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc index 3b0bf92364..ae6c01bdce 100644 --- a/crawl-ref/source/monplace.cc +++ b/crawl-ref/source/monplace.cc @@ -547,8 +547,15 @@ static int _is_near_stairs(coord_def &p) return (result); } +/* + * Checks if the monster is ok to place at mg_pos. If force_location + * is true, then we'll be less rigorous in our checks, in particular + * allowing land monsters to be placed in shallow water and water + * creatures in fountains. + */ static bool _valid_monster_location(const mgen_data &mg, - const coord_def &mg_pos) + const coord_def &mg_pos, + bool force_location) { const int htype = (mons_class_is_zombified(mg.cls) ? mg.base_type : mg.cls); @@ -563,7 +570,7 @@ static bool _valid_monster_location(const mgen_data &mg, return (false); // Is the monster happy where we want to put it? - if (!grid_compatible(grid_wanted, grd(mg_pos), true)) + if (!grid_compatible(grid_wanted, grd(mg_pos), !force_location)) return (false); if (mg.behaviour != BEH_FRIENDLY && is_sanctuary(mg_pos.x, mg_pos.y)) @@ -581,9 +588,9 @@ static bool _valid_monster_location(const mgen_data &mg, return (true); } -static bool _valid_monster_location(mgen_data &mg) +static bool _valid_monster_location(mgen_data &mg, bool force_location) { - return _valid_monster_location(mg, mg.pos); + return _valid_monster_location(mg, mg.pos, force_location); } int place_monster(mgen_data mg, bool force_pos) @@ -665,7 +672,7 @@ int place_monster(mgen_data mg, bool force_pos) if (mg.proximity != PROX_NEAR_STAIRS) mg.pos = random_in_bounds(); - if (!_valid_monster_location(mg)) + if (!_valid_monster_location(mg, false)) continue; // Is the grid verboten? @@ -731,7 +738,7 @@ int place_monster(mgen_data mg, bool force_pos) break; } // end while... place first monster } - else if (!_valid_monster_location(mg)) + else if (!_valid_monster_location(mg, true)) { // Sanity check that the specified position is valid. return (-1); @@ -852,7 +859,7 @@ static int _place_monster_aux( const mgen_data &mg, fpos = mg.pos + coord_def( random_range(-3, 3), random_range(-3, 3) ); - if (_valid_monster_location(mg, fpos)) + if (_valid_monster_location(mg, fpos, false)) break; } -- cgit v1.2.3-54-g00ecf