| 122 | typedef std::map<int, std::vector<df::item*> > item_table; |
| 123 | |
| 124 | static 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 | |
| 156 | df::item* find_item(ReagentSource &info, item_table &table) |
| 157 | { |
no test coverage detected