diff --git a/src/map.cpp b/src/map.cpp index 7f6c8b6e86d96..920f3105e8862 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -10036,18 +10036,19 @@ tripoint_abs_ms map::getglobal( const tripoint &p ) const tripoint_abs_ms map::getglobal( const tripoint_bub_ms &p ) const { - return project_to( abs_sub.xy() ) + p.raw(); + return tripoint_abs_ms{ p.x() + abs_ms.x(), p.y() + abs_ms.y(), p.z() }; } tripoint_bub_ms map::bub_from_abs( const tripoint_abs_ms &p ) const { - return tripoint_bub_ms() + ( p - project_to( abs_sub.xy() ) ); + return tripoint_bub_ms { p.x() - abs_ms.x(), p.y() - abs_ms.y(), p.z()}; } void map::set_abs_sub( const tripoint_abs_sm &p ) { abs_sub = p; -} + abs_ms = point_abs_ms{ project_to( abs_sub.xy() ) }; +}; tripoint_abs_sm map::get_abs_sub() const { diff --git a/src/map.h b/src/map.h index 6d19b412f2f03..c418a5b112fdc 100644 --- a/src/map.h +++ b/src/map.h @@ -2251,6 +2251,8 @@ class map * - shifting the map with @ref shift */ tripoint_abs_sm abs_sub; + // Cached value of project_to( abs_sub.xy() ) + point_abs_ms abs_ms; /** * Sets @ref abs_sub, see there. Uses the same coordinate system as @ref abs_sub. */