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
EJ4GIPFSSQCQASUMRF4CR2WPUQOTEHFRGLOYEZ7BH6YEMIR6DN4QC
L4RYVF46EQKMVOEADGRG4WMPVTQ6NNFGYMU4SHAH6XJIKWVHT77QC
7Y5HSDFKA5TPLS2TWTRFMQVX6UXUDHXU5MUMXQSDFAIY4THQ3BIQC
GQL5SIGBHLU3FMCE54XVGLRY5AZHRM6DUEB722REA2DPLGJSN6EQC
TLO257LZSB6ZO36STDUEWJBO2LETXFKTFGXELA6Y4BZBVAEIIINAC
UZ6N6HOUPGVSPC5NQROEEDWMEGJA5XUWUY2AKH5QG65AZ25PVXDAC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
DBGS3HXMW24VO5GBITT3UI2ZNIISUXUHAEAYUI52QPUT7IO46ITQC
};
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;
}
////////////////////////////////////////////////////////////////////////////
// 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");
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();
}
#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
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);
}