Skip to content

Commit

Permalink
Merge pull request #38604 from kevingranade/fix-ammo-disassemble-exploit
Browse files Browse the repository at this point in the history
Supress selecting number of charges to disassemble for non-discrete a…
  • Loading branch information
ZhilkinSerg authored Mar 7, 2020
2 parents 029bc8c + 575e1e5 commit fc36f71
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions data/json/recipes/armor/other.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@
],
"using": [ [ "soldering_standard", 10 ] ],
"qualities": [ { "id": "SCREW", "level": 1 } ],
"flags": [ "UNCRAFT_BY_QUANTITY" ],
"components": [
[ [ "oxy_powder", 50 ] ],
[ [ "charcoal", 5 ], [ "coal_lump", 5 ] ],
Expand All @@ -271,6 +272,7 @@
"reversible": true,
"decomp_learn": 2,
"autolearn": true,
"flags": [ "UNCRAFT_BY_QUANTITY" ],
"components": [ [ [ "charcoal", 5 ] ], [ [ "paper", 2 ] ], [ [ "bag_plastic", 1 ] ] ]
},
{
Expand All @@ -285,6 +287,7 @@
"reversible": true,
"decomp_learn": 2,
"autolearn": true,
"flags": [ "UNCRAFT_BY_QUANTITY" ],
"components": [ [ [ "charcoal", 10 ] ], [ [ "paper", 2 ] ], [ [ "bag_plastic", 1 ] ] ]
},
{
Expand All @@ -298,6 +301,7 @@
"time": "60 m",
"reversible": true,
"decomp_learn": 4,
"flags": [ "UNCRAFT_BY_QUANTITY" ],
"book_learn": [
[ "textbook_fireman", 4 ],
[ "atomic_survival", 4 ],
Expand Down
1 change: 1 addition & 0 deletions doc/JSON_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,7 @@ These branches are also the valid entries for the categories of `dreams` in `dre
- ```BLIND_EASY``` Easy to craft with little to no light.
- ```BLIND_HARD``` Possible to craft with little to no light, but difficult.
- ```SECRET``` Not automatically learned at character creation time based on high skill levels.
- ```UNCRAFT_BY_QUANTITY``` Supresses the per-charge handling of uncraft recipes.
- ```UNCRAFT_LIQUIDS_CONTAINED``` Spawn liquid items in its default container.
- ```UNCRAFT_SINGLE_CHARGE``` Lists returned amounts for one charge of an item that is counted by charges.
- ```FULL_MAGAZINE``` If this recipe requires magazines, it needs one that is full. For deconstruction recipes, it will spawn a full magazine when deconstructed.
Expand Down
4 changes: 2 additions & 2 deletions src/crafting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2004,7 +2004,7 @@ bool player::disassemble( item_location target, bool interactive )
// If we're disassembling ammo, prompt the player to specify amount
// This could be extended more generally in the future
int num_dis = 0;
if( obj.is_ammo() ) {
if( obj.is_ammo() && !r.has_flag( "UNCRAFT_BY_QUANTITY" ) ) {
string_input_popup popup_input;
const std::string title = string_format( _( "Disassemble how many %s [MAX: %d]: " ),
obj.type_name( 1 ), obj.charges );
Expand Down Expand Up @@ -2129,7 +2129,7 @@ void player::complete_disassemble( item_location &target, const recipe &dis )

if( dis_item.count_by_charges() ) {
// remove the charges that one would get from crafting it
if( org_item.is_ammo() ) {
if( org_item.is_ammo() && !dis.has_flag( "UNCRAFT_BY_QUANTITY" ) ) {
//subtract selected number of rounds to disassemble
org_item.charges -= activity.position;
} else {
Expand Down

0 comments on commit fc36f71

Please sign in to comment.