Dwarf Fortress Bug Tracker - Dwarf Fortress
View Issue Details
0005739Dwarf FortressDwarf Mode -- Stockpilespublic2012-03-31 18:392014-07-23 10:40
Andrakon 
Toady One 
normalminoralways
resolvedfixed 
Windows VistaWindows Vista
0.34.07 
0.40.01 
0005739: Stockpile settings for cloth are broken if adamantine cloth is permitted
If a stockpile only has adamantine thread allowed, nothing will be stored there. If a stockpile only has adamantine cloth allowed, all types of cloth will be stored there.

All of my cloth and thread is in bins.

I have two stockpiles set up, one for adamntine strands and cloth, and the other for all other cloth plus leather.

In the stockpile settings on the adamntine stockpile I have everything except adamantine thread and cloth forbidden and everything except adamntine thread and cloth allowed in the other stockpile.

My dwarves were storing the adamntine thread in the regular thread and cloth stockpile, so I had the adamntine thread stockpile take from the regular thread and cloth stockpile, then my dwarves start moving bins of regular thread and cloth to the adamntine only stockpile and did not take out the regular thread or cloth. Most bins did not even have adamntine stuff in them. Strangely they would not take all of the bins either. And if I set number of bins to 0 then nothing would be stored in the stockpile.

I double checked the stockpile settings on both and confirmed that they are correct.
Have two stockpiles, a lot of cloth and thread in bins, and some adamantine strands. Set one stockpile to forbid adamantine strands and cloth but allow the rest of the cloth category. Do the opposite for the other stockpile.

Dwarves will store adamantine strands in the wrong stockpile.

Have the adamantine strand stockpile take from the regular stockpile.

Dwarves will start moving bins of regular cloth to the adamantine stockpile.
Phoebus graphics pack
binary patch
has duplicate 0004790resolved Footkerchief Cloth stockpiles ignoring preferences 
has duplicate 0004788resolved Footkerchief Dwarves ignore thread type when storing thread in a thread stockpile. (Thread (Metal) option not working) 
has duplicate 0004913resolved Knight Otu metal cloth stockpiles accept non-metal cloth 
has duplicate 0004473resolved Footkerchief Stockpiles ignore settings for adamantine/metal cloth/thread 
has duplicate 0005492resolved Knight Otu Dwarves putting Pig tails on prohibited stock pile 
has duplicate 0006290resolved Dwarfu Metal thread stockpiles accept any thread 
related to 0004380new  Stockpile options don't work for cloth 
related to 0005569resolved Toady One Stone globs (generated by magma crabs) get stored in food stockpiles 
Issue History
2012-03-31 18:39AndrakonNew Issue
2012-04-01 09:17FootkerchiefRelationship addedchild of 0004380
2012-04-01 09:17FootkerchiefRelationship addedhas duplicate 0004790
2012-04-01 09:17FootkerchiefRelationship addedhas duplicate 0004788
2012-04-01 09:18FootkerchiefRelationship addedhas duplicate 0004913
2012-04-01 09:21FootkerchiefRelationship addedhas duplicate 0004473
2012-04-01 09:21FootkerchiefRelationship addedhas duplicate 0005492
2012-04-01 09:22FootkerchiefRelationship replacedrelated to 0004380
2012-11-03 03:50AlumineNote Added: 0023704
2013-02-04 08:15DwarfuRelationship addedhas duplicate 0006290
2013-02-11 12:10lethosorNote Added: 0023848
2013-02-12 09:43agNote Added: 0023849
2013-02-12 09:48agIssue Monitored: ag
2013-02-12 09:50QuietustNote Added: 0023850
2013-02-12 09:53QuietustNote Edited: 0023850bug_revision_view_page.php?bugnote_id=0023850#r8903
2013-02-14 13:45QuietustNote Edited: 0023850bug_revision_view_page.php?bugnote_id=0023850#r8904
2013-03-21 19:32QuietustNote Added: 0023908
2013-03-21 19:33QuietustNote Edited: 0023908bug_revision_view_page.php?bugnote_id=0023908#r8910
2014-02-19 17:58FootkerchiefRelationship addedrelated to 0005569
2014-02-19 17:59FootkerchiefTag Attached: binary patch
2014-03-25 13:18DwarfuAssigned To => Dwarfu
2014-03-25 13:18DwarfuStatusnew => acknowledged
2014-07-23 10:40Toady OneNote Added: 0027328
2014-07-23 10:40Toady OneStatusacknowledged => resolved
2014-07-23 10:40Toady OneFixed in Version => 0.40.01
2014-07-23 10:40Toady OneResolutionopen => fixed
2014-07-23 10:40Toady OneAssigned ToDwarfu => Toady One

Notes
(0023704)
Alumine   
2012-11-03 03:50   
yep, still the case for 34.11
(0023848)
lethosor   
2013-02-11 12:10   
Possible workaround (not mine):
http://www.bay12forums.com/smf/index.php?topic=122782.0 [^]
(0023849)
ag   
2013-02-12 09:43   
I got curious about that workaround and looked at the code. It turns out this bug is most likely caused by the same uninitalized reference array in the material structure that crashes the economy if it is enabled via memory hacking (as found by Quietust).

Basically, for use in stockpiling and economy, the game pre-sorts the materials into a certain set of groups; here is the list of them:

https://github.com/angavrilov/df-structures/blob/master/df.materials.xml#L448 [^]

This sorting process fills an array of vectors with material ids, and also sets things up for reverse lookup by storing the index of each material id within the material id vector inside the matching material structure itself.

Unfortunately, while the array inside the material structure that is used to store the reverse lookup references is supposed to be preinitialized with -1, it isn't filled at all, and ends up containing whatever there was in memory before.

As a result, since the most likely value for newly allocated memory contents when DF is just being loaded is 0, thread&cloth end up being matched against index 0 within all categories they don't really belong to (and should thus be referencing -1).
(0023850)
Quietust   
2013-02-12 09:50   
(edited on: 2013-02-14 13:45)
Specifically, the material descriptor structure contains a 37-element array near the end (between the PREFIX string and the POWDER_DYE/STATE_COLOR temp-strings) which refers to a set of vectors in the raws sub-structure (immediately after the custom building raws and the interactions list), and the values in this array are assumed to be initialized to -1 - the code for stockpiling cloth/thread and for nobles adjusting economy prices both rely on this, the latter actually crashing if this assumption is violated.

Similar references appear to be present inside the creature caste raw structure, between the TRADE_CAPACITY and ATTACK_TRIGGER fields.

(0023908)
Quietust   
2013-03-21 19:32   
(edited on: 2013-03-21 19:33)
This bug may also be the root cause of 0005569.

(0027328)
Toady One   
2014-07-23 10:40   
It looks like I had the values initialized for 0.40.01, changed at some point I don't remember.