diff options
| author | Alexander Gavrilov | 2012-09-17 21:15:51 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2012-09-17 21:15:51 +0400 |
| commit | 36e44c682cc2cecb552eca8dfc75ad1a436086cc (patch) | |
| tree | 60793f2c17ceeb9a2849e60e819551e21fbf8c90 /library | |
| parent | 613063cef4d87b3b4307144b85da60dc40daceb3 (diff) | |
| download | dfhack-36e44c682cc2cecb552eca8dfc75ad1a436086cc.tar.gz dfhack-36e44c682cc2cecb552eca8dfc75ad1a436086cc.tar.bz2 dfhack-36e44c682cc2cecb552eca8dfc75ad1a436086cc.tar.xz | |
Add a plugin implementing 'add spatter to item' reactions.
Diffstat (limited to 'library')
| -rw-r--r-- | library/include/modules/Materials.h | 5 | ||||
| -rw-r--r-- | library/modules/Materials.cpp | 13 | ||||
| m--------- | library/xml | 0 |
3 files changed, 18 insertions, 0 deletions
diff --git a/library/include/modules/Materials.h b/library/include/modules/Materials.h index 76c89de3..fb5a6353 100644 --- a/library/include/modules/Materials.h +++ b/library/include/modules/Materials.h @@ -131,6 +131,11 @@ namespace DFHack bool findPlant(const std::string &token, const std::string &subtoken); bool findCreature(const std::string &token, const std::string &subtoken); + bool findProduct(df::material *material, const std::string &name); + bool findProduct(const MaterialInfo &info, const std::string &name) { + return findProduct(info.material, name); + } + std::string getToken(); std::string toString(uint16_t temp = 10015, bool named = true); diff --git a/library/modules/Materials.cpp b/library/modules/Materials.cpp index 50cf21a9..db9c9c7d 100644 --- a/library/modules/Materials.cpp +++ b/library/modules/Materials.cpp @@ -283,6 +283,19 @@ bool MaterialInfo::findCreature(const std::string &token, const std::string &sub return decode(-1); } +bool MaterialInfo::findProduct(df::material *material, const std::string &name) +{ + if (!material || name.empty()) + return decode(-1); + + auto &pids = material->reaction_product.id; + for (size_t i = 0; i < pids.size(); i++) + if ((*pids[i]) == name) + return decode(material->reaction_product.material, i); + + return decode(-1); +} + std::string MaterialInfo::getToken() { if (isNone()) diff --git a/library/xml b/library/xml -Subproject a6b95f1c42991e485f7e0bb5d029a5eca14ce9a +Subproject 260ff4a1ddcfd54d0143aa6d908a93c4ff709c8 |
