diff --git a/src/actions.cpp b/src/actions.cpp index 5c5e2124e47..1f939ffa441 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -263,14 +263,13 @@ std::string find_recruit_location(int side, map_location &recruit_loc, bool need return std::string(); } -bool place_recruit(const unit &u, const map_location &recruit_location, +void place_recruit(const unit &u, const map_location &recruit_location, bool is_recall, bool show, bool full_movement, bool wml_triggered) { LOG_NG << "placing new unit on location " << recruit_location << "\n"; - if (resources::units->count(recruit_location) == 1) - return false; + assert(resources::units->count(recruit_location) == 0); unit new_unit = u; if (full_movement) { @@ -348,8 +347,6 @@ bool place_recruit(const unit &u, const map_location &recruit_location, cfg["checksum"] = checksum; set_random_results(cfg); } - - return true; } map_location under_leadership(const unit_map& units, diff --git a/src/actions.hpp b/src/actions.hpp index 32b4c95fcd1..3fd8f76ea56 100644 --- a/src/actions.hpp +++ b/src/actions.hpp @@ -62,12 +62,8 @@ std::string find_recruit_location(int side, map_location &recruit_location, * Place a unit into the game. * The unit will be placed on @a recruit_location, which should be retrieved * through a call to recruit_location(). - * - * If @a disp is not NULL, the new unit will be faded in. - * - * @return false if the location was already occupied. True on success. */ -bool place_recruit(const unit &u, const map_location &recruit_location, +void place_recruit(const unit &u, const map_location &recruit_location, bool is_recall, bool show = false, bool full_movement = false, bool wml_triggered = false); diff --git a/src/ai/actions.cpp b/src/ai/actions.cpp index 5a9d7c3a501..12160682235 100644 --- a/src/ai/actions.cpp +++ b/src/ai/actions.cpp @@ -676,7 +676,7 @@ void recruit_result::do_execute() const std::string recruit_err = find_recruit_location(get_side(), loc); if(recruit_err.empty()) { const unit new_unit(&info.units, &u->second, get_side(), true); - assert(place_recruit(new_unit, loc, false, preferences::show_ai_moves())); + place_recruit(new_unit, loc, false, preferences::show_ai_moves()); statistics::recruit_unit(new_unit); get_my_team(info).spend_gold(u->second.cost()); // Confirm the transaction - i.e. don't undo recruitment diff --git a/src/ai/contexts.cpp b/src/ai/contexts.cpp index a1fb66c60a9..a9cd4954e16 100644 --- a/src/ai/contexts.cpp +++ b/src/ai/contexts.cpp @@ -188,7 +188,7 @@ bool readwrite_context_impl::recruit(const std::string& unit_name, map_location const std::string recruit_err = find_recruit_location(get_side(), loc); if(recruit_err.empty()) { const unit new_unit(&get_info().units, &u->second, get_side(), true); - assert(place_recruit(new_unit, loc, false, preferences::show_ai_moves())); + place_recruit(new_unit, loc, false, preferences::show_ai_moves()); statistics::recruit_unit(new_unit); current_team_w().spend_gold(u->second.cost()); diff --git a/src/game_events.cpp b/src/game_events.cpp index fa20d8c8674..ec8f50eaecc 100644 --- a/src/game_events.cpp +++ b/src/game_events.cpp @@ -2015,7 +2015,7 @@ WML_HANDLER_FUNCTION(recall, /*event_info*/, cfg) unit to_recruit(*u); avail.erase(u); // Erase before recruiting, since recruiting can fire more events find_recruit_location(index + 1, loc, false); - assert(place_recruit(to_recruit, loc, true, utils::string_bool(cfg["show"], true), true, true)); + place_recruit(to_recruit, loc, true, utils::string_bool(cfg["show"], true), true, true); unit_recalled = true; break; } diff --git a/src/menu_events.cpp b/src/menu_events.cpp index 3c1a212bcf0..1b737a8eb3d 100644 --- a/src/menu_events.cpp +++ b/src/menu_events.cpp @@ -787,7 +787,7 @@ private: const std::string &msg = find_recruit_location(side_num, loc); if(msg.empty()) { const unit new_unit(&units_, &u_type->second, side_num, true); - assert(place_recruit(new_unit, loc, false, gui_ != NULL)); + place_recruit(new_unit, loc, false, true); current_team.spend_gold(u_type->second.cost()); statistics::recruit_unit(new_unit); @@ -947,7 +947,7 @@ private: } else { unit& un = recall_list_team[res]; un.set_game_context(&units_); - assert(place_recruit(un, loc, true, gui_ != NULL)); + place_recruit(un, loc, true, true); statistics::recall_unit(un); current_team.spend_gold(game_config::recall_cost); @@ -1116,7 +1116,7 @@ private: if(msg.empty()) { unit un = current_team.recall_list()[action.recall_pos]; un.set_game_context(&units_); - assert(place_recruit(un, loc, true, gui_ != NULL)); + place_recruit(un, loc, true, true); statistics::recall_unit(un); current_team.spend_gold(game_config::recall_cost); current_team.recall_list().erase(current_team.recall_list().begin()+action.recall_pos); @@ -1156,7 +1156,7 @@ private: if(msg.empty()) { const unit new_unit = action.affected_unit; //unit new_unit(action.affected_unit.type(),team_num_,true); - assert(place_recruit(new_unit, loc, false, gui_ != NULL)); + place_recruit(new_unit, loc, false, true); current_team.spend_gold(new_unit.type()->cost()); statistics::recruit_unit(new_unit); diff --git a/src/replay.cpp b/src/replay.cpp index 66b00153977..0c088cd4bf6 100644 --- a/src/replay.cpp +++ b/src/replay.cpp @@ -926,7 +926,7 @@ bool do_replay_handle(int side_num, const std::string &do_untill) const std::string res = find_recruit_location(side_num, loc); const unit new_unit(resources::units, &u_type->second, side_num, true, false); if (res.empty()) { - assert(place_recruit(new_unit, loc, false, !get_replay_source().is_skipping())); + place_recruit(new_unit, loc, false, !get_replay_source().is_skipping()); } else { std::stringstream errbuf; errbuf << "cannot recruit unit: " << res << "\n";