From 97e81645c4ea5c07f4bd0f4359f8780ca6c5dff7 Mon Sep 17 00:00:00 2001 From: Static Variable Date: Thu, 22 Aug 2024 13:16:53 -0400 Subject: [PATCH 1/3] Removing z-level restriction for zone activities. --- src/clzones.cpp | 19 +++++++++---------- src/game.cpp | 8 ++++++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/clzones.cpp b/src/clzones.cpp index 5c7e59e21443..71c95a0197c3 100644 --- a/src/clzones.cpp +++ b/src/clzones.cpp @@ -675,25 +675,24 @@ bool zone_manager::has( const zone_type_id &type, const tripoint &where, return point_set.find( where ) != point_set.end() || vzone_set.find( where ) != vzone_set.end(); } -bool zone_manager::has_near( const zone_type_id &type, const tripoint &where, int range, - const faction_id &fac ) const +bool zone_manager::has_near( const zone_type_id &type, const tripoint &where, int range, const faction_id &fac ) const { const auto &point_set = get_point_set( type, fac ); for( auto &point : point_set ) { - if( point.z == where.z ) { + //if( point.z == where.z ) { if( square_dist( point, where ) <= range ) { return true; } - } + // } } const auto &vzone_set = get_vzone_set( type, fac ); for( auto &point : vzone_set ) { - if( point.z == where.z ) { + // if( point.z == where.z ) { if( square_dist( point, where ) <= range ) { return true; } - } + // } } return false; @@ -752,7 +751,7 @@ std::unordered_set zone_manager::get_near( const zone_type_id &type, auto near_point_set = std::unordered_set(); for( auto &point : point_set ) { - if( point.z == where.z ) { + //if( point.z == where.z ) { if( square_dist( point, where ) <= range ) { if( it && has( zone_LOOT_CUSTOM, point ) ) { if( custom_loot_has( point, it ) ) { @@ -762,12 +761,12 @@ std::unordered_set zone_manager::get_near( const zone_type_id &type, near_point_set.insert( point ); } } - } + //} } const auto &vzone_set = get_vzone_set( type, fac ); for( auto &point : vzone_set ) { - if( point.z == where.z ) { + // if( point.z == where.z ) { if( square_dist( point, where ) <= range ) { if( it && has( zone_LOOT_CUSTOM, point ) ) { if( custom_loot_has( point, it ) ) { @@ -777,7 +776,7 @@ std::unordered_set zone_manager::get_near( const zone_type_id &type, near_point_set.insert( point ); } } - } + // } } return near_point_set; diff --git a/src/game.cpp b/src/game.cpp index ccb707ae8a17..cb203d65e55c 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -6395,8 +6395,12 @@ void game::zones_manager() break; } - mgr.add( name, id, g->u.get_faction()->id, false, true, position->first, - position->second, options ); + if (position->first.z != position->second.z) { + popup(_("The zone start and end should be on the same z-level!")); + break; + } + + mgr.add( name, id, g->u.get_faction()->id, false, true, position->first, position->second, options ); zones = get_zones(); active_index = zone_cnt - 1; From 848cca0b37dc9778d4d3f841b2593a919aca28e7 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 22 Aug 2024 17:25:52 +0000 Subject: [PATCH 2/3] style(autofix.ci): automated formatting --- src/clzones.cpp | 49 +++++++++++++++++++++++++------------------------ src/game.cpp | 7 ++++--- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/clzones.cpp b/src/clzones.cpp index 71c95a0197c3..0a7f6bb92593 100644 --- a/src/clzones.cpp +++ b/src/clzones.cpp @@ -675,24 +675,25 @@ bool zone_manager::has( const zone_type_id &type, const tripoint &where, return point_set.find( where ) != point_set.end() || vzone_set.find( where ) != vzone_set.end(); } -bool zone_manager::has_near( const zone_type_id &type, const tripoint &where, int range, const faction_id &fac ) const +bool zone_manager::has_near( const zone_type_id &type, const tripoint &where, int range, + const faction_id &fac ) const { const auto &point_set = get_point_set( type, fac ); for( auto &point : point_set ) { //if( point.z == where.z ) { - if( square_dist( point, where ) <= range ) { - return true; - } - // } + if( square_dist( point, where ) <= range ) { + return true; + } + // } } const auto &vzone_set = get_vzone_set( type, fac ); for( auto &point : vzone_set ) { - // if( point.z == where.z ) { - if( square_dist( point, where ) <= range ) { - return true; - } - // } + // if( point.z == where.z ) { + if( square_dist( point, where ) <= range ) { + return true; + } + // } } return false; @@ -752,31 +753,31 @@ std::unordered_set zone_manager::get_near( const zone_type_id &type, for( auto &point : point_set ) { //if( point.z == where.z ) { - if( square_dist( point, where ) <= range ) { - if( it && has( zone_LOOT_CUSTOM, point ) ) { - if( custom_loot_has( point, it ) ) { - near_point_set.insert( point ); - } - } else { + if( square_dist( point, where ) <= range ) { + if( it && has( zone_LOOT_CUSTOM, point ) ) { + if( custom_loot_has( point, it ) ) { near_point_set.insert( point ); } + } else { + near_point_set.insert( point ); } + } //} } const auto &vzone_set = get_vzone_set( type, fac ); for( auto &point : vzone_set ) { - // if( point.z == where.z ) { - if( square_dist( point, where ) <= range ) { - if( it && has( zone_LOOT_CUSTOM, point ) ) { - if( custom_loot_has( point, it ) ) { - near_point_set.insert( point ); - } - } else { + // if( point.z == where.z ) { + if( square_dist( point, where ) <= range ) { + if( it && has( zone_LOOT_CUSTOM, point ) ) { + if( custom_loot_has( point, it ) ) { near_point_set.insert( point ); } + } else { + near_point_set.insert( point ); } - // } + } + // } } return near_point_set; diff --git a/src/game.cpp b/src/game.cpp index cb203d65e55c..594d4c4b65a7 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -6395,12 +6395,13 @@ void game::zones_manager() break; } - if (position->first.z != position->second.z) { - popup(_("The zone start and end should be on the same z-level!")); + if( position->first.z != position->second.z ) { + popup( _( "The zone start and end should be on the same z-level!" ) ); break; } - mgr.add( name, id, g->u.get_faction()->id, false, true, position->first, position->second, options ); + mgr.add( name, id, g->u.get_faction()->id, false, true, position->first, position->second, + options ); zones = get_zones(); active_index = zone_cnt - 1; From d48d2e39d14de080dd13066051f662bd7d2af106 Mon Sep 17 00:00:00 2001 From: Static Variable Date: Thu, 22 Aug 2024 20:52:04 -0400 Subject: [PATCH 3/3] removed commented out lines --- src/clzones.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/clzones.cpp b/src/clzones.cpp index 0a7f6bb92593..117ae6cf4b2f 100644 --- a/src/clzones.cpp +++ b/src/clzones.cpp @@ -680,20 +680,16 @@ bool zone_manager::has_near( const zone_type_id &type, const tripoint &where, in { const auto &point_set = get_point_set( type, fac ); for( auto &point : point_set ) { - //if( point.z == where.z ) { if( square_dist( point, where ) <= range ) { return true; } - // } } const auto &vzone_set = get_vzone_set( type, fac ); for( auto &point : vzone_set ) { - // if( point.z == where.z ) { if( square_dist( point, where ) <= range ) { return true; } - // } } return false; @@ -752,7 +748,6 @@ std::unordered_set zone_manager::get_near( const zone_type_id &type, auto near_point_set = std::unordered_set(); for( auto &point : point_set ) { - //if( point.z == where.z ) { if( square_dist( point, where ) <= range ) { if( it && has( zone_LOOT_CUSTOM, point ) ) { if( custom_loot_has( point, it ) ) { @@ -762,12 +757,10 @@ std::unordered_set zone_manager::get_near( const zone_type_id &type, near_point_set.insert( point ); } } - //} } const auto &vzone_set = get_vzone_set( type, fac ); for( auto &point : vzone_set ) { - // if( point.z == where.z ) { if( square_dist( point, where ) <= range ) { if( it && has( zone_LOOT_CUSTOM, point ) ) { if( custom_loot_has( point, it ) ) { @@ -777,7 +770,6 @@ std::unordered_set zone_manager::get_near( const zone_type_id &type, near_point_set.insert( point ); } } - // } } return near_point_set;