Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005739Dwarf FortressDwarf Mode -- Stockpilespublic2012-03-31 18:392014-07-23 10:40
Assigned ToToady One 
PlatformWindows OSVistaOS VersionWindows Vista
Product Version0.34.07 
Target VersionFixed in Version0.40.01 
Summary0005739: Stockpile settings for cloth are broken if adamantine cloth is permitted
DescriptionIf 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.
Steps To ReproduceHave 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.
Additional InformationPhoebus graphics pack
Tagsbinary patch
Attached Files

- Relationships
has duplicate 0004790resolvedFootkerchief Cloth stockpiles ignoring preferences 
has duplicate 0004788resolvedFootkerchief Dwarves ignore thread type when storing thread in a thread stockpile. (Thread (Metal) option not working) 
has duplicate 0004913resolvedKnight Otu metal cloth stockpiles accept non-metal cloth 
has duplicate 0004473resolvedFootkerchief Stockpiles ignore settings for adamantine/metal cloth/thread 
has duplicate 0005492resolvedKnight Otu Dwarves putting Pig tails on prohibited stock pile 
has duplicate 0006290resolvedDwarfu Metal thread stockpiles accept any thread 
related to 0004380new Stockpile options don't work for cloth 
related to 0005569resolvedToady One Stone globs (generated by magma crabs) get stored in food stockpiles 

-  Notes
Alumine (reporter)
2012-11-03 03:50

yep, still the case for 34.11
lethosor (manager)
2013-02-11 12:10

Possible workaround (not mine): [^]
ag (reporter)
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: [^]

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).
Quietust (reporter)
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.

Quietust (reporter)
2013-03-21 19:32
edited on: 2013-03-21 19:33

This bug may also be the root cause of 0005569.

Toady One (administrator)
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.

- Issue History
Date Modified Username Field Change
2012-03-31 18:39 Andrakon New Issue
2012-04-01 09:17 Footkerchief Relationship added child of 0004380
2012-04-01 09:17 Footkerchief Relationship added has duplicate 0004790
2012-04-01 09:17 Footkerchief Relationship added has duplicate 0004788
2012-04-01 09:18 Footkerchief Relationship added has duplicate 0004913
2012-04-01 09:21 Footkerchief Relationship added has duplicate 0004473
2012-04-01 09:21 Footkerchief Relationship added has duplicate 0005492
2012-04-01 09:22 Footkerchief Relationship replaced related to 0004380
2012-11-03 03:50 Alumine Note Added: 0023704
2013-02-04 08:15 Dwarfu Relationship added has duplicate 0006290
2013-02-11 12:10 lethosor Note Added: 0023848
2013-02-12 09:43 ag Note Added: 0023849
2013-02-12 09:48 ag Issue Monitored: ag
2013-02-12 09:50 Quietust Note Added: 0023850
2013-02-12 09:53 Quietust Note Edited: 0023850 View Revisions
2013-02-14 13:45 Quietust Note Edited: 0023850 View Revisions
2013-03-21 19:32 Quietust Note Added: 0023908
2013-03-21 19:33 Quietust Note Edited: 0023908 View Revisions
2014-02-19 17:58 Footkerchief Relationship added related to 0005569
2014-02-19 17:59 Footkerchief Tag Attached: binary patch
2014-03-25 13:18 Dwarfu Assigned To => Dwarfu
2014-03-25 13:18 Dwarfu Status new => acknowledged
2014-07-23 10:40 Toady One Note Added: 0027328
2014-07-23 10:40 Toady One Status acknowledged => resolved
2014-07-23 10:40 Toady One Fixed in Version => 0.40.01
2014-07-23 10:40 Toady One Resolution open => fixed
2014-07-23 10:40 Toady One Assigned To Dwarfu => Toady One

Copyright © 2000 - 2010 MantisBT Group
Powered by Mantis Bugtracker