Dwarf Fortress Bug Tracker - Dwarf Fortress
View Issue Details
0006026Dwarf FortressDwarf Mode -- Jobs, Smeltingpublic2012-06-15 08:512015-03-03 17:32
Quietust 
Footkerchief 
normalminorhave not tried
confirmedopen 
0.34.11 
 
0006026: Melting coins creates too much metal
Minting a stack of 500 coins costs 1 bar of metal. Melting that stack down at a smelter, however, yields 1.1 bars - melting 10 stacks of coins nets 11 bars.

This seems to be due to a rounding error - the code takes the item's stack size, divides it by 50, then adds 1, meaning a stack of 500 coins yields 11/10 bars when melted.
1. Mint 10 stacks of coins, using 10 bars of metal
2. Melt down those 10 stacks of coins at a smelter
3. Observe that the smelter now contains 11 bars of metal
I originally discovered this while annotating a disassembly of version 0.23.130.23a, so this bug dates back quite a long time.
No tags attached.
related to 0008339resolved Knight Otu Bar-melting exploit no longer seems to work. 
related to 0006027confirmed Footkerchief Melting weapons/armor/etc. yields too much metal 
Issue History
2012-06-15 08:51QuietustNew Issue
2012-06-15 08:53QuietustNote Added: 0023015
2012-06-15 13:51QuietustNote Added: 0023021
2012-06-15 13:52FootkerchiefRelationship addedrelated to 0006027
2012-06-16 08:01QuietustNote Edited: 0023021bug_revision_view_page.php?bugnote_id=0023021#r8587
2012-06-22 17:14QuietustNote Edited: 0023021bug_revision_view_page.php?bugnote_id=0023021#r8619
2014-09-15 17:33QuietustNote Added: 0030206
2014-09-15 17:50FootkerchiefAssigned To => Footkerchief
2014-09-15 17:50FootkerchiefStatusnew => confirmed
2014-09-23 19:16FootkerchiefRelationship addedrelated to 0008339
2015-03-03 07:35jwoodward48dfNote Added: 0032316
2015-03-03 17:32QuietustNote Added: 0032320

Notes
(0023015)
Quietust   
2012-06-15 08:53   
The simplest solution to this problem would be to subtract 1 from the stack size before performing the division - since an item can never have a stack size of zero, this should work as intended.

This problem technically also exists with ammo (99 bolts would give 1 bar, 100 bolts would give 1.1 bars), but it's not an issue since forging metal bolts only gives you a stack of 25.
(0023021)
Quietust   
2012-06-15 13:51   
(edited on: 2012-06-22 17:14)
There are several other item types which melt down to yield exactly the same amount of metal that was needed to make them: chains, instruments, animal traps, and buckets. Interestingly, buckets have had a 1 bar melt yield ever since 0.23.130.23a (and possibly earlier), while the others only yielded 0.5 bars prior to 0.34.06.

(0030206)
Quietust   
2014-09-15 17:33   
Confirmed still present in 0.40.12
(0032316)
jwoodward48df   
2015-03-03 07:35   
This problem does exist with bolts.
(0032320)
Quietust   
2015-03-03 17:32   
jwoodward48df: just like I said in my original comment above...