Skip to content

Commit

Permalink
Merge branch 'CleverRaven:master' into afs-geist
Browse files Browse the repository at this point in the history
  • Loading branch information
Standing-Storm authored Jan 9, 2025
2 parents 66c795a + b0eb712 commit 2e847c6
Show file tree
Hide file tree
Showing 30 changed files with 433 additions and 734 deletions.
7 changes: 1 addition & 6 deletions src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3827,12 +3827,7 @@ void craft_activity_actor::do_turn( player_activity &act, Character &crafter )
if( rec.is_practice() && !is_long && craft.get_making_batch_size() == 1 ) {
if( query_yn( _( "Keep practicing until proficiency increases?" ) ) ) {
is_long = true;
// TODO: Remove when craft_command is typed
std::optional<tripoint> tmp;
if( location.has_value() ) {
tmp = location.value().raw();
}
*( crafter.last_craft ) = craft_command( &craft.get_making(), 1, is_long, &crafter, tmp );
*( crafter.last_craft ) = craft_command( &craft.get_making(), 1, is_long, &crafter, location );
}
}
item craft_copy = craft;
Expand Down
20 changes: 2 additions & 18 deletions src/craft_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,26 +113,10 @@ template void comp_selection<item_comp>::serialize( JsonOut &jsout ) const;
template void comp_selection<tool_comp>::deserialize( const JsonObject &data );
template void comp_selection<item_comp>::deserialize( const JsonObject &data );

void craft_command::execute( const std::optional<tripoint> &new_loc )
{
// TODO: Get rid of this when operation typified.
std::optional<tripoint_bub_ms> temp;
if( new_loc.has_value() ) {
temp = tripoint_bub_ms( new_loc.value() );
}

loc = temp;

execute();
}

void craft_command::execute( const std::optional<tripoint_bub_ms> &new_loc )
{
std::optional<tripoint> tmp;
if( new_loc.has_value() ) {
tmp = new_loc.value().raw();
}
craft_command::execute( tmp );
loc = new_loc;
execute();
}

void craft_command::execute( bool only_cache_comps )
Expand Down
4 changes: 1 addition & 3 deletions src/craft_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,13 @@ class craft_command
/** Instantiates an empty craft_command, which can't be executed. */
craft_command() = default;
craft_command( const recipe *to_make, int batch_size, bool is_long, Character *crafter,
const std::optional<tripoint> &loc ) :
const std::optional<tripoint_bub_ms> &loc ) :
rec( to_make ), batch_size( batch_size ), longcraft( is_long ), crafter( crafter ), loc( loc ) {}

/**
* Selects components to use for the craft, then assigns the crafting activity to 'crafter'.
* Executes with supplied location, std::nullopt means crafting from inventory.
*/
// TODO: Get rid of untyped overload
void execute( const std::optional<tripoint> &new_loc );
void execute( const std::optional<tripoint_bub_ms> &new_loc );
/** Executes with saved location, NOT the same as execute( std::nullopt )! */
void execute( bool only_cache_comps = false );
Expand Down
8 changes: 1 addition & 7 deletions src/crafting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,13 +721,7 @@ void Character::make_craft_with_command( const recipe_id &id_to_make, int batch_
return;
}

// TODO: Get rid of this when craft_command is typified.
std::optional<tripoint> temp;
if( loc.has_value() ) {
temp = loc.value().raw();
}

*last_craft = craft_command( &recipe_to_make, batch_size, is_long, this, temp );
*last_craft = craft_command( &recipe_to_make, batch_size, is_long, this, loc );
last_craft->execute();
}

Expand Down
20 changes: 10 additions & 10 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8034,9 +8034,9 @@ static void add_item_recursive( std::vector<std::string> &item_order,

if( std::find( item_order.begin(), item_order.end(), name ) == item_order.end() ) {
item_order.push_back( name );
temp_items[name] = map_item_stack( it, relative_pos.raw() );
temp_items[name] = map_item_stack( it, relative_pos );
} else {
temp_items[name].add_at_pos( it, relative_pos.raw() );
temp_items[name].add_at_pos( it, relative_pos );
}

for( const item *content : it->all_known_contents() ) {
Expand Down Expand Up @@ -8459,7 +8459,7 @@ game::vmenu_ret game::list_items( const std::vector<map_item_stack> &item_list )
max_name_width = max_name_width + padding + 6 + ( highlight_unread_items ? std::max(
item_new_str_width, item_maybe_new_str_width ) : 0 );

tripoint active_pos;
tripoint_rel_ms active_pos;
map_item_stack *activeItem = nullptr;

catacurses::window w_items;
Expand All @@ -8484,7 +8484,7 @@ game::vmenu_ret game::list_items( const std::vector<map_item_stack> &item_list )
point( offsetX, TERMY - iInfoHeight ) );

if( activeItem ) {
centerlistview( active_pos, width );
centerlistview( active_pos.raw(), width );
}

ui.position( point( offsetX, 0 ), point( width, TERMY ) );
Expand Down Expand Up @@ -8630,16 +8630,16 @@ game::vmenu_ret game::list_items( const std::vector<map_item_stack> &item_list )
}
trim_and_print( w_items, point( 1, iNum - iStartPos ), width_nob - padding - new_width, col,
sText );
const point p( iter->vIG[iThisPage].pos.xy() );
const point_rel_ms p( iter->vIG[iThisPage].pos.xy() );
if( print_new ) {
// +1 move space between item description and "new"
mvwprintz( w_items, point( width_nob - right_padding - new_width + 1, iNum - iStartPos ), *new_col,
*new_str );
}
mvwprintz( w_items, point( width_nob - right_padding, iNum - iStartPos ),
iNum == iActive ? c_light_green : c_light_gray,
"%2d %s", rl_dist( point::zero, p ),
direction_name_short( direction_from( point::zero, p ) ) );
"%2d %s", rl_dist( point_rel_ms::zero, p ),
direction_name_short( direction_from( point_rel_ms::zero, p ) ) );
++iter;
}
// ITEM DESCRIPTION
Expand Down Expand Up @@ -8701,7 +8701,7 @@ game::vmenu_ret game::list_items( const std::vector<map_item_stack> &item_list )
do {
bool recalc_unread = false;
if( action == "COMPARE" && activeItem ) {
game_menus::inv::compare( active_pos );
game_menus::inv::compare( active_pos.raw() );
recalc_unread = highlight_unread_items;
} else if( action == "FILTER" ) {
ui.invalidate_ui();
Expand Down Expand Up @@ -8910,7 +8910,7 @@ game::vmenu_ret game::list_items( const std::vector<map_item_stack> &item_list )
return game::vmenu_ret::CHANGE_TAB;
}

active_pos = tripoint::zero;
active_pos = tripoint_rel_ms::zero;
activeItem = nullptr;

if( mSortCategory[iActive].empty() ) {
Expand All @@ -8927,7 +8927,7 @@ game::vmenu_ret game::list_items( const std::vector<map_item_stack> &item_list )
}

if( activeItem ) {
centerlistview( active_pos, width );
centerlistview( active_pos.raw(), width );
trail_start = u.pos_bub();
trail_end = u.pos_bub() + active_pos;
// Actually accessed from the terrain overlay callback `trail_cb` in the
Expand Down
24 changes: 13 additions & 11 deletions src/handle_liquid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "character.h"
#include "colony.h"
#include "color.h"
#include "coordinates.h"
#include "debug.h"
#include "enums.h"
#include "game_inventory.h"
Expand Down Expand Up @@ -61,7 +62,8 @@ static void serialize_liquid_source( player_activity &act, const vehicle &veh, c
act.str_values.push_back( serialize( liquid ) );
}

static void serialize_liquid_source( player_activity &act, const tripoint &pos, const item &liquid )
static void serialize_liquid_source( player_activity &act, const tripoint_bub_ms &pos,
const item &liquid )
{
const map_stack stack = get_map().i_at( pos );
// Need to store the *index* of the item on the ground, but it may be a virtual item from
Expand All @@ -76,7 +78,7 @@ static void serialize_liquid_source( player_activity &act, const tripoint &pos,
act.values.push_back( static_cast<int>( liquid_source_type::MAP_ITEM ) );
act.values.push_back( std::distance( stack.begin(), iter ) );
}
act.coords.push_back( pos );
act.coords.push_back( pos.raw() );
act.str_values.push_back( serialize( liquid ) );
}

Expand Down Expand Up @@ -138,7 +140,7 @@ bool handle_all_liquids_from_container( item_location &container, int radius )

// todo: remove in favor of the item_location version
static bool get_liquid_target( item &liquid, const item *const source, const int radius,
const tripoint *const source_pos,
const tripoint_bub_ms *const source_pos,
const vehicle *const source_veh,
const monster *const source_mon,
liquid_dest_opt &target )
Expand Down Expand Up @@ -258,7 +260,7 @@ static bool get_liquid_target( item &liquid, const item *const source, const int
if( !iexamine::has_keg( target_pos ) ) {
continue;
}
if( source_pos != nullptr && *source_pos == target_pos.raw() ) {
if( source_pos != nullptr && *source_pos == target_pos ) {
continue;
}
const std::string dir = direction_name( direction_from( player_character.pos_bub(), target_pos ) );
Expand Down Expand Up @@ -286,7 +288,7 @@ static bool get_liquid_target( item &liquid, const item *const source, const int
}
target.pos = *target_pos_;

if( source_pos != nullptr && *source_pos == target.pos ) {
if( source_pos != nullptr && source_pos->raw() == target.pos ) {
add_msg( m_info, _( "That's where you took it from!" ) );
return;
}
Expand Down Expand Up @@ -322,17 +324,17 @@ static bool get_liquid_target( item &liquid, const item *const source, const int
static bool get_liquid_target( item_location &liquid, const item *const source, const int radius,
liquid_dest_opt &target )
{
const tripoint *source_pos = nullptr;
const tripoint_bub_ms *source_pos = nullptr;
const vehicle *source_veh = nullptr;
const monster *source_mon = nullptr;

tripoint pos;
tripoint_bub_ms pos;
switch( liquid.where() ) {
case item_location::type::container:
// intentionally empty
break;
case item_location::type::map:
pos = liquid.position();
pos = liquid.pos_bub();
source_pos = &pos;
break;
case item_location::type::vehicle:
Expand Down Expand Up @@ -439,7 +441,7 @@ bool perform_liquid_transfer( item_location &liquid, liquid_dest_opt &target )
return true;
} else if( liquid.where() == item_location::type::map ) {
player_character.assign_activity( ACT_FILL_LIQUID );
serialize_liquid_source( player_character.activity, liquid.position(), *liquid );
serialize_liquid_source( player_character.activity, liquid.pos_bub(), *liquid );
return true;
} else {
return false;
Expand All @@ -466,7 +468,7 @@ bool perform_liquid_transfer( item_location &liquid, liquid_dest_opt &target )
}

// todo: Remove in favor of the item_location version.
bool perform_liquid_transfer( item &liquid, const tripoint *const source_pos,
bool perform_liquid_transfer( item &liquid, const tripoint_bub_ms *const source_pos,
const vehicle *const source_veh, const int part_num,
const monster *const /*source_mon*/, liquid_dest_opt &target )
{
Expand Down Expand Up @@ -526,7 +528,7 @@ bool can_handle_liquid( const item &liquid )
}

bool handle_liquid( item &liquid, const item *const source, const int radius,
const tripoint *const source_pos,
const tripoint_bub_ms *const source_pos,
const vehicle *const source_veh, const int part_num,
const monster *const source_mon )
{
Expand Down
4 changes: 2 additions & 2 deletions src/handle_liquid.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ bool can_handle_liquid( const item &liquid );
* indicates they want to handle it.
*/
bool handle_liquid( item &liquid, const item *source = nullptr, int radius = 0,
const tripoint *source_pos = nullptr,
const tripoint_bub_ms *source_pos = nullptr,
const vehicle *source_veh = nullptr, int part_num = -1,
const monster *source_mon = nullptr );
bool handle_liquid( item_location &liquid, const item *source = nullptr, int radius = 0 );

/* Not to be used directly. Use liquid_handler::handle_liquid instead. */
bool perform_liquid_transfer( item &liquid, const tripoint *source_pos,
bool perform_liquid_transfer( item &liquid, const tripoint_bub_ms *source_pos,
const vehicle *source_veh, int part_num,
const monster * /*source_mon*/, liquid_dest_opt &target );
bool perform_liquid_transfer( item_location &liquid, liquid_dest_opt &target );
Expand Down
2 changes: 1 addition & 1 deletion src/iexamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4729,7 +4729,7 @@ void iexamine::water_source( Character &, const tripoint_bub_ms &examp )
{
map &here = get_map();
item water = here.liquid_from( examp );
liquid_handler::handle_liquid( water, nullptr, 0, &examp.raw() );
liquid_handler::handle_liquid( water, nullptr, 0, &examp );
}

void iexamine::finite_water_source( Character &, const tripoint_bub_ms &examp )
Expand Down
5 changes: 0 additions & 5 deletions src/lightmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,11 +804,6 @@ map::apparent_light_info map::apparent_light_helper( const level_cache &map_cach
return { obstructed, abs_obstructed, apparent_light };
}

lit_level map::apparent_light_at( const tripoint &p, const visibility_variables &cache ) const
{
return apparent_light_at( tripoint_bub_ms( p ), cache );
}

lit_level map::apparent_light_at( const tripoint_bub_ms &p,
const visibility_variables &cache ) const
{
Expand Down
Loading

0 comments on commit 2e847c6

Please sign in to comment.