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

Method find

library/modules/Items.cpp:181–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179}
180
181bool 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;
210ITEMDEF_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
222bool ItemTypeInfo::matches(df::job_item_vector_id vec_id) {
223 auto other_id = ENUM_ATTR(job_item_vector_id, other, vec_id);

Callers 15

removeFromTickQueueFunction · 0.45
unregisterMethod · 0.45
unregisterAllMethod · 0.45
manageTickEventFunction · 0.45
manageJobCompletedEventFunction · 0.45
manageUnitDeathEventFunction · 0.45
manageConstructionEventFunction · 0.45
manageEquipmentEventFunction · 0.45
manageUnitAttackEventFunction · 0.45
gatherRelevantUnitsFunction · 0.45
manageInteractionEventFunction · 0.45
alreadyDoneMethod · 0.45

Calls 3

split_stringFunction · 0.85
find_enum_itemFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected