location: use consistent reference (&) placement

a cosmetic change only.
This commit is contained in:
Subhraman Sarkar 2025-01-13 12:56:56 +05:30
parent 5b4f8f932f
commit d30b0e9bd1
2 changed files with 18 additions and 18 deletions

View File

@ -33,12 +33,12 @@
static lg::log_domain log_config("config");
#define ERR_CF LOG_STREAM(err, log_config)
std::ostream &operator<<(std::ostream &s, const map_location& l) {
std::ostream& operator<<(std::ostream& s, const map_location& l) {
s << (l.wml_x()) << ',' << (l.wml_y());
return s;
}
std::ostream &operator<<(std::ostream &s, const std::vector<map_location>& v) {
std::ostream& operator<<(std::ostream& s, const std::vector<map_location>& v) {
std::vector<map_location>::const_iterator i = v.begin();
for(; i!= v.end(); ++i) {
s << "(" << *i << ") ";
@ -228,16 +228,16 @@ void map_location::write(config& cfg) const
cfg["y"] = y + 1;
}
static bool is_vertically_higher_than ( const map_location & m1, const map_location & m2 ) {
static bool is_vertically_higher_than (const map_location& m1, const map_location& m2) {
return (is_odd(m1.wml_x()) && is_even(m2.wml_x())) ? (m1.wml_y() <= m2.wml_y()) : (m1.wml_y() < m2.wml_y());
}
map_location::direction map_location::get_relative_dir(const map_location & loc) const
map_location::direction map_location::get_relative_dir(const map_location& loc) const
{
return get_relative_dir(loc, map_location::RADIAL_SYMMETRY);
}
map_location::direction map_location::get_relative_dir(const map_location & loc, map_location::RELATIVE_DIR_MODE opt) const
map_location::direction map_location::get_relative_dir(const map_location& loc, map_location::RELATIVE_DIR_MODE opt) const
{
if (opt == map_location::DEFAULT) {
map_location::direction dir = direction::indeterminate;
@ -298,7 +298,7 @@ map_location::direction map_location::get_relative_dir(const map_location & loc,
}
}
map_location map_location::rotate_right_around_center(const map_location & center, int k) const {
map_location map_location::rotate_right_around_center(const map_location& center, int k) const {
auto me_as_cube = to_cubic(), c_as_cube = center.to_cubic();
auto vec = cubic_location{me_as_cube.q - c_as_cube.q, me_as_cube.r - c_as_cube.r, me_as_cube.s - c_as_cube.s};
// These represent the 6 possible rotation matrices on the hex grid.
@ -319,7 +319,7 @@ map_location map_location::rotate_right_around_center(const map_location & cente
return from_cubic(vec);
}
bool map_location::matches_range(const std::string& xloc, const std::string &yloc) const
bool map_location::matches_range(const std::string& xloc, const std::string& yloc) const
{
const auto xlocs = utils::split(xloc);
const auto ylocs = utils::split(yloc);
@ -439,7 +439,7 @@ void write_location_range(const std::set<map_location>& locs, config& cfg)
cfg["y"] = y.str();
}
static map_location read_locations_helper(const std::string & xi, const std::string & yi)
static map_location read_locations_helper(const std::string& xi, const std::string& yi)
{
return map_location(std::stoi(xi)-1, std::stoi(yi)-1);
}

View File

@ -93,13 +93,13 @@ struct map_location {
map_location(const config_attribute_value& x, const config_attribute_value& y, wml_loc);
map_location(const config& cfg, const variable_set *variables = nullptr);
static const map_location & ZERO()
static const map_location& ZERO()
{
static const map_location z(0,0);
return z;
}
static const map_location & null_location()
static const map_location& null_location()
{
static const map_location l;
return l;
@ -134,12 +134,12 @@ struct map_location {
return map_location(-x, -y - (x & 1)); //subtract one if we're on an odd x coordinate
}
map_location vector_sum(const map_location &a) const
map_location vector_sum(const map_location& a) const
{
return map_location(*this).vector_sum_assign(a);
}
map_location& vector_sum_assign(const map_location &a)
map_location& vector_sum_assign(const map_location& a)
{
y += ((x & 1) && (a.x & 1)); //add one if both x coords are odd
x += a.x;
@ -147,7 +147,7 @@ struct map_location {
return *this;
}
map_location& vector_difference_assign(const map_location &a)
map_location& vector_difference_assign(const map_location& a)
{
return vector_sum_assign(a.vector_negation());
}
@ -160,8 +160,8 @@ struct map_location {
}
enum RELATIVE_DIR_MODE { DEFAULT , RADIAL_SYMMETRY };
direction get_relative_dir(const map_location & loc, map_location::RELATIVE_DIR_MODE mode /*= map_location::RADIAL_SYMMETRY*/ ) const;
direction get_relative_dir(const map_location & loc) const; //moved the default setting to .cpp file for ease of testing
direction get_relative_dir(const map_location& loc, map_location::RELATIVE_DIR_MODE mode /*= map_location::RADIAL_SYMMETRY*/ ) const;
direction get_relative_dir(const map_location& loc) const; //moved the default setting to .cpp file for ease of testing
cubic_location to_cubic() const {
int q = x;
@ -176,7 +176,7 @@ struct map_location {
}
// Rotates the map_location clockwise in 60 degree increments around a center point. Negative numbers of steps are permitted.
map_location rotate_right_around_center(const map_location & center, int k) const;
map_location rotate_right_around_center(const map_location& center, int k) const;
friend std::size_t hash_value(const map_location& a);
@ -230,9 +230,9 @@ void read_locations(const config& cfg, std::vector<map_location>& locs);
void write_locations(const std::vector<map_location>& locs, config& cfg);
/** Dumps a position on a stream, for debug purposes. */
std::ostream &operator<<(std::ostream &s, const map_location& l);
std::ostream& operator<<(std::ostream& s, const map_location& l);
/** Dumps a vector of positions on a stream, for debug purposes. */
std::ostream &operator<<(std::ostream &s, const std::vector<map_location>& v);
std::ostream& operator<<(std::ostream& s, const std::vector<map_location>& v);
/** Print a direction's string representation to stream. */
std::ostream& operator<<(std::ostream& s, map_location::direction dir);