summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-24 09:36:00 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-24 09:36:00 +0000
commitd2cdd021c717fcc16134b3943543b01d710181f1 (patch)
treef61a275d8b7dc20d2e9b462c36282a6ef597d544 /crawl-ref
parent7e0d56433b95ea95b2cc06dfbc98d7887a50b968 (diff)
downloadcrawl-ref-d2cdd021c717fcc16134b3943543b01d710181f1.tar.gz
crawl-ref-d2cdd021c717fcc16134b3943543b01d710181f1.zip
Portal vault entries now show up on the overmap. Breaks savefile
compatabilty. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7583 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/docs/level_design.txt5
-rw-r--r--crawl-ref/source/acr.cc2
-rw-r--r--crawl-ref/source/dat/sewer.des1
-rw-r--r--crawl-ref/source/overmap.cc174
-rw-r--r--crawl-ref/source/tags.cc12
-rw-r--r--crawl-ref/source/tags.h2
6 files changed, 163 insertions, 33 deletions
diff --git a/crawl-ref/docs/level_design.txt b/crawl-ref/docs/level_design.txt
index 22ef69203a..14e4f7c25c 100644
--- a/crawl-ref/docs/level_design.txt
+++ b/crawl-ref/docs/level_design.txt
@@ -1316,6 +1316,11 @@ dump to be different than the default you can give one_way_stair a
You can dynamically change the origin string using the lua function
dgn.set_level_type_origin().
+Known portal vault entries will be displayed on the overmap. By default
+the name shown on the overmap will be the "dstname" parameter, or if
+that isn't present the "dst" paremeter. It can be set to something else
+with the "dstovermap" parameter.
+
This will produce a portal, but attempting to use it will trigger an
ASSERT since there's no map for the destination. So we create a
destination map like so:
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index c835f3e781..b5f17de3f9 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -780,11 +780,11 @@ static void _do_wizard_command(int wiz_command, bool silent_fail)
break;
}
- dungeon_terrain_changed(you.pos(), DNGN_ENTER_PORTAL_VAULT, false);
map_wiz_props_marker *marker = new map_wiz_props_marker(you.pos());
marker->set_property("dst", dst);
marker->set_property("desc", "wizard portal, dest = " + dst);
env.markers.add(marker);
+ dungeon_terrain_changed(you.pos(), DNGN_ENTER_PORTAL_VAULT, false);
break;
}
diff --git a/crawl-ref/source/dat/sewer.des b/crawl-ref/source/dat/sewer.des
index 82a5c0f4ae..f68e93ec8b 100644
--- a/crawl-ref/source/dat/sewer.des
+++ b/crawl-ref/source/dat/sewer.des
@@ -17,6 +17,7 @@
function sewer_portal(e)
e.marker([[O = lua:one_way_stair { desc = "A glowing drain",
dst = "sewer",
+ dstovermap = "glowing drain",
dstorigin = "in the sewers",
floor = "stone_arch" }]])
e.kfeat("O = enter_portal_vault")
diff --git a/crawl-ref/source/overmap.cc b/crawl-ref/source/overmap.cc
index 067b160a95..b945877a0e 100644
--- a/crawl-ref/source/overmap.cc
+++ b/crawl-ref/source/overmap.cc
@@ -25,6 +25,7 @@
#include "directn.h"
#include "dungeon.h"
#include "files.h"
+#include "initfile.h"
#include "menu.h"
#include "misc.h"
#include "religion.h"
@@ -38,12 +39,19 @@ typedef std::map<branch_type, level_id> stair_map_type;
typedef std::map<level_pos, shop_type> shop_map_type;
typedef std::map<level_pos, god_type> altar_map_type;
typedef std::map<level_pos, portal_type> portal_map_type;
+typedef std::map<level_pos, std::string> portal_vault_map_type;
+// NOTE: The value for colours here is char rather than unsigned char
+// because g++ needs it to be char for marshallMap in tags.cc to
+// compile properly.
+typedef std::map<level_pos, char> portal_vault_colour_map_type;
typedef std::map<level_id, std::string> annotation_map_type;
stair_map_type stair_level;
shop_map_type shops_present;
altar_map_type altars_present;
portal_map_type portals_present;
+portal_vault_map_type portal_vaults_present;
+portal_vault_colour_map_type portal_vault_colours;
annotation_map_type level_annotations;
static void seen_altar( god_type god, const coord_def& pos );
@@ -176,6 +184,106 @@ bool overmap_knows_portal(dungeon_feature_type portal)
return (false);
}
+static std::string _portals_description_string()
+{
+ std::string disp;
+ level_id last_id;
+ for (int cur_portal = PORTAL_NONE; cur_portal < NUM_PORTALS; ++cur_portal)
+ {
+ last_id.depth = 10000;
+ portal_map_type::const_iterator ci_portals;
+ for ( ci_portals = portals_present.begin();
+ ci_portals != portals_present.end();
+ ++ci_portals )
+ {
+ // one line per region should be enough, they're all of
+ // the form D:XX, except for labyrinth portals, of which
+ // you would need 11 (at least) to have a problem.
+ if ( ci_portals->second == cur_portal )
+ {
+ if ( last_id.depth == 10000 )
+ disp += portaltype_to_string(ci_portals->second);
+
+ if ( ci_portals->first.id == last_id )
+ disp += '*';
+ else
+ {
+ disp += ' ';
+ disp += ci_portals->first.id.describe(false, true);
+ }
+ last_id = ci_portals->first.id;
+ }
+ }
+ if ( last_id.depth != 10000 )
+ disp += "\n";
+ }
+ return disp;
+}
+
+static std::string _portal_vaults_description_string()
+{
+ // Collect all the different portal vault entrance names and then
+ // display them in alphabetical order.
+ std::set<std::string> vault_names_set;
+ std::vector<std::string> vault_names_vec;
+
+ portal_vault_map_type::const_iterator ci_portals;
+ for ( ci_portals = portal_vaults_present.begin();
+ ci_portals != portal_vaults_present.end();
+ ++ci_portals )
+ {
+ vault_names_set.insert(ci_portals->second);
+ }
+
+ for (std::set<std::string>::iterator i = vault_names_set.begin();
+ i != vault_names_set.end(); ++i)
+ {
+ vault_names_vec.push_back(*i);
+ }
+ std::sort(vault_names_vec.begin(), vault_names_vec.end() );
+
+ std::string disp;
+ level_id last_id;
+ for (unsigned int i = 0; i < vault_names_vec.size(); i++)
+ {
+ last_id.depth = 10000;
+ for ( ci_portals = portal_vaults_present.begin();
+ ci_portals != portal_vaults_present.end();
+ ++ci_portals )
+ {
+ // one line per region should be enough, they're all of
+ // the form D:XX, except for labyrinth portals, of which
+ // you would need 11 (at least) to have a problem.
+ if ( ci_portals->second == vault_names_vec[i] )
+ {
+ if ( last_id.depth == 10000 )
+ {
+ unsigned char col =
+ (unsigned char) portal_vault_colours[ci_portals->first];
+ disp += '<';
+ disp += colour_to_str(col) + '>';
+ disp += vault_names_vec[i];
+ disp += "</";
+ disp += colour_to_str(col) + '>';
+ disp += ':';
+ }
+
+ if ( ci_portals->first.id == last_id )
+ disp += '*';
+ else
+ {
+ disp += ' ';
+ disp += ci_portals->first.id.describe(false, true);
+ }
+ last_id = ci_portals->first.id;
+ }
+ }
+ if ( last_id.depth != 10000 )
+ disp += "\n";
+ }
+ return disp;
+}
+
std::string overview_description_string()
{
char buffer[100];
@@ -323,40 +431,13 @@ std::string overview_description_string()
disp += "\n";
// print portals
- if ( !portals_present.empty() )
+ if ( !portals_present.empty() || !portal_vaults_present.empty() )
{
disp += "\n<green>Portals:</green>\n";
seen_anything = true;
}
- for (int cur_portal = PORTAL_NONE; cur_portal < NUM_PORTALS; ++cur_portal)
- {
- last_id.depth = 10000;
- std::map<level_pos, portal_type>::const_iterator ci_portals;
- for ( ci_portals = portals_present.begin();
- ci_portals != portals_present.end();
- ++ci_portals )
- {
- // one line per region should be enough, they're all of
- // the form D:XX, except for labyrinth portals, of which
- // you would need 11 (at least) to have a problem.
- if ( ci_portals->second == cur_portal )
- {
- if ( last_id.depth == 10000 )
- disp += portaltype_to_string(ci_portals->second);
-
- if ( ci_portals->first.id == last_id )
- disp += '*';
- else
- {
- disp += ' ';
- disp += ci_portals->first.id.describe(false, true);
- }
- last_id = ci_portals->first.id;
- }
- }
- if ( last_id.depth != 10000 )
- disp += "\n";
- }
+ disp += _portals_description_string();
+ disp += _portal_vaults_description_string();
if (!seen_anything)
{
@@ -440,6 +521,12 @@ static bool unnotice_portal(const level_pos &pos)
return find_erase(portals_present, pos);
}
+static bool unnotice_portal_vault(const level_pos &pos)
+{
+ (void) find_erase(portal_vault_colours, pos);
+ return find_erase(portal_vaults_present, pos);
+}
+
static bool unnotice_altar(const level_pos &pos)
{
return find_erase(altars_present, pos);
@@ -470,6 +557,7 @@ static bool unnotice_stair(const level_pos &pos)
bool unnotice_feature(const level_pos &pos)
{
return (unnotice_portal(pos)
+ || unnotice_portal_vault(pos)
|| unnotice_altar(pos)
|| unnotice_shop(pos)
|| unnotice_stair(pos));
@@ -555,6 +643,32 @@ void seen_other_thing( dungeon_feature_type which_thing, const coord_def& pos )
shops_present[where] =
static_cast<shop_type>(get_shop(pos)->type);
break;
+
+ case DNGN_ENTER_PORTAL_VAULT:
+ {
+ std::string portal_name;
+
+ portal_name = env.markers.property_at(pos, MAT_ANY, "dstovermap");
+ if (portal_name.empty())
+ portal_name = env.markers.property_at(pos, MAT_ANY, "dstname");
+ if (portal_name.empty())
+ portal_name = env.markers.property_at(pos, MAT_ANY, "dst");
+ if (portal_name.empty())
+ portal_name = "buggy vault portal";
+
+ portal_name = replace_all(portal_name, "_", " ");
+ portal_vaults_present[where] = uppercase_first(portal_name);
+
+ unsigned char col;
+ if (env.grid_colours(pos) != BLACK)
+ col = env.grid_colours(pos);
+ else
+ col = get_feature_def(which_thing).colour;
+ portal_vault_colours[where] = (char) element_colour(col, true);
+
+ break;
+ }
+
default:
const portal_type portal = feature_to_portal(which_thing);
if ( portal != PORTAL_NONE )
diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc
index 34f510109b..3e6c484140 100644
--- a/crawl-ref/source/tags.cc
+++ b/crawl-ref/source/tags.cc
@@ -91,6 +91,8 @@ extern std::map<branch_type, level_id> stair_level;
extern std::map<level_pos, shop_type> shops_present;
extern std::map<level_pos, god_type> altars_present;
extern std::map<level_pos, portal_type> portals_present;
+extern std::map<level_pos, std::string> portal_vaults_present;
+extern std::map<level_pos, char> portal_vault_colours;
extern std::map<level_id, std::string> level_annotations;
// temp file pairs used for file level cleanup
@@ -213,7 +215,7 @@ int read2(FILE * file, void *buffer, unsigned int count)
return fread(buffer, 1, count, file);
}
-void marshallByte(writer &th, char data)
+void marshallByte(writer &th, const char& data)
{
th.writeByte(data);
}
@@ -1122,6 +1124,10 @@ static void tag_construct_you_dungeon(writer &th)
marshall_level_pos, marshall_as_long<god_type>);
marshallMap(th, portals_present,
marshall_level_pos, marshall_as_long<portal_type>);
+ marshallMap(th, portal_vaults_present,
+ marshall_level_pos, marshallStringNoMax);
+ marshallMap(th, portal_vault_colours,
+ marshall_level_pos, marshallByte);
marshallMap(th, level_annotations,
marshall_level_id, marshallStringNoMax);
@@ -1575,6 +1581,10 @@ static void tag_read_you_dungeon(reader &th)
unmarshall_level_pos, unmarshall_long_as<god_type>);
unmarshallMap(th, portals_present,
unmarshall_level_pos, unmarshall_long_as<portal_type>);
+ unmarshallMap(th, portal_vaults_present,
+ unmarshall_level_pos, unmarshallStringNoMax);
+ unmarshallMap(th, portal_vault_colours,
+ unmarshall_level_pos, unmarshallByte);
unmarshallMap(th, level_annotations,
unmarshall_level_id, unmarshallStringNoMax);
diff --git a/crawl-ref/source/tags.h b/crawl-ref/source/tags.h
index 0f9df30f9c..22e8489a9f 100644
--- a/crawl-ref/source/tags.h
+++ b/crawl-ref/source/tags.h
@@ -82,7 +82,7 @@ private:
std::vector<unsigned char>* _pbuf;
};
-void marshallByte (writer &, char );
+void marshallByte (writer &, const char& );
void marshallShort (writer &, int16_t );
void marshallLong (writer &, int32_t );
void marshallFloat (writer &, float );