summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/dat/icecave.des20
-rw-r--r--crawl-ref/source/describe.cc69
-rw-r--r--crawl-ref/source/describe.h7
-rw-r--r--crawl-ref/source/directn.cc85
-rw-r--r--crawl-ref/source/directn.h14
-rw-r--r--crawl-ref/source/files.cc1
-rw-r--r--crawl-ref/source/luadgn.cc35
-rw-r--r--crawl-ref/source/store.cc2
8 files changed, 215 insertions, 18 deletions
diff --git a/crawl-ref/source/dat/icecave.des b/crawl-ref/source/dat/icecave.des
index 6be16e91bf..533f348e1b 100644
--- a/crawl-ref/source/dat/icecave.des
+++ b/crawl-ref/source/dat/icecave.des
@@ -46,6 +46,26 @@ function ice_cave_portal(e)
end
}}
+{{
+-- Alter short feature descriptions for all ice cave destination vaults.
+function ice_cave_feat_descs()
+ dgn.set_feature_desc_short("rock wall", "ice covered $BASE")
+ dgn.set_feature_desc_short("gate leading back to the Dungeon",
+ "ice covered $BASE")
+ dgn.set_feature_desc_short("empty arch of ancient stone",
+ "ice choked $BASE")
+ dgn.set_feature_desc_short("Some shallow water",
+ "Some ice crusted shallow water")
+ dgn.set_feature_desc_short("Some deep water",
+ "Some ice crusted deep water")
+
+ dgn.set_feature_desc_long("Some deep water",
+ "It looks freezing!");
+end
+
+dgn.set_lt_callback("ice_cave", "ice_cave_feat_descs")
+}}
+
# For destination (not entry) vaults, use the following line after all
# substitutions have been performed:
# : ice_cave_colours(_G)
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index 477f9bddbe..3d7e0720fd 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -50,6 +50,8 @@
#include "tutorial.h"
#include "xom.h"
+#define LONG_DESC_KEY "long_desc_key"
+
// ========================================================================
// Internal Functions
// ========================================================================
@@ -1995,17 +1997,52 @@ static std::string _get_feature_description_wide(int feat)
void describe_feature_wide(int x, int y)
{
- std::string desc = feature_description(coord_def(x, y));
- desc += "$$";
+ const coord_def pos(x, y);
+ const dungeon_feature_type feat = grd(pos);
- // Get rid of trailing .$$ before lookup
+ std::string desc = feature_description(pos, false, DESC_CAP_A, false);
std::string db_name =
- grd[x][y] == DNGN_ENTER_SHOP ? "A shop"
- : desc.substr(0, desc.length() - 3);
+ grd[x][y] == DNGN_ENTER_SHOP ? "A shop" : desc;
+ std::string long_desc = getLongDescription(db_name);
+
+ desc += ".$$";
+
+ // If we couldn't find a description in the database then see if
+ // the feature's base name is different.
+ if (long_desc.empty())
+ {
+ db_name = feature_description(pos, false, DESC_CAP_A, false, true);
+ long_desc = getLongDescription(db_name);
+ }
+
+ bool custom_desc = false;
+
+ const CrawlHashTable &props = env.properties;
+ if (props.exists(LONG_DESC_KEY))
+ {
+ const CrawlHashTable &desc_table = props[LONG_DESC_KEY].get_table();
+
+ // First try the modified name, then the base name.
+ std::string key = raw_feature_description(feat);
+ if (!desc_table.exists(key))
+ key = raw_feature_description(feat, NUM_TRAPS, true);
+
+ if (desc_table.exists(key))
+ {
+ long_desc = desc_table[key].get_string();
+ custom_desc = true;
+ }
+
+ std::string quote = getQuoteString(key);
+ if (!quote.empty())
+ db_name = key;
+ }
+
+ desc += long_desc;
- desc += getLongDescription(db_name);
// For things which require logic
- desc += _get_feature_description_wide(grd[x][y]);
+ if (!custom_desc)
+ desc += _get_feature_description_wide(grd[x][y]);
std::string quote = getQuoteString(db_name);
@@ -2020,6 +2057,24 @@ void describe_feature_wide(int x, int y)
getch();
}
+void set_feature_desc_long(const std::string &raw_name,
+ const std::string &desc)
+{
+ ASSERT(!raw_name.empty());
+
+ CrawlHashTable &props = env.properties;
+
+ if (!props.exists(LONG_DESC_KEY))
+ props[LONG_DESC_KEY].new_table(SV_STR);
+
+ CrawlHashTable &desc_table = props[LONG_DESC_KEY];
+
+ if (desc.empty())
+ desc_table.erase(raw_name);
+ else
+ desc_table[raw_name] = desc;
+}
+
// Returns true if spells can be shown to player.
static bool _show_item_description(const item_def &item)
{
diff --git a/crawl-ref/source/describe.h b/crawl-ref/source/describe.h
index 969c615472..1b938b6740 100644
--- a/crawl-ref/source/describe.h
+++ b/crawl-ref/source/describe.h
@@ -52,6 +52,13 @@ void describe_god( god_type which_god, bool give_title );
* *********************************************************************** */
void describe_feature_wide(int x, int y);
+// last updated 24 Dec 2008 {mpc}
+/* ***********************************************************************
+ * called from: luadgn
+ * *********************************************************************** */
+void set_feature_desc_long(const std::string &raw_name,
+ const std::string &desc);
+
/* ***********************************************************************
* called from: item_use - shopping
* *********************************************************************** */
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc
index 45c079f662..3750b72eb4 100644
--- a/crawl-ref/source/directn.cc
+++ b/crawl-ref/source/directn.cc
@@ -57,6 +57,12 @@
#include "macro.h"
+#define SHORT_DESC_KEY "short_desc_key"
+
+typedef std::map<std::string, std::string> desc_map;
+
+static desc_map base_desc_to_short;
+
enum LOSSelect
{
LOS_ANY = 0x00,
@@ -2314,17 +2320,17 @@ std::string thing_do_grammar(description_level_type dtype,
std::string feature_description(dungeon_feature_type grid,
trap_type trap, bool bloody,
description_level_type dtype,
- bool add_stop)
+ bool add_stop, bool base_desc)
{
- std::string desc = raw_feature_description(grid, trap);
+ std::string desc = raw_feature_description(grid, trap, base_desc);
if (bloody)
desc += ", spattered with blood";
return thing_do_grammar(dtype, add_stop, grid_is_trap(grid), desc);
}
-std::string raw_feature_description(dungeon_feature_type grid,
- trap_type trap)
+static std::string _base_feature_desc(dungeon_feature_type grid,
+ trap_type trap)
{
if (grid_is_trap(grid) && trap != NUM_TRAPS)
{
@@ -2551,6 +2557,69 @@ std::string raw_feature_description(dungeon_feature_type grid,
}
}
+std::string raw_feature_description(dungeon_feature_type grid,
+ trap_type trap, bool base_desc)
+{
+ std::string base_str = _base_feature_desc(grid, trap);
+
+ if (base_desc)
+ return (base_str);
+
+ desc_map::iterator i = base_desc_to_short.find(base_str);
+
+ if (i != base_desc_to_short.end())
+ return (i->second);
+
+ return (base_str);
+}
+
+void set_feature_desc_short(dungeon_feature_type grid,
+ const std::string &desc)
+{
+ set_feature_desc_short(_base_feature_desc(grid, NUM_TRAPS), desc);
+}
+
+void set_feature_desc_short(const std::string &base_name,
+ const std::string &_desc)
+{
+ ASSERT(!base_name.empty());
+
+ CrawlHashTable &props = env.properties;
+
+ if (!props.exists(SHORT_DESC_KEY))
+ props[SHORT_DESC_KEY].new_table(SV_STR);
+
+ CrawlHashTable &desc_table = props[SHORT_DESC_KEY];
+
+ if (_desc.empty())
+ {
+ base_desc_to_short.erase(base_name);
+ desc_table.erase(base_name);
+ }
+ else
+ {
+ std::string desc = replace_all(_desc, "$BASE", base_name);
+ base_desc_to_short[base_name] = desc;
+ desc_table[base_name] = desc;
+ }
+}
+
+void setup_feature_descs_short()
+{
+ base_desc_to_short.clear();
+
+ const CrawlHashTable &props = env.properties;
+
+ if (!props.exists(SHORT_DESC_KEY))
+ return;
+
+ const CrawlHashTable &desc_table = props[SHORT_DESC_KEY].get_table();
+
+ CrawlHashTable::const_iterator i;
+ for (i = desc_table.begin(); i != desc_table.end(); ++i)
+ 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);
@@ -2574,7 +2643,8 @@ static bool _interesting_feature(dungeon_feature_type feat)
#endif
std::string feature_description(const coord_def& where, bool bloody,
- description_level_type dtype, bool add_stop)
+ description_level_type dtype, bool add_stop,
+ bool base_desc)
{
dungeon_feature_type grid = grd(where);
if (grid == DNGN_SECRET_DOOR)
@@ -2603,7 +2673,7 @@ std::string feature_description(const coord_def& where, bool bloody,
case DNGN_TRAP_MAGICAL:
case DNGN_TRAP_NATURAL:
return (feature_description(grid, get_trap_type(where), bloody,
- dtype, add_stop));
+ dtype, add_stop, base_desc));
case DNGN_ABANDONED_SHOP:
return thing_do_grammar(dtype, add_stop, false, "An abandoned shop");
@@ -2615,7 +2685,8 @@ std::string feature_description(const coord_def& where, bool bloody,
dtype, add_stop, false,
_marker_feature_description(where)));
default:
- return (feature_description(grid, NUM_TRAPS, bloody, dtype, add_stop));
+ return (feature_description(grid, NUM_TRAPS, bloody, dtype, add_stop,
+ base_desc));
}
}
diff --git a/crawl-ref/source/directn.h b/crawl-ref/source/directn.h
index 4b0b5ae841..3d95e9f8d7 100644
--- a/crawl-ref/source/directn.h
+++ b/crawl-ref/source/directn.h
@@ -171,13 +171,21 @@ int dos_direction_unmunge(int doskey);
std::string feature_description(const coord_def& where, bool bloody = false,
description_level_type dtype = DESC_CAP_A,
- bool add_stop = true);
+ bool add_stop = true, bool base_desc = false);
std::string raw_feature_description(dungeon_feature_type grid,
- trap_type tr = NUM_TRAPS);
+ trap_type tr = NUM_TRAPS,
+ bool base_desc = false);
std::string feature_description(dungeon_feature_type grid,
trap_type trap = NUM_TRAPS, bool bloody = false,
description_level_type dtype = DESC_CAP_A,
- bool add_stop = true);
+ bool add_stop = true, bool base_desc = false);
+
+void set_feature_desc_short(dungeon_feature_type grid,
+ const std::string &desc);
+void set_feature_desc_short(const std::string &base_name,
+ const std::string &desc);
+
+void setup_feature_descs_short();
std::vector<dungeon_feature_type> features_by_desc(const base_pattern &pattern);
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index b0b894c16b..24a9299791 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -1306,6 +1306,7 @@ bool load( dungeon_feature_type stair_taken, load_mode_type load_mode,
setup_environment_effects();
setup_vault_mon_list();
+ setup_feature_descs_short();
// Inform user of level's annotation.
if (load_mode != LOAD_VISITOR
diff --git a/crawl-ref/source/luadgn.cc b/crawl-ref/source/luadgn.cc
index 88c0be8bef..66ef2b23f9 100644
--- a/crawl-ref/source/luadgn.cc
+++ b/crawl-ref/source/luadgn.cc
@@ -17,6 +17,7 @@
#include "chardump.h"
#include "clua.h"
#include "cloud.h"
+#include "describe.h"
#include "directn.h"
#include "dungeon.h"
#include "files.h"
@@ -1582,6 +1583,38 @@ static int dgn_feature_desc_at(lua_State *ls)
return (1);
}
+static int dgn_set_feature_desc_short(lua_State *ls)
+{
+ const std::string base_name = luaL_checkstring(ls, 1);
+ const std::string desc = luaL_checkstring(ls, 2);
+
+ if (base_name.empty())
+ {
+ luaL_argerror(ls, 1, "Base name can't be empty");
+ return (0);
+ }
+
+ set_feature_desc_short(base_name, desc);
+
+ return (0);
+}
+
+static int dgn_set_feature_desc_long(lua_State *ls)
+{
+ const std::string raw_name = luaL_checkstring(ls, 1);
+ const std::string desc = luaL_checkstring(ls, 2);
+
+ if (raw_name.empty())
+ {
+ luaL_argerror(ls, 1, "Raw name can't be empty");
+ return (0);
+ }
+
+ set_feature_desc_long(raw_name, desc);
+
+ return (0);
+}
+
static int dgn_terrain_changed(lua_State *ls)
{
dungeon_feature_type type = DNGN_UNSEEN;
@@ -2939,6 +2972,8 @@ static const struct luaL_reg dgn_lib[] =
{ "num_matching_markers", dgn_num_matching_markers },
{ "feature_desc", dgn_feature_desc },
{ "feature_desc_at", dgn_feature_desc_at },
+ { "set_feature_desc_short", dgn_set_feature_desc_short },
+ { "set_feature_desc_long", dgn_set_feature_desc_long },
{ "item_from_index", dgn_item_from_index },
{ "mons_from_index", dgn_mons_from_index },
{ "mons_at", dgn_mons_at },
diff --git a/crawl-ref/source/store.cc b/crawl-ref/source/store.cc
index 44cd6483df..f952398b51 100644
--- a/crawl-ref/source/store.cc
+++ b/crawl-ref/source/store.cc
@@ -610,7 +610,7 @@ CrawlVector &CrawlStoreValue::new_vector(store_val_type _type,
#define GET_VAL_PTR(x, _type, value) \
ASSERT((flags & SFLAG_UNSET) || !(flags & SFLAG_CONST_VAL)); \
- if (type != (x)) \
+ if (type != (x) || (flags & SFLAG_UNSET)) \
{ \
if (type == SV_NONE) \
{ \