mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-05 20:21:00 +00:00
Removed annoying parameters.
This commit is contained in:
parent
6a60c523a3
commit
89c68c9e22
@ -2210,7 +2210,7 @@ size_t move_unit(move_unit_spectator *move_spectator,
|
||||
team_num = ui->second.side()-1;
|
||||
tm = &teams[team_num];
|
||||
|
||||
if (!skirmisher && enemy_zoc(map, units, teams, *step, *tm, ui->second.side())) {
|
||||
if (!skirmisher && enemy_zoc(units, teams, *step, *tm, ui->second.side())) {
|
||||
moves_left = 0;
|
||||
}
|
||||
|
||||
|
@ -360,7 +360,7 @@ bool ai_default::desperate_attack(const map_location &loc)
|
||||
|
||||
for (unsigned n = 0; n != 6; ++n)
|
||||
{
|
||||
const unit *enemy = get_visible_unit(units_, adj[n], map_, teams_, current_team());
|
||||
const unit *enemy = get_visible_unit(units_, adj[n], current_team());
|
||||
if (!enemy || !current_team().is_enemy(enemy->side()) || enemy->incapacitated())
|
||||
continue;
|
||||
const std::vector<attack_type> &attacks = u.attacks();
|
||||
@ -395,7 +395,7 @@ bool ai_default::desperate_attack(const map_location &loc)
|
||||
// Who would do most damage to us when they attack? (approximate: may be different ToD)
|
||||
for (unsigned n = 0; n != 6; ++n)
|
||||
{
|
||||
const unit *enemy = get_visible_unit(units_, adj[n], map_, teams_, current_team());
|
||||
const unit *enemy = get_visible_unit(units_, adj[n], current_team());
|
||||
if (!enemy || !current_team().is_enemy(enemy->side()) || enemy->incapacitated())
|
||||
continue;
|
||||
const std::vector<attack_type> &attacks = enemy->attacks();
|
||||
|
@ -218,12 +218,12 @@ void game_display::select_hex(map_location hex)
|
||||
|
||||
void game_display::highlight_hex(map_location hex)
|
||||
{
|
||||
const unit *u = get_visible_unit(units_, hex, get_map(), teams_, teams_[viewing_team()], !viewpoint_);
|
||||
const unit *u = get_visible_unit(units_, hex, teams_[viewing_team()], !viewpoint_);
|
||||
if (u) {
|
||||
displayedUnitHex_ = hex;
|
||||
invalidate_unit();
|
||||
} else {
|
||||
u = get_visible_unit(units_, mouseoverHex_, get_map(), teams_, teams_[viewing_team()], !viewpoint_);
|
||||
u = get_visible_unit(units_, mouseoverHex_, teams_[viewing_team()], !viewpoint_);
|
||||
if (u) {
|
||||
// mouse moved from unit hex to non-unit hex
|
||||
if (units_.count(selectedHex_)) {
|
||||
@ -240,7 +240,7 @@ void game_display::highlight_hex(map_location hex)
|
||||
|
||||
void game_display::display_unit_hex(map_location hex)
|
||||
{
|
||||
const unit *u = get_visible_unit(units_, hex, get_map(), teams_, teams_[viewing_team()], !viewpoint_);
|
||||
const unit *u = get_visible_unit(units_, hex, teams_[viewing_team()], !viewpoint_);
|
||||
if (u) {
|
||||
displayedUnitHex_ = hex;
|
||||
invalidate_unit();
|
||||
@ -298,8 +298,7 @@ image::TYPE game_display::get_image_type(const map_location& loc) {
|
||||
if (loc == mouseoverHex_ || loc == attack_indicator_src_) {
|
||||
return image::BRIGHTENED;
|
||||
} else if (loc == selectedHex_) {
|
||||
const unit *un = get_visible_unit(units_, loc, get_map(),
|
||||
teams_, teams_[currentTeam_], !viewpoint_);
|
||||
const unit *un = get_visible_unit(units_, loc, teams_[currentTeam_], !viewpoint_);
|
||||
if (un && !un->get_hidden()) {
|
||||
return image::BRIGHTENED;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ report generate_report(TYPE type,
|
||||
const unit *u = NULL;
|
||||
|
||||
if((int(type) >= int(UNIT_REPORTS_BEGIN) && int(type) < int(UNIT_REPORTS_END)) || type == POSITION){
|
||||
u = get_visible_unit(units, displayed_unit_hex, map, teams, current_team, show_everything);
|
||||
u = get_visible_unit(units, displayed_unit_hex, current_team, show_everything);
|
||||
if (!u && type != POSITION) {
|
||||
return report();
|
||||
}
|
||||
|
@ -1343,12 +1343,12 @@ void menu_handler::rename_unit(mouse_handler& mousehandler)
|
||||
unit_map::iterator menu_handler::current_unit(mouse_handler& mousehandler)
|
||||
{
|
||||
unit_map::iterator res = find_visible_unit(units_, mousehandler.get_last_hex(),
|
||||
map_, teams_, teams_[gui_->viewing_team()]);
|
||||
teams_[gui_->viewing_team()]);
|
||||
if(res != units_.end()) {
|
||||
return res;
|
||||
} else {
|
||||
return find_visible_unit(units_, mousehandler.get_selected_hex(),
|
||||
map_, teams_, teams_[gui_->viewing_team()]);
|
||||
teams_[gui_->viewing_team()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,12 +261,12 @@ unit_map::iterator mouse_handler::selected_unit()
|
||||
|
||||
unit_map::iterator mouse_handler::find_unit(const map_location& hex)
|
||||
{
|
||||
return find_visible_unit(units_,hex,map_,teams_,viewing_team());
|
||||
return find_visible_unit(units_, hex, viewing_team());
|
||||
}
|
||||
|
||||
unit_map::const_iterator mouse_handler::find_unit(const map_location& hex) const
|
||||
{
|
||||
return find_visible_unit(units_,hex,map_,teams_,viewing_team());
|
||||
return find_visible_unit(units_, hex, viewing_team());
|
||||
}
|
||||
|
||||
map_location mouse_handler::current_unit_attacks_from(const map_location& loc)
|
||||
|
@ -84,17 +84,15 @@ map_location find_vacant_tile(const gamemap& map,
|
||||
return map_location();
|
||||
}
|
||||
|
||||
bool enemy_zoc(gamemap const &map,
|
||||
unit_map const &units,
|
||||
std::vector<team> const &teams,
|
||||
map_location const &loc, team const &viewing_team, int side, bool see_all)
|
||||
bool enemy_zoc(unit_map const &units, std::vector<team> const &teams,
|
||||
map_location const &loc, team const &viewing_team, int side, bool see_all)
|
||||
{
|
||||
map_location locs[6];
|
||||
const team ¤t_team = teams[side-1];
|
||||
get_adjacent_tiles(loc,locs);
|
||||
for (int i = 0; i != 6; ++i)
|
||||
{
|
||||
const unit *u = get_visible_unit(units, locs[i], map, teams, viewing_team, see_all);
|
||||
const unit *u = get_visible_unit(units, locs[i], viewing_team, see_all);
|
||||
if (u && u->side() != side && current_team.is_enemy(u->side()) &&
|
||||
u->emits_zoc())
|
||||
{
|
||||
@ -182,7 +180,7 @@ static void find_routes(const gamemap& map, const unit_map& units,
|
||||
viewing_team.fogged(l))
|
||||
continue;
|
||||
if (!ignore_units && l != loc &&
|
||||
get_visible_unit(units, l, map, teams, viewing_team, see_all))
|
||||
get_visible_unit(units, l, viewing_team, see_all))
|
||||
continue;
|
||||
teleports.insert(l);
|
||||
}
|
||||
@ -242,12 +240,12 @@ static void find_routes(const gamemap& map, const unit_map& units,
|
||||
|
||||
if (!ignore_units) {
|
||||
const unit *v =
|
||||
get_visible_unit(units, locs[i], map, teams, viewing_team, see_all);
|
||||
get_visible_unit(units, locs[i], viewing_team, see_all);
|
||||
if (v && current_team.is_enemy(v->side()))
|
||||
continue;
|
||||
|
||||
if (!force_ignore_zocs && t.movement_left > 0
|
||||
&& enemy_zoc(map, units, teams, locs[i], viewing_team, u.side(), see_all)
|
||||
&& enemy_zoc(units, teams, locs[i], viewing_team, u.side(), see_all)
|
||||
&& !u.get_ability_bool("skirmisher", locs[i])) {
|
||||
t.movement_left = 0;
|
||||
}
|
||||
@ -428,7 +426,7 @@ marked_route mark_route(const plain_route &rt,
|
||||
res.waypoints[*i] = marked_route::waypoint(0, pass_here, zoc, false, invisible);
|
||||
}
|
||||
|
||||
zoc = enemy_zoc(map,units,teams, *(i+1), viewing_team,u.side())
|
||||
zoc = enemy_zoc(units, teams, *(i + 1), viewing_team,u.side())
|
||||
&& !u.get_ability_bool("skirmisher", *(i+1));
|
||||
|
||||
if (zoc || capture) {
|
||||
@ -472,7 +470,7 @@ double shortest_path_calculator::cost(const map_location& loc, const double so_f
|
||||
int other_unit_subcost = 0;
|
||||
if (!ignore_unit_) {
|
||||
const unit *other_unit =
|
||||
get_visible_unit(units_, loc, map_, teams_, viewing_team_);
|
||||
get_visible_unit(units_, loc, viewing_team_);
|
||||
|
||||
// We can't traverse visible enemy and we also prefer empty hexes
|
||||
// (less blocking in multi-turn moves and better when exploring fog,
|
||||
@ -511,7 +509,7 @@ double shortest_path_calculator::cost(const map_location& loc, const double so_f
|
||||
|
||||
// check ZoC
|
||||
if (!ignore_unit_ && remaining_movement != terrain_cost
|
||||
&& enemy_zoc(map_,units_,teams_, loc, viewing_team_, unit_.side())
|
||||
&& enemy_zoc(units_, teams_, loc, viewing_team_, unit_.side())
|
||||
&& !unit_.get_ability_bool("skirmisher", loc)) {
|
||||
// entering ZoC cost all remaining MP
|
||||
move_cost += remaining_movement;
|
||||
|
@ -48,8 +48,7 @@ map_location find_vacant_tile(const gamemap& map,
|
||||
const unit* pass_check=NULL);
|
||||
|
||||
/** Function which determines if a given location is in an enemy zone of control. */
|
||||
bool enemy_zoc(gamemap const &map,
|
||||
unit_map const &units,
|
||||
bool enemy_zoc(unit_map const &units,
|
||||
std::vector<team> const &teams, map_location const &loc,
|
||||
team const &viewing_team, int side, bool see_all=false);
|
||||
|
||||
|
29
src/unit.cpp
29
src/unit.cpp
@ -2824,32 +2824,23 @@ int side_upkeep(const unit_map& units, int side)
|
||||
return res;
|
||||
}
|
||||
|
||||
unit_map::iterator find_visible_unit(unit_map& units,
|
||||
const map_location &loc,
|
||||
const gamemap& map,
|
||||
const std::vector<team>& teams, const team& current_team,
|
||||
bool see_all)
|
||||
unit_map::iterator find_visible_unit(unit_map& units, const map_location &loc,
|
||||
const team& current_team, bool see_all)
|
||||
{
|
||||
if (!resources::game_map->on_board(loc)) return units.end();
|
||||
unit_map::iterator u = units.find(loc);
|
||||
if(map.on_board(loc) && !see_all){
|
||||
if(u != units.end()){
|
||||
if(current_team.fogged(loc)){
|
||||
return units.end();
|
||||
}
|
||||
if(current_team.is_enemy(u->second.side()) &&
|
||||
u->second.invisible(loc,units,teams)) {
|
||||
return units.end();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (see_all) return u;
|
||||
if (!u.valid() || current_team.fogged(loc) ||
|
||||
(current_team.is_enemy(u->second.side()) &&
|
||||
u->second.invisible(loc, units, *resources::teams)))
|
||||
return units.end();
|
||||
return u;
|
||||
}
|
||||
|
||||
const unit *get_visible_unit(const unit_map &units, const map_location &loc,
|
||||
const gamemap &map, const std::vector<team> &teams, const team ¤t_team,
|
||||
bool see_all)
|
||||
const team ¤t_team, bool see_all)
|
||||
{
|
||||
unit_map::const_iterator ui = find_visible_unit(units, loc, map, teams,
|
||||
unit_map::const_iterator ui = find_visible_unit(units, loc,
|
||||
current_team, see_all);
|
||||
if (ui == units.end()) return NULL;
|
||||
return &ui->second;
|
||||
|
19
src/unit.hpp
19
src/unit.hpp
@ -480,25 +480,18 @@ int side_units_cost(const unit_map& units, int side_num);
|
||||
|
||||
int side_upkeep(const unit_map& units, int side_num);
|
||||
|
||||
unit_map::iterator find_visible_unit(unit_map& units,
|
||||
const map_location &loc,
|
||||
const gamemap& map,
|
||||
const std::vector<team>& teams, const team& current_team,
|
||||
bool see_all=false);
|
||||
unit_map::iterator find_visible_unit(unit_map &units, const map_location &loc,
|
||||
const team ¤t_team, bool see_all = false);
|
||||
|
||||
inline unit_map::const_iterator find_visible_unit(const unit_map &units,
|
||||
const map_location &loc,
|
||||
const gamemap& map,
|
||||
const std::vector<team>& teams, const team& current_team,
|
||||
bool see_all = false)
|
||||
const map_location &loc, const team ¤t_team, bool see_all = false)
|
||||
{
|
||||
return find_visible_unit(const_cast<unit_map &>(units), loc, map,
|
||||
teams, current_team, see_all);
|
||||
return find_visible_unit(const_cast<unit_map &>(units), loc,
|
||||
current_team, see_all);
|
||||
}
|
||||
|
||||
const unit *get_visible_unit(const unit_map &units, const map_location &loc,
|
||||
const gamemap &map, const std::vector<team> &teams, const team ¤t_team,
|
||||
bool see_all = false);
|
||||
const team ¤t_team, bool see_all = false);
|
||||
|
||||
struct team_data
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user