Skip to content

Commit

Permalink
Prevent non-reversible items from appearing in sleep menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel-SE committed Feb 7, 2015
1 parent 9b41ffc commit b549b38
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3274,7 +3274,7 @@ bool game::handle_action()
// List all active items, bionics or mutations so player can deactivate them
std::vector<std::string> active;
for ( auto &it : g->u.inv_dump() ) {
if ( it->active && it->is_tool() && it->charges > 0 ) {
if ( it->active && it->charges > 0 && it->is_tool_reversible() ) {
active.push_back( it->tname() );
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2875,6 +2875,21 @@ bool item::is_tool() const
return type->is_tool();
}

bool item::is_tool_reversible() const
{
const it_tool *source = dynamic_cast<const it_tool *>( type );
if( source != nullptr && source->revert_to != "null" ) {
item revert( source->revert_to, 0 );
npc n;
revert.type->invoke( &n, &revert, false, point(-999, -999) );
const it_tool *target = dynamic_cast<const it_tool *>( revert.type );
if ( target != nullptr ) {
return ( source->id == target->id );
}
}
return false;
}

bool item::is_software() const
{
return type->software.get() != nullptr;
Expand Down
1 change: 1 addition & 0 deletions src/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ class item : public JsonSerializer, public JsonDeserializer
bool is_funnel_container(int &bigger_than) const;

bool is_tool() const;
bool is_tool_reversible() const;
bool is_software() const;
bool is_var_veh_part() const;
bool is_artifact() const;
Expand Down

0 comments on commit b549b38

Please sign in to comment.