diff options
-rw-r--r-- | crawl-ref/source/acr.cc | 22 | ||||
-rw-r--r-- | crawl-ref/source/command.cc | 1 | ||||
-rw-r--r-- | crawl-ref/source/dungeon.cc | 33 | ||||
-rw-r--r-- | crawl-ref/source/enum.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/mapmark.cc | 90 | ||||
-rw-r--r-- | crawl-ref/source/mapmark.h | 22 |
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 |