diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-09-19 04:18:53 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-09-19 04:18:53 +0000 |
commit | 63318a4b57b03ffc4686e4a3b78d64b73f50b6b9 (patch) | |
tree | ad233d952c0197fdf2ec3e1707cd1cc6d31a2bff /crawl-ref/source/mapmark.cc | |
parent | 5b3a525f14d218f3a8efec572ea347c2f6c13c3d (diff) | |
download | crawl-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/mapmark.cc')
-rw-r--r-- | crawl-ref/source/mapmark.cc | 90 |
1 files changed, 90 insertions, 0 deletions
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. |