diff options
author | ennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-07-26 02:48:43 +0000 |
---|---|---|
committer | ennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-07-26 02:48:43 +0000 |
commit | 60ff7d048c65e762425bd89d34b55df6fec66080 (patch) | |
tree | 003da8fd5cb7edbf81b3f2ccc8ba3b41d1e9df0a | |
parent | fcdae070af8fe650f7e9df51a88f622b2973a11f (diff) | |
download | crawl-ref-60ff7d048c65e762425bd89d34b55df6fec66080.tar.gz crawl-ref-60ff7d048c65e762425bd89d34b55df6fec66080.zip |
Applying r6683 to 0.4.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.4@6684 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/dungeon.cc | 40 | ||||
-rw-r--r-- | crawl-ref/source/enum.h | 3 |
2 files changed, 43 insertions, 0 deletions
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 9276ba9218..0eb4f393a6 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -911,6 +911,44 @@ static void _fixup_walls() } } +// Remove any items that are on squares that items should not be on. +// link_items() must be called after this function. +static void _fixup_misplaced_items() +{ + for (int i = 0; i < MAX_ITEMS; i++) + { + if (!is_valid_item(mitm[i]) || (mitm[i].x == 0 && mitm[i].y == 0)) + continue; + + coord_def gc(mitm[i].x, mitm[i].y); + + if (in_bounds(gc)) + { + dungeon_feature_type feat = grd(gc); + if (feat >= DNGN_MINITEM) + continue; + +#ifdef DEBUG_DIAGNOSTICS + mprf(MSGCH_DIAGNOSTICS, + "Item buggily placed in feature at (%d, %d).", gc.x, gc.y); +#endif + } + else + { +#ifdef DEBUG_DIAGNOSTICS + mprf(MSGCH_DIAGNOSTICS, + "Item buggily placed out of bounds at (%d, %d).", gc.x, gc.y); +#endif + } + + // Can't just unlink item because it might not have been linked yet. + mitm[i].base_type = OBJ_UNASSIGNED; + mitm[i].quantity = 0; + mitm[i].x = 0; + mitm[i].y = 0; + } +} + static void _fixup_branch_stairs() { // Top level of branch levels - replaces up stairs @@ -1282,6 +1320,8 @@ static void _build_dungeon_level(int level_number, int level_type) _place_altars(); + _fixup_misplaced_items(); + link_items(); if (!player_in_branch(BRANCH_COCYTUS) diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 12495f8a47..b78ef3325c 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -919,6 +919,9 @@ enum dungeon_feature_type DNGN_SHALLOW_WATER = 65, // 65 DNGN_WATER_STUCK, + // Lowest grid value that an item can be placed on. + DNGN_MINITEM = DNGN_SHALLOW_WATER, + DNGN_FLOOR_MIN = 67, DNGN_FLOOR = DNGN_FLOOR_MIN, DNGN_FLOOR_SPECIAL, // currently only used for colouring bazaars |