Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typified game.h and .cpp #78405

Merged
merged 2 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2920,7 +2920,7 @@ static void rod_fish( Character *you, const std::vector<monster *> &fishables )
monster *chosen_fish = random_entry( fishables );
chosen_fish->fish_population -= 1;
if( chosen_fish->fish_population <= 0 ) {
g->catch_a_monster( chosen_fish, you->pos(), you, 50_hours );
g->catch_a_monster( chosen_fish, you->pos_bub(), you, 50_hours );
} else {
here.add_item_or_charges( you->pos_bub(), item::make_corpse( chosen_fish->type->id,
calendar::turn + rng( 0_turns,
Expand Down
2 changes: 1 addition & 1 deletion src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3092,7 +3092,7 @@ static bool generic_multi_activity_do(
you.activity.targets.emplace_back( you, &best_rod );
// TODO: fix point types
you.activity.coord_set =
g->get_fishable_locations( ACTIVITY_SEARCH_DISTANCE, src_loc.raw() );
g->get_fishable_locations( ACTIVITY_SEARCH_DISTANCE, src_loc );
return false;
} else if( reason == do_activity_reason::NEEDS_MINING ) {
// if have enough batteries to continue etc.
Expand Down
4 changes: 2 additions & 2 deletions src/avatar_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ bool avatar_action::move( avatar &you, map &m, const tripoint_rel_ms &d )
if( veh0 != nullptr && std::abs( veh0->velocity ) > 100 ) {
if( veh1 == nullptr ) {
if( query_yn( _( "Dive from moving vehicle?" ) ) ) {
g->moving_vehicle_dismount( dest_loc.raw() );
g->moving_vehicle_dismount( dest_loc );
}
return false;
} else if( veh1 != veh0 ) {
Expand Down Expand Up @@ -656,7 +656,7 @@ void avatar_action::swim( map &m, avatar &you, const tripoint_bub_ms &p )
you.setpos( p );
g->update_map( you );

cata_event_dispatch::avatar_moves( old_abs_pos.raw(), you, m );
cata_event_dispatch::avatar_moves( old_abs_pos, you, m );

if( m.veh_at( you.pos_bub() ).part_with_feature( VPFLAG_BOARDABLE, true ) ) {
m.board_vehicle( you.pos_bub(), &you );
Expand Down
10 changes: 5 additions & 5 deletions src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ bool Character::activate_bionic( bionic &bio, bool eff_only, bool *close_bionics
add_msg_activate();
const w_point weatherPoint = *get_weather().weather_precise;
int humidity = get_local_humidity( weatherPoint.humidity, get_weather().weather_id,
g->is_sheltered( player_character.pos() ) );
g->is_sheltered( player_character.pos_bub() ) );
// thirst units = 5 mL
int water_available = std::lround( humidity * 3.0 / 100.0 );
if( water_available == 0 ) {
Expand Down Expand Up @@ -1069,13 +1069,13 @@ bool Character::activate_bionic( bionic &bio, bool eff_only, bool *close_bionics
weather_manager &weather = get_weather();
const units::temperature player_local_temp = weather.get_temperature( player_character.pos() );
const int windpower = get_local_windpower( weather.windspeed + vehwindspeed,
cur_om_ter, get_location(), weather.winddirection, g->is_sheltered( pos() ) );
cur_om_ter, get_location(), weather.winddirection, g->is_sheltered( pos_bub() ) );
add_msg_if_player( m_info, _( "Temperature: %s." ), print_temperature( player_local_temp ) );
const w_point weatherPoint = *weather.weather_precise;
add_msg_if_player( m_info, _( "Relative Humidity: %s." ),
print_humidity(
get_local_humidity( weatherPoint.humidity, get_weather().weather_id,
g->is_sheltered( player_character.pos() ) ) ) );
g->is_sheltered( player_character.pos_bub() ) ) ) );
add_msg_if_player( m_info, _( "Pressure: %s." ),
print_pressure( static_cast<int>( weatherPoint.pressure ) ) );
add_msg_if_player( m_info, _( "Wind Speed: %.1f %s." ),
Expand Down Expand Up @@ -1438,7 +1438,7 @@ void Character::burn_fuel( bionic &bio )
bool solar_powered = ( !bio.id->fuel_opts.empty() &&
bio.id->fuel_opts.front() == fuel_type_sun_light ) ||
!result.connected_solar.empty();
if( energy_gain == 0_J && solar_powered && !g->is_sheltered( pos() ) ) {
if( energy_gain == 0_J && solar_powered && !g->is_sheltered( pos_bub() ) ) {
// Some sort of solar source

const weather_type_id &wtype = current_weather( get_location() );
Expand Down Expand Up @@ -1709,7 +1709,7 @@ void Character::process_bionic( bionic &bio )
if( calendar::once_every( 5_minutes ) ) {
const w_point weatherPoint = *get_weather().weather_precise;
int humidity = get_local_humidity( weatherPoint.humidity, get_weather().weather_id,
g->is_sheltered( pos() ) );
g->is_sheltered( pos_bub() ) );
// in thirst units = 5 mL water
int water_available = std::lround( humidity * 3.0 / 100.0 );
// At 50% relative humidity or more, the player will draw 10 mL
Expand Down
4 changes: 2 additions & 2 deletions src/cata_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1945,10 +1945,10 @@ void cata_tiles::draw( const point &dest, const tripoint &center, int width, int
false );
}
if( you.controlling_vehicle ) {
std::optional<tripoint> indicator_offset = g->get_veh_dir_indicator_location( true );
std::optional<tripoint_rel_ms> indicator_offset = g->get_veh_dir_indicator_location( true );
if( indicator_offset ) {
draw_from_id_string( "cursor", TILE_CATEGORY::NONE, empty_string,
indicator_offset->xy() +
indicator_offset->raw().xy() +
tripoint( you.posx(), you.posy(), center.z ),
0, 0, lit_level::LIT, false );
}
Expand Down
12 changes: 6 additions & 6 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1911,7 +1911,7 @@ void Character::dismount()
add_msg_debug( debugmode::DF_CHARACTER, "dismount called when not riding" );
return;
}
if( const std::optional<tripoint> pnt = choose_adjacent( _( "Dismount where?" ) ) ) {
if( const std::optional<tripoint_bub_ms> pnt = choose_adjacent_bub( _( "Dismount where?" ) ) ) {
if( !g->is_empty( *pnt ) ) {
add_msg( m_warning, _( "You cannot dismount there!" ) );
return;
Expand Down Expand Up @@ -8179,7 +8179,7 @@ dealt_damage_instance Character::deal_damage( Creature *source, bodypart_id bp,

// And slimespawners too
if( has_trait( trait_SLIMESPAWNER ) && ( dam >= 10 ) && one_in( 20 - dam ) ) {
if( monster *const slime = g->place_critter_around( mon_player_blob, pos(), 1 ) ) {
if( monster *const slime = g->place_critter_around( mon_player_blob, pos_bub(), 1 ) ) {
slime->friendly = -1;
add_msg_if_player( m_warning, _( "A mass of slime is torn from you, and moves on its own!" ) );
}
Expand Down Expand Up @@ -9972,11 +9972,11 @@ float Character::adjust_for_focus( float amount ) const
return amount * ( effective_focus / 100.0f );
}

std::function<bool( const tripoint & )> Character::get_path_avoid() const
std::function<bool( const tripoint_bub_ms & )> Character::get_path_avoid() const
{
// TODO: Add known traps in a way that doesn't destroy performance

return [this]( const tripoint & p ) {
return [this]( const tripoint_bub_ms & p ) {
Creature *critter = get_creature_tracker().creature_at( p, true );
return critter && critter->is_npc() && this->sees( *critter );
};
Expand Down Expand Up @@ -10943,7 +10943,7 @@ void Character::process_one_effect( effect &it, bool is_new )
void Character::process_effects()
{
//Special Removals
if( has_effect( effect_darkness ) && g->is_in_sunlight( pos() ) ) {
if( has_effect( effect_darkness ) && g->is_in_sunlight( pos_bub() ) ) {
remove_effect( effect_darkness );
}
if( has_trait( trait_M_IMMUNE ) && has_effect( effect_fungus ) ) {
Expand Down Expand Up @@ -12214,7 +12214,7 @@ void Character::recalc_speed_bonus()
// Ectothermic/COLDBLOOD4 is intended to buff folks in the Summer
// Threshold-crossing has its charms ;-)
if( g != nullptr ) {
if( has_trait( trait_SUNLIGHT_DEPENDENT ) && !g->is_in_sunlight( pos() ) ) {
if( has_trait( trait_SUNLIGHT_DEPENDENT ) && !g->is_in_sunlight( pos_bub() ) ) {
//FIXME get trait name directly
mod_speed_bonus( -( g->light_level( posz() ) >= 12 ? 5 : 10 ), _( "Sunlight Dependent" ) );
}
Expand Down
2 changes: 1 addition & 1 deletion src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -3277,7 +3277,7 @@ class Character : public Creature, public visitable
int run_cost( int base_cost, bool diag = false ) const;

const pathfinding_settings &get_pathfinding_settings() const override;
std::function<bool( const tripoint & )> get_path_avoid() const override;
std::function<bool( const tripoint_bub_ms & )> get_path_avoid() const override;
/**
* Get all hostile creatures currently visible to this player.
*/
Expand Down
6 changes: 3 additions & 3 deletions src/character_body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,10 @@ void Character::update_bodytemp()
// Sunlight
const float scaled_sun_irradiance = incident_sun_irradiance( get_weather().weather_id,
calendar::turn ) / max_sun_irradiance();
const units::temperature_delta sunlight_warmth = !g->is_sheltered( pos() ) ? 3_C_delta *
const units::temperature_delta sunlight_warmth = !g->is_sheltered( pos_bub() ) ? 3_C_delta *
scaled_sun_irradiance :
0_C_delta;
const int best_fire = get_best_fire( pos() );
const int best_fire = get_best_fire( pos_bub() );

const units::temperature_delta lying_warmth = use_floor_warmth ? floor_warmth( pos() ) : 0_C_delta;
const units::temperature water_temperature =
Expand All @@ -519,7 +519,7 @@ void Character::update_bodytemp()
// Difference between high and low is the "safe" heat - one we only apply if it's beneficial
const units::temperature_delta mutation_heat_bonus = mutation_heat_high - mutation_heat_low;

const units::temperature_delta h_radiation = get_heat_radiation( pos() );
const units::temperature_delta h_radiation = get_heat_radiation( pos_bub() );

// 111F (44C) is a temperature in which proteins break down: https://en.wikipedia.org/wiki/Burn
// Blisters arbitrarily scale with the sqrt of the temperature difference in fahrenheit.
Expand Down
8 changes: 4 additions & 4 deletions src/computer_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1623,8 +1623,8 @@ void computer_session::failure_alarm()
void computer_session::failure_manhacks()
{
int num_robots = rng( 4, 8 );
const tripoint_range<tripoint> range =
get_map().points_in_radius( get_player_character().pos(), 3 );
const tripoint_range<tripoint_bub_ms> range =
get_map().points_in_radius( get_player_character().pos_bub(), 3 );
for( int i = 0; i < num_robots; i++ ) {
if( g->place_critter_within( mon_manhack, range ) ) {
add_msg( m_warning, _( "Manhacks drop from compartments in the ceiling." ) );
Expand All @@ -1634,8 +1634,8 @@ void computer_session::failure_manhacks()

void computer_session::failure_secubots()
{
const tripoint_range<tripoint> range =
get_map().points_in_radius( get_player_character().pos(), 3 );
const tripoint_range<tripoint_bub_ms> range =
get_map().points_in_radius( get_player_character().pos_bub(), 3 );
if( g->place_critter_within( mon_secubot, range ) ) {
add_msg( m_warning, _( "A secubot emerges from a compartment in the floor." ) );
}
Expand Down
2 changes: 1 addition & 1 deletion src/consumption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,7 @@ bool Character::consume_effects( item &food )
mod_pain( 5 );
int numslime = 1;
for( int i = 0; i < numslime; i++ ) {
if( monster *const slime = g->place_critter_around( mon_player_blob, pos(), 1 ) ) {
if( monster *const slime = g->place_critter_around( mon_player_blob, pos_bub(), 1 ) ) {
slime->friendly = -1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ class Creature : public viewer
/** Returns settings for pathfinding. */
virtual const pathfinding_settings &get_pathfinding_settings() const = 0;
/** Returns a set of points we do not want to path through. */
virtual std::function<bool( const tripoint & )> get_path_avoid() const = 0;
virtual std::function<bool( const tripoint_bub_ms & )> get_path_avoid() const = 0;

bool underwater;
void draw( const catacurses::window &w, const point_bub_ms &origin, bool inverted ) const;
Expand Down
8 changes: 4 additions & 4 deletions src/debug_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3597,10 +3597,10 @@ static void set_automove()
return;
}

// TODO: fix point types
auto rt = get_map().route( player_character.pos_bub(), tripoint_bub_ms( *dest ),
player_character.get_pathfinding_settings(),
player_character.get_path_avoid() );
std::vector<tripoint_bub_ms> rt = get_map().route( player_character.pos_bub(),
tripoint_bub_ms( *dest ),
player_character.get_pathfinding_settings(),
player_character.get_path_avoid() );
if( !rt.empty() ) {
player_character.set_destination( rt );
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ std::string display::sundial_text_color( const Character &u, int width )
const int azm_pos = static_cast<int>( std::round( azm / scale ) ) - 1;
const int night_h = h >= h_dawn + 12 ? h - ( h_dawn + 12 ) : h + ( 12 - h_dawn );
std::string ret = "[";
if( g->is_sheltered( u.pos() ) ) {
if( g->is_sheltered( u.pos_bub() ) ) {
ret += ( width > 0 ? std::string( width, '?' ) : "" );
} else {
for( int i = 0; i < width; i++ ) {
Expand Down Expand Up @@ -1507,7 +1507,7 @@ std::pair<std::string, nc_color> display::wind_text_color( const Character &u )
const oter_id &cur_om_ter = overmap_buffer.ter( u.global_omt_location() );
weather_manager &weather = get_weather();
double windpower = get_local_windpower( weather.windspeed, cur_om_ter,
u.get_location(), weather.winddirection, g->is_sheltered( u.pos() ) );
u.get_location(), weather.winddirection, g->is_sheltered( u.pos_bub() ) );

// Wind descriptor followed by a directional arrow
const std::string wind_text = get_wind_desc( windpower ) + " " + get_wind_arrow(
Expand Down
Loading
Loading