summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-30 15:49:18 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-30 15:49:18 +0000
commitfd34c17a54e69fa53b0b6ae7123fdbd60e6303f7 (patch)
tree01846cf5096208daf13e1005b38647afe6676409 /crawl-ref/source
parent34cc3ee5d9832be20c635849dc592611c4697f2c (diff)
downloadcrawl-ref-fd34c17a54e69fa53b0b6ae7123fdbd60e6303f7.tar.gz
crawl-ref-fd34c17a54e69fa53b0b6ae7123fdbd60e6303f7.zip
[1742338] Fixed Hell portals not being revealed correctly when the horn is
sounded. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1701 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/dat/levdes.vim2
-rw-r--r--crawl-ref/source/dat/splev.des23
-rw-r--r--crawl-ref/source/describe.cc3
-rw-r--r--crawl-ref/source/direct.cc9
-rw-r--r--crawl-ref/source/dungeon.cc91
-rw-r--r--crawl-ref/source/dungeon.h43
-rw-r--r--crawl-ref/source/enum.h10
-rw-r--r--crawl-ref/source/externs.h17
-rw-r--r--crawl-ref/source/files.cc12
-rw-r--r--crawl-ref/source/files.h2
-rw-r--r--crawl-ref/source/it_use3.cc43
-rw-r--r--crawl-ref/source/itemname.cc13
-rw-r--r--crawl-ref/source/items.cc11
-rw-r--r--crawl-ref/source/libunix.cc3
-rw-r--r--crawl-ref/source/luadgn.cc108
-rw-r--r--crawl-ref/source/luadgn.h3
-rw-r--r--crawl-ref/source/mapdef.cc226
-rw-r--r--crawl-ref/source/mapdef.h45
-rw-r--r--crawl-ref/source/maps.cc13
-rw-r--r--crawl-ref/source/message.cc2
-rw-r--r--crawl-ref/source/notes.cc15
-rw-r--r--crawl-ref/source/stuff.cc63
-rw-r--r--crawl-ref/source/tags.cc47
-rw-r--r--crawl-ref/source/tags.h2
-rw-r--r--crawl-ref/source/travel.cc12
-rw-r--r--crawl-ref/source/util/levcomp.lpp1
-rw-r--r--crawl-ref/source/util/levcomp.ypp23
27 files changed, 690 insertions, 152 deletions
diff --git a/crawl-ref/source/dat/levdes.vim b/crawl-ref/source/dat/levdes.vim
index f466a49802..cc29473f35 100644
--- a/crawl-ref/source/dat/levdes.vim
+++ b/crawl-ref/source/dat/levdes.vim
@@ -48,7 +48,7 @@ syn region desShuffle start=/^SHUFFLE:\s*/ end=/$/ contains=desShuffleDec,desMap
syn keyword desSubstDec SUBST: contained
syn keyword desShuffleDec SHUFFLE: contained
-syn keyword desDeclarator NAME: ORIENT: DEPTH: PLACE: MONS: FLAGS: default-depth: TAGS: CHANCE: ITEM: KFEAT: KMONS: KITEM:
+syn keyword desDeclarator NAME: ORIENT: DEPTH: PLACE: MONS: FLAGS: default-depth: TAGS: CHANCE: ITEM: KFEAT: KMONS: KITEM: MARKER:
syn keyword desOrientation encompass north south east west northeast northwest southeast southwest float no_hmirror no_vmirror no_rotate entry pan no_pool_fixup no_monster_gen generate_awake
syn match desComment "^\s*#.*$"
diff --git a/crawl-ref/source/dat/splev.des b/crawl-ref/source/dat/splev.des
index 5f85e274ea..246db49cc8 100644
--- a/crawl-ref/source/dat/splev.des
+++ b/crawl-ref/source/dat/splev.des
@@ -6,24 +6,12 @@
#############################################################################
# Vestibule of Hell and Geryon
-#
-# If modifying the Vestibule, ensure that:
-#
-# * The portal to Dis is surrounded by floor squares and nothing but floor
-# squares.
-# * The portal to Tartarus is surrounded only by floor, doors of any kind, and
-# at least one rock wall.
-# * The portal to Gehenna is surrounded by nothing but floor and at least one
-# lava square.
-# * The portal to Cocytus is surrounded by nothing but floor and at least one
-# water square.
-#
-# If you don't do this, the portals will not be unbarred correctly when
-# Geryon's horn is sounded.
NAME: vestibule_of_hell
PLACE: Hell
ORIENT: encompass
+MARKER: D=enter_dis, G=enter_gehenna, C=enter_cocytus, T=enter_tartarus
+SUBST: D=A, G=A, C=A, T=A
MONS: Geryon
@@ -38,7 +26,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxvvvvvvvxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx..v.....v..xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.....v.....v.....xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxx........v.....v........xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-xxxxxxxxxxxxxxxxxxxxxxxxxx..........v..A..v..........xxxxxxxxxxxxxxxxxxxxxxxxxxx
+xxxxxxxxxxxxxxxxxxxxxxxxxx..........v..D..v..........xxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxx............v.....v............xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxx.............v.....v.............xxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxx..............vvv+vvv..............xxxxxxxxxxxxxxxxxxxxxxx
@@ -62,7 +50,7 @@ xxxxxxxxxx..l.l.l.l..................................................xxxxxxxxxxx
xxxxxxxxxx.l.l.l.l.l.................................................xxxxxxxxxxx
xxxxxxxxx.l.l.l.l.l...................................................xxxxxxxxxx
xxxxxxxxxl.l.l.l.l.l..................................................xxxxxxxxxx
-xxxxxxxxx.l.l.l.A.l.l.................}1].............................=Axxxxxxxx
+xxxxxxxxx.l.l.l.G.l.l.................}1].............................=Txxxxxxxx
xxxxxxxxxl.l.l.l.l.l.l.................)..............................xxxxxxxxxx
xxxxxxxxx.l.l.l.l.l.l.................................................xxxxxxxxxx
xxxxxxxxxx.l.l.l.l.l.l...............................................xxxxxxxxxxx
@@ -86,7 +74,7 @@ xxxxxxxxxxxxxxxxxxxxx.........ww....wwww...wwwwwwwwww.....xxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxx.........ww....ww....wwwwwwwwwww...xxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxx........wwww.......wwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxx......wwwwwww....wwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxxxxxxxx
-xxxxxxxxxxxxxxxxxxxxxxxxxx...wwwwwwwwwwAwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxxxxxxxxxx
+xxxxxxxxxxxxxxxxxxxxxxxxxx...wwwwwwwwwwCwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxwwwwwwwwwwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxwwwwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxwwwwwwwwwwwxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
@@ -100,7 +88,6 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ENDMAP
-
#############################################################################
# Dispater's castle - rest of level filled up with plan_4 (irregular city)
#
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index 852e231a7c..b6eced76c3 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -868,9 +868,8 @@ static std::string describe_weapon( const item_def &item, bool verbose)
break;
case WPN_HAND_AXE:
- description += "An small axe designed for either hand combat "
+ description += "A small axe designed for either hand combat "
"or throwing. ";
- // "It might also make a good tool.";
break;
case WPN_BATTLEAXE:
diff --git a/crawl-ref/source/direct.cc b/crawl-ref/source/direct.cc
index 56b2a41963..7598971924 100644
--- a/crawl-ref/source/direct.cc
+++ b/crawl-ref/source/direct.cc
@@ -36,6 +36,7 @@
#include "command.h"
#include "debug.h"
#include "describe.h"
+#include "dungeon.h"
#include "itemname.h"
#include "monstuff.h"
#include "mon-util.h"
@@ -1675,9 +1676,13 @@ static void describe_cell(int mx, int my)
std::string feature_desc = feature_description(mx, my);
#ifdef DEBUG_DIAGNOSTICS
- mprf("(%d,%d): %s - %s", mx, my,
+ std::string marker;
+ if (map_marker *mark = env.find_marker(coord_def(mx, my), MAT_ANY))
+ marker = " (" + mark->describe() + ")";
+ mprf("(%d,%d): %s - %s%s", mx, my,
stringize_glyph(get_screen_glyph(mx, my)).c_str(),
- feature_desc.c_str());
+ feature_desc.c_str(),
+ marker.c_str());
#else
mpr(feature_desc.c_str());
#endif
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 87ee0b0ade..b626a49e1a 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -55,6 +55,7 @@
#include "randart.h"
#include "spl-book.h"
#include "stuff.h"
+#include "tags.h"
#include "travel.h"
#define MAX_PIT_MONSTERS 10
@@ -347,6 +348,9 @@ static void reset_level()
// reset all shops
for (unsigned char shcount = 0; shcount < 5; shcount++)
env.shop[shcount].type = SHOP_UNASSIGNED;
+
+ // clear all markers
+ env.clear_markers();
}
static void build_layout_skeleton(int level_number, int level_type,
@@ -2617,6 +2621,8 @@ static bool build_minivaults(int level_number, int force_vault)
place.x = v1x;
place.y = v1y;
+
+ place.map.map.apply_markers(coord_def(v1x, v1y));
level_vaults.push_back(place);
vault_zones.push_back(
@@ -3003,6 +3009,8 @@ static bool build_vaults(int level_number, int force_vault, int rune_subst,
if (gluggy == MAP_NONE || !gluggy)
return (false);
+ place.map.map.apply_markers(coord_def(place.x, place.y));
+
int vx, vy;
int num_runes = 0;
@@ -6242,3 +6250,86 @@ coord_def dgn_region::random_point() const
{
return coord_def( pos.x + random2(size.x), pos.y + random2(size.y) );
}
+
+////////////////////////////////////////////////////////////////////////
+// Dungeon markers
+
+map_marker::marker_reader
+map_marker::readers[NUM_MAP_MARKER_TYPES] =
+{
+ &map_feature_marker::read,
+};
+
+map_marker::map_marker(map_marker_type t, const coord_def &p)
+ : pos(p), type(t)
+{
+}
+
+map_marker::~map_marker()
+{
+}
+
+void map_marker::write(tagHeader &outf) const
+{
+ marshallShort(outf, type);
+ marshallCoord(outf, pos);
+}
+
+void map_marker::read(tagHeader &inf)
+{
+ // Don't read type! The type has to be read by someone who knows how
+ // to look up the unmarshall function.
+ unmarshallCoord(inf, pos);
+}
+
+map_marker *map_marker::read_marker(tagHeader &inf)
+{
+ const map_marker_type type =
+ static_cast<map_marker_type>(unmarshallShort(inf));
+ return readers[type]? (*readers[type])(inf, type) : NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////
+// map_feature_marker
+
+map_feature_marker::map_feature_marker(
+ const coord_def &p,
+ dungeon_feature_type _feat)
+ : map_marker(MAT_FEATURE, p), feat(_feat)
+{
+}
+
+map_feature_marker::map_feature_marker(
+ const map_feature_marker &other)
+ : map_marker(MAT_FEATURE, other.pos), feat(other.feat)
+{
+}
+
+void map_feature_marker::write(tagHeader &outf) const
+{
+ this->map_marker::write(outf);
+ marshallShort(outf, feat);
+}
+
+void map_feature_marker::read(tagHeader &inf)
+{
+ map_marker::read(inf);
+ feat = static_cast<dungeon_feature_type>(unmarshallShort(inf));
+}
+
+map_marker *map_feature_marker::read(tagHeader &inf, map_marker_type)
+{
+ map_marker *mapf = new map_feature_marker();
+ mapf->read(inf);
+ return (mapf);
+}
+
+map_marker *map_feature_marker::clone() const
+{
+ return new map_feature_marker(pos, feat);
+}
+
+std::string map_feature_marker::describe() const
+{
+ return make_stringf("feature (%s)", dungeon_feature_name(feat));
+}
diff --git a/crawl-ref/source/dungeon.h b/crawl-ref/source/dungeon.h
index 1ba0aaf3df..34fd78690c 100644
--- a/crawl-ref/source/dungeon.h
+++ b/crawl-ref/source/dungeon.h
@@ -99,6 +99,49 @@ void place_spec_shop(int level_number, int shop_x, int shop_y,
int force_s_type, bool representative = false);
bool unforbidden(const coord_def &c, const dgn_region_list &forbidden);
+//////////////////////////////////////////////////////////////////////////
+// Map markers
+
+class map_marker
+{
+public:
+ map_marker(map_marker_type type, const coord_def &pos);
+ virtual ~map_marker();
+
+ map_marker_type get_type() const { return type; }
+
+ virtual void write(tagHeader &) const;
+ virtual void read(tagHeader &);
+ virtual map_marker *clone() const = 0;
+ virtual std::string describe() const = 0;
+
+ static map_marker *read_marker(tagHeader&);
+
+public:
+ coord_def pos;
+
+protected:
+ map_marker_type type;
+
+ typedef map_marker *(*marker_reader)(tagHeader &, map_marker_type);
+ static marker_reader readers[NUM_MAP_MARKER_TYPES];
+};
+
+class map_feature_marker : public map_marker
+{
+public:
+ map_feature_marker(const coord_def &pos = coord_def(0, 0),
+ dungeon_feature_type feat = DNGN_UNSEEN);
+ map_feature_marker(const map_feature_marker &other);
+ void write(tagHeader &) const;
+ void read(tagHeader &);
+ map_marker *clone() const;
+ std::string describe() const;
+ static map_marker *read(tagHeader &, map_marker_type);
+
+public:
+ dungeon_feature_type feat;
+};
//////////////////////////////////////////////////////////////////////////
template <typename fgrd, typename bound_check>
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index 9ab0ea7940..4cf476bef2 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -1015,7 +1015,6 @@ enum dungeon_feature_type
DNGN_EXIT_HELL, // 68
DNGN_ENTER_HELL, // 69
DNGN_OPEN_DOOR, // 70
- // DNGN_BRANCH_STAIRS, // 71
DNGN_TRAP_MECHANICAL = 75, // 75
DNGN_TRAP_MAGICAL,
DNGN_TRAP_III,
@@ -1110,6 +1109,7 @@ enum dungeon_feature_type
DNGN_DRY_FOUNTAIN_VII,
DNGN_DRY_FOUNTAIN_VIII,
DNGN_PERMADRY_FOUNTAIN = 210, // added (from dungeon.cc/maps.cc) 22jan2000 {dlb}
+ NUM_REAL_FEATURES,
// Real terrain must all occur before 256 to guarantee it fits
// into the unsigned char used for the grid!
@@ -1739,6 +1739,14 @@ enum load_mode_type
LOAD_ENTER_LEVEL
};
+// Can't change this order without breaking saves.
+enum map_marker_type
+{
+ MAT_FEATURE, // Stock marker.
+ NUM_MAP_MARKER_TYPES,
+ MAT_ANY
+};
+
// [dshaligram] Maps can be mirrored; for every orientation, there must be
// a suitable mirror.
enum map_section_type // see maps.cc and dungeon.cc {dlb}
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index 2a4cbd362b..89b419129c 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -1167,8 +1167,13 @@ struct map_cell
};
typedef FixedArray<dungeon_feature_type, GXM, GYM> feature_grid;
+class map_marker;
+typedef std::multimap<coord_def, map_marker *> dgn_marker_map;
+typedef std::pair<coord_def, map_marker *> dgn_pos_marker;
+
struct crawl_environment
{
+public:
unsigned char rock_colour;
unsigned char floor_colour;
@@ -1193,11 +1198,21 @@ struct crawl_environment
FixedVector< shop_struct, MAX_SHOPS > shop; // shop list
FixedVector< trap_struct, MAX_TRAPS > trap; // trap list
- FixedVector< int, 20 > mons_alloc;
+ FixedVector< int, 20 > mons_alloc;
+ dgn_marker_map markers;
+
double elapsed_time; // used during level load
// Number of turns the player has spent on this level.
int turns_on_level;
+
+public:
+ void add_marker(map_marker *);
+ void remove_marker(map_marker *);
+ void remove_markers_at(const coord_def &c);
+ map_marker *find_marker(const coord_def &c, map_marker_type) const;
+ std::vector<map_marker*> get_markers(const coord_def &c) const;
+ void clear_markers();
};
extern struct crawl_environment env;
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index ad55283bfc..e774f3c08b 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -1677,6 +1677,18 @@ long readLong(FILE *file)
(long) (unsigned short) readShort(file);
}
+void writeCoord(FILE *file, const coord_def &pos)
+{
+ writeShort(file, pos.x);
+ writeShort(file, pos.y);
+}
+
+void readCoord(FILE *file, coord_def &pos)
+{
+ pos.x = readShort(file);
+ pos.y = readShort(file);
+}
+
////////////////////////////////////////////////////////////////////////////
// Locking for multiuser systems
diff --git a/crawl-ref/source/files.h b/crawl-ref/source/files.h
index d3defbf8d0..d8f79b34c7 100644
--- a/crawl-ref/source/files.h
+++ b/crawl-ref/source/files.h
@@ -96,6 +96,8 @@ void writeString(FILE* file, const std::string &s, int cap = STR_CAP);
std::string readString(FILE *file, int cap = STR_CAP);
void writeLong(FILE* file, long num);
long readLong(FILE *file);
+void writeCoord(FILE *file, const coord_def &pos);
+void readCoord(FILE *file, coord_def &pos);
FILE *lk_open(const char *mode, const std::string &file);
void lk_close(FILE *handle, const char *mode, const std::string &file);
diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc
index 664f448b06..52cd5065ad 100644
--- a/crawl-ref/source/it_use3.cc
+++ b/crawl-ref/source/it_use3.cc
@@ -570,41 +570,16 @@ bool evoke_wielded( void )
{
opened_gates++;
- // [dshaligram] New approach to placing Hell
- // portals to handle the possibility of a mirrored
- // Vestibule.
- int surround_grid = DNGN_FLOOR;
-
- for (int y = -1; y <= 1; ++y)
- for (int x = -1; x <= 1; ++x)
- {
- if (!x && !y)
- continue;
- const int grid =
- grd[count_x + x][count_y + y];
-
- if (grid != DNGN_FLOOR
- && grid != DNGN_SECRET_DOOR
- && grid != DNGN_CLOSED_DOOR
- && grid != DNGN_OPEN_DOOR)
- surround_grid = grid;
- }
-
- // this may generate faulty [][] values {dlb}
- switch (surround_grid)
+ map_marker *marker =
+ env.find_marker(coord_def(count_x, count_y),
+ MAT_FEATURE);
+
+ if (marker)
{
- case DNGN_FLOOR:
- grd[count_x][count_y] = DNGN_ENTER_DIS;
- break;
- case DNGN_LAVA:
- grd[count_x][count_y] = DNGN_ENTER_GEHENNA;
- break;
- case DNGN_ROCK_WALL:
- grd[count_x][count_y] = DNGN_ENTER_TARTARUS;
- break;
- case DNGN_DEEP_WATER:
- grd[count_x][count_y] = DNGN_ENTER_COCYTUS;
- break;
+ map_feature_marker *featm =
+ dynamic_cast<map_feature_marker*>(marker);
+ grd[count_x][count_y] = featm->feat;
+ env.remove_marker(marker);
}
}
}
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index b9554065c9..646b203065 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -1898,14 +1898,15 @@ static char retlet( int sed )
bool is_interesting_item( const item_def& item )
{
- if ( is_random_artefact(item) ||
- is_unrandom_artefact(item) ||
- is_fixed_artefact(item) )
- return true;
+ if (fully_identified(item)
+ && (is_random_artefact(item) ||
+ is_unrandom_artefact(item) ||
+ is_fixed_artefact(item)))
+ return (true);
const std::string iname = item.name(DESC_PLAIN);
for (unsigned i = 0; i < Options.note_items.size(); ++i)
if (Options.note_items[i].matches(iname))
- return true;
- return false;
+ return (true);
+ return (false);
}
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index ac28060190..79048b4938 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -52,6 +52,7 @@
#include "mstuff2.h"
#include "mon-util.h"
#include "mutation.h"
+#include "notes.h"
#include "overmap.h"
#include "player.h"
#include "randart.h"
@@ -844,6 +845,13 @@ static void milestone_check(const item_def &item)
}
#endif // DGL_MILESTONES
+static void check_note_item(const item_def &item)
+{
+ if (is_interesting_item(item))
+ take_note(Note(NOTE_GET_ITEM, 0, 0, item.name(DESC_NOCAP_A).c_str(),
+ origin_desc(item).c_str()));
+}
+
void origin_set(int x, int y)
{
int monnum = first_corpse_monnum(x, y);
@@ -857,7 +865,7 @@ void origin_set(int x, int y)
if (!item.orig_monnum)
item.orig_monnum = static_cast<short>( monnum );
item.orig_place = pplace;
-
+ check_note_item(item);
#ifdef DGL_MILESTONES
milestone_check(item);
#endif
@@ -876,6 +884,7 @@ void origin_freeze(item_def &item, int x, int y)
if (!item.orig_monnum && x != -1 && y != -1)
origin_set_monstercorpse(item, x, y);
item.orig_place = get_packed_place();
+ check_note_item(item);
#ifdef DGL_MILESTONES
milestone_check(item);
#endif
diff --git a/crawl-ref/source/libunix.cc b/crawl-ref/source/libunix.cc
index 84d0beaa80..8e6ea6fce9 100644
--- a/crawl-ref/source/libunix.cc
+++ b/crawl-ref/source/libunix.cc
@@ -230,7 +230,8 @@ void set_mouse_enabled(bool enabled)
{
#ifdef NCURSES_MOUSE_VERSION
const int mask = enabled? ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION : 0;
- mousemask(mask, NULL);
+ mmask_t oldmask = 0;
+ mousemask(mask, &oldmask);
#endif
}
diff --git a/crawl-ref/source/luadgn.cc b/crawl-ref/source/luadgn.cc
index 3060248deb..85b0aeaaa7 100644
--- a/crawl-ref/source/luadgn.cc
+++ b/crawl-ref/source/luadgn.cc
@@ -601,6 +601,35 @@ static int dgn_item(lua_State *ls)
return (0);
}
+static int dgn_marker(lua_State *ls)
+{
+ MAP(ls, 1, map);
+ if (lua_gettop(ls) == 1)
+ return (0);
+ if (lua_isnil(ls, 2))
+ {
+ map->map.clear_markers();
+ return (0);
+ }
+
+ if (lua_isstring(ls, 2))
+ {
+ std::string err = map->map.add_feature_marker(luaL_checkstring(ls, 2));
+ if (!err.empty())
+ luaL_error(ls, err.c_str());
+ return (0);
+ }
+
+ const coord_def pos(luaL_checkint(ls, 2), luaL_checkint(ls, 3));
+ dungeon_feature_type feat = DNGN_UNSEEN;
+ if (lua_isnumber(ls, 4))
+ feat = static_cast<dungeon_feature_type>( luaL_checkint(ls, 4) );
+ else
+ feat = dungeon_feature_by_name( luaL_checkstring(ls, 4) );
+ map->map.add_marker( new map_feature_marker(pos, feat) );
+ return (0);
+}
+
static int dgn_kfeat(lua_State *ls)
{
MAP(ls, 1, map);
@@ -739,6 +768,82 @@ static int dgn_load_des_file(lua_State *ls)
return (0);
}
+const char *dngn_feature_names[] =
+{
+ "unseen", "rock_wall", "stone_wall", "closed_door", "metal_wall",
+ "secret_door", "green_crystal_wall", "orcish_idol", "wax_wall",
+ "permarock_wall", "", "", "", "", "", "", "", "", "", "", "",
+ "silver_statue", "granite_statue", "orange_crystal_statue",
+ "statue_reserved_1", "statue_reserved_2", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "lava", "deep_water", "", "",
+ "shallow_water", "water_stuck", "floor", "exit_hell", "enter_hell",
+ "open_door", "", "", "", "", "trap_mechanical", "trap_magical", "trap_iii",
+ "undiscovered_trap", "", "enter_shop", "enter_labyrinth",
+ "stone_stairs_down_i", "stone_stairs_down_ii", "stone_stairs_down_iii",
+ "rock_stairs_down", "stone_stairs_up_i", "stone_stairs_up_ii",
+ "stone_stairs_up_iii", "rock_stairs_up", "", "", "enter_dis",
+ "enter_gehenna", "enter_cocytus", "enter_tartarus", "enter_abyss",
+ "exit_abyss", "stone_arch", "enter_pandemonium", "exit_pandemonium",
+ "transit_pandemonium", "", "", "", "builder_special_wall",
+ "builder_special_floor", "", "", "", "enter_orcish_mines", "enter_hive",
+ "enter_lair", "enter_slime_pits", "enter_vaults", "enter_crypt",
+ "enter_hall_of_blades", "enter_zot", "enter_temple", "enter_snake_pit",
+ "enter_elven_halls", "enter_tomb", "enter_swamp", "enter_shoals",
+ "enter_reserved_2", "enter_reserved_3", "enter_reserved_4", "", "", "",
+ "return_from_orcish_mines", "return_from_hive", "return_from_lair",
+ "return_from_slime_pits", "return_from_vaults", "return_from_crypt",
+ "return_from_hall_of_blades", "return_from_zot", "return_from_temple",
+ "return_from_snake_pit", "return_from_elven_halls", "return_from_tomb",
+ "return_from_swamp", "return_from_shoals", "return_reserved_2",
+ "return_reserved_3", "return_reserved_4", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "altar_zin", "altar_shining_one",
+ "altar_kikubaaqudgha", "altar_yredelemnul", "altar_xom", "altar_vehumet",
+ "altar_okawaru", "altar_makhleb", "altar_sif_muna", "altar_trog",
+ "altar_nemelex_xobeh", "altar_elyvilon", "altar_lugonu", "altar_beogh", "",
+ "", "", "", "", "", "blue_fountain", "dry_fountain_i",
+ "sparkling_fountain", "dry_fountain_ii", "dry_fountain_iii",
+ "dry_fountain_iv", "dry_fountain_v", "dry_fountain_vi", "dry_fountain_vii",
+ "dry_fountain_viii", "permadry_fountain"
+};
+
+dungeon_feature_type dungeon_feature_by_name(const std::string &name)
+{
+ ASSERT(ARRAYSIZE(dngn_feature_names) == NUM_REAL_FEATURES);
+ if (name.empty())
+ return (DNGN_UNSEEN);
+
+ for (unsigned i = 0; i < ARRAYSIZE(dngn_feature_names); ++i)
+ if (dngn_feature_names[i] == name)
+ return static_cast<dungeon_feature_type>(i);
+
+ return (DNGN_UNSEEN);
+}
+
+const char *dungeon_feature_name(dungeon_feature_type rfeat)
+{
+ const unsigned feat = rfeat;
+
+ if (feat >= ARRAYSIZE(dngn_feature_names))
+ return (NULL);
+
+ return dngn_feature_names[feat];
+}
+
+static int dgn_feature_number(lua_State *ls)
+{
+ const std::string &name = luaL_checkstring(ls, 1);
+ PLUARET(number, dungeon_feature_by_name(name));
+}
+
+static int dgn_feature_name(lua_State *ls)
+{
+ const unsigned feat = luaL_checkint(ls, 1);
+ PLUARET(string,
+ dungeon_feature_name(static_cast<dungeon_feature_type>(feat)));
+}
+
static const struct luaL_reg dgn_lib[] =
{
{ "default_depth", dgn_default_depth },
@@ -757,6 +862,7 @@ static const struct luaL_reg dgn_lib[] =
{ "map", dgn_map },
{ "mons", dgn_mons },
{ "item", dgn_item },
+ { "marker", dgn_marker },
{ "kfeat", dgn_kfeat },
{ "kitem", dgn_kitem },
{ "kmons", dgn_kmons },
@@ -768,6 +874,8 @@ static const struct luaL_reg dgn_lib[] =
{ "gly_points", dgn_gly_points },
{ "original_map", dgn_original_map },
{ "load_des_file", dgn_load_des_file },
+ { "feature_number", dgn_feature_number },
+ { "feature_name", dgn_feature_name },
{ NULL, NULL }
};
diff --git a/crawl-ref/source/luadgn.h b/crawl-ref/source/luadgn.h
index 9573fb5a67..102a4e87e7 100644
--- a/crawl-ref/source/luadgn.h
+++ b/crawl-ref/source/luadgn.h
@@ -65,6 +65,9 @@ std::string dgn_set_default_depth(const std::string &s);
void dgn_reset_default_depth();
int dlua_stringtable(lua_State *ls, const std::vector<std::string> &s);
+dungeon_feature_type dungeon_feature_by_name(const std::string &name);
+const char *dungeon_feature_name(dungeon_feature_type feat);
+
//////////////////////////////////////////////////////////////////////////
#endif
diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc
index a8044f1952..0a8c339c88 100644
--- a/crawl-ref/source/mapdef.cc
+++ b/crawl-ref/source/mapdef.cc
@@ -337,7 +337,7 @@ map_transformer::~map_transformer()
// map_lines
map_lines::map_lines()
- : transforms(), lines(), map_width(0), solid_north(false),
+ : transforms(), markers(), lines(), map_width(0), solid_north(false),
solid_east(false), solid_south(false), solid_west(false),
solid_checked(false)
{
@@ -362,12 +362,14 @@ map_lines &map_lines::operator = (const map_lines &map)
map_lines::~map_lines()
{
- release_transforms();
+ clear_transforms();
+ clear_markers();
}
void map_lines::init_from(const map_lines &map)
{
- release_transforms();
+ clear_transforms();
+ clear_markers();
lines = map.lines;
map_width = map.map_width;
solid_north = map.solid_north;
@@ -378,13 +380,60 @@ void map_lines::init_from(const map_lines &map)
for (int i = 0, size = map.transforms.size(); i < size; ++i)
transforms.push_back( map.transforms[i]->clone() );
+
+ for (int i = 0, size = map.markers.size(); i < size; ++i)
+ markers.push_back( map.markers[i]->clone() );
}
-void map_lines::release_transforms()
+template <typename V>
+void map_lines::clear_vector(V &vect)
{
- for (int i = 0, size = transforms.size(); i < size; ++i)
- delete transforms[i];
- transforms.clear();
+ for (int i = 0, size = vect.size(); i < size; ++i)
+ delete vect[i];
+ vect.clear();
+}
+
+void map_lines::clear_transforms()
+{
+ clear_vector(transforms);
+}
+
+void map_lines::clear_markers()
+{
+ clear_vector(markers);
+}
+
+void map_lines::add_marker(map_marker *marker)
+{
+ markers.push_back(marker);
+}
+
+std::string map_lines::add_feature_marker(const std::string &s)
+{
+ std::string arg;
+ int key = 0, sep = 0;
+ std::string err = split_key_item(s, &key, &sep, &arg);
+ if (!err.empty())
+ return (err);
+
+ const dungeon_feature_type feat = dungeon_feature_by_name(arg);
+ if (feat == DNGN_UNSEEN)
+ return make_stringf("unknown feature: %s", arg.c_str());
+
+ transforms.push_back(new map_feat_marker_spec(key, feat));
+ return ("");
+}
+
+void map_lines::apply_markers(const coord_def &c)
+{
+ for (int i = 0, size = markers.size(); i < size; ++i)
+ {
+ markers[i]->pos += c;
+ env.add_marker(markers[i]);
+ }
+ // *not* clear_markers() since we've offloaded marker ownership to
+ // the crawl env.
+ markers.clear();
}
const std::vector<std::string> &map_lines::get_lines() const
@@ -640,7 +689,8 @@ bool map_lines::solid_borders(map_section_type border)
void map_lines::clear()
{
- release_transforms();
+ clear_transforms();
+ clear_markers();
lines.clear();
map_width = 0;
solid_checked = false;
@@ -715,13 +765,19 @@ void map_lines::resolve_shuffle(const std::string &shufflage)
}
}
-void map_lines::apply_transforms()
+std::string map_lines::apply_transforms()
{
+ std::string error;
for (int i = 0, size = transforms.size(); i < size; ++i)
- transforms[i]->apply_transform(*this);
+ {
+ error = transforms[i]->apply_transform(*this);
+ if (!error.empty())
+ return (error);
+ }
// Release the transforms so we don't try them again.
- release_transforms();
+ clear_transforms();
+ return ("");
}
void map_lines::normalise(char fillch)
@@ -762,11 +818,53 @@ void map_lines::rotate(bool clockwise)
}
map_width = lines.size();
- lines = newlines;
-
+ lines = newlines;
+ rotate_markers(clockwise);
solid_checked = false;
}
+void map_lines::translate_marker(
+ void (map_lines::*xform)(map_marker *, int),
+ int par)
+{
+ for (int i = 0, size = markers.size(); i < size; ++i)
+ (this->*xform)(markers[i], par);
+}
+
+void map_lines::vmirror_marker(map_marker *marker, int)
+{
+ marker->pos.y = height() - 1 - marker->pos.y;
+}
+
+void map_lines::hmirror_marker(map_marker *marker, int)
+{
+ marker->pos.x = width() - 1 - marker->pos.x;
+}
+
+void map_lines::rotate_marker(map_marker *marker, int clockwise)
+{
+ const coord_def c = marker->pos;
+ if (clockwise)
+ marker->pos = coord_def(width() - 1 - c.y, c.x);
+ else
+ marker->pos = coord_def(c.y, height() - 1 - c.x);
+}
+
+void map_lines::vmirror_markers()
+{
+ translate_marker(&map_lines::vmirror_marker);
+}
+
+void map_lines::hmirror_markers()
+{
+ translate_marker(&map_lines::hmirror_marker);
+}
+
+void map_lines::rotate_markers(bool clock)
+{
+ translate_marker(&map_lines::rotate_marker, clock);
+}
+
void map_lines::vmirror()
{
const int size = lines.size();
@@ -778,7 +876,7 @@ void map_lines::vmirror()
lines[i] = lines[size - 1 - i];
lines[size - 1 - i] = temp;
}
-
+ vmirror_markers();
solid_checked = false;
}
@@ -795,7 +893,7 @@ void map_lines::hmirror()
s[map_width - 1 - j] = c;
}
}
-
+ hmirror_markers();
solid_checked = false;
}
@@ -817,6 +915,36 @@ std::vector<std::string> map_lines::get_subst_strings() const
return (substs);
}
+std::vector<coord_def> map_lines::find_glyph(int gly) const
+{
+ std::vector<coord_def> points;
+ for (int y = height() - 1; y >= 0; --y)
+ {
+ for (int x = width() - 1; x >= 0; --x)
+ {
+ const coord_def c(x, y);
+ if ((*this)(c) == gly)
+ points.push_back(c);
+ }
+ }
+ return (points);
+}
+
+coord_def map_lines::find_first_glyph(int gly) const
+{
+ for (int y = 0, h = height(); y < h; ++y)
+ {
+ for (int x = 0, w = width(); x < w; ++x)
+ {
+ const coord_def c(x, y);
+ if ((*this)(c) == gly)
+ return (c);
+ }
+ }
+
+ return coord_def(-1, -1);
+}
+
///////////////////////////////////////////////
// dlua_set_map
@@ -924,32 +1052,12 @@ void map_def::load()
std::vector<coord_def> map_def::find_glyph(int glyph) const
{
- std::vector<coord_def> points;
- for (int y = map.height() - 1; y >= 0; --y)
- {
- for (int x = map.width() - 1; x >= 0; --x)
- {
- const coord_def c(x, y);
- if (map(c) == glyph)
- points.push_back(c);
- }
- }
- return (points);
+ return map.find_glyph(glyph);
}
coord_def map_def::find_first_glyph(int glyph) const
{
- for (int y = 0, height = map.height(); y < height; ++y)
- {
- for (int x = 0, width = map.width(); x < width; ++x)
- {
- const coord_def c(x, y);
- if (map(c) == glyph)
- return (c);
- }
- }
-
- return coord_def(-1, -1);
+ return map.find_first_glyph(glyph);
}
void map_def::write_index(FILE *outf) const
@@ -1120,7 +1228,7 @@ std::string map_def::validate_map_def()
if (map.height() == 0)
return ("Must define map.");
- return ("");
+ return (map.apply_transforms());
}
bool map_def::is_usable_in(const level_id &lid) const
@@ -1362,9 +1470,9 @@ void map_def::normalise()
map.normalise(is_minivault()? '.' : 'x');
}
-void map_def::resolve()
+std::string map_def::resolve()
{
- map.apply_transforms();
+ return map.apply_transforms();
}
void map_def::fixup()
@@ -1980,9 +2088,10 @@ int subst_spec::value()
return (chosen);
}
-void subst_spec::apply_transform(map_lines &map)
+std::string subst_spec::apply_transform(map_lines &map)
{
map.subst(*this);
+ return ("");
}
map_transformer *subst_spec::clone() const
@@ -2029,9 +2138,10 @@ bool subst_spec::operator == (const subst_spec &other) const
//////////////////////////////////////////////////////////////////////////
// shuffle_spec
-void shuffle_spec::apply_transform(map_lines &map)
+std::string shuffle_spec::apply_transform(map_lines &map)
{
map.resolve_shuffle(shuffle);
+ return ("");
}
map_transformer *shuffle_spec::clone() const
@@ -2050,6 +2160,38 @@ std::string shuffle_spec::describe() const
}
//////////////////////////////////////////////////////////////////////////
+// map_feat_marker_spec
+
+std::string map_feat_marker_spec::apply_transform(map_lines &map)
+{
+ std::vector<coord_def> positions = map.find_glyph(key);
+ if (positions.size() == 1)
+ {
+ map.add_marker(new map_feature_marker(positions[0], feat));
+ return ("");
+ }
+ else if (positions.empty())
+ return make_stringf("cant find key '%c' for marker", key);
+ else
+ return make_stringf("too many matches for key '%c' for marker", key);
+}
+
+map_transformer::transform_type map_feat_marker_spec::type() const
+{
+ return (TT_MARKER);
+}
+
+std::string map_feat_marker_spec::describe() const
+{
+ return map_feature_marker(coord_def(), feat).describe();
+}
+
+map_transformer *map_feat_marker_spec::clone() const
+{
+ return new map_feat_marker_spec(key, feat);
+}
+
+//////////////////////////////////////////////////////////////////////////
// keyed_mapspec
keyed_mapspec::keyed_mapspec()
diff --git a/crawl-ref/source/mapdef.h b/crawl-ref/source/mapdef.h
index cfd1488510..d761668f3d 100644
--- a/crawl-ref/source/mapdef.h
+++ b/crawl-ref/source/mapdef.h
@@ -78,12 +78,13 @@ public:
enum transform_type
{
TT_SHUFFLE,
- TT_SUBST
+ TT_SUBST,
+ TT_MARKER
};
public:
virtual ~map_transformer() = 0;
- virtual void apply_transform(map_lines &map) = 0;
+ virtual std::string apply_transform(map_lines &map) = 0;
virtual map_transformer *clone() const = 0;
virtual transform_type type() const = 0;
virtual std::string describe() const = 0;
@@ -101,7 +102,7 @@ public:
int value();
- void apply_transform(map_lines &map);
+ std::string apply_transform(map_lines &map);
map_transformer *clone() const;
transform_type type() const;
std::string describe() const;
@@ -125,7 +126,7 @@ struct shuffle_spec : public map_transformer
{
}
- void apply_transform(map_lines &map);
+ std::string apply_transform(map_lines &map);
map_transformer *clone() const;
transform_type type() const;
std::string describe() const;
@@ -135,6 +136,19 @@ struct shuffle_spec : public map_transformer
}
};
+struct map_feat_marker_spec : public map_transformer
+{
+ int key;
+ dungeon_feature_type feat;
+
+ map_feat_marker_spec(int _key, dungeon_feature_type _feat)
+ : key(_key), feat(_feat) { }
+ std::string apply_transform(map_lines &map);
+ transform_type type() const;
+ std::string describe() const;
+ map_transformer *clone() const;
+};
+
class map_lines
{
public:
@@ -151,7 +165,11 @@ public:
void remove_subst(const std::string &s);
void clear_shuffles();
void clear_substs();
+ void clear_markers();
+ std::vector<coord_def> find_glyph(int glyph) const;
+ coord_def find_first_glyph(int glyph) const;
+
void set_orientation(const std::string &s);
int width() const;
@@ -162,7 +180,7 @@ public:
bool solid_borders(map_section_type border);
- void apply_transforms();
+ std::string apply_transforms();
// Make all lines the same length.
void normalise(char fillc = 'x');
@@ -174,6 +192,9 @@ public:
void clear();
+ void add_marker(map_marker *marker);
+ std::string add_feature_marker(const std::string &desc);
+ void apply_markers(const coord_def &pos);
const std::vector<std::string> &get_lines() const;
std::vector<std::string> &get_lines();
std::vector<std::string> get_shuffle_strings() const;
@@ -183,7 +204,16 @@ public:
private:
void init_from(const map_lines &map);
- void release_transforms();
+ void clear_transforms();
+ template <typename V> void clear_vector(V &vect);
+ void vmirror_markers();
+ void hmirror_markers();
+ void rotate_markers(bool clock);
+ void vmirror_marker(map_marker *, int par);
+ void hmirror_marker(map_marker *, int par);
+ void rotate_marker(map_marker *, int par);
+ void translate_marker(void (map_lines::*xform)(map_marker *, int par),
+ int par = 0);
void resolve_shuffle(const std::string &shuffle);
void subst(std::string &s, subst_spec &spec);
@@ -203,6 +233,7 @@ private:
private:
std::vector<map_transformer *> transforms;
+ std::vector<map_marker *> markers;
std::vector<std::string> lines;
int map_width;
bool solid_north, solid_east, solid_south, solid_west;
@@ -467,7 +498,7 @@ public:
void vmirror();
void rotate(bool clockwise);
void normalise();
- void resolve();
+ std::string resolve();
void fixup();
bool is_usable_in(const level_id &lid) const;
diff --git a/crawl-ref/source/maps.cc b/crawl-ref/source/maps.cc
index 11eb43412f..7b387941ce 100644
--- a/crawl-ref/source/maps.cc
+++ b/crawl-ref/source/maps.cc
@@ -75,9 +75,11 @@ int vault_main(
vgrid[vx][MAP_SIDE] = 0;
}
- // NB - a return value of zero is not handled well by dungeon.cc (but there it is) 10mar2000 {dlb}
+ // Return value of zero forces dungeon.cc to regenerate the level, except
+ // for branch entry vaults where dungeon.cc just rejects the vault and
+ // places a vanilla entry.
return write_vault( vdefs[which_vault], vgrid, place, avoid );
-} // end vault_main()
+}
static int write_vault(map_def &mdef, map_type map,
vault_placement &place,
@@ -118,7 +120,12 @@ static bool resolve_map(map_def &map, const map_def &original)
mprf(MSGCH_WARN, "Lua error: %s", err.c_str());
return (false);
}
- map.resolve();
+ err = map.resolve();
+ if (!err.empty())
+ {
+ mprf(MSGCH_WARN, "Error: %s", err.c_str());
+ return (false);
+ }
if (!map.test_lua_validate(false))
return (false);
diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc
index 781adbc659..b5bde3ec19 100644
--- a/crawl-ref/source/message.cc
+++ b/crawl-ref/source/message.cc
@@ -85,7 +85,7 @@ namespace msg
}
mpr_stream_buf::mpr_stream_buf(msg_channel_type chan) :
- internal_count(0), muted(false), channel(chan)
+ internal_count(0), param(0), muted(false), channel(chan)
{}
void mpr_stream_buf::set_param(int p)
diff --git a/crawl-ref/source/notes.cc b/crawl-ref/source/notes.cc
index 7b21af98e1..9b6050c9d0 100644
--- a/crawl-ref/source/notes.cc
+++ b/crawl-ref/source/notes.cc
@@ -113,8 +113,7 @@ static bool is_noteworthy( const Note& note )
return true;
/* never noteworthy, hooked up for fun or future use */
- if ( note.type == NOTE_GET_ITEM ||
- note.type == NOTE_MP_CHANGE ||
+ if ( note.type == NOTE_MP_CHANGE ||
note.type == NOTE_MAXHP_CHANGE ||
note.type == NOTE_MAXMP_CHANGE )
return false;
@@ -177,6 +176,7 @@ static bool is_noteworthy( const Note& note )
return false;
break;
case NOTE_ID_ITEM:
+ case NOTE_GET_ITEM:
/* re-id'ing an item, e.g. second copy of book, isn't
noteworthy */
if ( rnote.name == note.name )
@@ -190,10 +190,10 @@ static bool is_noteworthy( const Note& note )
return false;
break;
default:
- mpr("Buggy note passed: unknown note type");
- // Return now, rather than give a "Buggy note passed" message
- // for each note of the matching type in the note list.
- return true;
+ mpr("Buggy note passed: unknown note type");
+ // Return now, rather than give a "Buggy note passed" message
+ // for each note of the matching type in the note list.
+ return true;
}
}
return true;
@@ -340,7 +340,8 @@ Note::Note( NOTE_TYPES t, int f, int s, const char* n, const char* d ) :
void Note::check_milestone() const
{
#ifdef DGL_MILESTONES
- if (type == NOTE_DUNGEON_LEVEL_CHANGE) {
+ if (type == NOTE_DUNGEON_LEVEL_CHANGE)
+ {
const int br = place_branch(packed_place),
dep = place_depth(packed_place);
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc
index f7cd439ae1..27e40476ce 100644
--- a/crawl-ref/source/stuff.cc
+++ b/crawl-ref/source/stuff.cc
@@ -1081,3 +1081,66 @@ int coord_def::distance_from(const coord_def &other) const
return (grid_distance(x, y, other.x, other.y));
}
+//////////////////////////////////////////////////////////////////////////
+// crawl_environment
+
+void crawl_environment::add_marker(map_marker *marker)
+{
+ markers.insert(dgn_pos_marker(marker->pos, marker));
+}
+
+void crawl_environment::remove_marker(map_marker *marker)
+{
+ std::pair<dgn_marker_map::iterator, dgn_marker_map::iterator>
+ els = markers.equal_range(marker->pos);
+ for (dgn_marker_map::iterator i = els.first; i != els.second; ++i)
+ {
+ if (i->second == marker)
+ {
+ markers.erase(i);
+ break;
+ }
+ }
+ delete marker;
+}
+
+void crawl_environment::remove_markers_at(const coord_def &c)
+{
+ std::pair<dgn_marker_map::iterator, dgn_marker_map::iterator>
+ els = markers.equal_range(c);
+ for (dgn_marker_map::iterator i = els.first; i != els.second; )
+ {
+ dgn_marker_map::iterator todel = i++;
+ delete todel->second;
+ markers.erase(todel);
+ }
+}
+
+map_marker *crawl_environment::find_marker(const coord_def &c,
+ map_marker_type type) const
+{
+ std::pair<dgn_marker_map::const_iterator, dgn_marker_map::const_iterator>
+ els = markers.equal_range(c);
+ for (dgn_marker_map::const_iterator i = els.first; i != els.second; )
+ if (type == MAT_ANY || i->second->get_type() == type)
+ return (i->second);
+ return (NULL);
+}
+
+std::vector<map_marker*> crawl_environment::get_markers(const coord_def &c)
+ const
+{
+ std::pair<dgn_marker_map::const_iterator, dgn_marker_map::const_iterator>
+ els = markers.equal_range(c);
+ std::vector<map_marker*> rmarkers;
+ for (dgn_marker_map::const_iterator i = els.first; i != els.second; )
+ rmarkers.push_back(i->second);
+ return (rmarkers);
+}
+
+void crawl_environment::clear_markers()
+{
+ for (dgn_marker_map::iterator i = markers.begin(); i != markers.end(); ++i)
+ delete i->second;
+ markers.clear();
+}
diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc
index 55b4433fe3..159b82bd05 100644
--- a/crawl-ref/source/tags.cc
+++ b/crawl-ref/source/tags.cc
@@ -71,6 +71,7 @@
#include "abl-show.h"
#include "branch.h"
+#include "dungeon.h"
#include "enum.h"
#include "externs.h"
#include "files.h"
@@ -271,8 +272,8 @@ void marshall_level_pos( struct tagHeader& th, const level_pos& lpos )
marshall_level_id(th, lpos.id);
}
-template<typename key, typename value>
-void unmarshallMap(struct tagHeader& th, std::map<key,value>& data,
+template<typename key, typename value, typename map>
+void unmarshallMap(struct tagHeader& th, map& data,
key (*key_unmarshall) (tagHeader&),
value (*value_unmarshall)(tagHeader&) )
{
@@ -281,7 +282,8 @@ void unmarshallMap(struct tagHeader& th, std::map<key,value>& data,
for ( i = 0; i < len; ++i )
{
k = key_unmarshall(th);
- data[k] = value_unmarshall(th);
+ std::pair<key, value> p(k, value_unmarshall(th));
+ data.insert(p);
}
}
@@ -309,6 +311,18 @@ level_pos unmarshall_level_pos( struct tagHeader& th )
return lpos;
}
+void marshallCoord(tagHeader &th, const coord_def &c)
+{
+ marshallShort(th, c.x);
+ marshallShort(th, c.y);
+}
+
+void unmarshallCoord(tagHeader &th, coord_def &c)
+{
+ c.x = unmarshallShort(th);
+ c.y = unmarshallShort(th);
+}
+
union float_marshall_kludge
{
// [ds] Does ANSI C guarantee that sizeof(float) == sizeof(long)?
@@ -1270,9 +1284,6 @@ static void tag_read_lost_monsters(tagHeader &th, int minorVersion)
static void tag_construct_level(struct tagHeader &th)
{
- int i;
- int count_x, count_y;
-
marshallFloat(th, (float)you.elapsed_time);
// map grids
@@ -1283,9 +1294,9 @@ static void tag_construct_level(struct tagHeader &th)
marshallLong(th, env.turns_on_level);
- for (count_x = 0; count_x < GXM; count_x++)
+ for (int count_x = 0; count_x < GXM; count_x++)
{
- for (count_y = 0; count_y < GYM; count_y++)
+ for (int count_y = 0; count_y < GYM; count_y++)
{
marshallByte(th, grd[count_x][count_y]);
marshallShort(th, env.map[count_x][count_y].object);
@@ -1299,7 +1310,7 @@ static void tag_construct_level(struct tagHeader &th)
// how many clouds?
marshallShort(th, MAX_CLOUDS);
- for (i = 0; i < MAX_CLOUDS; i++)
+ for (int i = 0; i < MAX_CLOUDS; i++)
{
marshallByte(th, env.cloud[i].x);
marshallByte(th, env.cloud[i].y);
@@ -1310,7 +1321,7 @@ static void tag_construct_level(struct tagHeader &th)
// how many shops?
marshallByte(th, 5);
- for (i = 0; i < 5; i++)
+ for (int i = 0; i < 5; i++)
{
marshallByte(th, env.shop[i].keeper_name[0]);
marshallByte(th, env.shop[i].keeper_name[1]);
@@ -1321,6 +1332,14 @@ static void tag_construct_level(struct tagHeader &th)
marshallByte(th, env.shop[i].type);
marshallByte(th, env.shop[i].level);
}
+
+ // how many markers
+ marshallShort(th, env.markers.size());
+ for (dgn_marker_map::const_iterator i = env.markers.begin();
+ i != env.markers.end(); ++i)
+ {
+ i->second->write(th);
+ }
}
static void marshall_item(tagHeader &th, const item_def &item)
@@ -1536,6 +1555,14 @@ static void tag_read_level( struct tagHeader &th, char minorVersion )
env.shop[i].type = unmarshallByte(th);
env.shop[i].level = unmarshallByte(th);
}
+
+ env.clear_markers();
+ const int nmarkers = unmarshallShort(th);
+ for (int i = 0; i < nmarkers; ++i)
+ {
+ if (map_marker *mark = map_marker::read_marker(th))
+ env.add_marker(mark);
+ }
}
static void tag_read_level_items(struct tagHeader &th, char minorVersion)
diff --git a/crawl-ref/source/tags.h b/crawl-ref/source/tags.h
index 3f98a0d216..154cdef1ad 100644
--- a/crawl-ref/source/tags.h
+++ b/crawl-ref/source/tags.h
@@ -40,6 +40,7 @@ void marshallLong(struct tagHeader &th, long data);
void marshallFloat(struct tagHeader &th, float data);
void marshallBoolean(struct tagHeader &th, bool data);
void marshallString(struct tagHeader &th, const char *data, int maxSize = 0);
+void marshallCoord(tagHeader &th, const coord_def &c);
// last updated 22jan2001 {gdl}
/* ***********************************************************************
@@ -52,6 +53,7 @@ float unmarshallFloat(struct tagHeader &th);
bool unmarshallBoolean(struct tagHeader &th);
void unmarshallString(struct tagHeader &th, char *data, int maxSize);
std::string unmarshallString(tagHeader &th, int maxSize);
+void unmarshallCoord(tagHeader &th, coord_def &c);
std::string make_date_string( time_t in_date );
time_t parse_date_string( char[20] );
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index 539fe436c8..592cf24289 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -2625,18 +2625,6 @@ void arrange_features(std::vector<coord_def> &features)
//////////////////////////////////////////////////////////////////////////
// Interlevel travel classes
-static void writeCoord(FILE *file, const coord_def &pos)
-{
- writeShort(file, pos.x);
- writeShort(file, pos.y);
-}
-
-static void readCoord(FILE *file, coord_def &pos)
-{
- pos.x = readShort(file);
- pos.y = readShort(file);
-}
-
level_id level_id::current()
{
const level_id id(you.where_are_you,
diff --git a/crawl-ref/source/util/levcomp.lpp b/crawl-ref/source/util/levcomp.lpp
index cf803cdc00..9331f32e19 100644
--- a/crawl-ref/source/util/levcomp.lpp
+++ b/crawl-ref/source/util/levcomp.lpp
@@ -177,6 +177,7 @@ TAGS: { BEGIN(KEYWORDS); return TAGS; }
SUBST: { BEGIN(ITEM_LIST); return SUBST; }
MONS: { BEGIN(MNAME); return MONS; }
ITEM: { BEGIN(ITEM_LIST); return ITEM; }
+MARKER: { BEGIN(ITEM_LIST); return MARKER; }
SHUFFLE: { BEGIN(ITEM_LIST); return SHUFFLE; }
KFEAT: { BEGIN(ARGUMENT); return KFEAT; }
diff --git a/crawl-ref/source/util/levcomp.ypp b/crawl-ref/source/util/levcomp.ypp
index 4a319c94f4..f8a49b844d 100644
--- a/crawl-ref/source/util/levcomp.ypp
+++ b/crawl-ref/source/util/levcomp.ypp
@@ -66,7 +66,7 @@ level_range set_range(const char *s, int start, int end)
%expect 2
%token <i> DEFAULT_DEPTH SHUFFLE SUBST TAGS KFEAT KITEM KMONS
-%token <i> NAME DEPTH ORIENT PLACE CHANCE MONS ITEM
+%token <i> NAME DEPTH ORIENT PLACE CHANCE MONS ITEM MARKER
%token <i> PRELUDE MAIN VALIDATE VETO
%token <i> COMMA INTEGER CHARACTER
@@ -159,9 +159,10 @@ metaline : place
| orientation
| mons
| items
+ | marker
| subst
- | tags
| shuffle
+ | tags
| kfeat
| kitem
| kmons
@@ -284,6 +285,22 @@ tagstring : STRING
}
;
+marker : MARKER marker_specs { }
+ ;
+
+marker_specs : marker_spec { }
+ | marker_specs COMMA marker_spec { }
+ ;
+
+marker_spec : ITEM_INFO
+ {
+ lc_map.main.add(
+ yylineno,
+ make_stringf("marker(\"%s\")",
+ quote_lua_string($1).c_str()));
+ }
+ ;
+
subst : SUBST subst_specifiers { }
;
@@ -304,7 +321,7 @@ items : ITEM {}
| ITEM item_specifiers {}
;
-item_specifiers : item_specifier COMMA item_specifiers
+item_specifiers : item_specifiers COMMA item_specifier
| item_specifier
;