summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorMatthew Cline <zelgadis@sourceforge.net>2009-10-25 00:23:09 -0700
committerMatthew Cline <zelgadis@sourceforge.net>2009-10-25 00:23:09 -0700
commita0ae32c8f8a04398b4b99880069eb31a26b43eff (patch)
treee619d8de305de18bb7c9fc1ead65ee33a1377f33 /crawl-ref/source
parent83d7fbfa11973abf823ed07f4c7b39956fc6aa4a (diff)
downloadcrawl-ref-a0ae32c8f8a04398b4b99880069eb31a26b43eff.tar.gz
crawl-ref-a0ae32c8f8a04398b4b99880069eb31a26b43eff.zip
Let markers change the description of any feature
Allow markers to change the short and/or long description of any feature, not just portal vault entrances. The feature_description() and feature_description_long() functions have been removed from the mapmark classes and turned into ordinary properties. Also added the marker property "door_description_suffix", which can be used to alter the short description of (known) doors by appending a string to them.
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/dat/clua/lm_pdesc.lua14
-rw-r--r--crawl-ref/source/dat/clua/lm_toll.lua4
-rw-r--r--crawl-ref/source/describe.cc31
-rw-r--r--crawl-ref/source/directn.cc31
-rw-r--r--crawl-ref/source/mapmark.cc30
-rw-r--r--crawl-ref/source/mapmark.h5
6 files changed, 44 insertions, 71 deletions
diff --git a/crawl-ref/source/dat/clua/lm_pdesc.lua b/crawl-ref/source/dat/clua/lm_pdesc.lua
index 49b6273680..e96c852336 100644
--- a/crawl-ref/source/dat/clua/lm_pdesc.lua
+++ b/crawl-ref/source/dat/clua/lm_pdesc.lua
@@ -32,15 +32,13 @@ function PortalDescriptor:unmangle(x)
end
end
-function PortalDescriptor:feature_description(marker)
- return self:unmangle(self.props.desc)
-end
-
-function PortalDescriptor:feature_description_long(marker)
- return self:unmangle(self.props.desc_long)
-end
-
function PortalDescriptor:property(marker, pname)
+ if pname == 'feature_description' then
+ return self:unmangle(self.props.desc)
+ elseif pname == 'feature_description_long' then
+ return self:unmangle(self.props.desc_long)
+ end
+
return self:unmangle(self.props and self.props[pname] or '')
end
diff --git a/crawl-ref/source/dat/clua/lm_toll.lua b/crawl-ref/source/dat/clua/lm_toll.lua
index a4cd7b913e..616ff7ed27 100644
--- a/crawl-ref/source/dat/clua/lm_toll.lua
+++ b/crawl-ref/source/dat/clua/lm_toll.lua
@@ -61,6 +61,10 @@ function TollStair:property(marker, pname)
return self:check_veto(marker, pname)
end
+ if pname == 'feature_description_long' then
+ return self:feature_description_long(marker)
+ end
+
return self.super.property(self, marker, pname)
end
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index bcce934a0c..482d467f2c 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -2008,18 +2008,6 @@ std::string get_item_description( const item_def &item, bool verbose,
return description.str();
}
-static std::string _marker_feature_description(const coord_def &pos)
-{
- std::vector<map_marker*> markers = env.markers.get_markers_at(pos);
- for (int i = 0, size = markers.size(); i < size; ++i)
- {
- const std::string desc = markers[i]->feature_description_long();
- if (!desc.empty())
- return (desc);
- }
- return ("");
-}
-
static std::string _get_feature_description_wide(int feat)
{
return std::string();
@@ -2044,14 +2032,19 @@ void get_feature_desc(const coord_def &pos, describe_info &inf)
bool custom_desc = false;
- if (feat == DNGN_ENTER_PORTAL_VAULT)
+ const std::string marker_desc =
+ env.markers.property_at(pos, MAT_ANY, "feature_description_long");
+
+ if (!marker_desc.empty())
{
- std::string _desc = _marker_feature_description(pos);
- if (!_desc.empty())
- {
- long_desc = _desc;
- custom_desc = true;
- }
+ long_desc = marker_desc;
+ custom_desc = true;
+ }
+
+ if (feat == DNGN_ENTER_PORTAL_VAULT && !custom_desc)
+ {
+ long_desc = "UNDESCRIBE PORTAL VAULT ENTRANCE.";
+ custom_desc = true;
}
const CrawlHashTable &props = env.properties;
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc
index dc49279f14..ca40ea7fdc 100644
--- a/crawl-ref/source/directn.cc
+++ b/crawl-ref/source/directn.cc
@@ -2873,18 +2873,6 @@ void setup_feature_descs_short()
base_desc_to_short[i->first] = i->second.get_string();
}
-static std::string _marker_feature_description(const coord_def &p)
-{
- std::vector<map_marker*> markers = env.markers.get_markers_at(p);
- for (int i = 0, size = markers.size(); i < size; ++i)
- {
- const std::string desc = markers[i]->feature_description();
- if (!desc.empty())
- return (desc);
- }
- return ("");
-}
-
#ifndef DEBUG_DIAGNOSTICS
// Is a feature interesting enough to 'v'iew it, even if a player normally
// doesn't care about descriptions, i.e. does the description hold important
@@ -2899,6 +2887,17 @@ std::string feature_description(const coord_def& where, bool bloody,
description_level_type dtype, bool add_stop,
bool base_desc)
{
+ std::string marker_desc =
+ env.markers.property_at(where, MAT_ANY, "feature_description");
+
+ if (!marker_desc.empty())
+ {
+ if (bloody)
+ marker_desc += ", spattered with blood";
+
+ return thing_do_grammar(dtype, add_stop, false, marker_desc);
+ }
+
dungeon_feature_type grid = grd(where);
if (grid == DNGN_SECRET_DOOR)
grid = grid_secret_door_appearance(where);
@@ -2916,6 +2915,11 @@ std::string feature_description(const coord_def& where, bool bloody,
desc += "detected secret ";
desc += noun;
+ const std::string door_desc_suffix =
+ env.markers.property_at(where, MAT_ANY,
+ "door_description_suffix");
+ desc += door_desc_suffix;
+
if (bloody)
desc += ", spattered with blood";
@@ -2946,9 +2950,10 @@ std::string feature_description(const coord_def& where, bool bloody,
return shop_name(where, add_stop);
case DNGN_ENTER_PORTAL_VAULT:
+ // Should have been handled at the top of the function.
return (thing_do_grammar(
dtype, add_stop, false,
- _marker_feature_description(where)));
+ "UNAMED PORTAL VAULT ENTRY"));
default:
return (feature_description(grid, NUM_TRAPS, bloody, dtype, add_stop,
base_desc));
diff --git a/crawl-ref/source/mapmark.cc b/crawl-ref/source/mapmark.cc
index 794cfb74d5..253855eb23 100644
--- a/crawl-ref/source/mapmark.cc
+++ b/crawl-ref/source/mapmark.cc
@@ -65,16 +65,6 @@ void map_marker::read(reader &inf)
unmarshallCoord(inf, pos);
}
-std::string map_marker::feature_description() const
-{
- return ("");
-}
-
-std::string map_marker::feature_description_long() const
-{
- return ("");
-}
-
std::string map_marker::property(const std::string &pname) const
{
return ("");
@@ -381,16 +371,6 @@ std::string map_lua_marker::debug_describe() const
return (call_str_fn("describe"));
}
-std::string map_lua_marker::feature_description() const
-{
- return (call_str_fn("feature_description"));
-}
-
-std::string map_lua_marker::feature_description_long() const
-{
- return (call_str_fn("feature_description_long"));
-}
-
std::string map_lua_marker::property(const std::string &pname) const
{
lua_stack_cleaner cln(dlua);
@@ -533,13 +513,11 @@ void map_wiz_props_marker::read(reader &inf)
}
}
-std::string map_wiz_props_marker::feature_description() const
-{
- return property("desc");
-}
-
std::string map_wiz_props_marker::property(const std::string &pname) const
{
+ if (pname == "desc")
+ return property("feature_description");
+
std::map<std::string, std::string>::const_iterator
i = properties.find(pname);
@@ -577,7 +555,7 @@ map_marker *map_wiz_props_marker::parse(
std::string map_wiz_props_marker::debug_describe() const
{
- return make_stringf("wizard props: ") + feature_description();
+ return "Wizard props: " + property("feature_description");
}
//////////////////////////////////////////////////////////////////////////
diff --git a/crawl-ref/source/mapmark.h b/crawl-ref/source/mapmark.h
index e9560b950e..71a142ce13 100644
--- a/crawl-ref/source/mapmark.h
+++ b/crawl-ref/source/mapmark.h
@@ -39,8 +39,6 @@ public:
virtual void write(writer &) const;
virtual void read(reader &);
virtual std::string debug_describe() const = 0;
- virtual std::string feature_description() const;
- virtual std::string feature_description_long() const;
virtual std::string property(const std::string &pname) const;
static map_marker *read_marker(reader &);
@@ -112,8 +110,6 @@ public:
void read(reader &);
map_marker *clone() const;
std::string debug_describe() const;
- std::string feature_description() const;
- std::string feature_description_long() const;
std::string property(const std::string &pname) const;
bool notify_dgn_event(const dgn_event &e);
@@ -143,7 +139,6 @@ public:
void write(writer &) const;
void read(reader &);
std::string debug_describe() const;
- std::string feature_description() const;
std::string property(const std::string &pname) const;
std::string set_property(const std::string &key, const std::string &val);
map_marker *clone() const;