diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-05-09 19:52:59 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-05-09 19:52:59 +0000 |
commit | d69688f0d70ebd684181678a77ca10f800258cfe (patch) | |
tree | 19b8b9fdd4c8194ea65d0729cdf44adf31ee7e60 /crawl-ref/source/util | |
parent | b31a9edb3090aa8dac6dc1fc70c5e241c3019642 (diff) | |
download | crawl-ref-d69688f0d70ebd684181678a77ca10f800258cfe.tar.gz crawl-ref-d69688f0d70ebd684181678a77ca10f800258cfe.zip |
Added Lemuel's mines minivaults.
Extended map DEPTH: attribute to support branch specifiers and negated depth
specifiers.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1442 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/util')
-rw-r--r-- | crawl-ref/source/util/levcomp.cc | 5 | ||||
-rw-r--r-- | crawl-ref/source/util/levcomp.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/util/levcomp.lpp | 4 | ||||
-rw-r--r-- | crawl-ref/source/util/levcomp.ypp | 91 |
4 files changed, 85 insertions, 17 deletions
diff --git a/crawl-ref/source/util/levcomp.cc b/crawl-ref/source/util/levcomp.cc index 5e0bb4cb64..af92a23bb6 100644 --- a/crawl-ref/source/util/levcomp.cc +++ b/crawl-ref/source/util/levcomp.cc @@ -1,10 +1,11 @@ #include "AppHdr.h" #include "levcomp.h" +#include <vector> std::string lc_desfile; map_def lc_map; level_range lc_range; -level_range lc_default_depth; +depth_ranges lc_default_depths; extern int yylineno; @@ -12,7 +13,7 @@ void reset_map_parser() { lc_map.init(); lc_range.reset(); - lc_default_depth.reset(); + lc_default_depths.clear(); yylineno = 1; } diff --git a/crawl-ref/source/util/levcomp.h b/crawl-ref/source/util/levcomp.h index 99f0495f90..c3bf3a73ea 100644 --- a/crawl-ref/source/util/levcomp.h +++ b/crawl-ref/source/util/levcomp.h @@ -6,7 +6,7 @@ extern map_def lc_map; extern level_range lc_range; -extern level_range lc_default_depth; +extern depth_ranges lc_default_depths; extern std::string lc_desfile; void reset_map_parser(); diff --git a/crawl-ref/source/util/levcomp.lpp b/crawl-ref/source/util/levcomp.lpp index 64d790017c..157d53b5bc 100644 --- a/crawl-ref/source/util/levcomp.lpp +++ b/crawl-ref/source/util/levcomp.lpp @@ -188,6 +188,10 @@ float return FLOAT; \" return QUOTE; +: return COLON; +\* return STAR; +! return NOT; + [a-zA-Z_][a-zA-Z_0-9]+ { settext(); return IDENTIFIER; diff --git a/crawl-ref/source/util/levcomp.ypp b/crawl-ref/source/util/levcomp.ypp index f917ad37e6..d62800845e 100644 --- a/crawl-ref/source/util/levcomp.ypp +++ b/crawl-ref/source/util/levcomp.ypp @@ -3,6 +3,7 @@ #include "AppHdr.h" #include "libutil.h" #include "levcomp.h" +#include "mapdef.h" #include "stuff.h" #include <map> @@ -34,12 +35,26 @@ void yyerror(const char *e) end(1); } +level_range set_range(const char *s, int start, int end) +{ + try + { + lc_range.set(s, start, end); + } + catch (const std::string &err) + { + yyerror(err.c_str()); + } + return (lc_range); +} + %} %union { int i; const char *text; + raw_range range; } %token <i> BRANCHDEF BRANCH DESC DEFAULT @@ -58,10 +73,11 @@ void yyerror(const char *e) %token <i> NO_HMIRROR NO_VMIRROR NO_ROTATE %token <i> PANDEMONIC -%token <i> DASH COMMA QUOTE OPAREN CPAREN +%token <i> DASH COMMA QUOTE OPAREN CPAREN COLON STAR NOT %token <i> INTEGER %type <i> orient_name flagname +%type <range> lev_range ext_range %token <text> STRING MAP_LINE MONSTER_NAME ITEM_INFO %token <text> IDENTIFIER @@ -72,20 +88,19 @@ file : definitions { } ; definitions : /* empty */ {} - | definition definitions {} + | definitions definition {} ; definition : def {} | level {} ; -def : defdepth +def : defdepth {} ; -defdepth : DEFAULT_DEPTH depth_range - { - lc_default_depth = lc_range; - } +defdepth : DEFAULT_DEPTH + { lc_default_depths.clear(); } + default_depth_ranges ; level : name metalines map_def metalines @@ -123,6 +138,10 @@ level : name metalines map_def metalines if (lc_map.map.height() == 0) yyerror("Must define map."); + if (!lc_map.has_depth() && !lc_default_depths.empty()) + lc_map.add_depths(lc_default_depths.begin(), + lc_default_depths.end()); + add_parsed_map( lc_map ); } ; @@ -130,7 +149,6 @@ level : name metalines map_def metalines name : NAME STRING { lc_map.init(); - lc_map.depth = lc_default_depth; lc_map.name = $2; map_load_info_t::const_iterator i = @@ -203,7 +221,7 @@ shuffle : SHUFFLE shuffle_specifiers {} ; shuffle_specifiers : shuffle_spec - | shuffle_spec COMMA shuffle_specifiers + | shuffle_specifiers COMMA shuffle_spec ; shuffle_spec : ITEM_INFO @@ -300,20 +318,65 @@ place : PLACE STRING ; depth : DEPTH {} - | DEPTH depth_range + | DEPTH extended_depth_ranges {} + ; + +default_depth_ranges : + ext_range + { + lc_default_depths.push_back($1); + } + + | default_depth_ranges COMMA ext_range + { + lc_default_depths.push_back($3); + } + ; + +extended_depth_ranges : + ext_range { - lc_map.depth = lc_range; + lc_map.add_depth($1); + } + + | extended_depth_ranges COMMA ext_range + { + lc_map.add_depth($3); } ; -depth_range : INTEGER DASH INTEGER +ext_range : lev_range { $$ = $1; } + | NOT lev_range { $$ = $2; $$.deny = true; } + ; + +lev_range : IDENTIFIER + { + $$ = set_range($1, 1, 100); + } + + | IDENTIFIER COLON STAR + { + $$ = set_range($1, 1, 100); + } + + | IDENTIFIER COLON INTEGER DASH INTEGER + { + $$ = set_range($1, $3, $5); + } + + | IDENTIFIER COLON INTEGER + { + $$ = set_range($1, $3, $3); + } + + | INTEGER DASH INTEGER { - lc_range.set($1, $3); + $$ = set_range("Any", $1, $3); } | INTEGER { - lc_range.set($1); + $$ = set_range("Any", $1, $1); } ; |