From caad029e611bb2eeedcab049d624a9e2be4e0dd5 Mon Sep 17 00:00:00 2001 From: Vsevolod Kozlov Date: Sun, 27 Dec 2009 18:21:20 +0300 Subject: Unify wizard_create_feature_{name,number}. It works fine, but it does not show the verbose message about placing the feature, as wizard_create_feature_name used to. (This doesn't seem very necessary since debug-mode 'x' tends to give enough information.) --- crawl-ref/source/wiz-dgn.cc | 91 ++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 55 deletions(-) (limited to 'crawl-ref/source/wiz-dgn.cc') diff --git a/crawl-ref/source/wiz-dgn.cc b/crawl-ref/source/wiz-dgn.cc index ea55dc9e56..8251e6c76e 100644 --- a/crawl-ref/source/wiz-dgn.cc +++ b/crawl-ref/source/wiz-dgn.cc @@ -269,70 +269,53 @@ void wizard_create_portal() } } -void wizard_create_feature_number() +void wizard_create_feature() { char specs[256]; int feat_num; - mpr("Create which feature (by number)? ", MSGCH_PROMPT); + dungeon_feature_type feat; + mpr("Create which feature? ", MSGCH_PROMPT); - if (!cancelable_get_line(specs, sizeof(specs)) - && (feat_num = atoi(specs))) + if (!cancelable_get_line(specs, sizeof(specs)) && specs[0] != 0) { - dungeon_feature_type feat = static_cast(feat_num); - if (feat == DNGN_ENTER_SHOP) + if ((feat_num = atoi(specs))) { - debug_make_shop(); - return; + feat = static_cast(feat_num); } - - dungeon_terrain_changed(you.pos(), feat, false); -#ifdef USE_TILE - env.tile_flv(you.pos()).special = 0; -#endif - } - else - canned_msg(MSG_OK); -} - -void wizard_create_feature_name() -{ - char specs[256]; - mpr("Create which feature (by name)? ", MSGCH_PROMPT); - if (!cancelable_get_line(specs, sizeof(specs)) && specs[0] != 0) - { - // Accept both "shallow_water" and "Shallow water" - std::string name = lowercase_string(specs); - name = replace_all(name, " ", "_"); - - dungeon_feature_type feat = dungeon_feature_by_name(name); - if (feat == DNGN_UNSEEN) // no exact match + else { - std::vector matches = dungeon_feature_matches(name); - - if (matches.empty()) + std::string name = lowercase_string(specs); + name = replace_all(name, " ", "_"); + feat = dungeon_feature_by_name(name); + if (feat == DNGN_UNSEEN) // no exact match { - mprf(MSGCH_DIAGNOSTICS, "No features matching '%s'", - name.c_str()); - return; - } + std::vector matches = dungeon_feature_matches(name); - // Only one possible match, use that. - if (matches.size() == 1) - { - name = matches[0]; - feat = dungeon_feature_by_name(name); - } - // Multiple matches, list them to wizard - else - { - std::string prefix = "No exact match for feature '" + - name + "', possible matches are: "; + if (matches.empty()) + { + mprf(MSGCH_DIAGNOSTICS, "No features matching '%s'", + name.c_str()); + return; + } - // Use mpr_comma_separated_list() because the list - // might be *LONG*. - mpr_comma_separated_list(prefix, matches, " and ", ", ", - MSGCH_DIAGNOSTICS); - return; + // Only one possible match, use that. + if (matches.size() == 1) + { + name = matches[0]; + feat = dungeon_feature_by_name(name); + } + // Multiple matches, list them to wizard + else + { + std::string prefix = "No exact match for feature '" + + name + "', possible matches are: "; + + // Use mpr_comma_separated_list() because the list + // might be *LONG*. + mpr_comma_separated_list(prefix, matches, " and ", ", ", + MSGCH_DIAGNOSTICS); + return; + } } } @@ -342,8 +325,6 @@ void wizard_create_feature_name() return; } - mprf(MSGCH_DIAGNOSTICS, "Setting (%d,%d) to %s (%d)", - you.pos().x, you.pos().y, name.c_str(), feat); dungeon_terrain_changed(you.pos(), feat, false); #ifdef USE_TILE env.tile_flv(you.pos()).special = 0; -- cgit v1.2.3-54-g00ecf