Skip to content

Commit

Permalink
Merge pull request #78753 from PatrikLundell/typify
Browse files Browse the repository at this point in the history
typified stuff
  • Loading branch information
Maleclypse authored Dec 26, 2024
2 parents ae78ca8 + af4d722 commit ef49525
Show file tree
Hide file tree
Showing 27 changed files with 255 additions and 254 deletions.
2 changes: 1 addition & 1 deletion src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6611,7 +6611,7 @@ void chop_tree_activity_actor::finish( player_activity &act, Character &who )
}
}

here.cut_down_tree( pos, direction.xy().raw() );
here.cut_down_tree( pos, direction.xy() );

who.add_msg_if_player( m_good, _( "You finish chopping down a tree." ) );
// sound of falling tree
Expand Down
42 changes: 21 additions & 21 deletions src/basecamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@

static const zone_type_id zone_type_CAMP_STORAGE( "CAMP_STORAGE" );

const std::map<point, base_camps::direction_data> base_camps::all_directions = {
const std::map<point_rel_omt, base_camps::direction_data> base_camps::all_directions = {
// direction, direction id, tab order, direction abbreviation with bracket, direction tab title
{ base_camps::base_dir, { "[B]", base_camps::TAB_MAIN, to_translation( "base camp: base", "[B]" ), to_translation( "base camp: base", " MAIN " ) } },
{ point::north, { "[N]", base_camps::TAB_N, to_translation( "base camp: north", "[N]" ), to_translation( "base camp: north", " [N] " ) } },
{ point::north_east, { "[NE]", base_camps::TAB_NE, to_translation( "base camp: northeast", "[NE]" ), to_translation( "base camp: northeast", " [NE] " ) } },
{ point::east, { "[E]", base_camps::TAB_E, to_translation( "base camp: east", "[E]" ), to_translation( "base camp: east", " [E] " ) } },
{ point::south_east, { "[SE]", base_camps::TAB_SE, to_translation( "base camp: southeast", "[SE]" ), to_translation( "base camp: southeast", " [SE] " ) } },
{ point::south, { "[S]", base_camps::TAB_S, to_translation( "base camp: south", "[S]" ), to_translation( "base camp: south", " [S] " ) } },
{ point::south_west, { "[SW]", base_camps::TAB_SW, to_translation( "base camp: southwest", "[SW]" ), to_translation( "base camp: southwest", " [SW] " ) } },
{ point::west, { "[W]", base_camps::TAB_W, to_translation( "base camp: west", "[W]" ), to_translation( "base camp: west", " [W] " ) } },
{ point::north_west, { "[NW]", base_camps::TAB_NW, to_translation( "base camp: northwest", "[NW]" ), to_translation( "base camp: northwest", " [NW] " ) } },
{ point_rel_omt::north, { "[N]", base_camps::TAB_N, to_translation( "base camp: north", "[N]" ), to_translation( "base camp: north", " [N] " ) } },
{ point_rel_omt::north_east, { "[NE]", base_camps::TAB_NE, to_translation( "base camp: northeast", "[NE]" ), to_translation( "base camp: northeast", " [NE] " ) } },
{ point_rel_omt::east, { "[E]", base_camps::TAB_E, to_translation( "base camp: east", "[E]" ), to_translation( "base camp: east", " [E] " ) } },
{ point_rel_omt::south_east, { "[SE]", base_camps::TAB_SE, to_translation( "base camp: southeast", "[SE]" ), to_translation( "base camp: southeast", " [SE] " ) } },
{ point_rel_omt::south, { "[S]", base_camps::TAB_S, to_translation( "base camp: south", "[S]" ), to_translation( "base camp: south", " [S] " ) } },
{ point_rel_omt::south_west, { "[SW]", base_camps::TAB_SW, to_translation( "base camp: southwest", "[SW]" ), to_translation( "base camp: southwest", " [SW] " ) } },
{ point_rel_omt::west, { "[W]", base_camps::TAB_W, to_translation( "base camp: west", "[W]" ), to_translation( "base camp: west", " [W] " ) } },
{ point_rel_omt::north_west, { "[NW]", base_camps::TAB_NW, to_translation( "base camp: northwest", "[NW]" ), to_translation( "base camp: northwest", " [NW] " ) } },
};

point base_camps::direction_from_id( const std::string &id )
point_rel_omt base_camps::direction_from_id( const std::string &id )
{
for( const auto &dir : all_directions ) {
if( dir.second.id == id ) {
Expand Down Expand Up @@ -132,9 +132,9 @@ basecamp::basecamp( const std::string &name_, const tripoint_abs_omt &omt_pos_ )
{
}

basecamp::basecamp( const std::string &name_, const tripoint &bb_pos_,
const std::vector<point> &directions_,
const std::map<point, expansion_data> &expansions_ )
basecamp::basecamp( const std::string &name_, const tripoint_abs_ms &bb_pos_,
const std::vector<point_rel_omt> &directions_,
const std::map<point_rel_omt, expansion_data> &expansions_ )
: directions( directions_ ), name( name_ ), bb_pos( bb_pos_ ), expansions( expansions_ )
{
}
Expand Down Expand Up @@ -171,14 +171,14 @@ void basecamp::add_expansion( const std::string &terrain, const tripoint_abs_omt
return;
}

const point dir = talk_function::om_simple_dir( omt_pos, new_pos );
const point_rel_omt dir = talk_function::om_simple_dir( omt_pos, new_pos );
expansions[ dir ] = parse_expansion( terrain, new_pos );
update_provides( terrain, expansions[ dir ] );
directions.push_back( dir );
}

void basecamp::add_expansion( const std::string &bldg, const tripoint_abs_omt &new_pos,
const point &dir )
const point_rel_omt &dir )
{
expansion_data e;
e.type = base_camps::faction_decode( bldg );
Expand Down Expand Up @@ -270,7 +270,7 @@ std::string basecamp::om_upgrade_description( const std::string &bldg, const map

// upgrade levels
// legacy next upgrade
std::string basecamp::next_upgrade( const point &dir, const int offset ) const
std::string basecamp::next_upgrade( const point_rel_omt &dir, const int offset ) const
{
const auto &e = expansions.find( dir );
if( e == expansions.end() ) {
Expand Down Expand Up @@ -303,7 +303,7 @@ bool basecamp::has_provides( const std::string &req, const expansion_data &e_dat
return false;
}

bool basecamp::has_provides( const std::string &req, const std::optional<point> &dir,
bool basecamp::has_provides( const std::string &req, const std::optional<point_rel_omt> &dir,
int level ) const
{
if( !dir ) {
Expand Down Expand Up @@ -345,7 +345,7 @@ bool basecamp::allowed_access_by( Character &guy, bool water_request ) const
return false;
}

std::vector<basecamp_upgrade> basecamp::available_upgrades( const point &dir )
std::vector<basecamp_upgrade> basecamp::available_upgrades( const point_rel_omt &dir )
{
std::vector<basecamp_upgrade> ret_data;
auto e = expansions.find( dir );
Expand Down Expand Up @@ -434,7 +434,7 @@ std::unordered_set<recipe_id> basecamp::recipe_deck_all() const
}

// recipes and craft support functions
std::map<recipe_id, translation> basecamp::recipe_deck( const point &dir ) const
std::map<recipe_id, translation> basecamp::recipe_deck( const point_rel_omt &dir ) const
{
std::map<recipe_id, translation> recipes;

Expand Down Expand Up @@ -492,7 +492,7 @@ void basecamp::update_provides( const std::string &bldg, expansion_data &e_data
}
}

void basecamp::update_in_progress( const std::string &bldg, const point &dir )
void basecamp::update_in_progress( const std::string &bldg, const point_rel_omt &dir )
{
if( !recipe_id( bldg ).is_valid() ) {
return;
Expand Down Expand Up @@ -945,7 +945,7 @@ void basecamp::form_crafting_inventory()
}

// display names
std::string basecamp::expansion_tab( const point &dir ) const
std::string basecamp::expansion_tab( const point_rel_omt &dir ) const
{
if( dir == base_camps::base_dir ) {
return _( "Base Missions" );
Expand Down
57 changes: 29 additions & 28 deletions src/basecamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ struct direction_data {
};

// base_dir and the eight directional points
extern const std::map<point, direction_data> all_directions;
extern const std::map<point_rel_omt, direction_data> all_directions;

point direction_from_id( const std::string &id );
point_rel_omt direction_from_id( const std::string &id );

constexpr point base_dir;
constexpr point_rel_omt base_dir;
const std::string prefix = "faction_base_";
const std::string id = "FACTION_CAMP";
const int prefix_len = 13;
Expand Down Expand Up @@ -139,8 +139,8 @@ struct expansion_salt_water_pipe_segment {
};

struct expansion_salt_water_pipe {
point expansion;
point connection_direction;
point_rel_omt expansion;
point_rel_omt connection_direction;
std::vector<expansion_salt_water_pipe_segment> segments;
};

Expand All @@ -160,9 +160,9 @@ class basecamp
public:
basecamp();
basecamp( const std::string &name_, const tripoint_abs_omt &omt_pos );
basecamp( const std::string &name_, const tripoint &bb_pos_,
const std::vector<point> &directions_,
const std::map<point, expansion_data> &expansions_ );
basecamp( const std::string &name_, const tripoint_abs_ms &bb_pos_,
const std::vector<point_rel_omt> &directions_,
const std::map<point_rel_omt, expansion_data> &expansions_ );
inline bool is_valid() const {
return !name.empty() && omt_pos != tripoint_abs_omt();
}
Expand All @@ -178,8 +178,8 @@ class basecamp
inline const std::string &camp_name() const {
return name;
}
tripoint get_bb_pos() const {
return bb_pos.raw();
tripoint_abs_ms get_bb_pos() const {
return bb_pos;
}
tripoint_abs_ms get_bb_pos_abs() const {
return bb_pos;
Expand All @@ -195,7 +195,7 @@ class basecamp
void set_by_radio( bool access_by_radio );

std::string board_name() const;
std::vector<point> directions; // NOLINT(cata-serialize)
std::vector<point_rel_omt> directions; // NOLINT(cata-serialize)
std::vector<std::vector<ui_mission_id>> hidden_missions;
std::vector<tripoint_abs_omt> fortifications;
std::vector<expansion_salt_water_pipe *> salt_water_pipes;
Expand All @@ -212,25 +212,25 @@ class basecamp
void scan_pseudo_items();
void add_expansion( const std::string &terrain, const tripoint_abs_omt &new_pos );
void add_expansion( const std::string &bldg, const tripoint_abs_omt &new_pos,
const point &dir );
const point_rel_omt &dir );
void define_camp( const tripoint_abs_omt &p, std::string_view camp_type,
bool player_founded = true );

std::string expansion_tab( const point &dir ) const;
std::string expansion_tab( const point_rel_omt &dir ) const;
// check whether the point is the part of camp
bool point_within_camp( const tripoint_abs_omt &p ) const;
// upgrade levels
bool has_provides( const std::string &req, const expansion_data &e_data, int level = 0 ) const;
bool has_provides( const std::string &req, const std::optional<point> &dir = std::nullopt,
bool has_provides( const std::string &req, const std::optional<point_rel_omt> &dir = std::nullopt,
int level = 0 ) const;
void update_resources( const std::string &bldg );
void update_provides( const std::string &bldg, expansion_data &e_data );
void update_in_progress( const std::string &bldg, const point &dir );
void update_in_progress( const std::string &bldg, const point_rel_omt &dir );

/// Returns the name of the building the current building @ref dir upgrades into,
/// "null" if there isn't one
std::string next_upgrade( const point &dir, int offset = 1 ) const;
std::vector<basecamp_upgrade> available_upgrades( const point &dir );
std::string next_upgrade( const point_rel_omt &dir, int offset = 1 ) const;
std::vector<basecamp_upgrade> available_upgrades( const point_rel_omt &dir );

// camp utility functions
int recruit_evaluation() const;
Expand Down Expand Up @@ -266,8 +266,8 @@ class basecamp
/// food_supply
bool distribute_food( bool player_command = true );
std::string name_display_of( const mission_id &miss_id );
void handle_hide_mission( const point &dir );
void handle_reveal_mission( const point &dir );
void handle_hide_mission( const point_rel_omt &dir );
void handle_reveal_mission( const point_rel_omt &dir );
bool has_water() const;
/// The number of days the current camp supplies lasts at the given exertion level.
int camp_food_supply_days( float exertion_level ) const;
Expand All @@ -286,7 +286,7 @@ class basecamp
void handle_takeover_by( faction_id new_owner, bool violent_takeover );
// recipes, gathering, and craft support functions
// from a direction
std::map<recipe_id, translation> recipe_deck( const point &dir ) const;
std::map<recipe_id, translation> recipe_deck( const point_rel_omt &dir ) const;
// from a building
std::map<recipe_id, translation> recipe_deck( const std::string &bldg ) const;
// All recipes known by NPCs stationed here + all recipes provided by all expansions
Expand Down Expand Up @@ -338,23 +338,24 @@ class basecamp
void place_results( const item &result );

// mission description functions
void add_available_recipes( mission_data &mission_key, mission_kind kind, const point &dir );
void add_available_recipes( mission_data &mission_key, mission_kind kind,
const point_rel_omt &dir );

std::string recruit_description( int npc_count ) const;
/// Provides a "guess" for some of the things your gatherers will return with
/// to upgrade the camp
std::string gathering_description();
/// Returns a string for the number of plants that are harvestable, plots ready to plant,
/// and ground that needs tilling
std::string farm_description( const point &dir, size_t &plots_count,
std::string farm_description( const point_rel_omt &dir, size_t &plots_count,
farm_ops operation );
/// Returns the description of a camp crafting options. converts fire charges to charcoal,
/// allows dark crafting
std::string craft_description( const recipe_id &itm );

// main mission description collection
void get_available_missions( mission_data &mission_key, map &here );
void get_available_missions_by_dir( mission_data &mission_key, const point &dir );
void get_available_missions_by_dir( mission_data &mission_key, const point_rel_omt &dir );
void choose_new_leader();
// available companion list manipulation
void reset_camp_workers();
Expand Down Expand Up @@ -407,7 +408,7 @@ class basecamp
void start_salt_water_pipe( const mission_id &miss_id );
void continue_salt_water_pipe( const mission_id &miss_id );
void start_combat_mission( const mission_id &miss_id, float exertion_level );
void start_farm_op( const point &dir, const mission_id &miss_id,
void start_farm_op( const point_rel_omt &dir, const mission_id &miss_id,
float exertion_level );
///Display items listed in @ref equipment to let the player pick what to give the departing
///NPC, loops until quit or empty.
Expand All @@ -416,7 +417,7 @@ class basecamp
drop_locations give_equipment( Character *pc, const inventory_filter_preset &preset,
const std::string &msg, const std::string &title, units::volume &total_volume,
units::mass &total_mass );
drop_locations get_equipment( tinymap *target_bay, const tripoint &target, Character *pc,
drop_locations get_equipment( tinymap *target_bay, const tripoint_omt_ms &target, Character *pc,
const inventory_filter_preset &preset,
const std::string &msg, const std::string &title, units::volume &total_volume,
units::mass &total_mass );
Expand Down Expand Up @@ -457,8 +458,8 @@ class basecamp
* @param omt_tgt the overmap pos3 of the farm_ops
* @param op whether to plow, plant, or harvest
*/
bool farm_return( const mission_id &miss_id, const point &dir );
std::pair<size_t, std::string> farm_action( const point &dir, farm_ops op,
bool farm_return( const mission_id &miss_id, const point_rel_omt &dir );
std::pair<size_t, std::string> farm_action( const point_rel_omt &dir, farm_ops op,
const npc_ptr &comp = nullptr );
void fortifications_return( const mission_id &miss_id );
bool salt_water_pipe_swamp_return( const mission_id &miss_id,
Expand Down Expand Up @@ -504,7 +505,7 @@ class basecamp
std::vector<npc_ptr> assigned_npcs; // NOLINT(cata-serialize)
// location of associated bulletin board
tripoint_abs_ms bb_pos;
std::map<point, expansion_data> expansions;
std::map<point_rel_omt, expansion_data> expansions;
comp_list camp_workers; // NOLINT(cata-serialize)
basecamp_map camp_map; // NOLINT(cata-serialize)
// dumping spot in absolute co-ords
Expand Down
8 changes: 4 additions & 4 deletions src/climbing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ static void detect_conditions_sub( climbing_aid::condition_list &list,
}

climbing_aid::condition_list climbing_aid::detect_conditions( Character &you,
const tripoint &examp )
const tripoint_bub_ms &examp )
{
condition_list list;

Expand All @@ -346,8 +346,8 @@ climbing_aid::condition_list climbing_aid::detect_conditions( Character &you,
return cond.uses_item > 0;
};
auto detect_ter_furn_flag = [&here, &fall]( condition & cond ) {
tripoint pos = fall.pos_furniture_or_floor();
cond.range = fall.pos_top().z - pos.z;
tripoint_bub_ms pos = fall.pos_furniture_or_floor();
cond.range = fall.pos_top().z() - pos.z();
return here.has_flag( cond.flag, pos );
};
auto detect_vehicle = [&fall]( condition & cond ) {
Expand All @@ -365,7 +365,7 @@ climbing_aid::condition_list climbing_aid::detect_conditions( Character &you,
return list;
}

climbing_aid::fall_scan::fall_scan( const tripoint &examp )
climbing_aid::fall_scan::fall_scan( const tripoint_bub_ms &examp )
{
map &here = get_map();
creature_tracker &creatures = get_creature_tracker();
Expand Down
Loading

0 comments on commit ef49525

Please sign in to comment.