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

Random legacy code cleanup #74351

Merged
merged 14 commits into from
Jun 10, 2024
Merged
6 changes: 0 additions & 6 deletions data/json/item_actions.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
"id": "firestarter",
"name": { "str": "Start a fire quickly" }
},
{
"//": "Remove after 0.G.",
"type": "item_action",
"id": "HAMMER",
"name": { "str": "Pry crate, window, door or nails" }
},
{
"type": "item_action",
"id": "PICK_LOCK",
Expand Down
24 changes: 0 additions & 24 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2309,7 +2309,6 @@ void Character::process_turn()
{
// Has to happen before reset_stats
clear_miss_reasons();
migrate_items_to_storage( false );

for( bionic &i : *my_bionics ) {
if( i.incapacitated_time > 0_turns ) {
Expand Down Expand Up @@ -9082,29 +9081,6 @@ void Character::fall_asleep( const time_duration &duration )
get_event_bus().send<event_type::character_falls_asleep>( getID(), to_seconds<int>( duration ) );
}

void Character::migrate_items_to_storage( bool disintegrate )
{
inv->visit_items( [&]( const item * it, item * ) {
if( disintegrate ) {
if( try_add( *it, /*avoid=*/nullptr, it ) == item_location::nowhere ) {
std::string profession_id = prof->ident().str();
debugmsg( "ERROR: Could not put %s (%s) into inventory. Check if the "
"profession (%s) has enough space.",
it->tname(), it->typeId().str(), profession_id );
return VisitResponse::ABORT;
}
} else {
item_location added = i_add( *it, true, /*avoid=*/nullptr,
it, /*allow_drop=*/false, /*allow_wield=*/!has_wield_conflicts( *it ) );
if( added == item_location::nowhere ) {
put_into_vehicle_or_drop( *this, item_drop_reason::tumbling, { *it } );
}
}
return VisitResponse::SKIP;
} );
inv->clear();
}

std::string Character::is_snuggling() const
{
map &here = get_map();
Expand Down
3 changes: 0 additions & 3 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -1500,9 +1500,6 @@ class Character : public Creature, public visitable

int calc_spell_training_cost( bool knows, int difficulty, int level ) const;

/** used for profession spawning and save migration for nested containers. remove after 0.F */
void migrate_items_to_storage( bool disintegrate );

/**
* Displays menu with body part hp, optionally with hp estimation after healing.
* Returns selected part.
Expand Down
7 changes: 1 addition & 6 deletions src/damage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,12 +864,7 @@ void damage_over_time_data::serialize( JsonOut &jsout ) const

void damage_over_time_data::deserialize( const JsonObject &jo )
{
std::string tmp_string = jo.get_string( "damage_type" );
// Remove after 0.F, migrating DT_TRUE to DT_PURE
if( tmp_string == "true" ) {
tmp_string = "pure";
}
type = damage_type_id( tmp_string );
jo.read( "damage_type", type );
jo.read( "amount", amount );
jo.read( "duration", duration );
jo.read( "bodyparts", bps );
Expand Down
9 changes: 1 addition & 8 deletions src/effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1697,14 +1697,7 @@ void effect::deserialize( const JsonObject &jo )
jo.read( "eff_type", id );
eff_type = &id.obj();
jo.read( "duration", duration );

// TEMPORARY until 0.F
if( jo.has_int( "bp" ) ) {
bp = convert_bp( static_cast<body_part>( jo.get_int( "bp" ) ) );
} else {
jo.read( "bp", bp );
}

jo.read( "bp", bp );
jo.read( "permanent", permanent );
jo.read( "intensity", intensity );
start_time = calendar::turn_zero;
Expand Down
2 changes: 0 additions & 2 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,8 +874,6 @@ bool game::start_game()

// Make sure the items are added after the calendar is started
u.add_profession_items();
// Move items from the inventory. eventually the inventory should not contain items at all.
u.migrate_items_to_storage( true );

const start_location &start_loc = u.random_start_location ? scen->random_start_location().obj() :
u.start_location.obj();
Expand Down
1 change: 0 additions & 1 deletion src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1796,7 +1796,6 @@ void Item_factory::init()
add_iuse( "GUNMOD_ATTACH", &iuse::gunmod_attach );
add_iuse( "TOOLMOD_ATTACH", &iuse::toolmod_attach );
add_iuse( "HACKSAW", &iuse::hacksaw );
add_iuse( "HAMMER", &iuse::hammer );
add_iuse( "HEATPACK", &iuse::heatpack );
add_iuse( "HEAT_FOOD", &iuse::heat_food );
add_iuse( "HONEYCOMB", &iuse::honeycomb );
Expand Down
8 changes: 1 addition & 7 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2706,12 +2706,7 @@ std::optional<int> iuse::ma_manual( Character *p, item *it, const tripoint & )
return 1;
}

// Remove after 0.G
std::optional<int> iuse::hammer( Character *p, item *it, const tripoint &pos )
{
return iuse::crowbar( p, it, pos );
}

// Why this still exist?
Procyonae marked this conversation as resolved.
Show resolved Hide resolved
std::optional<int> iuse::crowbar_weak( Character *p, item *it, const tripoint &pos )
{
return iuse::crowbar( p, it, pos );
Expand Down Expand Up @@ -2766,7 +2761,6 @@ std::optional<int> iuse::crowbar( Character *p, item *it, const tripoint &pos )
return std::nullopt;
}

// previously iuse::hammer
if( prying->prying_nails ) {
p->assign_activity( prying_activity_actor( pnt, item_location{*p, it} ) );
return std::nullopt;
Expand Down
1 change: 0 additions & 1 deletion src/iuse.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ std::optional<int> gun_repair( Character *, item *, const tripoint & );
std::optional<int> gunmod_attach( Character *, item *, const tripoint & );
std::optional<int> hacksaw( Character *, item *, const tripoint &it_pnt );
std::optional<int> hairkit( Character *, item *, const tripoint & );
std::optional<int> hammer( Character *, item *, const tripoint & );
std::optional<int> hand_crank( Character *, item *, const tripoint & );
std::optional<int> heat_food( Character *, item *, const tripoint & );
std::optional<int> heatpack( Character *, item *, const tripoint & );
Expand Down
44 changes: 1 addition & 43 deletions src/savegame_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,13 +550,7 @@ void Character::trait_data::deserialize( const JsonObject &data )
{
data.allow_omitted_members();
data.read( "key", key );

//Remove after 0.G
if( data.has_int( "charge" ) ) {
charge = time_duration::from_turns( data.get_int( "charge" ) );
} else {
data.read( "charge", charge );
}
data.read( "charge", charge );
data.read( "powered", powered );
data.read( "show_sprite", show_sprite );
if( data.has_member( "variant-parent" ) ) {
Expand Down Expand Up @@ -673,8 +667,6 @@ void Character::load( const JsonObject &data )
data.read( "hunger", hunger );
data.read( "sleepiness", sleepiness );
data.read( "cardio_acc", cardio_acc );
// Legacy read, remove after 0.F
data.read( "weary", activity_history );
data.read( "activity_history", activity_history );
data.read( "sleep_deprivation", sleep_deprivation );
data.read( "stored_calories", stored_calories );
Expand Down Expand Up @@ -1616,25 +1608,6 @@ void avatar::load( const JsonObject &data )
{
Character::load( data );

// TEMPORARY until 0.G
if( !data.has_member( "location" ) ) {
set_location( get_map().getglobal( read_legacy_creature_pos( data ) ) );
}

// TEMPORARY until 0.G
if( !data.has_member( "kill_xp" ) ) {
kill_xp = g->get_kill_tracker().legacy_kill_xp();
}

// Remove after 0.F
// Exists to prevent failed to visit member errors
if( data.has_member( "reactor_plut" ) ) {
data.get_int( "reactor_plut" );
}
if( data.has_member( "tank_plut" ) ) {
data.get_int( "tank_plut" );
}

std::string prof_ident = "(null)";
if( data.read( "profession", prof_ident ) && string_id<profession>( prof_ident ).is_valid() ) {
prof = &string_id<profession>( prof_ident ).obj();
Expand Down Expand Up @@ -2088,15 +2061,6 @@ void npc::load( const JsonObject &data )
time_point companion_mission_t_r = calendar::turn_zero;
std::string act_id;

// Remove after 0.F
// Exists to prevent failed to visit member errors
if( data.has_member( "reactor_plut" ) ) {
data.get_int( "reactor_plut" );
}
if( data.has_member( "tank_plut" ) ) {
data.get_int( "tank_plut" );
}

data.read( "marked_for_death", marked_for_death );
data.read( "dead", dead );
data.read( "patience", patience );
Expand Down Expand Up @@ -3125,12 +3089,6 @@ void item::deserialize( const JsonObject &data )
contents = item_contents( type->pockets );
}

// FIXME: batch_size migration from charges - remove after 0.G
if( is_craft() && craft_data_->batch_size <= 0 ) {
craft_data_->batch_size = clamp( charges, 1, charges );
charges = 0;
}

if( !has_itype_variant( false ) && can_have_itype_variant() ) {
if( possible_itype_variant( typeId().str() ) ) {
set_itype_variant( typeId().str() );
Expand Down
19 changes: 5 additions & 14 deletions src/trade_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,12 @@ trade_ui::trade_ui( party_t &you, npc &trader, currency_t cost, std::string titl

zone_manager &zmgr = zone_manager::get_manager();

// FIXME: migration for traders in old saves - remove after 0.G
zone_data const *const fallback =
zmgr.get_zone_at( trader.get_location(), true, trader.get_fac_id() );
bool const legacy = fallback != nullptr && fallback->get_name() == fallback_name;
std::unordered_set<tripoint> const src =
zmgr.get_point_set_loot( trader.get_location(), PICKUP_RANGE, trader.get_fac_id() );

if( legacy ) {
_panes[_trader]->add_nearby_items( PICKUP_RANGE );
} else {
std::unordered_set<tripoint> const src =
zmgr.get_point_set_loot( trader.get_location(), PICKUP_RANGE, trader.get_fac_id() );

for( tripoint const &pt : src ) {
_panes[_trader]->add_map_items( pt );
_panes[_trader]->add_vehicle_items( pt );
}
for( tripoint const &pt : src ) {
_panes[_trader]->add_map_items( pt );
_panes[_trader]->add_vehicle_items( pt );
}
} else if( !trader.is_player_ally() ) {
_panes[_trader]->add_nearby_items( 1 );
Expand Down
15 changes: 0 additions & 15 deletions src/units.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ void specific_energy::serialize( JsonOut &jsout ) const
template<>
void specific_energy::deserialize( const JsonValue &jv )
{
if( jv.test_int() ) {
// Compatibility with old 0.F saves
*this = units::from_joule_per_gram( jv.get_int() );
return;
}
*this = units::from_joule_per_gram( std::stof( jv.get_string() ) );
}

Expand All @@ -67,11 +62,6 @@ void temperature::serialize( JsonOut &jsout ) const
template<>
void temperature::deserialize( const JsonValue &jv )
{
if( jv.test_int() ) {
// Compatibility with old 0.F saves
*this = from_kelvin( jv.get_int() );
return;
}
*this = from_kelvin( std::stof( jv.get_string() ) );
}

Expand Down Expand Up @@ -108,11 +98,6 @@ void power::serialize( JsonOut &jsout ) const
template<>
void power::deserialize( const JsonValue &jv )
{
if( jv.test_int() ) {
// Compatibility with old 0.F saves
*this = from_watt( static_cast<std::int64_t>( jv.get_int() ) );
return;
}
*this = read_from_json_string( jv, units::power_units );
}

Expand Down
Loading