summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dungeon.cc
diff options
context:
space:
mode:
authorennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-26 02:34:48 +0000
committerennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-26 02:34:48 +0000
commit7865993ce0e6e5aa1eccafdc462f37e6ebf82951 (patch)
tree91eb0aaf1ab0375f62769fb8d5ac77a7eaa2659c /crawl-ref/source/dungeon.cc
parent7b4bf560e594279a0859b30a89f65b2bb251acb0 (diff)
downloadcrawl-ref-7865993ce0e6e5aa1eccafdc462f37e6ebf82951.tar.gz
crawl-ref-7865993ce0e6e5aa1eccafdc462f37e6ebf82951.zip
[2022204] Don't allow items to be created on features that they shouldn't be. Complain via diagnostic if they are, and then remove the item.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6683 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/dungeon.cc')
-rw-r--r--crawl-ref/source/dungeon.cc40
1 files changed, 40 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)