From b1ff610c3ab9951b28f60747c70d81bcb21a6229 Mon Sep 17 00:00:00 2001 From: Charles Otto Date: Sun, 10 Jan 2010 14:08:42 -0500 Subject: Don't prompt the user in growth if they can't use the ability Don't prompt the user to specify the amount of plants to create if they can't create any due to having no fruit or no empty adjacent squares to put plants on. --- crawl-ref/source/godabil.cc | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'crawl-ref/source/godabil.cc') diff --git a/crawl-ref/source/godabil.cc b/crawl-ref/source/godabil.cc index dce5c197d1..0755e70e81 100644 --- a/crawl-ref/source/godabil.cc +++ b/crawl-ref/source/godabil.cc @@ -345,7 +345,7 @@ bool fedhas_shoot_through(const bolt & beam, const monsters * victim) { monsters * temp = dynamic_cast (originator); if (!temp) - return false; + return (false); origin_worships_fedhas = temp->god == GOD_FEDHAS; origin_attitude = temp->attitude; } @@ -684,7 +684,7 @@ bool sunlight() template bool less_second(const T & left, const T & right) { - return left.second < right.second; + return (left.second < right.second); } typedef std::pair point_distance; @@ -904,19 +904,19 @@ bool _prompt_amount(int max, int & selected) // Default is max if (keyin == '\n' || keyin == '\r') - return true; + return (true); // Otherwise they should enter a digit if (isdigit(keyin)) { selected = keyin - '0'; if (selected > 0 && selected <= max) - return true; + return (true); } // else they entered some garbage? } - return max; + return (max); } @@ -934,12 +934,12 @@ int _collect_fruit(std::vector > & available_fruit) } } - return total; + return (total); } bool _less_first(const std::pair & left, const std::pair & right) { - return left.first < right.first; + return (left.first < right.first); } void _decrease_amount(std::vector > & available, int amount) { @@ -979,11 +979,16 @@ bool plant_ring_from_fruit() int max_use = std::min(total_fruit, int(adjacent.size()) ); + // Don't prompt if we can't do anything (due to having no fruit or + // no squares to place plants on). + if (max_use == 0) + return (false); + // And how many plants does the user want to create? int target_count; if (!_prompt_amount(max_use, target_count)) { - return false; + return (false); } if ((int)adjacent.size() > target_count) -- cgit v1.2.3-54-g00ecf