Skip to content

Commit

Permalink
Ensure that linkable transforming items keep their links after transform
Browse files Browse the repository at this point in the history
  • Loading branch information
moxian committed Dec 14, 2024
1 parent 791bd3f commit dea3076
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/iuse_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ std::string iuse_transform::get_name() const
return iuse_actor::get_name();
}

void iuse_transform::finalize( const itype_id & )
void iuse_transform::finalize( const itype_id &source )
{
if( !item::type_is_defined( target ) && target_group.is_empty() ) {
debugmsg( "Invalid transform target: %s", target.c_str() );
Expand All @@ -447,6 +447,19 @@ void iuse_transform::finalize( const itype_id & )
// todo: check contents fit container?
// transform uses migration pocket if not
}

if( source.obj().can_use( "link_up" ) ) {
// The linkage logic currently assumes that the links persist
// through transformation, and fails pretty badly (segfaults)
// if that happens to not be the case.
// It is not unreasonable to want items that violate this assumption (one example is
// the infamous Apple mouse which cannot be operated while charging),
// but we don't have any of those implemented right now, so the check stays.
if( !target.obj().can_use( "link_up" ) ) {
debugmsg( "Item %s has link_up action, yet transforms into %s which doesn't.",
source.c_str(), target.c_str() );
}
}
}

void iuse_transform::info( const item &it, std::vector<iteminfo> &dump ) const
Expand Down

0 comments on commit dea3076

Please sign in to comment.