diff options
| author | Quietust | 2012-01-16 21:29:09 -0600 |
|---|---|---|
| committer | Quietust | 2012-01-16 21:29:09 -0600 |
| commit | e75291ee91adb0c76619a7d61814b85ea22402a1 (patch) | |
| tree | b0556281878781af05998ecc17c4859503e53ec8 /plugins/seedwatch.cpp | |
| parent | 9d8c67b71038e7d0cacb13f5b026bbdedf21c4ed (diff) | |
| download | dfhack-e75291ee91adb0c76619a7d61814b85ea22402a1.tar.gz dfhack-e75291ee91adb0c76619a7d61814b85ea22402a1.tar.bz2 dfhack-e75291ee91adb0c76619a7d61814b85ea22402a1.tar.xz | |
Unlink seedwatch plugin from Materials module
Diffstat (limited to 'plugins/seedwatch.cpp')
| -rwxr-xr-x | plugins/seedwatch.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/plugins/seedwatch.cpp b/plugins/seedwatch.cpp index 20d59be3..43de4149 100755 --- a/plugins/seedwatch.cpp +++ b/plugins/seedwatch.cpp @@ -8,15 +8,18 @@ #include "Core.h" #include "Export.h" #include "PluginManager.h" -#include "modules/Items.h" #include "modules/World.h" #include "modules/kitchen.h" #include "VersionInfo.h" +#include "df/world.h" +#include "df/plant_raw.h" #include "df/item_flags.h" using namespace DFHack; using namespace DFHack::Simple; +using df::global::world; + const int buffer = 20; // seed number buffer - 20 is reasonable bool running = false; // whether seedwatch is counting the seeds or not @@ -101,14 +104,10 @@ DFhackCExport command_result df_seedwatch(Core* pCore, std::vector<std::string>& } core.Suspend(); - Materials& materialsModule = *core.getMaterials(); - std::vector<t_matgloss> organics; - materialsModule.CopyOrganicMaterials(organics); - std::map<std::string, t_materialIndex> materialsReverser; - for(std::size_t i = 0; i < organics.size(); ++i) + for(std::size_t i = 0; i < world->raws.plants.all.size(); ++i) { - materialsReverser[organics[i].id] = i; + materialsReverser[world->raws.plants.all[i]->id] = i; } World *w = core.getWorld(); @@ -172,7 +171,7 @@ DFhackCExport command_result df_seedwatch(Core* pCore, std::vector<std::string>& core.con.print("The watch list is:\n"); for(std::map<t_materialIndex, unsigned int>::const_iterator i = watchMap.begin(); i != watchMap.end(); ++i) { - core.con.print("%s : %u\n", organics[i->first].id.c_str(), i->second); + core.con.print("%s : %u\n", world->raws.plants.all[i->first]->id.c_str(), i->second); } } } @@ -321,15 +320,11 @@ DFhackCExport command_result plugin_onupdate(Core* pCore) } // this is dwarf mode, continue std::map<t_materialIndex, unsigned int> seedCount; // the number of seeds - Items& itemsModule = *core.getItems(); - itemsModule.Start(); - std::vector<df::item*> items; - itemsModule.readItemVector(items); - df::item * item; + // count all seeds and plants by RAW material - for(std::size_t i = 0; i < items.size(); ++i) + for(std::size_t i = 0; i < world->items.all.size(); ++i) { - item = items[i]; + df::item * item = world->items.all[i]; t_materialIndex materialIndex = item->getMaterialIndex(); switch(item->getType()) { @@ -340,7 +335,6 @@ DFhackCExport command_result plugin_onupdate(Core* pCore) break; } } - itemsModule.Finish(); std::map<t_materialIndex, unsigned int> watchMap; Kitchen::fillWatchMap(watchMap); |
