diff --git a/src/magic_spell_effect.cpp b/src/magic_spell_effect.cpp index c92862502cdce..61bdbd0f19503 100644 --- a/src/magic_spell_effect.cpp +++ b/src/magic_spell_effect.cpp @@ -96,15 +96,16 @@ static const trait_id trait_PYROMANIA( "PYROMANIA" ); namespace spell_detail { struct line_iterable { - const std::vector &delta_line; - point cur_origin; - point delta; + const std::vector &delta_line; + point_rel_ms cur_origin; + point_rel_ms delta; size_t index; - line_iterable( const point &origin, const point &delta, const std::vector &dline ) + line_iterable( const point_rel_ms &origin, const point_rel_ms &delta, + const std::vector &dline ) : delta_line( dline ), cur_origin( origin ), delta( delta ), index( 0 ) {} - point get() const { + point_rel_ms get() const { return cur_origin + delta_line[index]; } // Move forward along point set, wrap around and move origin forward if necessary @@ -117,28 +118,30 @@ struct line_iterable { cur_origin = cur_origin - delta * ( index == 0 ); index = ( index + delta_line.size() - 1 ) % delta_line.size(); } - void reset( const point &origin ) { + void reset( const point_rel_ms &origin ) { cur_origin = origin; index = 0; } }; // Orientation of point C relative to line AB -static int side_of( const point &a, const point &b, const point &c ) +static int side_of( const point_rel_ms &a, const point_rel_ms &b, const point_rel_ms &c ) { - int cross = ( b.x - a.x ) * ( c.y - a.y ) - ( b.y - a.y ) * ( c.x - a.x ); + int cross = ( b.x() - a.x() ) * ( c.y() - a.y() ) - ( b.y() - a.y() ) * ( c.x() - a.x() ); return ( cross > 0 ) - ( cross < 0 ); } // Tests if point c is between or on lines (a0, a0 + d) and (a1, a1 + d) -static bool between_or_on( const point &a0, const point &a1, const point &d, const point &c ) +static bool between_or_on( const point_rel_ms &a0, const point_rel_ms &a1, const point_rel_ms &d, + const point_rel_ms &c ) { return side_of( a0, a0 + d, c ) != 1 && side_of( a1, a1 + d, c ) != -1; } // Builds line until obstructed or outside of region bound by near and far lines. Stores result in set static void build_line( spell_detail::line_iterable line, const tripoint_bub_ms &source, - const point &delta, const point &delta_perp, bool ( *test )( const tripoint_bub_ms & ), + const point_rel_ms &delta, const point_rel_ms &delta_perp, + bool ( *test )( const tripoint_bub_ms & ), std::set &result ) { - while( between_or_on( point::zero, delta, delta_perp, line.get() ) ) { + while( between_or_on( point_rel_ms::zero, delta, delta_perp, line.get() ) ) { if( !test( source + line.get() ) ) { break; } @@ -298,43 +301,44 @@ static bool test_passable( const tripoint_bub_ms &p ) std::set spell_effect::spell_effect_line( const override_parameters ¶ms, const tripoint_bub_ms &source, const tripoint_bub_ms &target ) { - const point delta = ( target - source ).xy().raw(); - const int dist = square_dist( point::zero, delta ); + const point_rel_ms delta = ( target - source ).xy(); + const int dist = square_dist( point_rel_ms::zero, delta ); // Early out to prevent unnecessary calculations if( dist == 0 ) { return std::set(); } // Clockwise Perpendicular of Delta vector - const point delta_perp( -delta.y, delta.x ); + const point_rel_ms delta_perp( -delta.y(), delta.x() ); - const point abs_delta = delta.abs(); + const point_rel_ms abs_delta = delta.abs(); // Primary axis of delta vector - const point axis_delta = abs_delta.x > abs_delta.y ? point( delta.x, 0 ) : point( 0, delta.y ); + const point_rel_ms axis_delta = abs_delta.x() > abs_delta.y() ? point_rel_ms( delta.x(), + 0 ) : point_rel_ms( 0, delta.y() ); // Clockwise Perpendicular of axis vector - const point cw_perp_axis( -axis_delta.y, axis_delta.x ); - const point unit_cw_perp_axis( sgn( cw_perp_axis.x ), sgn( cw_perp_axis.y ) ); + const point_rel_ms cw_perp_axis( -axis_delta.y(), axis_delta.x() ); + const point_rel_ms unit_cw_perp_axis( sgn( cw_perp_axis.x() ), sgn( cw_perp_axis.y() ) ); // bias leg length toward cw side if uneven int ccw_len = params.aoe_radius / 2; int cw_len = params.aoe_radius - ccw_len; if( !trigdist ) { - ccw_len = ( ccw_len * ( abs_delta.x + abs_delta.y ) ) / dist; - cw_len = ( cw_len * ( abs_delta.x + abs_delta.y ) ) / dist; + ccw_len = ( ccw_len * ( abs_delta.x() + abs_delta.y() ) ) / dist; + cw_len = ( cw_len * ( abs_delta.x() + abs_delta.y() ) ) / dist; } // is delta aligned with, cw, or ccw of primary axis - int delta_side = spell_detail::side_of( point::zero, axis_delta, delta ); + int delta_side = spell_detail::side_of( point_rel_ms::zero, axis_delta, delta ); bool ( *test )( const tripoint_bub_ms & ) = params.ignore_walls ? test_always_true : test_passable; // Canonical path from source to target, offset to local space - std::vector path_to_target = line_to( point::zero, delta ); + std::vector path_to_target = line_to( point_rel_ms::zero, delta ); // Remove endpoint, path_to_target.pop_back(); // and insert startpoint. Path is now prepared for wrapped iteration - path_to_target.insert( path_to_target.begin(), point::zero ); + path_to_target.insert( path_to_target.begin(), point_rel_ms::zero ); - spell_detail::line_iterable base_line( point::zero, delta, path_to_target ); + spell_detail::line_iterable base_line( point_rel_ms::zero, delta, path_to_target ); std::set result; @@ -344,7 +348,7 @@ std::set spell_effect::spell_effect_line( const override_parame // Add cw and ccw legs if( delta_side == 0 ) { // delta is already axis aligned, only need straight lines // cw leg - for( const point &p : line_to( point::zero, unit_cw_perp_axis * cw_len ) ) { + for( const point_rel_ms &p : line_to( point_rel_ms::zero, unit_cw_perp_axis * cw_len ) ) { base_line.reset( p ); if( !test( source + p ) ) { break; @@ -353,7 +357,7 @@ std::set spell_effect::spell_effect_line( const override_parame spell_detail::build_line( base_line, source, delta, delta_perp, test, result ); } // ccw leg - for( const point &p : line_to( point::zero, unit_cw_perp_axis * -ccw_len ) ) { + for( const point_rel_ms &p : line_to( point_rel_ms::zero, unit_cw_perp_axis * -ccw_len ) ) { base_line.reset( p ); if( !test( source + p ) ) { break; @@ -363,11 +367,11 @@ std::set spell_effect::spell_effect_line( const override_parame } } else if( delta_side == 1 ) { // delta is cw of primary axis // ccw leg is behind perp axis - for( const point &p : line_to( point::zero, unit_cw_perp_axis * -ccw_len ) ) { + for( const point_rel_ms &p : line_to( point_rel_ms::zero, unit_cw_perp_axis * -ccw_len ) ) { base_line.reset( p ); // forward until in - while( spell_detail::side_of( point::zero, delta_perp, base_line.get() ) == 1 ) { + while( spell_detail::side_of( point_rel_ms::zero, delta_perp, base_line.get() ) == 1 ) { base_line.next(); } if( !test( source + p ) ) { @@ -376,11 +380,11 @@ std::set spell_effect::spell_effect_line( const override_parame spell_detail::build_line( base_line, source, delta, delta_perp, test, result ); } // cw leg is before perp axis - for( const point &p : line_to( point::zero, unit_cw_perp_axis * cw_len ) ) { + for( const point_rel_ms &p : line_to( point_rel_ms::zero, unit_cw_perp_axis * cw_len ) ) { base_line.reset( p ); // move back - while( spell_detail::side_of( point::zero, delta_perp, base_line.get() ) != 1 ) { + while( spell_detail::side_of( point_rel_ms::zero, delta_perp, base_line.get() ) != 1 ) { base_line.prev(); } base_line.next(); @@ -391,11 +395,11 @@ std::set spell_effect::spell_effect_line( const override_parame } } else if( delta_side == -1 ) { // delta is ccw of primary axis // ccw leg is before perp axis - for( const point &p : line_to( point::zero, unit_cw_perp_axis * -ccw_len ) ) { + for( const point_rel_ms &p : line_to( point_rel_ms::zero, unit_cw_perp_axis * -ccw_len ) ) { base_line.reset( p ); // move back - while( spell_detail::side_of( point::zero, delta_perp, base_line.get() ) != 1 ) { + while( spell_detail::side_of( point_rel_ms::zero, delta_perp, base_line.get() ) != 1 ) { base_line.prev(); } base_line.next(); @@ -405,11 +409,11 @@ std::set spell_effect::spell_effect_line( const override_parame spell_detail::build_line( base_line, source, delta, delta_perp, test, result ); } // cw leg is behind perp axis - for( const point &p : line_to( point::zero, unit_cw_perp_axis * cw_len ) ) { + for( const point_rel_ms &p : line_to( point_rel_ms::zero, unit_cw_perp_axis * cw_len ) ) { base_line.reset( p ); // forward until in - while( spell_detail::side_of( point::zero, delta_perp, base_line.get() ) == 1 ) { + while( spell_detail::side_of( point_rel_ms::zero, delta_perp, base_line.get() ) == 1 ) { base_line.next(); } if( !test( source + p ) ) { diff --git a/src/magic_teleporter_list.cpp b/src/magic_teleporter_list.cpp index a0010e13b7418..c156f15b5dc07 100644 --- a/src/magic_teleporter_list.cpp +++ b/src/magic_teleporter_list.cpp @@ -63,7 +63,7 @@ void teleporter_list::deactivate_teleporter( const tripoint_abs_omt &omt_pt, // returns the first valid teleport location near a teleporter // returns map square (global coordinates) -static std::optional find_valid_teleporters_omt( const tripoint_abs_omt &omt_pt ) +static std::optional find_valid_teleporters_omt( const tripoint_abs_omt &omt_pt ) { // this is the top left hand square of the global absolute coordinate // of the overmap terrain we want to try to teleport to. @@ -72,7 +72,7 @@ static std::optional find_valid_teleporters_omt( const tripoint_abs_om checker.load( omt_pt, true ); for( const tripoint_omt_ms &p : checker.points_on_zlevel() ) { if( checker.has_flag_furn( ter_furn_flag::TFLAG_TRANSLOCATOR, p ) ) { - return checker.get_abs( p ).raw(); + return checker.get_abs( p ); } } return std::nullopt; @@ -82,11 +82,11 @@ bool teleporter_list::place_avatar_overmap( Character &you, const tripoint_abs_o { tinymap omt_dest; omt_dest.load( omt_pt, true ); - std::optional global_dest = find_valid_teleporters_omt( omt_pt ); + std::optional global_dest = find_valid_teleporters_omt( omt_pt ); if( !global_dest ) { return false; } - tripoint_omt_ms local_dest = omt_dest.get_omt( tripoint_abs_ms( *global_dest ) ) + point( 60, + tripoint_omt_ms local_dest = omt_dest.get_omt( *global_dest ) + point( 60, 60 ); you.add_effect( effect_ignore_fall_damage, 1_seconds, false, 0, true ); g->place_player_overmap( omt_pt ); diff --git a/src/mapgen.cpp b/src/mapgen.cpp index e85736a9bc8db..872040ebab58f 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -7571,7 +7571,7 @@ void science_room( map *m, const point_bub_ms &p1, const point_bub_ms &p2, int z case room_bionics: if( rotate % 2 == 0 ) { point_bub_ms bio( p1.x() + 2, static_cast( ( p1.y() + p2.y() ) / 2 ) ); - mapf::formatted_set_simple( m, bio.raw() + point::north_west, + mapf::formatted_set_simple( m, bio + point::north_west, "---\n" "|c|\n" "-=-\n", @@ -7590,7 +7590,7 @@ void science_room( map *m, const point_bub_ms &p1, const point_bub_ms &p2, int z _( "ERROR! Access denied! Unauthorized access will be met with lethal force!" ) ); bio.x() = p2.x() - 2; - mapf::formatted_set_simple( m, bio.raw() + point::north_west, + mapf::formatted_set_simple( m, bio + point::north_west, "-=-\n" "|c|\n" "---\n", @@ -7610,7 +7610,7 @@ void science_room( map *m, const point_bub_ms &p1, const point_bub_ms &p2, int z } else { int bioy = p1.y() + 2; int biox = static_cast( ( p1.x() + p2.x() ) / 2 ); - mapf::formatted_set_simple( m, point( biox - 1, bioy - 1 ), + mapf::formatted_set_simple( m, point_bub_ms( biox - 1, bioy - 1 ), "|-|\n" "|c=\n" "|-|\n", @@ -7629,7 +7629,7 @@ void science_room( map *m, const point_bub_ms &p1, const point_bub_ms &p2, int z _( "ERROR! Access denied! Unauthorized access will be met with lethal force!" ) ); bioy = p2.y() - 2; - mapf::formatted_set_simple( m, point( biox - 1, bioy - 1 ), + mapf::formatted_set_simple( m, point_bub_ms( biox - 1, bioy - 1 ), "|-|\n" "=c|\n" "|-|\n", diff --git a/src/mapgen_functions.cpp b/src/mapgen_functions.cpp index ad611002296b2..30984ffac0653 100644 --- a/src/mapgen_functions.cpp +++ b/src/mapgen_functions.cpp @@ -333,7 +333,7 @@ void mapgen_subway( mapgendata &dat ) switch( num_dirs ) { case 4: // 4-way intersection - mapf::formatted_set_simple( m, point::zero, + mapf::formatted_set_simple( m, point_bub_ms::zero, "..^/D^^/D^....^D/^^D/^..\n" ".^/DX^/DX......XD/^XD/^.\n" "^/D^X/D^X......X^D/X^D/^\n" @@ -375,7 +375,7 @@ void mapgen_subway( mapgendata &dat ) break; case 3: // tee - mapf::formatted_set_simple( m, point::zero, + mapf::formatted_set_simple( m, point_bub_ms::zero, "..^/D^^/D^...^/D^^/D^...\n" ".^/D^^/D^...^/D^^/D^....\n" "^/D^^/D^...^/D^^/D^.....\n" @@ -422,7 +422,7 @@ void mapgen_subway( mapgendata &dat ) case 2: // straight or diagonal if( diag ) { // diagonal subway get drawn differently from all other types - mapf::formatted_set_simple( m, point::zero, + mapf::formatted_set_simple( m, point_bub_ms::zero, "...^DD^^DD^...^DD^^DD^..\n" "....^DD^^DD^...^DD^^DD^.\n" ".....^DD^^DD^...^DD^^DD^\n" @@ -458,7 +458,7 @@ void mapgen_subway( mapgendata &dat ) furn_str_id::NULL_ID(), furn_str_id::NULL_ID() ) ); } else { // normal subway drawing - mapf::formatted_set_simple( m, point::zero, + mapf::formatted_set_simple( m, point_bub_ms::zero, "...^X^^^X^....^X^^^X^...\n" "...-x---x-....-x---x-...\n" "...^X^^^X^....^X^^^X^...\n" @@ -501,7 +501,7 @@ void mapgen_subway( mapgendata &dat ) break; case 1: // dead end - mapf::formatted_set_simple( m, point::zero, + mapf::formatted_set_simple( m, point_bub_ms::zero, "...^X^^^X^..../D^^/D^...\n" "...-x---x-.../DX^/DX^...\n" "...^X^^^X^../D^X/D^X^...\n" diff --git a/src/mapgenformat.cpp b/src/mapgenformat.cpp index 29cad25e3c2a8..053b0019ea836 100644 --- a/src/mapgenformat.cpp +++ b/src/mapgenformat.cpp @@ -11,7 +11,7 @@ static const furn_str_id furn_f_toilet( "f_toilet" ); namespace mapf { -void formatted_set_simple( map *m, const point &start, const char *cstr, +void formatted_set_simple( map *m, const point_bub_ms &start, const char *cstr, const format_effect &ter_b, const format_effect &furn_b ) { const char *p = cstr; @@ -19,7 +19,7 @@ void formatted_set_simple( map *m, const point &start, const char *cstr, while( *p != 0 ) { if( *p == '\n' ) { p2.y()++; - p2.x() = start.x; + p2.x() = start.x(); } else { const ter_id &ter = ter_b.translate( *p ); const furn_id &furn = furn_b.translate( *p ); @@ -28,7 +28,7 @@ void formatted_set_simple( map *m, const point &start, const char *cstr, } if( furn != furn_str_id::NULL_ID() ) { if( furn == furn_f_toilet ) { - m->place_toilet( tripoint_bub_ms( p2, m->get_abs_sub().z() ) ); + m->place_toilet( { p2, m->get_abs_sub().z() } ); } else { m->furn_set( p2, furn ); } diff --git a/src/mapgenformat.h b/src/mapgenformat.h index 86bbc53e6dece..8840ba94b492c 100644 --- a/src/mapgenformat.h +++ b/src/mapgenformat.h @@ -7,6 +7,7 @@ #include #include +#include "coords_fwd.h" #include "type_id.h" class map; @@ -28,7 +29,7 @@ class format_effect; * A newline character continues on the next line (resets `x` to \p startx and increments `y`). * @param start Coordinates in the map where to start drawing \p cstr. */ -void formatted_set_simple( map *m, const point &start, const char *cstr, +void formatted_set_simple( map *m, const point_bub_ms &start, const char *cstr, const format_effect &ter_b, const format_effect &furn_b ); template diff --git a/src/math_parser_diag.cpp b/src/math_parser_diag.cpp index 6ce5e35cf29f0..5c43d55b941a5 100644 --- a/src/math_parser_diag.cpp +++ b/src/math_parser_diag.cpp @@ -1534,8 +1534,7 @@ diag_eval_dbl_f vision_range_eval( char scope, std::vector const & / return chr->unimpaired_range(); } else if( monster const *const mon = actor->get_const_monster(); mon != nullptr ) { map &here = get_map(); - tripoint_bub_ms tripoint = get_map().get_bub( mon->pos_abs() ); - return mon->sight_range( here.ambient_light_at( tripoint ) ); + return mon->sight_range( here.ambient_light_at( mon->pos_bub() ) ); } throw math::runtime_error( "Tried to access vision range of a non-Character talker" ); }; diff --git a/src/melee.cpp b/src/melee.cpp index 1aa26a8433021..788695ecf163e 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -1786,25 +1786,25 @@ void Character::perform_technique( const ma_technique &technique, Creature &t, if( technique.side_switch && !( t.has_flag( mon_flag_IMMOBILE ) || t.has_flag( json_flag_CANNOT_MOVE ) ) ) { const tripoint_bub_ms b = t.pos_bub(); - point new_; + point_bub_ms new_; if( b.x() > posx() ) { - new_.x = posx() - 1; + new_.x() = posx() - 1; } else if( b.x() < posx() ) { - new_.x = posx() + 1; + new_.x() = posx() + 1; } else { - new_.x = b.x(); + new_.x() = b.x(); } if( b.y() > posy() ) { - new_.y = posy() - 1; + new_.y() = posy() - 1; } else if( b.y() < posy() ) { - new_.y = posy() + 1; + new_.y() = posy() + 1; } else { - new_.y = b.y(); + new_.y() = b.y(); } - const tripoint_bub_ms &dest{ new_.x, new_.y, b.z()}; + const tripoint_bub_ms &dest{ new_, b.z()}; if( g->is_empty( dest ) ) { t.setpos( dest ); } @@ -1813,9 +1813,9 @@ void Character::perform_technique( const ma_technique &technique, Creature &t, if( technique.knockback_dist && !( t.has_flag( mon_flag_IMMOBILE ) || t.has_flag( json_flag_CANNOT_MOVE ) ) ) { const tripoint_bub_ms prev_pos = t.pos_bub(); // track target startpoint for knockback_follow - const point kb_offset( rng( -technique.knockback_spread, technique.knockback_spread ), - rng( -technique.knockback_spread, technique.knockback_spread ) ); - tripoint_bub_ms kb_point( posx() + kb_offset.x, posy() + kb_offset.y, posz() ); + const point_rel_ms kb_offset( rng( -technique.knockback_spread, technique.knockback_spread ), + rng( -technique.knockback_spread, technique.knockback_spread ) ); + tripoint_bub_ms kb_point( posx() + kb_offset.x(), posy() + kb_offset.y(), posz() ); for( int dist = rng( 1, technique.knockback_dist ); dist > 0; dist-- ) { t.knock_back_from( kb_point ); } diff --git a/src/mission_companion.h b/src/mission_companion.h index 610a53f89b4d0..3779c91330005 100644 --- a/src/mission_companion.h +++ b/src/mission_companion.h @@ -224,7 +224,7 @@ npc_ptr temp_npc( const string_id &type ); //Utility functions /// Returns npcs that have the given companion mission. comp_list companion_list( const npc &p, const mission_id &miss_id, bool contains = false ); -comp_list companion_list( const tripoint &omt_pos, const std::string &role_id, +comp_list companion_list( const tripoint_abs_omt &omt_pos, const std::string &role_id, const mission_id &miss_id, bool contains = false ); comp_list companion_sort( comp_list available, const std::map &required_skills = {} ); diff --git a/src/mission_util.cpp b/src/mission_util.cpp index 32ad6279b6196..a2d7e4e5d4704 100644 --- a/src/mission_util.cpp +++ b/src/mission_util.cpp @@ -121,7 +121,6 @@ tripoint_abs_omt mission_util::reveal_om_ter( const std::string &omter, int reve */ static tripoint_abs_omt random_house_in_city( const city_reference &cref ) { - // TODO: fix point types const tripoint_abs_omt city_center_omt = project_to( cref.abs_sm_pos ); std::vector valid; diff --git a/src/monattack.cpp b/src/monattack.cpp index 15a1af2904465..af9dbf9042cf2 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -739,7 +739,7 @@ bool mattack::acid( monster *z ) dealt_projectile_attack dealt; projectile_attack( dealt, proj, z->pos_bub(), target->pos_bub(), dispersion_sources{ 5400 }, z ); - const tripoint_bub_ms &hitp = tripoint_bub_ms( dealt.end_point ); + const tripoint_bub_ms &hitp = dealt.end_point ; const Creature *hit_critter = dealt.last_hit_critter; if( hit_critter == nullptr && here.hit_with_acid( hitp ) ) { add_msg_if_player_sees( hitp, _( "A glob of acid hits the %s!" ), here.tername( hitp ) ); diff --git a/src/monmove.cpp b/src/monmove.cpp index 6bf437ca07884..f80c1a176f97a 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -296,11 +296,6 @@ bool monster::can_reach_to( const tripoint_bub_ms &p ) const return true; } -bool monster::can_move_to( const tripoint &p ) const -{ - return monster::can_move_to( tripoint_bub_ms( p ) ); -} - bool monster::can_move_to( const tripoint_bub_ms &p ) const { return can_reach_to( p ) && will_move_to( p ); @@ -2104,13 +2099,13 @@ bool monster::push_to( const tripoint_bub_ms &p, const int boost, const size_t d add_effect( effect_pushed, 1_turns ); for( size_t i = 0; i < 6; i++ ) { - const point d( rng( -1, 1 ), rng( -1, 1 ) ); - if( d.x == 0 && d.y == 0 ) { + const point_rel_ms d( rng( -1, 1 ), rng( -1, 1 ) ); + if( d.x() == 0 && d.y() == 0 ) { continue; } // Pushing forward is easier than pushing aside - const int direction_penalty = std::abs( d.x - dir.x() ) + std::abs( d.y - dir.y() ); + const int direction_penalty = std::abs( d.x() - dir.x() ) + std::abs( d.y() - dir.y() ); if( direction_penalty > 2 ) { continue; } diff --git a/src/monster.cpp b/src/monster.cpp index 760dbb62b764e..99d07357c8e07 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -2980,7 +2980,6 @@ void monster::die( Creature *nkiller ) const tripoint_abs_sm abssub = coords::project_to( here.get_abs( pos_bub() ) ); // Do it for overmap above/below too for( const tripoint_abs_sm &p : points_in_radius( abssub, HALF_MAPSIZE, 1 ) ) { - // TODO: fix point types for( mongroup *&mgp : overmap_buffer.groups_at( p ) ) { if( MonsterGroupManager::IsMonsterInGroup( mgp->type, type->id ) ) { mgp->dying = true; diff --git a/src/monster.h b/src/monster.h index 65c021189d574..50591316d1d11 100644 --- a/src/monster.h +++ b/src/monster.h @@ -212,8 +212,6 @@ class monster : public Creature * can_move_to() is a wrapper for both of them. * know_danger_at() checks for fire, trap etc. (flag PATH_AVOID_) */ - // TODO: Get rid of untyped overload - bool can_move_to( const tripoint &p ) const; bool can_move_to( const tripoint_bub_ms &p ) const; bool can_reach_to( const tripoint_bub_ms &p ) const; bool will_move_to( const tripoint_bub_ms &p ) const; diff --git a/src/npc.cpp b/src/npc.cpp index 2278d9a55c993..1ecb0b7c2162e 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -3474,15 +3474,15 @@ std::function npc::get_path_avoid() const return true; } if( rules.has_flag( ally_rule::avoid_locks ) && - doors::can_unlock_door( here, *this, tripoint_bub_ms( p ) ) ) { + doors::can_unlock_door( here, *this, p ) ) { return true; } if( rules.has_flag( ally_rule::hold_the_line ) && - ( here.close_door( tripoint_bub_ms( p ), true, true ) || + ( here.close_door( p, true, true ) || here.move_cost( p ) > 2 ) ) { return true; } - if( sees_dangerous_field( tripoint_bub_ms( p ) ) ) { + if( sees_dangerous_field( p ) ) { return true; } return false; diff --git a/src/npc_attack.cpp b/src/npc_attack.cpp index da87d0a8547b6..13b3dc1935153 100644 --- a/src/npc_attack.cpp +++ b/src/npc_attack.cpp @@ -268,7 +268,7 @@ void npc_attack_melee::use( npc &source, const tripoint_bub_ms &location ) const source.look_for_player( get_player_character() ); } } else { - source.update_path( tripoint_bub_ms( location ) ); + source.update_path( location ); if( source.path.size() > 1 ) { bool clear_path = can_move_melee( source ); if( clear_path && source.mem_combat.formation_distance == -1 ) { @@ -436,7 +436,7 @@ void npc_attack_gun::use( npc &source, const tripoint_bub_ms &location ) const if( has_obstruction( source.pos_bub(), location, false ) || ( source.rules.has_flag( ally_rule::avoid_friendly_fire ) && - !source.wont_hit_friend( tripoint_bub_ms( location ), gun, false ) ) ) { + !source.wont_hit_friend( location, gun, false ) ) ) { if( can_move( source ) ) { source.avoid_friendly_fire(); } else { @@ -567,7 +567,7 @@ npc_attack_rating npc_attack_gun::evaluate_tripoint( if( has_obstruction( source.pos_bub(), location, avoids_friendly_fire ) ) { potential *= 0.9f; } else if( avoids_friendly_fire && - !source.wont_hit_friend( tripoint_bub_ms( location ), gun, false ) ) { + !source.wont_hit_friend( location, gun, false ) ) { potential *= 0.95f; } @@ -823,7 +823,7 @@ npc_attack_rating npc_attack_throw::evaluate_tripoint( } if( source.rules.has_flag( ally_rule::avoid_friendly_fire ) && - !source.wont_hit_friend( tripoint_bub_ms( location ), thrown_item, true ) ) { + !source.wont_hit_friend( location, thrown_item, true ) ) { // Avoid friendy fire return npc_attack_rating( std::nullopt, location ); } diff --git a/src/npctalk.cpp b/src/npctalk.cpp index 9a9c3b261ebfe..64d0d562a7e99 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -3582,7 +3582,7 @@ void receive_item( const itype_id &item_id, int count, const itype_id &container const dialogue &d, bool suppress_message, const std::vector &flags, bool add_talker = true, - const tripoint_abs_ms &p = tripoint_abs_ms(), bool force_equip = false ) + const tripoint_abs_ms &p = tripoint_abs_ms::zero, bool force_equip = false ) { item new_item = item( item_id, calendar::turn ); for( const std::string &flag : flags ) { @@ -3638,7 +3638,7 @@ void receive_item( const itype_id &item_id, int count, const itype_id &container void receive_item_group( const item_group_id &group_id, const dialogue &d, bool suppress_message, const std::vector &flags, bool add_talker = true, - const tripoint_abs_ms &p = tripoint_abs_ms(), bool force_equip = false ) + const tripoint_abs_ms &p = tripoint_abs_ms::zero, bool force_equip = false ) { item_group::ItemList new_items; new_items = item_group::items_from( group_id, calendar::turn ); @@ -4277,8 +4277,9 @@ talk_effect_fun_t::func f_location_variable( const JsonObject &jo, std::string_v target_pos = target_pos + tripoint( dov_x_adjust.evaluate( d ), dov_y_adjust.evaluate( d ), 0 ); if( z_override ) { - target_pos = tripoint_abs_ms( target_pos.xy(), - dov_z_adjust.evaluate( d ) ); + target_pos = { target_pos.xy(), + dov_z_adjust.evaluate( d ) + }; } else { target_pos = target_pos + tripoint( 0, 0, dov_z_adjust.evaluate( d ) ); @@ -4315,7 +4316,7 @@ talk_effect_fun_t::func f_location_variable_adjust( const JsonObject &jo, } if( z_override ) { - target_pos = tripoint_abs_ms( target_pos.xy(), dov_z_adjust.evaluate( d ) ); + target_pos = { target_pos.xy(), dov_z_adjust.evaluate( d ) }; } else { target_pos = target_pos + tripoint( 0, 0, dov_z_adjust.evaluate( d ) ); } @@ -6245,7 +6246,7 @@ talk_effect_fun_t::func f_map_run_item_eocs( const JsonObject &jo, std::string_v for( const tripoint_bub_ms &pos : here.points_in_radius( center, max_radius ) ) { if( rl_dist( center, pos ) >= min_radius && here.inbounds( pos ) ) { for( item &it : here.i_at( pos ) ) { - items.emplace_back( map_cursor( tripoint_bub_ms( pos ) ), &it ); + items.emplace_back( map_cursor( pos ), &it ); } } } diff --git a/src/npctalk_funcs.cpp b/src/npctalk_funcs.cpp index f17de3b8c27b5..78cb5f54dcb50 100644 --- a/src/npctalk_funcs.cpp +++ b/src/npctalk_funcs.cpp @@ -403,7 +403,7 @@ void talk_function::goto_location( npc &p ) p.goal = destination; p.omt_path = overmap_buffer.get_travel_path( p.pos_abs_omt(), p.goal, overmap_path_params::for_npc() ).points; - if( destination == tripoint_abs_omt() || destination.is_invalid() || + if( destination == tripoint_abs_omt::zero || destination.is_invalid() || p.omt_path.empty() ) { p.goal = npc::no_goal_point; p.omt_path.clear(); diff --git a/src/omdata.h b/src/omdata.h index 35bbbaeeef94a..0e1378512928f 100644 --- a/src/omdata.h +++ b/src/omdata.h @@ -18,7 +18,7 @@ #include "catacharset.h" #include "color.h" #include "common_types.h" -#include "coords_fwd.h" +#include "coordinates.h" #include "cube_direction.h" #include "enum_bitset.h" #include "mapgen_parameter.h" @@ -88,7 +88,7 @@ uint32_t rotate_symbol( uint32_t sym, type dir ); * @param dir Direction of displacement * @param dist Distance of displacement */ -point displace( type dir, int dist = 1 ); +point_rel_omt displace( type dir, int dist = 1 ); /** Returns a sum of two numbers * @param dir1 first number @@ -579,7 +579,7 @@ struct overmap_special_spawns : public overmap_spawns { // This is the information needed to know whether you can place a particular // piece of an overmap_special at a particular location struct overmap_special_locations { - tripoint p; + tripoint_rel_omt p; cata::flat_set> locations; /** @@ -592,7 +592,7 @@ struct overmap_special_locations { struct overmap_special_terrain : overmap_special_locations { overmap_special_terrain() = default; - overmap_special_terrain( const tripoint &, const oter_str_id &, + overmap_special_terrain( const tripoint_rel_omt &, const oter_str_id &, const cata::flat_set> &, const std::set & ); oter_str_id terrain; @@ -604,8 +604,8 @@ struct overmap_special_terrain : overmap_special_locations { }; struct overmap_special_connection { - tripoint p; - std::optional from; + tripoint_rel_omt p; + std::optional from; cube_direction initial_dir = cube_direction::last; // NOLINT(cata-serialize) // TODO: Remove it. string_id terrain; @@ -664,7 +664,7 @@ class overmap_special } bool can_spawn() const; /** Returns terrain at the given point. */ - const overmap_special_terrain &get_terrain_at( const tripoint &p ) const; + const overmap_special_terrain &get_terrain_at( const tripoint_rel_omt &p ) const; /** @returns true if this special requires a city */ bool requires_city() const; /** @returns whether the special at specified tripoint can belong to the specified city. */ diff --git a/src/overmap.cpp b/src/overmap.cpp index 373435fc8f25e..9cb55f063b5d1 100644 --- a/src/overmap.cpp +++ b/src/overmap.cpp @@ -1288,7 +1288,8 @@ void overmap_special_terrain::deserialize( const JsonObject &om ) } overmap_special_terrain::overmap_special_terrain( - const tripoint &p, const oter_str_id &t, const cata::flat_set> &l, + const tripoint_rel_omt &p, const oter_str_id &t, + const cata::flat_set> &l, const std::set &fs ) : overmap_special_locations{ p, l } , terrain( t ) @@ -1463,7 +1464,7 @@ struct fixed_overmap_special_data : overmap_special_data { void check( const std::string &context ) const override { std::set invalid_terrains; - std::set points; + std::set points; for( const overmap_special_terrain &elem : terrains ) { const oter_str_id &oter = elem.terrain; @@ -1485,7 +1486,7 @@ struct fixed_overmap_special_data : overmap_special_data { } } - const tripoint &pos = elem.p; + const tripoint_rel_omt &pos = elem.p; if( points.count( pos ) > 0 ) { debugmsg( "In %s, point %s is duplicated.", context, pos.to_string() ); @@ -1553,7 +1554,7 @@ struct fixed_overmap_special_data : overmap_special_data { } } - const overmap_special_terrain &get_terrain_at( const tripoint &p ) const { + const overmap_special_terrain &get_terrain_at( const tripoint_rel_omt &p ) const { const auto iter = std::find_if( terrains.begin(), terrains.end(), [ &p ]( const overmap_special_terrain & elem ) { return elem.p == p; @@ -1569,7 +1570,7 @@ struct fixed_overmap_special_data : overmap_special_data { std::vector result; std::copy_if( terrains.begin(), terrains.end(), std::back_inserter( result ), []( const overmap_special_terrain & terrain ) { - return terrain.p.z == 0; + return terrain.p.z() == 0; } ); return result; } @@ -1658,7 +1659,8 @@ struct fixed_overmap_special_data : overmap_special_data { } else { target = om.get_fallback_road_connection_point(); } - om.build_connection( target, rp.xy(), elem.p.z, *elem.connection, must_be_unexplored, initial_dir ); + om.build_connection( target, rp.xy(), elem.p.z(), *elem.connection, must_be_unexplored, + initial_dir ); } } @@ -2700,7 +2702,7 @@ struct mutable_overmap_special_data : overmap_special_data { return {}; } const mutable_overmap_terrain &root_om = it->second; - return { tripoint::zero, root_om.terrain, root_om.locations, {} }; + return { tripoint_rel_omt::zero, root_om.terrain, root_om.locations, {} }; } std::vector preview_terrains() const override { @@ -2915,16 +2917,16 @@ int overmap_special::longest_side() const std::vector req_locations = required_locations(); auto min_max_x = std::minmax_element( req_locations.begin(), req_locations.end(), []( const overmap_special_locations & lhs, const overmap_special_locations & rhs ) { - return lhs.p.x < rhs.p.x; + return lhs.p.x() < rhs.p.x(); } ); auto min_max_y = std::minmax_element( req_locations.begin(), req_locations.end(), []( const overmap_special_locations & lhs, const overmap_special_locations & rhs ) { - return lhs.p.y < rhs.p.y; + return lhs.p.y() < rhs.p.y(); } ); - const int width = min_max_x.second->p.x - min_max_x.first->p.x; - const int height = min_max_y.second->p.y - min_max_y.first->p.y; + const int width = min_max_x.second->p.x() - min_max_x.first->p.x(); + const int height = min_max_y.second->p.y() - min_max_y.first->p.y(); return std::max( width, height ) + 1; } @@ -3002,25 +3004,25 @@ void overmap_special::load( const JsonObject &jo, const std::string &src ) JsonObject joc = jar.next_object(); cata::flat_set> type; - tripoint from; - tripoint to; + tripoint_rel_omt from; + tripoint_rel_omt to; mandatory( joc, was_loaded, "type", type ); mandatory( joc, was_loaded, "from", from ); mandatory( joc, was_loaded, "to", to ); - if( from.x > to.x ) { - std::swap( from.x, to.x ); + if( from.x() > to.x() ) { + std::swap( from.x(), to.x() ); } - if( from.y > to.y ) { - std::swap( from.y, to.y ); + if( from.y() > to.y() ) { + std::swap( from.y(), to.y() ); } - if( from.z > to.z ) { - std::swap( from.z, to.z ); + if( from.z() > to.z() ) { + std::swap( from.z(), to.z() ); } - for( int x = from.x; x <= to.x; x++ ) { - for( int y = from.y; y <= to.y; y++ ) { - for( int z = from.z; z <= to.z; z++ ) { + for( int x = from.x(); x <= to.x(); x++ ) { + for( int y = from.y(); y <= to.y(); y++ ) { + for( int z = from.z(); z <= to.z(); z++ ) { overmap_special_locations loc; - loc.p = tripoint( x, y, z ); + loc.p = tripoint_rel_omt( x, y, z ); loc.locations = type; check_for_locations_merged_data.push_back( loc ); } @@ -4382,13 +4384,13 @@ void mongroup::wander( const overmap &om ) point_abs_sm target_abs = project_to( project_combine( om.pos(), target_city->pos ) ); int range = target_city->size * 2; - point delta( rng( -range, range ), rng( -range, range ) ); + point_rel_sm delta( rng( -range, range ), rng( -range, range ) ); target = target_abs + delta; interest = 100; } else { // No city to target, wander aimlessly. - target = abs_pos.xy() + point( rng( -10, 10 ), rng( -10, 10 ) ); + target = abs_pos.xy() + point_rel_sm( rng( -10, 10 ), rng( -10, 10 ) ); interest = 30; } } @@ -4785,7 +4787,7 @@ void overmap::place_forest_trails() // If we don't have enough points to build a trail, move on. if( forest_points.empty() || - forest_points.size() < static_cast::size_type> + forest_points.size() < static_cast ( forest_trail.minimum_forest_size ) ) { continue; } @@ -4994,7 +4996,7 @@ void overmap::place_lakes() // If this lake doesn't exceed our minimum size threshold, then skip it. We can use this to // exclude the tiny lakes that don't provide interesting map features and exist mostly as a // noise artifact. - if( lake_points.size() < static_cast::size_type> + if( lake_points.size() < static_cast ( settings->overmap_lake.lake_size_min ) ) { continue; } @@ -5178,7 +5180,7 @@ void overmap::place_oceans() // Ocean size is checked like lake size, but minimum size is much bigger. // you could change this, if you want little tiny oceans all over the place. // I'm not sure why you'd want that. Use place_lakes, my friend. - if( ocean_points.size() < static_cast::size_type> + if( ocean_points.size() < static_cast ( settings->overmap_ocean.ocean_size_min ) ) { continue; } @@ -6831,9 +6833,9 @@ uint32_t om_direction::rotate_symbol( uint32_t sym, type dir ) return rotatable_symbols::get( sym, static_cast( dir ) ); } -point om_direction::displace( type dir, int dist ) +point_rel_omt om_direction::displace( type dir, int dist ) { - return rotate( { 0, -dist }, dir ); + return rotate( point_rel_omt{ 0, -dist }, dir ); } static om_direction::type rotate_internal( om_direction::type dir, int step ) diff --git a/src/overmap_ui.cpp b/src/overmap_ui.cpp index 3a27d3a995ca4..8ce4ca9489686 100644 --- a/src/overmap_ui.cpp +++ b/src/overmap_ui.cpp @@ -606,9 +606,8 @@ static void draw_ascii( const catacurses::window &w, overmap_draw_data_t &data ) if( data.iZoneIndex != -1 ) { const zone_data &zone = zones.get_zones()[data.iZoneIndex].get(); sZoneName = zone.get_name(); - // TODO: fix point types tripointZone = project_to( - tripoint_abs_ms( zone.get_center_point() ) ); + zone.get_center_point() ); } // If we're debugging monster groups, find the monster group we've selected @@ -635,9 +634,8 @@ static void draw_ascii( const catacurses::window &w, overmap_draw_data_t &data ) if( blink && uistate.place_special ) { for( const overmap_special_terrain &s_ter : uistate.place_special->preview_terrains() ) { // Preview should only yield the terrains on the zero z-level - cata_assert( s_ter.p.z == 0 ); + cata_assert( s_ter.p.z() == 0 ); - // TODO: fix point types const point_rel_omt rp( om_direction::rotate( s_ter.p.xy(), uistate.omedit_rotation ) ); const oter_id oter = s_ter.terrain->get_rotated( uistate.omedit_rotation ); diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp index 86af20a861fe4..50461dc72b894 100644 --- a/src/sdltiles.cpp +++ b/src/sdltiles.cpp @@ -976,7 +976,7 @@ void cata_tiles::draw_om( const point &dest, const tripoint_abs_omt ¢er_abs_ } if( uistate.place_special ) { for( const overmap_special_terrain &s_ter : uistate.place_special->preview_terrains() ) { - if( s_ter.p.z == 0 ) { + if( s_ter.p.z() == 0 ) { const point_rel_omt rp( om_direction::rotate( s_ter.p.xy(), uistate.omedit_rotation ) ); oter_id rotated_id = s_ter.terrain->get_rotated( uistate.omedit_rotation ); const oter_t &terrain = *rotated_id; diff --git a/src/simple_pathfinding.cpp b/src/simple_pathfinding.cpp index 6730862862cdf..aaa2733e205ee 100644 --- a/src/simple_pathfinding.cpp +++ b/src/simple_pathfinding.cpp @@ -84,13 +84,14 @@ directed_path greedy_path( const point &source, const point &dest, const const int n = map_index( p ); const om_direction::type dir = static_cast( dirs[n] ); res.nodes.emplace_back( p, dir ); - p += om_direction::displace( dir ); + p += om_direction::displace( dir ).raw(); // Abusing omt operations requires type stripping. } res.nodes.emplace_back( p ); return res; } for( om_direction::type dir : om_direction::all ) { - const point p = mn.pos + om_direction::displace( dir ); + const point p = mn.pos + om_direction::displace( + dir ).raw(); // Abusing omt operations requires type stripping. const int n = map_index( p ); // don't allow out of bounds or already traversed tiles if( !inbounds( p ) || closed[n] ) {