Skip to content

Commit 94f7f3c

Browse files
committed
2 parents a4dd5e8 + 726816a commit 94f7f3c

File tree

4 files changed

+33
-38
lines changed

4 files changed

+33
-38
lines changed

src/activity_actor.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9059,7 +9059,9 @@ bool butchery_activity_actor::initiate_butchery( player_activity &act, Character
90599059

90609060
if( !set_up_butchery( act, you, this_bd ) ) {
90619061
return false;
9062-
};
9062+
}
9063+
act.moves_total = to_moves<int>( this_bd.time_to_butcher );
9064+
act.moves_left = to_moves<int>( this_bd.time_to_butcher - this_bd.progress );
90639065
return true;
90649066
}
90659067

@@ -9137,16 +9139,16 @@ void butchery_activity_actor::do_turn( player_activity &act, Character &you )
91379139
}
91389140

91399141
if( this_bd->progress >= this_bd->time_to_butcher ) {
9142+
const butchery_data bd_copy = *this_bd;
9143+
bd.pop_back();
91409144
// this corpse is done
9141-
destroy_the_carcass( *this_bd, you );
9142-
if( bd.empty() ) {
9143-
act.moves_left = 0;
9144-
return;
9145-
} else {
9146-
bd.pop_back();
9147-
}
9145+
destroy_the_carcass( bd_copy, you );
9146+
// WARNING: destroy_the_carcass might spill acid, which gives the player the option to cancel this activity. If so, then `this` might be invalidated, along with all `butchery_data` elements. So here we need to be sure to not use either of those after this call.
91489147
} else {
91499148
this_bd->progress += 1_seconds;
9149+
// Uses max(1, ..) to prevent it going all the way to zero, which would stop the activity by the general `activity_actor` handling.
9150+
// Instead, the checks for `bd.empty()` will make sure to stop the activity by explicitly setting it to zero.
9151+
act.moves_left = std::max( 1, to_moves<int>( this_bd->time_to_butcher - this_bd->progress ) );
91509152
}
91519153
}
91529154

src/butchery.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ void destroy_the_carcass( const butchery_data &bd, Character &you )
11751175
you.recoil = MAX_RECOIL;
11761176

11771177
get_event_bus().send<event_type::character_butchered_corpse>( you.getID(),
1178-
corpse_item.get_mtype()->id, "ACT_" + io::enum_to_string<butcher_type>( bd.b_type ) );
1178+
corpse->id, "ACT_" + io::enum_to_string<butcher_type>( action ) );
11791179

11801180
}
11811181

src/overmap.cpp

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,38 +2355,22 @@ void overmap::place_roads( const std::vector<const overmap *> &neighbor_overmaps
23552355

23562356
// At least 3 exit points, to guarantee road continuity across overmaps
23572357
if( roads_out.size() < 3 ) {
2358-
2359-
// x and y coordinates for a point on the edge in each direction
2360-
// -1 represents a variable one dimensional coordinate along that edge
2361-
// east == point( OMAPX - 1, n ); north == point( n, 0 );
2362-
static constexpr std::array<int, 4> edge_coords_x = {OMAPX - 1, -1, 0, -1};
2363-
static constexpr std::array<int, 4> edge_coords_y = {-1, OMAPY - 1, -1, 0};
2364-
2365-
// all the points on an edge except the 10 on each end
2366-
std::array < int, OMAPX - 20 > omap_num;
2367-
for( int i = 0; i < OMAPX - 20; i++ ) {
2368-
omap_num[i] = i + 10;
2369-
}
2370-
2371-
std::array < size_t, 4 > dirs = {0, 1, 2, 3};
2372-
std::shuffle( dirs.begin(), dirs.end(), rng_get_engine() );
2373-
2374-
for( size_t dir : dirs ) {
2358+
for( const om_direction::type dir : om_direction::all ) {
23752359
// only potentially add a new random connection toward ungenerated overmaps
2376-
if( neighbor_overmaps[dir] == nullptr ) {
2377-
std::shuffle( omap_num.begin(), omap_num.end(), rng_get_engine() );
2378-
for( const int &i : omap_num ) {
2379-
tripoint_om_omt tmp = tripoint_om_omt(
2380-
edge_coords_x[dir] >= 0 ? edge_coords_x[dir] : i,
2381-
edge_coords_y[dir] >= 0 ? edge_coords_y[dir] : i,
2382-
0 );
2360+
if( neighbor_overmaps[static_cast<int>( dir )] == nullptr ) {
2361+
// all the points on an edge except the 10 on each corner
2362+
std::vector<tripoint_om_omt> border = get_border( dir, 0, 10 );
2363+
std::shuffle( border.begin(), border.end(), rng_get_engine() );
2364+
for( const tripoint_om_omt &p : border ) {
23832365
// Make sure these points don't conflict with rivers.
2384-
if( !( is_river( ter( tmp ) ) ||
2385-
// avoid adjacent rivers
2366+
if( !( is_river( ter( p ) ) ||
2367+
// avoid immediately adjacent rivers
23862368
// east/west of a point on the north/south edge, and vice versa
2387-
is_river( ter( tmp + point_rel_omt( four_adjacent_offsets[( dir + 1 ) % 4] ) ) ) ||
2388-
is_river( ter( tmp + point_rel_omt( four_adjacent_offsets[( dir + 3 ) % 4] ) ) ) ) ) {
2389-
roads_out.push_back( tmp );
2369+
is_river( ter( p + point_rel_omt(
2370+
four_adjacent_offsets[static_cast<int>( om_direction::turn_right( dir ) )] ) ) ) ||
2371+
is_river( ter( p + point_rel_omt(
2372+
four_adjacent_offsets[static_cast<int>( om_direction::turn_left( dir ) )] ) ) ) ) ) {
2373+
roads_out.push_back( p );
23902374
break;
23912375
}
23922376
}
@@ -2515,6 +2499,13 @@ std::vector<tripoint_om_omt> overmap::get_border( const point_rel_om &direction,
25152499
return get_neighbor_border( flip_direction, z, distance_corner );
25162500
}
25172501

2502+
std::vector<tripoint_om_omt> overmap::get_border( const om_direction::type direction, int z,
2503+
int distance_corner )
2504+
{
2505+
return get_border( point_rel_om( four_adjacent_offsets[static_cast<int>( direction )] ), z,
2506+
distance_corner );
2507+
}
2508+
25182509
void overmap::calculate_forestosity()
25192510
{
25202511
if( !settings->overmap_forest ) {

src/overmap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,8 @@ class overmap
847847
//gets border OMT points of this overmap in cardinal direction
848848
std::vector<tripoint_om_omt> get_border( const point_rel_om &direction, int z,
849849
int distance_corner );
850+
std::vector<tripoint_om_omt> get_border( om_direction::type direction, int z,
851+
int distance_corner );
850852
//gets border OMT points of the neighboring overmap in cardinal direction
851853
std::vector<tripoint_om_omt> get_neighbor_border( const point_rel_om &direction, int z,
852854
int distance_corner );

0 commit comments

Comments
 (0)