summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/dat/clua/loadmaps.lua3
-rw-r--r--crawl-ref/source/dat/didact.des3
-rw-r--r--crawl-ref/source/dat/minitomb.des9
-rw-r--r--crawl-ref/source/mapdef.cc16
4 files changed, 24 insertions, 7 deletions
diff --git a/crawl-ref/source/dat/clua/loadmaps.lua b/crawl-ref/source/dat/clua/loadmaps.lua
index 2822a5545a..fcabf8907d 100644
--- a/crawl-ref/source/dat/clua/loadmaps.lua
+++ b/crawl-ref/source/dat/clua/loadmaps.lua
@@ -10,6 +10,9 @@ local des_files = {
-- The dummy vaults that define global vault generation odds.
"dummy.des",
+ -- Example vaults, included here so that Crawl will syntax-check them
+ "didact.des",
+
"altar.des", "bazaar.des", "entry.des", "elf.des", "float.des", "hells.des",
"hive.des", "icecave.des", "lab.des", "lair.des", "large.des", "layout.des",
"mini.des", "minitomb.des", "orc.des", "pan.des", "sewer.des", "temple.des",
diff --git a/crawl-ref/source/dat/didact.des b/crawl-ref/source/dat/didact.des
index df6a4cbad9..d640bad8a6 100644
--- a/crawl-ref/source/dat/didact.des
+++ b/crawl-ref/source/dat/didact.des
@@ -1,7 +1,8 @@
##############################################################################
#
# This file contains vaults and lua for didactical purposes --
-# it is not included in clua/loadmaps.lua (and shouldn't be!).
+# it is included in clua/loadmaps.lua for syntax checking. None of the maps
+# here will be used in real games.
#
##############################################################################
diff --git a/crawl-ref/source/dat/minitomb.des b/crawl-ref/source/dat/minitomb.des
index 9f1761462f..c9731575d1 100644
--- a/crawl-ref/source/dat/minitomb.des
+++ b/crawl-ref/source/dat/minitomb.des
@@ -30,7 +30,7 @@ function minitomb_setup_features(e)
end
}}
-default-depth: D:4-8 ######################################
+default-depth: D:4-8
#### Portal entry vaults.
@@ -51,6 +51,7 @@ ENDMAP
NAME: enter_minitomb_2
TAGS: uniq_minitomb no_monster_gen
COLOUR: C = yellow
+# [ds] Why is the portal buried in stone?
SUBST: C:cc.
: minitomb_portal(_G)
MAP
@@ -77,9 +78,11 @@ MAP
...
ENDMAP
-
#### The portal vaults.####################################
+# Reset default depth to prevent random generation of portal vaults.
+default-depth:
+
NAME: minitomb_1
WEIGHT: 60
ORIENT: encompass
@@ -248,4 +251,4 @@ cc........TTTTTTTTTTTTTTTT^.....cc
ccc.......c+c+c+c+c+c+c+c^.....c
ccccccccc2c2c2c3c3c3c3cddddccc
cccccccccccccccccccc
-ENDMAP \ No newline at end of file
+ENDMAP
diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc
index 9954147c62..617b4c2c8d 100644
--- a/crawl-ref/source/mapdef.cc
+++ b/crawl-ref/source/mapdef.cc
@@ -47,6 +47,16 @@ static const char *map_section_names[] = {
"float",
};
+// atoi that rejects strings containing non-numeric trailing characters.
+// returns defval for invalid input.
+template <typename V>
+static V strict_aton(const char *s, V defval = 0)
+{
+ char *end;
+ const V res = strtol(s, &end, 10);
+ return (!*s || *end) ? defval : res;
+}
+
const char *map_section_name(int msect)
{
if (msect < 0 || msect >= MAP_NUM_SECTION_TYPES)
@@ -234,19 +244,19 @@ void level_range::parse_depth_range(const std::string &s, int *l, int *h)
std::string::size_type hy = s.find('-');
if (hy == std::string::npos)
{
- *l = *h = atoi(s.c_str());
+ *l = *h = strict_aton<int>(s.c_str());
if (!*l)
throw std::string("Bad depth: ") + s;
}
else
{
- *l = atoi(s.substr(0, hy).c_str());
+ *l = strict_aton<int>(s.substr(0, hy).c_str());
std::string tail = s.substr(hy + 1);
if (tail.empty())
*h = 100;
else
- *h = atoi(tail.c_str());
+ *h = strict_aton<int>(tail.c_str());
if (!*l || !*h || *l > *h)
throw std::string("Bad depth: ") + s;