/** * Constructs a list of vision paths for a unit. * * This constructor is provided so that only the relevant portion of a unit's * data is required to construct the vision paths. * @param view_costs The vision costs of the unit doing the viewing. * @param slowed Whether or not the unit is slowed. * @param sight_range The vision() of the unit. * @param loc The location from which the viewing occurs * (does not have to be the unit's location). */ vision_path::vision_path(const movetype::terrain_costs & view_costs, bool slowed, int sight_range, const map_location & loc, const std::map<map_location, int>& jamming_map) : paths(), edges() { // The four NULL parameters indicate (in order): no teleports, // ignore units, ignore ZoC (no effect), and see all (no effect). find_routes(loc, view_costs, slowed, sight_range, sight_range, 0, destinations, &edges, NULL, NULL, NULL, NULL, &jamming_map); }
/** * Constructs a list of jamming paths for a unit. * * This is used to construct a list of hexes that the indicated unit can jam. * It differs from pathfinding in that it will only ever go out one turn. * @param jammer The unit doing the jamming. * @param loc The location from which the jamming occurs * (does not have to be the unit's location). */ jamming_path::jamming_path(const unit& jammer, map_location const &loc) : paths() { const int jamming_range = jammer.jamming(); // The five NULL parameters indicate (in order): no edges, no teleports, // ignore units, ignore ZoC (no effect), and see all (no effect). find_routes(loc, jammer.movement_type().get_jamming(), jammer.get_state(unit::STATE_SLOWED), jamming_range, jamming_range, 0, destinations, NULL, NULL, NULL, NULL, NULL); }
/** * Constructs a list of vision paths for a unit. * * This is used to construct a list of hexes that the indicated unit can see. * It differs from pathfinding in that it will only ever go out one turn, * and that it will also collect a set of border hexes (the "one hex beyond" * movement to which vision extends). * @param viewer The unit doing the viewing. * @param loc The location from which the viewing occurs * (does not have to be the unit's location). */ vision_path::vision_path(const unit& viewer, map_location const &loc, const std::map<map_location, int>& jamming_map) : paths(), edges() { const int sight_range = viewer.vision(); // The four NULL parameters indicate (in order): no teleports, // ignore units, ignore ZoC (no effect), and see all (no effect). find_routes(loc, viewer.movement_type().get_vision(), viewer.get_state(unit::STATE_SLOWED), sight_range, sight_range, 0, destinations, &edges, NULL, NULL, NULL, NULL, &jamming_map); }
pathfind::paths::paths(gamemap const &map, unit_map const &units, const unit& u, std::vector<team> const &teams, bool force_ignore_zoc, bool allow_teleport, const team &viewing_team, int additional_turns, bool see_all, bool ignore_units) : destinations() { if (u.side() < 1 || u.side() > int(teams.size())) { return; } find_routes(map, units, u, u.movement_left(), destinations, teams, force_ignore_zoc, allow_teleport,additional_turns,viewing_team, see_all, ignore_units); }
/** * Construct a list of paths for the specified unit. * * This function is used for several purposes, including showing a unit's * potential moves and generating currently possible paths. * @param u The unit whose moves and movement type will be used. * @param force_ignore_zoc Set to true to completely ignore zones of control. * @param allow_teleport Set to true to consider teleportation abilities. * @param viewing_team Usually the current team, except for "show enemy moves", etc. * @param additional_turns The number of turns to account for, in addition to the current. * @param see_all Set to true to remove unit visibility from consideration. * @param ignore_units Set to true if units should never obstruct paths (implies ignoring ZoC as well). */ paths::paths(const unit& u, bool force_ignore_zoc, bool allow_teleport, const team &viewing_team, int additional_turns, bool see_all, bool ignore_units) : destinations() { std::vector<team> const &teams = *resources::teams; if (u.side() < 1 || u.side() > int(teams.size())) { return; } find_routes(u.get_location(), u.movement_type().get_movement(), u.get_state(unit::STATE_SLOWED), u.movement_left(), u.total_movement(), additional_turns, destinations, NULL, allow_teleport ? &u : NULL, ignore_units ? NULL : &teams[u.side()-1], force_ignore_zoc ? NULL : &u, see_all ? NULL : &viewing_team); }
paths::paths(gamemap const &map, unit_map const &units, map_location const &loc, std::vector<team> const &teams, bool force_ignore_zoc, bool allow_teleport, const team &viewing_team, int additional_turns, bool see_all, bool ignore_units) : destinations() { const unit_map::const_iterator i = units.find(loc); if(i == units.end()) { ERR_PF << "paths::paths() -- unit not found\n"; return; } if(i->second.side() < 1 || i->second.side() > int(teams.size())) { return; } find_routes(map,units,i->second,loc, i->second.movement_left(), destinations, teams, force_ignore_zoc, allow_teleport,additional_turns,viewing_team, see_all, ignore_units); }