summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/util
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2006-12-07 07:51:48 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2006-12-07 07:51:48 +0000
commitb58fbcfafc44bc2810863a3722bee2e6a8f7d22d (patch)
tree22a1199ad8ca845bfad04590d9dc5e9891ae8960 /crawl-ref/source/util
parentcf61c793d3d3783b2b5a39a8cf01b857806411b2 (diff)
downloadcrawl-ref-b58fbcfafc44bc2810863a3722bee2e6a8f7d22d.tar.gz
crawl-ref-b58fbcfafc44bc2810863a3722bee2e6a8f7d22d.zip
*Breaks save compatibility* - changed monster flags to long, added "god" field for future fun.
dungeon.cc cleanup and rework to support floating vaults. Updated levcomp to support the float orientation. coord_def now has a constructor. USE_RIVERS and USE_NEW_UNRANDS are no longer conditional. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@585 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/util')
-rw-r--r--crawl-ref/source/util/levcomp.lpp25
-rw-r--r--crawl-ref/source/util/levcomp.ypp36
2 files changed, 58 insertions, 3 deletions
diff --git a/crawl-ref/source/util/levcomp.lpp b/crawl-ref/source/util/levcomp.lpp
index 69ad33ee23..59118eee7e 100644
--- a/crawl-ref/source/util/levcomp.lpp
+++ b/crawl-ref/source/util/levcomp.lpp
@@ -8,13 +8,32 @@
#include "AppHdr.h"
#include "levcomp.tab.h"
#include <cstring>
+#include <queue>
static bool alloced = false;
+std::queue<const char *> free_queue;
+
+static void flush_free_queue(int max_allowed)
+{
+ while (free_queue.size() > max_allowed)
+ {
+ const char *s = free_queue.front();
+ free((void *) s);
+ free_queue.pop();
+ }
+}
+
+static void add_to_queue(const char *s)
+{
+ free_queue.push(s);
+ flush_free_queue(20);
+}
+
static void clean()
{
if (yylval.text && alloced)
- free( (void*) yylval.text);
+ add_to_queue(yylval.text);
yylval.text = NULL;
alloced = false;
}
@@ -83,7 +102,7 @@ EXIT_MSG: { BEGIN(ARGUMENT); return EXIT_MSG; }
MONSTERS return MONSTERS;
ENDMONSTERS return ENDMONSTERS;
-<KEYWORDS>[A-Za-z_0-9\-]+ {
+<KEYWORDS>[A-Za-z_0-9\-]+ {
settext();
return STRING;
}
@@ -114,6 +133,7 @@ northeast return NORTHEAST;
northwest return NORTHWEST;
southeast return SOUTHEAST;
southwest return SOUTHWEST;
+float return FLOAT;
- return DASH;
, return COMMA;
@@ -151,5 +171,6 @@ southwest return SOUTHWEST;
int yywrap()
{
clean();
+ flush_free_queue(0);
return 1;
}
diff --git a/crawl-ref/source/util/levcomp.ypp b/crawl-ref/source/util/levcomp.ypp
index e419bdc878..d5b0bb2c7f 100644
--- a/crawl-ref/source/util/levcomp.ypp
+++ b/crawl-ref/source/util/levcomp.ypp
@@ -28,7 +28,7 @@ void yyerror(const char *e)
%token <i> NAME DEPTH ORIENT PLACE CHANCE FLAGS MONS
%token <i> ROOT_DEPTH ENTRY_MSG EXIT_MSG
%token <i> ROCK_COLOUR FLOOR_COLOUR
-%token <i> ENCOMPASS
+%token <i> ENCOMPASS FLOAT
%token <i> NORTH EAST SOUTH WEST
%token <i> NORTHEAST SOUTHEAST SOUTHWEST NORTHWEST
@@ -71,6 +71,39 @@ defdepth : DEFAULT_DEPTH depth_range
level : name metalines map_def metalines
{
+ if (lc_map.orient == MAP_FLOAT
+ || lc_map.is_minivault())
+ {
+ if (lc_map.map.width() > GXM - MAPGEN_BORDER * 2
+ || lc_map.map.height() > GYM - MAPGEN_BORDER * 2)
+ {
+ char buf[300];
+ snprintf(buf, sizeof buf,
+ "%s is too big: %dx%d - max %dx%d",
+ lc_map.is_minivault()? "Minivault" : "Float",
+ lc_map.map.width(), lc_map.map.height(),
+ GXM - MAPGEN_BORDER * 2,
+ GYM - MAPGEN_BORDER * 2);
+ yyerror(buf);
+ }
+ }
+ else
+ {
+ if (lc_map.map.width() > GXM
+ || lc_map.map.height() > GYM)
+ {
+ char buf[300];
+ snprintf(buf, sizeof buf,
+ "Map is too big: %dx%d - max %dx%d",
+ lc_map.map.width(), lc_map.map.height(),
+ GXM, GYM);
+ yyerror(buf);
+ }
+ }
+
+ if (lc_map.map.height() == 0)
+ yyerror("Must define map.");
+
add_parsed_map( lc_map );
}
;
@@ -183,6 +216,7 @@ orient_name : ENCOMPASS { $$ = MAP_ENCOMPASS; }
| SOUTHEAST { $$ = MAP_SOUTHEAST; }
| SOUTHWEST { $$ = MAP_SOUTHWEST; }
| NORTHWEST { $$ = MAP_NORTHWEST; }
+ | FLOAT { $$ = MAP_FLOAT; }
;
flags : FLAGS flagnames {}