Skip to content

Commit

Permalink
sundry typification (#78985)
Browse files Browse the repository at this point in the history
* sundry typification

* demanded work around
  • Loading branch information
PatrikLundell authored Jan 7, 2025
1 parent 0534a82 commit befd448
Show file tree
Hide file tree
Showing 77 changed files with 556 additions and 585 deletions.
2 changes: 1 addition & 1 deletion src/ballistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ dealt_projectile_attack projectile_attack( const projectile &proj_arg,

static emit_id muzzle_smoke( "emit_smaller_smoke_plume" );
if( proj_effects.count( ammo_effect_MUZZLE_SMOKE ) ) {
here.emit_field( trajectory.front().raw(), muzzle_smoke );
here.emit_field( trajectory.front(), muzzle_smoke );
}

if( !no_overshoot && range < extend_to_range ) {
Expand Down
2 changes: 1 addition & 1 deletion src/cata_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,7 @@ void cata_tiles::draw( const point &dest, const tripoint_bub_ms &center, int wid
// Add scent type to the overlay_strings list for every visible tile when
// displaying scent
if( g->display_overlay_state( ACTION_DISPLAY_SCENT_TYPE ) && !invisible[0] ) {
const scenttype_id scent_type = get_scent().get_type( pos.raw() );
const scenttype_id scent_type = get_scent().get_type( pos );
if( !scent_type.is_empty() ) {
here.overlay_strings_cache.emplace( player_to_screen( point_bub_ms( x, y ) ) + half_tile,
formatted_text( scent_type.c_str(),
Expand Down
2 changes: 1 addition & 1 deletion src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7149,7 +7149,7 @@ bool Character::invoke_item( item *used, const std::string &method, const tripoi
}

std::optional<int> charges_used = actually_used->type->invoke( this, *actually_used,
pt.raw(), method );
pt, method );
if( !charges_used.has_value() ) {
set_moves( pre_obtain_moves );
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/character_escape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ bool Character::try_remove_grab( bool attacking )
pd[index]->get_name(), sturdiness, chance );
// the item is ripped off your character
if( sturdiness < chance ) {
pd[index]->spill_contents( adjacent_tile().raw() );
pd[index]->spill_contents( adjacent_tile() );
add_msg_player_or_npc( m_bad,
_( "As you struggle to escape the grab something comes loose and falls to the ground!" ),
_( "As <npcname> struggles to escape the grab something comes loose and falls to the ground!" ) );
Expand Down
4 changes: 2 additions & 2 deletions src/consumption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ static bool eat( item &food, Character &you, bool force )
int charges_used = 0;
if( food.type->has_use() ) {
if( !food.type->can_use( "PETFOOD" ) ) {
charges_used = food.type->invoke( &you, food, you.pos() ).value_or( 0 );
charges_used = food.type->invoke( &you, food, you.pos_bub() ).value_or( 0 );
if( charges_used <= 0 ) {
return false;
}
Expand Down Expand Up @@ -1878,7 +1878,7 @@ static bool consume_med( item &target, Character &you )

int amount_used = 1;
if( target.type->has_use() ) {
amount_used = target.type->invoke( &you, target, you.pos() ).value_or( 0 );
amount_used = target.type->invoke( &you, target, you.pos_bub() ).value_or( 0 );
if( amount_used <= 0 ) {
return false;
}
Expand Down
5 changes: 0 additions & 5 deletions src/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,6 @@ tripoint_bub_ms Creature::pos_bub() const
return get_map().bub_from_abs( location );
}

void Creature::setpos( const tripoint &p, bool check_gravity/* = true*/ )
{
Creature::setpos( tripoint_bub_ms( p ), check_gravity );
}

void Creature::setpos( const tripoint_bub_ms &p, bool check_gravity/* = true*/ )
{
const tripoint_abs_ms old_loc = get_location();
Expand Down
2 changes: 0 additions & 2 deletions src/creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,6 @@ class Creature : public viewer
return get_location().z();
}
virtual void gravity_check();
// TODO: Get rid of untyped overload
void setpos( const tripoint &p, bool check_gravity = true );
void setpos( const tripoint_bub_ms &p, bool check_gravity = true );

/** Checks if the creature fits confortably into a given tile. */
Expand Down
4 changes: 2 additions & 2 deletions src/do_turn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,10 @@ bool do_turn()
scent_map &scent = get_scent();
// No-scent debug mutation has to be processed here or else it takes time to start working
if( !u.has_flag( STATIC( json_character_flag( "NO_SCENT" ) ) ) ) {
scent.set( u.pos(), u.scent, u.get_type_of_scent() );
scent.set( u.pos_bub(), u.scent, u.get_type_of_scent() );
overmap_buffer.set_scent( u.global_omt_location(), u.scent );
}
scent.update( u.pos(), m );
scent.update( u.pos_bub(), m );

// We need floor cache before checking falling 'n stuff
m.build_floor_caches();
Expand Down
2 changes: 1 addition & 1 deletion src/faction_camp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5415,7 +5415,7 @@ drop_locations basecamp::get_equipment( tinymap *target_bay, const tripoint_omt_
inventory_multiselector inv_s( *pc, preset, msg,
make_raw_stats, /*allow_select_contained =*/ true );

inv_s.add_remote_map_items( target_bay, target.raw() );
inv_s.add_remote_map_items( target_bay, target );
inv_s.set_title( title );
inv_s.set_hint( _( "To select items, type a number before selecting." ) );

Expand Down
10 changes: 5 additions & 5 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11265,7 +11265,7 @@ point_rel_sm game::place_player( const tripoint_bub_ms &dest_loc, bool quick )
( !get_option<bool>( "AUTO_PICKUP_SAFEMODE" ) ||
!u.get_mon_visible().has_dangerous_creature_in_proximity ) &&
( m.has_items( u.pos_bub() ) || get_option<bool>( "AUTO_PICKUP_ADJACENT" ) ) ) {
Pickup::autopickup( u.pos() );
Pickup::autopickup( u.pos_bub() );
}

// If the new tile is a boardable part, board it
Expand Down Expand Up @@ -12902,7 +12902,7 @@ point_rel_sm game::update_map( int &x, int &y, bool z_level_changed )

if( shift == point_rel_sm::zero ) {
// adjust player position
u.setpos( tripoint( x, y, m.get_abs_sub().z() ) );
u.setpos( tripoint_bub_ms( x, y, m.get_abs_sub().z() ) );
if( z_level_changed ) {
// Update what parts of the world map we can see
// We may be able to see farther now that the z-level has changed.
Expand Down Expand Up @@ -12940,12 +12940,12 @@ point_rel_sm game::update_map( int &x, int &y, bool z_level_changed )
}
}

scent.shift( shift_ms.raw() );
scent.shift( shift_ms );

// Also ensure the player is on current z-level
// m.get_abs_sub().z should later be removed, when there is no longer such a thing
// as "current z-level"
u.setpos( tripoint( x, y, m.get_abs_sub().z() ) );
u.setpos( tripoint_bub_ms( x, y, m.get_abs_sub().z() ) );

// Only do the loading after all coordinates have been shifted.

Expand Down Expand Up @@ -13192,7 +13192,7 @@ void game::display_scent()
return;
}
shared_ptr_fast<game::draw_callback_t> scent_cb = make_shared_fast<game::draw_callback_t>( [&]() {
scent.draw( w_terrain, div * 2, u.pos_bub().raw() + u.view_offset.raw() );
scent.draw( w_terrain, div * 2, u.pos_bub() + u.view_offset );
} );
g->add_draw_callback( scent_cb );

Expand Down
35 changes: 20 additions & 15 deletions src/game_inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2205,17 +2205,32 @@ drop_locations game_menus::inv::multidrop( Character &you )

drop_locations game_menus::inv::pickup( const std::optional<tripoint> &target,
const std::vector<drop_location> &selection )
{
std::optional<tripoint_bub_ms> tmp;
if( target.has_value() ) {
tmp = tripoint_bub_ms( target.value() );
}
return game_menus::inv::pickup( tmp, selection );
}

drop_locations game_menus::inv::pickup( const std::optional<tripoint_bub_ms> &target,
const std::vector<drop_location> &selection )
{
avatar &you = get_avatar();
pickup_inventory_preset preset( you, /*skip_wield_check=*/true, /*ignore_liquidcont=*/true );
preset.save_state = &pickup_ui_default_state;

pickup_selector pick_s( you, preset, _( "ITEMS TO PICK UP" ), target );
std::optional<tripoint> tmp;
if( target.has_value() ) {
tmp = target.value().raw();
}

pickup_selector pick_s( you, preset, _( "ITEMS TO PICK UP" ), tmp );

// Add items from the selected tile, or from current and all surrounding tiles
if( target ) {
pick_s.add_vehicle_items( *target );
pick_s.add_map_items( *target );
pick_s.add_vehicle_items( tripoint_bub_ms( *target ) );
pick_s.add_map_items( tripoint_bub_ms( *target ) );
} else {
pick_s.add_nearby_items();
}
Expand All @@ -2237,16 +2252,6 @@ drop_locations game_menus::inv::pickup( const std::optional<tripoint> &target,
return pick_s.execute();
}

drop_locations game_menus::inv::pickup( const std::optional<tripoint_bub_ms> &target,
const std::vector<drop_location> &selection )
{
std::optional<tripoint> tmp;
if( target.has_value() ) {
tmp = target.value().raw();
}
return game_menus::inv::pickup( tmp, selection );
}

class smokable_selector_preset : public inventory_selector_preset
{
public:
Expand Down Expand Up @@ -2412,8 +2417,8 @@ void game_menus::inv::compare( const std::optional<tripoint> &offset )
inv_s.set_hint( _( "Select two items to compare them." ) );

if( offset ) {
inv_s.add_map_items( you.pos() + *offset );
inv_s.add_vehicle_items( you.pos() + *offset );
inv_s.add_map_items( you.pos_bub() + *offset );
inv_s.add_vehicle_items( you.pos_bub() + *offset );
} else {
inv_s.add_nearby_items();
}
Expand Down
2 changes: 1 addition & 1 deletion src/handle_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ static void haul()
break;
case 2: {
inventory_haul_selector selector( player_character );
selector.add_map_items( player_character.pos() );
selector.add_map_items( player_character.pos_bub() );
selector.apply_selection( player_character.haul_list );
selector.set_title( _( "Select items to haul" ) );
selector.set_hint( _( "To select x items, type a number before selecting." ) );
Expand Down
28 changes: 14 additions & 14 deletions src/inventory_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1873,7 +1873,7 @@ void selection_column::on_change( const inventory_entry &entry )
}
}
const item_category *inventory_selector::naturalize_category( const item_category &category,
const tripoint &pos )
const tripoint_bub_ms &pos )
{
const auto find_cat_by_id = [ this ]( const item_category_id & id ) {
const auto iter = std::find_if( categories.begin(),
Expand All @@ -1883,10 +1883,10 @@ const item_category *inventory_selector::naturalize_category( const item_categor
return iter != categories.end() ? &*iter : nullptr;
};

const int dist = rl_dist( u.pos_bub().raw(), pos );
const int dist = rl_dist( u.pos_bub(), pos );

if( dist != 0 ) {
const std::string suffix = direction_suffix( u.pos_bub().raw(), pos );
const std::string suffix = direction_suffix( u.pos_bub(), pos );
const item_category_id id = item_category_id( string_format( "%s_%s", category.get_id().c_str(),
suffix.c_str() ) );

Expand Down Expand Up @@ -2109,7 +2109,7 @@ void inventory_selector::add_character_ebooks( Character &character )
}
}

void inventory_selector::add_map_items( const tripoint &target )
void inventory_selector::add_map_items( const tripoint_bub_ms &target )
{
map &here = get_map();
if( here.accessible_items( target ) ) {
Expand All @@ -2122,7 +2122,7 @@ void inventory_selector::add_map_items( const tripoint &target )
}
}

void inventory_selector::add_vehicle_items( const tripoint &target )
void inventory_selector::add_vehicle_items( const tripoint_bub_ms &target )
{
const std::optional<vpart_reference> ovp = get_map().veh_at( target ).cargo();
if( !ovp ) {
Expand All @@ -2138,7 +2138,7 @@ void inventory_selector::add_vehicle_items( const tripoint &target )
} );
}

void inventory_selector::_add_map_items( tripoint const &target, item_category const &cat,
void inventory_selector::_add_map_items( tripoint_bub_ms const &target, item_category const &cat,
item_stack &items, std::function<item_location( item & )> const &floc )
{
bool const hierarchy = _uimode == uimode::hierarchy;
Expand Down Expand Up @@ -2170,19 +2170,19 @@ void inventory_selector::add_nearby_items( int radius )
!here.clear_path( u.pos_bub(), pos, rl_dist( u.pos_bub(), pos ), 1, 100 ) ) {
continue;
}
add_map_items( pos.raw() );
add_vehicle_items( pos.raw() );
add_map_items( pos );
add_vehicle_items( pos );
}
}
}

void inventory_selector::add_remote_map_items( tinymap *remote_map, const tripoint &target )
void inventory_selector::add_remote_map_items( tinymap *remote_map, const tripoint_omt_ms &target )
{
map_stack items = remote_map->i_at( target );
const std::string name = to_upper_case( remote_map->name( tripoint_omt_ms( target ) ) );
const std::string name = to_upper_case( remote_map->name( target ) );
const item_category map_cat( name, no_translation( name ), translation(), 100 );
_add_map_items( target, map_cat, items, [target]( item & it ) {
return item_location( map_cursor( tripoint_bub_ms( target ) ), &it );
_add_map_items( rebase_bub( target ), map_cat, items, [target]( item & it ) {
return item_location( map_cursor( rebase_bub( target ) ), &it );
} );
}

Expand All @@ -2191,7 +2191,7 @@ void inventory_selector::add_basecamp_items( const basecamp &camp )
std::unordered_set<tripoint_abs_ms> tiles = camp.get_storage_tiles();
map &here = get_map();
for( tripoint_abs_ms tile : tiles ) {
add_map_items( here.bub_from_abs( tile ).raw() );
add_map_items( here.bub_from_abs( tile ) );
}
}

Expand Down Expand Up @@ -3176,7 +3176,7 @@ void inventory_selector::_uncategorize( inventory_column &col )
if( ancestor.where() != item_location::type::character ) {
const std::string name = to_upper_case( remove_color_tags( ancestor.describe() ) );
const item_category map_cat( name, no_translation( name ), translation(), 100 );
custom_category = naturalize_category( map_cat, ancestor.position() );
custom_category = naturalize_category( map_cat, ancestor.pos_bub() );
} else {
custom_category = wielded_worn_category( ancestor, u );
}
Expand Down
10 changes: 5 additions & 5 deletions src/inventory_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -617,10 +617,10 @@ class inventory_selector
void add_contained_ebooks( item_location &container );
void add_character_items( Character &character );
void add_character_ebooks( Character &character );
void add_map_items( const tripoint &target );
void add_vehicle_items( const tripoint &target );
void add_map_items( const tripoint_bub_ms &target );
void add_vehicle_items( const tripoint_bub_ms &target );
void add_nearby_items( int radius = 1 );
void add_remote_map_items( tinymap *remote_map, const tripoint &target );
void add_remote_map_items( tinymap *remote_map, const tripoint_omt_ms &target );
void add_basecamp_items( const basecamp &camp );
/** Remove all items */
void clear_items();
Expand Down Expand Up @@ -686,7 +686,7 @@ class inventory_selector
input_context ctxt;

const item_category *naturalize_category( const item_category &category,
const tripoint &pos );
const tripoint_bub_ms &pos );

inventory_entry *add_entry( inventory_column &target_column,
std::vector<item_location> &&locations,
Expand Down Expand Up @@ -798,7 +798,7 @@ class inventory_selector
void draw_footer( const catacurses::window &w ) const;
void draw_columns( const catacurses::window &w );
void draw_frame( const catacurses::window &w ) const;
void _add_map_items( tripoint const &target, item_category const &cat, item_stack &items,
void _add_map_items( tripoint_bub_ms const &target, item_category const &cat, item_stack &items,
std::function<item_location( item & )> const &floc );

public:
Expand Down
Loading

0 comments on commit befd448

Please sign in to comment.