=== modified file 'src/cave.c'
--- src/cave.c
+++ src/cave.c
@@ -3780,6 +3780,7 @@
 		{
 			/* Process the grid */
 			cave_info[y][x] &= ~(CAVE_MARK);
+			cave_info2[y][x] &= ~(CAVE2_DTRAP);
 		}
 	}
 

=== modified file 'src/defines.h'
--- src/defines.h
+++ src/defines.h
@@ -2428,6 +2428,8 @@
 #define CAVE_TEMP	0x40 	/* temp flag */
 #define CAVE_WALL	0x80 	/* wall flag */
 
+#define CAVE2_DTRAP	0x001 	/* trap detected grid */
+
 
 
 /*** Object flags ***/

=== modified file 'src/externs.h'
--- src/externs.h
+++ src/externs.h
@@ -205,6 +205,7 @@
 extern byte *temp_y;
 extern byte *temp_x;
 extern byte (*cave_info)[256];
+extern byte (*cave_info2)[256];
 extern byte (*cave_feat)[DUNGEON_WID];
 extern s16b (*cave_o_idx)[DUNGEON_WID];
 extern s16b (*cave_m_idx)[DUNGEON_WID];

=== modified file 'src/generate.c'
--- src/generate.c
+++ src/generate.c
@@ -7042,11 +7042,6 @@
 	/* The dungeon is not ready */
 	character_dungeon = FALSE;
 
-	/* Reset trap detection region for disturbance */
-	p_ptr->dtrap_x=0;
-	p_ptr->dtrap_y=0;
-	p_ptr->dtrap_rad=0;
-
 	/* Assume level is not themed. */
 	p_ptr->themed_level = 0;
 
@@ -7068,6 +7063,7 @@
 			{
 				/* No flags */
 				cave_info[y][x] = 0;
+				cave_info2[y][x] = 0;
 
 #ifdef MONSTER_FLOW
 				/* No flow */

=== modified file 'src/init2.c'
--- src/init2.c
+++ src/init2.c
@@ -4247,6 +4247,7 @@
 
 	/* Padded into array */
 	C_MAKE(cave_info, DUNGEON_HGT, byte_256);
+	C_MAKE(cave_info2, DUNGEON_HGT, byte_256);
 
 	/* Feature array */
 	C_MAKE(cave_feat, DUNGEON_HGT, byte_wid);

=== modified file 'src/load2.c'
--- src/load2.c
+++ src/load2.c
@@ -2884,6 +2884,31 @@
 		}
 	}
 
+	/* Load the dungeon data */
+	for (x = y = 0; y < DUNGEON_HGT; )
+	{
+		/* Grab RLE info */
+		rd_byte(&count);
+		rd_byte(&tmp8u);
+
+		/* Apply the RLE info */
+		for (i = count; i > 0; i--)
+		{
+			/* Extract "info" */
+			cave_info2[y][x] = tmp8u;
+
+			/* Advance/Wrap */
+			if (++x >= DUNGEON_WID)
+			{
+				/* Wrap */
+				x = 0;
+
+				/* Advance/Wrap */
+				if (++y >= DUNGEON_HGT) break;
+			}
+		}
+	}
+
 
 	/*** Run length decoding ***/
 

=== modified file 'src/monster2.c'
--- src/monster2.c
+++ src/monster2.c
@@ -1322,6 +1322,16 @@
 	/* Did the player move? */
 	if (player_moved)
 	{
+		bool old_dtrap, new_dtrap;
+
+		/* Calculat changes in dtrap status */
+		old_dtrap = ((cave_info2[y1][x1] & (CAVE2_DTRAP)) != 0);
+		new_dtrap = ((cave_info2[y2][x2] & (CAVE2_DTRAP)) != 0);
+
+		/* Note the change in the detect status */
+		if (old_dtrap != new_dtrap)
+			p_ptr->redraw |= (PR_DTRAP);
+
 		/* Update the panel */
 		p_ptr->update |= (PU_PANEL);
 
@@ -1332,21 +1342,11 @@
 		p_ptr->window |= (PW_OVERHEAD);
 
 		/* Warn when leaving trap detected region */
-		if (disturb_trap_detect && p_ptr->dtrap_x && p_ptr->dtrap_y && p_ptr->dtrap_rad)
-		{
-			if (distance(p_ptr->py, p_ptr->px, p_ptr->dtrap_y, p_ptr->dtrap_x) >= (p_ptr->dtrap_rad - 1)) 
-			{
-				p_ptr->dtrap_x=0;
-				p_ptr->dtrap_y=0;
-				p_ptr->dtrap_rad=0;
-				msg_print("*Leaving trap detect region!*");
-
-				/* Disturb to break runs */
-				disturb(0, 0);
-
-				/* Redraw DTrap Status */
-				p_ptr->redraw |= (PR_DTRAP);
-			}
+		if (disturb_trap_detect && old_dtrap && !new_dtrap)
+		{
+			/* Disturb to break runs */
+			msg_print("*Leaving trap detect region!*");
+			disturb(0, 0);
 		}
 	}
 

=== modified file 'src/save.c'
--- src/save.c
+++ src/save.c
@@ -1258,6 +1258,42 @@
 		wr_byte((byte)prev_char);
 	}
 
+	/* Note that this will induce two wasted bytes */
+	count = 0;
+	prev_char = 0;
+
+	/* Dump the cave */
+	for (y = 0; y < DUNGEON_HGT; y++)
+	{
+		for (x = 0; x < DUNGEON_WID; x++)
+		{
+			/*  Keep all the information from info2 */
+			tmp8u = cave_info2[y][x];
+
+			/* If the run is broken, or too full, flush it */
+			if ((tmp8u != prev_char) || (count == MAX_UCHAR))
+			{
+				wr_byte((byte)count);
+				wr_byte((byte)prev_char);
+				prev_char = tmp8u;
+				count = 1;
+			}
+
+			/* Continue the run */
+			else
+			{
+				count++;
+			}
+		}
+	}
+
+	/* Flush the data (if any) */
+	if (count)
+	{
+		wr_byte((byte)count);
+		wr_byte((byte)prev_char);
+	}
+
 
 	/*** Simple "Run-Length-Encoding" of cave ***/
 

=== modified file 'src/spells2.c'
--- src/spells2.c
+++ src/spells2.c
@@ -720,8 +720,6 @@
 {
 	int y, x;
 
-	bool detect = FALSE;
-
 	int py = p_ptr->py;
 	int px = p_ptr->px;
 
@@ -759,25 +757,18 @@
 					/* increment number found */
 					num++;
 				}
+
+				/* Mark grid as detected */
+				cave_info2[y][x] |= (CAVE2_DTRAP);
 			}
 		}
 	}
-
-	/* Set region for disturbance */
-	p_ptr->dtrap_x=px;
-	p_ptr->dtrap_y=py;
-	p_ptr->dtrap_rad=range;
 
 	/* Found some */
 	if (num > 0)
 	{
-
-		/* Obvious */
-		detect = TRUE;
-
 		/* Print success message */
 		msg_print("You detect traps.");
-
 	}
 
 	/* Redraw DTrap Status */

=== modified file 'src/types.h'
--- src/types.h
+++ src/types.h
@@ -1246,11 +1246,6 @@
 	s16b old_specialties;
 	s16b specialties_allowed;	/* Number we can use right now */
 
-        /* Add some variables for disturb_trap_detect.  Not saved.  -BR- */
-        byte dtrap_x;           /* X location of last trap detection */
-        byte dtrap_y;           /* Y location of last trap detection */
-        byte dtrap_rad;         /* radius of last trap detection */
-
 	/* Helper variables for some specialty abilities */
 	s16b speed_boost;		/* Short term speed boost (Fury) */
 	s16b heighten_power;		/* Magic Intensity boose from casting (Heighten Magic) */

=== modified file 'src/variable.c'
--- src/variable.c
+++ src/variable.c
@@ -352,10 +352,11 @@
 /*
  * Array[DUNGEON_HGT][256] of cave grid info flags (padded)
  *
- * This array is padded to a width of 256 to allow fast access to elements
+ * These arrays are padded to a width of 256 to allow fast access to elements
  * in the array via "grid" values (see the GRID() macros).
  */
 byte (*cave_info)[256];
+byte (*cave_info2)[256];
 
 /*
  * Array[DUNGEON_HGT][DUNGEON_WID] of cave grid feature codes

=== modified file 'src/xtra1.c'
--- src/xtra1.c
+++ src/xtra1.c
@@ -1,4 +1,3 @@
-
 /* File: xtra1.c */
 
 /* Display of stats to the user from internal figures, char info shown on 
@@ -697,10 +696,15 @@
 
 static void prt_dtrap(void)
 {
-	if (p_ptr->dtrap_rad)
+	byte info = cave_info2[p_ptr->py][p_ptr->px];
+
+	/* The player is in a trap-detected grid */
+	if (info & (CAVE2_DTRAP))
 	{
 		c_put_str(TERM_YELLOW, "DTrap", Term->hgt - 1, COL_DTRAP);
 	}
+
+	/* Not in a trap-detected grid */
 	else
 	{
 		c_put_str(TERM_YELLOW, "     ", Term->hgt - 1, COL_DTRAP);


