summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/tags.cc
diff options
context:
space:
mode:
authorMatthew Cline <zelgadis@sourceforge.net>2009-11-03 16:46:15 -0800
committerMatthew Cline <zelgadis@sourceforge.net>2009-11-03 16:46:15 -0800
commitb9c2a1e344b2a3d60bd05c9f0e3c3598a43c5d2d (patch)
tree4f620f40f22804eeaa78c7d091c426e722767cae /crawl-ref/source/tags.cc
parent4a4204b4aeefee6e9a7dc43694fa49f0816ef1fe (diff)
downloadcrawl-ref-b9c2a1e344b2a3d60bd05c9f0e3c3598a43c5d2d.tar.gz
crawl-ref-b9c2a1e344b2a3d60bd05c9f0e3c3598a43c5d2d.zip
tags.cc: Debug msgs for invalid, !in_bounds mons
With DEBUG or DEBUG_MONS_SCAN, give error messages if marshalling or unmarshalling a monster with an invalid type or which is out of bounds.
Diffstat (limited to 'crawl-ref/source/tags.cc')
-rw-r--r--crawl-ref/source/tags.cc40
1 files changed, 39 insertions, 1 deletions
diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc
index f2da9a1018..04e6102d32 100644
--- a/crawl-ref/source/tags.cc
+++ b/crawl-ref/source/tags.cc
@@ -82,6 +82,10 @@
#include "travel.h"
#include "view.h"
+#if defined(DEBUG) || defined(DEBUG_MONS_SCAN)
+#include "coord.h"
+#endif
+
// defined in overmap.cc
extern std::map<branch_type, level_id> stair_level;
extern std::map<level_pos, shop_type> shops_present;
@@ -1910,7 +1914,28 @@ static void tag_construct_level_monsters(writer &th)
marshallByte(th, NUM_MONSTER_SLOTS);
for (int i = 0; i < MAX_MONSTERS; i++)
- marshall_monster(th, menv[i]);
+ {
+ monsters &m(menv[i]);
+
+#if defined(DEBUG) || defined(DEBUG_MONS_SCAN)
+ if (m.type != MONS_NO_MONSTER)
+ {
+ if (invalid_monster_type(m.type))
+ {
+ mprf(MSGCH_ERROR, "Marshalled monster #%d %s",
+ i, m.name(DESC_PLAIN, true).c_str());
+ }
+ if (!in_bounds(m.pos()))
+ {
+ mprf(MSGCH_ERROR,
+ "Marshalled monster #%d %s out of bounds at (%d, %d)",
+ i, m.name(DESC_PLAIN, true).c_str(),
+ m.pos().x, m.pos().y);
+ }
+ }
+#endif
+ marshall_monster(th, m);
+ }
}
void tag_construct_level_attitude(writer &th)
@@ -2216,10 +2241,23 @@ static void tag_read_level_monsters(reader &th, char minorVersion)
{
monsters &m = menv[i];
unmarshall_monster(th, m);
+
// place monster
if (m.type != MONS_NO_MONSTER)
{
#if defined(DEBUG) || defined(DEBUG_MONS_SCAN)
+ if (invalid_monster_type(m.type))
+ {
+ mprf(MSGCH_ERROR, "Unmarshalled monster #%d %s",
+ i, m.name(DESC_PLAIN, true).c_str());
+ }
+ if (!in_bounds(m.pos()))
+ {
+ mprf(MSGCH_ERROR,
+ "Unmarshalled monster #%d %s out of bounds at (%d, %d)",
+ i, m.name(DESC_PLAIN, true).c_str(),
+ m.pos().x, m.pos().y);
+ }
int midx = mgrd(m.pos());
if (midx != NON_MONSTER)
mprf(MSGCH_ERROR, "(%d,%d) for %s already occupied by %s",