Prefer get_location over get_location_[x|y] when possible

This commit is contained in:
Charles Dang 2024-09-02 13:44:31 -04:00
parent d37679a7c9
commit 647f7949cb
5 changed files with 13 additions and 28 deletions

View file

@ -1895,15 +1895,13 @@ void display::toggle_default_zoom()
bool display::tile_fully_on_screen(const map_location& loc) const
{
int x = get_location_x(loc);
int y = get_location_y(loc);
const auto [x, y] = get_location(loc);
return !outside_area(map_area(), x, y);
}
bool display::tile_nearly_on_screen(const map_location& loc) const
{
int x = get_location_x(loc);
int y = get_location_y(loc);
const auto [x, y] = get_location(loc);
const SDL_Rect &area = map_area();
int hw = hex_width(), hs = hex_size();
return x + hs >= area.x - hw && x < area.x + area.w + hw &&
@ -2030,8 +2028,7 @@ void display::scroll_to_tiles(const std::vector<map_location>::const_iterator &
if(get_map().on_board(*itor) == false) continue;
if(check_fogged && fogged(*itor)) continue;
int x = get_location_x(*itor);
int y = get_location_y(*itor);
const auto [x, y] = get_location(*itor);
if (!valid) {
minx = x;
@ -2612,8 +2609,7 @@ void display::draw_invalidated()
}
for(const map_location& loc : invalidated_) {
int xpos = get_location_x(loc);
int ypos = get_location_y(loc);
const auto [xpos, ypos] = get_location(loc);
rect hex_rect(xpos, ypos, zoom_, zoom_);
if(!hex_rect.overlaps(clip_rect)) {

View file

@ -218,8 +218,7 @@ void halo_impl::effect::update()
int w(tex_.w() * disp->get_zoom_factor());
int h(tex_.h() * disp->get_zoom_factor());
const int zero_x = disp->get_location_x(map_location::ZERO());
const int zero_y = disp->get_location_y(map_location::ZERO());
const auto [zero_x, zero_y] = disp->get_location(map_location::ZERO());
const int xpos = zero_x + abs_mid_.x - w/2;
const int ypos = zero_y + abs_mid_.y - h/2;

View file

@ -109,9 +109,7 @@ void play_controller::hotkey_handler::preferences(){
}
void play_controller::hotkey_handler::left_mouse_click(){
int x = gui()->get_location_x(gui()->mouseover_hex());
int y = gui()->get_location_y(gui()->mouseover_hex());
const auto [x, y] = gui()->get_location(gui()->mouseover_hex());
SDL_MouseButtonEvent event;
event.button = 1;
@ -144,9 +142,7 @@ void play_controller::hotkey_handler::select_hex(){
}
void play_controller::hotkey_handler::right_mouse_click(){
int x = gui()->get_location_x(gui()->mouseover_hex());
int y = gui()->get_location_y(gui()->mouseover_hex());
const auto [x, y] = gui()->get_location(gui()->mouseover_hex());
SDL_MouseButtonEvent event;
event.button = 3;

View file

@ -262,10 +262,8 @@ void unit_drawer::redraw_unit(const unit& u) const
const frame_parameters adjusted_params = ac.anim_->get_current_params(params);
const map_location dst = loc.get_direction(facing);
const int xsrc = disp.get_location_x(loc);
const int ysrc = disp.get_location_y(loc);
const int xdst = disp.get_location_x(dst);
const int ydst = disp.get_location_y(dst);
const auto [xsrc, ysrc] = disp.get_location(loc);
const auto [xdst, ydst] = disp.get_location(dst);
// We draw bars only if wanted, visible on the map view
bool draw_bars = ac.draw_bars_ ;

View file

@ -624,10 +624,8 @@ void unit_frame::redraw(const int frame_time, bool on_start_time, bool in_scope_
{
game_display* game_disp = game_display::get_singleton();
const int xsrc = game_disp->get_location_x(src);
const int ysrc = game_disp->get_location_y(src);
const int xdst = game_disp->get_location_x(dst);
const int ydst = game_disp->get_location_y(dst);
const auto [xsrc, ysrc] = game_disp->get_location(src);
const auto [xdst, ydst] = game_disp->get_location(dst);
const map_location::DIRECTION direction = src.get_relative_dir(dst);
const frame_parameters current_data = merge_parameters(frame_time,animation_val,engine_val);
@ -791,10 +789,8 @@ std::set<map_location> unit_frame::get_overlaped_hex(const int frame_time, const
{
display* disp = display::get_singleton();
const int xsrc = disp->get_location_x(src);
const int ysrc = disp->get_location_y(src);
const int xdst = disp->get_location_x(dst);
const int ydst = disp->get_location_y(dst);
const auto [xsrc, ysrc] = disp->get_location(src);
const auto [xdst, ydst] = disp->get_location(dst);
const map_location::DIRECTION direction = src.get_relative_dir(dst);
const frame_parameters current_data = merge_parameters(frame_time, animation_val, engine_val);