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

Fix issue with loading worn or wielded enchanted items #64206

Merged
merged 1 commit into from
Mar 13, 2023
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
3 changes: 3 additions & 0 deletions src/character_attire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2003,6 +2003,9 @@ void outfit::on_takeoff( Character &guy )
void outfit::on_item_wear( Character &guy )
{
for( item &clothing : worn ) {
if( clothing.relic_data && clothing.type->relic_data ) {
clothing.relic_data = clothing.type->relic_data;
}
guy.on_item_wear( clothing );
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -2928,10 +2928,9 @@ class item : public visitable
};

cata::value_ptr<craft_data> craft_data_;

public:
// any relic data specific to this item
cata::value_ptr<relic> relic_data;
public:
int charges = 0;
units::energy energy = 0_mJ; // Amount of energy currently stored in a battery

Expand Down
6 changes: 4 additions & 2 deletions src/magic_enchantment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,16 @@ void enchantment::load( const JsonObject &jo, const std::string &,
active_conditions.second = con.value();
} else {
active_conditions.second = condition::DIALOG_CONDITION;
read_condition<dialogue>( jo, "condition", dialog_condition, false );
}
} else if( jo.has_member( "condition" ) ) {
active_conditions.second = condition::DIALOG_CONDITION;
read_condition<dialogue>( jo, "condition", dialog_condition, false );
} else {
active_conditions.second = condition::ALWAYS;
}
if( active_conditions.second == condition::DIALOG_CONDITION ) {
read_condition<dialogue>( jo, "condition", dialog_condition, false );
}

for( JsonObject jsobj : jo.get_array( "ench_effects" ) ) {
ench_effects.emplace( efftype_id( jsobj.get_string( "effect" ) ), jsobj.get_int( "intensity" ) );
}
Expand Down
4 changes: 3 additions & 1 deletion src/savegame_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,9 @@ void Character::load( const JsonObject &data )

set_wielded_item( item() );
data.read( "weapon", weapon );

if( !weapon.is_null() && weapon.relic_data && weapon.type->relic_data ) {
weapon.relic_data = weapon.type->relic_data;
}
data.read( "move_mode", move_mode );

if( has_effect( effect_riding ) ) {
Expand Down