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

Infinite Armor Duplication Bug #23073

Closed
TrainStation123 opened this issue Feb 28, 2018 · 7 comments

Comments

Projects
None yet
6 participants
@TrainStation123
Copy link

commented Feb 28, 2018

Game version:
0.C g74036ec

Operating system:
Windows 7 x64

Tiles or curses:
Tiles

Mods active:
(Full List, top to bottom)
-Dark Days Ahead
-Filthy Clothing
-Disable NPC Needs
-Simplified Nutrition
-Bionics Systems Mod
-Makeshift Items Mod
-Icecoon's Arsenal
-More Survival Tools
-Mutant NPCs
-NPC traits
-More Buildings
-Extended Realistic Guns
-Classes and Scenarios Mod
-StatsThroughSkills

Expected behavior

Sort Armor on a friendly NPC to set up clothing/armor.

Actual behavior

Using the Equip armor from inventory (e), causes an error message (no crash). Continuing from error, the NPC is wearing the item, however it is not removed from the player inventory. This is easily exploited to make infinite armor/rags/weapons/etc.

DEBUG : Tried to remove a item in inventory (name: Example)

Function : item inventory::remove_item(const item*)
FILE : src/inventory.ccp
LINE : 525

Steps to reproduce the behavior

  • Talk to NPC
  • Sort Armor
  • Equip armor from inventory (e)
  • Give any armor/wearable item to NPC
@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor

commented Feb 28, 2018

There is also typo in error message - should be "Tried to remove an item in inventory".

@TrainStation123

This comment has been minimized.

Copy link
Author

commented Feb 28, 2018

Less of a typo and more of a direct copy.

image

@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor

commented Feb 28, 2018

It was not your typo. Typo is in that message. Article "an" should be used.

@TrainStation123

This comment has been minimized.

Copy link
Author

commented Feb 28, 2018

Ah, wasn't quite sure what you meant at first.

@CoroNaut

This comment has been minimized.

Copy link

commented Mar 1, 2018

All because correct grammar is more important the actual bug :D

@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor

commented Mar 1, 2018

Spellcheck ftw!

@WhiteRavenPL

This comment has been minimized.

Copy link
Contributor

commented Mar 23, 2018

I think the problem is linked to the NOTE here:

} else if( action == "EQUIP_ARMOR" ) {
// filter inventory for all items that are armor/clothing
// NOTE: This is from player's inventory, even for NPCs!
// @todo: Allow making NPCs equip their own stuff
item_location loc = game_menus::inv::wear( g->u );
// only equip if something valid selected!
if( loc ) {
// wear the item
if( wear( g->u.i_at( loc.obtain( g->u ) ) ) ) {
// reorder `worn` vector to place new item at cursor
auto iter = worn.end();
item new_equip = *( --iter );
// remove the item
worn.erase( iter );

This code is called from within a Character object representing an NPC, but items are taken from g->u which is the player. So the player picks an item from her inventory and then the code tries removing it from the NPCs inventory leading to an error.

Changing the code to use this:

            item_location loc = game_menus::inv::wear( *this );

            // only equip if something valid selected!
            if( loc ) {
                // wear the item
                if( wear( this->i_at( loc.obtain( *this ) ) ) ) {

seems to solve the problem, but then UI messages become inconsistent and keep referencing "you" instead of the NPCs name.

WhiteRavenPL added a commit to WhiteRavenPL/Cataclysm-DDA that referenced this issue Mar 27, 2018

Fix for armor duplication bug CleverRaven#23073
Adjusted UI messages to name NPC instead of the player
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.