MCPcopy Create free account
hub / github.com/DFHack/dfhack / index_items

Function index_items

plugins/add-spatter.cpp:124–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122typedef std::map<int, std::vector<df::item*> > item_table;
123
124static void index_items(item_table &table, df::job *job, ReactionInfo *info)
125{
126 for (int i = job->items.size()-1; i >= 0; i--)
127 {
128 auto iref = job->items[i];
129 if (iref->job_item_idx < 0) continue;
130 auto iitem = job->job_items.elements[iref->job_item_idx];
131
132 if (iitem->contains.empty())
133 {
134 table[iitem->reagent_index].push_back(iref->item);
135 }
136 else
137 {
138 std::vector<df::item*> contents;
139 Items::getContainedItems(iref->item, &contents);
140
141 for (int j = contents.size()-1; j >= 0; j--)
142 {
143 for (int k = iitem->contains.size()-1; k >= 0; k--)
144 {
145 int ridx = iitem->contains[k];
146 auto reag = info->react->reagents[ridx];
147
148 if (reag->matchesChild(contents[j], info->react, iitem->reaction_id))
149 table[ridx].push_back(contents[j]);
150 }
151 }
152 }
153 }
154}
155
156df::item* find_item(ReagentSource &info, item_table &table)
157{

Callers 1

Calls 2

sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected