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

Method findPlant

library/modules/Materials.cpp:252–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

250}
251
252bool MaterialInfo::findPlant(const std::string& token, const std::string& subtoken)
253{
254 if (token.empty())
255 return decode(-1);
256 auto& raws = world->raws;
257 for (size_t i = 0; i < raws.plants.all.size(); i++)
258 {
259 df::plant_raw* p = raws.plants.all[i];
260 if (p->id != token)
261 continue;
262
263 // As a special exception, return the structural material with empty subtoken
264 if (subtoken.empty())
265 return decode(p->material_defs.type[plant_material_def::basic_mat], p->material_defs.idx[plant_material_def::basic_mat]);
266
267 for (size_t j = 0; j < p->material.size(); j++)
268 if (p->material[j]->id == subtoken)
269 return decode(PLANT_BASE + j, i);
270
271 break;
272 }
273 return decode(-1);
274}
275
276bool MaterialInfo::findCreature(const std::string& token, const std::string& subtoken)
277{

Callers

nothing calls this directly

Calls 3

decodeFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected