| 250 | } |
| 251 | |
| 252 | bool 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 | |
| 276 | bool MaterialInfo::findCreature(const std::string& token, const std::string& subtoken) |
| 277 | { |