summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-09-19 04:18:53 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-09-19 04:18:53 +0000
commit63318a4b57b03ffc4686e4a3b78d64b73f50b6b9 (patch)
treead233d952c0197fdf2ec3e1707cd1cc6d31a2bff /crawl-ref/source
parent5b3a525f14d218f3a8efec572ea347c2f6c13c3d (diff)
downloadcrawl-ref-63318a4b57b03ffc4686e4a3b78d64b73f50b6b9.tar.gz
crawl-ref-63318a4b57b03ffc4686e4a3b78d64b73f50b6b9.zip
If wizard mode is on when going through a portal to a bazaar, Crawl will
ask the user for the name of a bazaar map to load (minus the "bazaar_" at the front of the name); escape or enter can be pressed to get a random map. Adds new wizard command 'P', to create portal-vault-portals to arbitrary destinations (though any desitnation but "bazaar" will currently cause an assertion when the portal is entered). Adds new map marker class map_wiz_props_marker, which can be used by wizard commands to create a map marker with abritrary properties. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2143 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/acr.cc22
-rw-r--r--crawl-ref/source/command.cc1
-rw-r--r--crawl-ref/source/dungeon.cc33
-rw-r--r--crawl-ref/source/enum.h1
-rw-r--r--crawl-ref/source/mapmark.cc90
-rw-r--r--crawl-ref/source/mapmark.h22
6 files changed, 169 insertions, 0 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 13e9a79ece..5869e7fbac 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -701,6 +701,28 @@ static void handle_wizard_command( void )
grd[you.x_pos][you.y_pos] = DNGN_ENTER_PANDEMONIUM;
break;
+ case 'P':
+ {
+ mpr( "Destination for portal? ", MSGCH_PROMPT );
+ get_input_line( specs, sizeof( specs ) );
+
+ std::string dst = specs;
+ dst = trim_string(dst);
+
+ if (dst == "")
+ canned_msg( MSG_OK );
+ else
+ {
+ grd[you.x_pos][you.y_pos] = DNGN_ENTER_PORTAL_VAULT;
+ 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);
+ }
+ break;
+ }
+
case 'l':
grd[you.x_pos][you.y_pos] = DNGN_ENTER_LABYRINTH;
break;
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc
index e10ec51b62..c450cecfe8 100644
--- a/crawl-ref/source/command.cc
+++ b/crawl-ref/source/command.cc
@@ -1163,6 +1163,7 @@ static void list_wizard_commands()
"m/M : create monster by number/name\n"
"o/% : create an object\n"
"p : make entrance to pandemonium\n"
+ "P : make a portal (i.e., bazaars)\n"
"r : change character's species\n"
"s : gain 20000 skill points\n"
"S : set skill to level\n"
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 5fc822b31d..8abb604604 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -68,6 +68,10 @@
#include "travel.h"
#include "view.h"
+#ifdef WIZARD
+#include "cio.h" // for cancelable_get_line()
+#endif
+
#define MAX_PIT_MONSTERS 10
struct pit_mons_def
@@ -1473,6 +1477,35 @@ static void fixup_bazaar_stairs()
static void bazaar_level(int level_number)
{
int vault = random_map_for_place(level_id::current(), false);
+
+#ifdef WIZARD
+ if (vault == -1 && you.wizard)
+ {
+ char buf[80];
+
+ do
+ {
+ mprf(MSGCH_PROMPT, "Which bazaar (ESC or ENTER for random): ");
+ if (cancelable_get_line(buf, sizeof buf))
+ break;
+
+ std::string name = buf;
+ trim_string(name);
+
+ if (name.empty())
+ break;
+
+ lowercase(name);
+ name = replace_all(name, " ", "_");
+
+ vault = find_map_by_name("bazaar_" + name);
+
+ if (vault == -1)
+ mprf(MSGCH_DIAGNOSTICS, "No such bazaar, try again.");
+ } while (vault == -1);
+ }
+#endif
+
if (vault == -1)
vault = random_map_for_tag("bazaar", false);
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index dbdef1f880..7190d429cf 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -1323,6 +1323,7 @@ enum map_marker_type
MAT_FEATURE, // Stock marker.
MAT_LUA_MARKER,
MAT_CORRUPTION_NEXUS,
+ MAT_WIZ_PROPS,
NUM_MAP_MARKER_TYPES,
MAT_ANY
};
diff --git a/crawl-ref/source/mapmark.cc b/crawl-ref/source/mapmark.cc
index a761568772..fbcbbf6d73 100644
--- a/crawl-ref/source/mapmark.cc
+++ b/crawl-ref/source/mapmark.cc
@@ -25,6 +25,7 @@ map_marker::marker_reader map_marker::readers[NUM_MAP_MARKER_TYPES] =
&map_feature_marker::read,
&map_lua_marker::read,
&map_corruption_marker::read,
+ &map_wiz_props_marker::read,
};
map_marker::marker_parser map_marker::parsers[NUM_MAP_MARKER_TYPES] =
@@ -32,6 +33,7 @@ map_marker::marker_parser map_marker::parsers[NUM_MAP_MARKER_TYPES] =
&map_feature_marker::parse,
&map_lua_marker::parse,
NULL,
+ NULL
};
map_marker::map_marker(map_marker_type t, const coord_def &p)
@@ -423,6 +425,94 @@ std::string map_corruption_marker::debug_describe() const
return make_stringf("Lugonu corrupt (%d)", duration);
}
+////////////////////////////////////////////////////////////////////////////
+// map_feature_marker
+
+map_wiz_props_marker::map_wiz_props_marker(
+ const coord_def &p)
+ : map_marker(MAT_WIZ_PROPS, p)
+{
+}
+
+map_wiz_props_marker::map_wiz_props_marker(
+ const map_wiz_props_marker &other)
+ : map_marker(MAT_WIZ_PROPS, other.pos), properties(other.properties)
+{
+}
+
+void map_wiz_props_marker::write(tagHeader &outf) const
+{
+ this->map_marker::write(outf);
+ marshallShort(outf, properties.size());
+ for (std::map<std::string, std::string>::const_iterator i =
+ properties.begin(); i != properties.end(); ++i)
+ {
+ marshallString(outf, i->first);
+ marshallString(outf, i->second);
+ }
+}
+
+void map_wiz_props_marker::read(tagHeader &inf)
+{
+ map_marker::read(inf);
+
+ short numPairs = unmarshallShort(inf);
+ for (short i = 0; i < numPairs; i++)
+ {
+ const std::string key = unmarshallString(inf);
+ const std::string val = unmarshallString(inf);
+
+ set_property(key, val);
+ }
+}
+
+std::string map_wiz_props_marker::feature_description() const
+{
+ return property("desc");
+}
+
+std::string map_wiz_props_marker::property(const std::string &pname) const
+{
+ std::map<std::string, std::string>::const_iterator
+ i = properties.find(pname);
+
+ if (i != properties.end())
+ return (i->second);
+ else
+ return ("");
+}
+
+std::string map_wiz_props_marker::set_property(const std::string &key,
+ const std::string &val)
+{
+ std::string old_val = properties[key];
+ properties[key] = val;
+ return (old_val);
+}
+
+map_marker *map_wiz_props_marker::clone() const
+{
+ return new map_wiz_props_marker(*this);
+}
+
+map_marker *map_wiz_props_marker::read(tagHeader &inf, map_marker_type)
+{
+ map_marker *mapf = new map_wiz_props_marker();
+ mapf->read(inf);
+ return (mapf);
+}
+
+map_marker *map_wiz_props_marker::parse(
+ const std::string &s, const std::string &) throw (std::string)
+{
+ throw make_stringf("map_wiz_props_marker::parse() not implemented");
+}
+
+std::string map_wiz_props_marker::debug_describe() const
+{
+ return make_stringf("wizard props: ") + feature_description();
+}
+
//////////////////////////////////////////////////////////////////////////
// Map markers in env.
diff --git a/crawl-ref/source/mapmark.h b/crawl-ref/source/mapmark.h
index 81c1e1d060..f277295db7 100644
--- a/crawl-ref/source/mapmark.h
+++ b/crawl-ref/source/mapmark.h
@@ -5,6 +5,8 @@
#include "dgnevent.h"
#include "clua.h"
#include "luadgn.h"
+#include <map>
+#include <string>
//////////////////////////////////////////////////////////////////////////
// Map markers
@@ -112,4 +114,24 @@ private:
std::string call_str_fn(const char *fn) const;
};
+class map_wiz_props_marker : public map_marker
+{
+public:
+ map_wiz_props_marker(const coord_def &pos = coord_def(0, 0));
+ map_wiz_props_marker(const map_wiz_props_marker &other);
+ void write(tagHeader &) const;
+ void read(tagHeader &);
+ 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;
+ static map_marker *read(tagHeader &, map_marker_type);
+ static map_marker *parse(const std::string &s, const std::string &)
+ throw (std::string);
+
+public:
+ std::map<std::string, std::string> properties;
+};
+
#endif