| 179 | } |
| 180 | |
| 181 | bool ItemTypeInfo::find(const string &token) |
| 182 | { using namespace df::enums::item_type; |
| 183 | vector<string> items; |
| 184 | split_string(&items, token, ":"); |
| 185 | |
| 186 | type = NONE; |
| 187 | subtype = -1; |
| 188 | custom = NULL; |
| 189 | |
| 190 | if (items.size() < 1 || items.size() > 2) |
| 191 | return false; |
| 192 | if (items[0] == "NONE") |
| 193 | return true; |
| 194 | if (!find_enum_item(&type, items[0]) || type == NONE) |
| 195 | return false; |
| 196 | if (items.size() == 1) |
| 197 | return true; |
| 198 | |
| 199 | auto &defs = world->raws.itemdefs; |
| 200 | switch (type) |
| 201 | { |
| 202 | #define ITEM(type,vec,tclass) \ |
| 203 | case type: \ |
| 204 | for (size_t i = 0; i < defs.vec.size(); i++) { \ |
| 205 | if (defs.vec[i]->id == items[1]) { \ |
| 206 | subtype = i; custom = defs.vec[i]; return true; \ |
| 207 | } \ |
| 208 | } \ |
| 209 | break; |
| 210 | ITEMDEF_VECTORS |
| 211 | #undef ITEM |
| 212 | |
| 213 | default: |
| 214 | if (items[1] == "NONE") |
| 215 | return true; |
| 216 | break; |
| 217 | } |
| 218 | |
| 219 | return (subtype >= 0); |
| 220 | } |
| 221 | |
| 222 | bool ItemTypeInfo::matches(df::job_item_vector_id vec_id) { |
| 223 | auto other_id = ENUM_ATTR(job_item_vector_id, other, vec_id); |
no test coverage detected