diff options
| author | Quietust | 2012-01-16 22:12:58 -0600 |
|---|---|---|
| committer | Quietust | 2012-01-16 22:12:58 -0600 |
| commit | fd653a0227f3bca86d8fd4b9e7f515b6c4015524 (patch) | |
| tree | 2b22522cad48b21f97e3ad96f09aafa087e6f325 /plugins/cleanowned.cpp | |
| parent | e75291ee91adb0c76619a7d61814b85ea22402a1 (diff) | |
| download | dfhack-fd653a0227f3bca86d8fd4b9e7f515b6c4015524.tar.gz dfhack-fd653a0227f3bca86d8fd4b9e7f515b6c4015524.tar.bz2 dfhack-fd653a0227f3bca86d8fd4b9e7f515b6c4015524.tar.xz | |
Kill the Items module
Diffstat (limited to 'plugins/cleanowned.cpp')
| -rw-r--r-- | plugins/cleanowned.cpp | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/plugins/cleanowned.cpp b/plugins/cleanowned.cpp index 0935c2ea..4e8c254b 100644 --- a/plugins/cleanowned.cpp +++ b/plugins/cleanowned.cpp @@ -20,6 +20,11 @@ using namespace std; #include "modules/Materials.h" #include "modules/Translation.h" using namespace DFHack; +using namespace DFHack::Simple; +#include "DataDefs.h" +#include "df/world.h" + +using df::global::world; DFhackCExport command_result df_cleanowned (Core * c, vector <string> & parameters); @@ -89,7 +94,6 @@ DFhackCExport command_result df_cleanowned (Core * c, vector <string> & paramete } c->Suspend(); DFHack::Materials *Materials = c->getMaterials(); - DFHack::Items *Items = c->getItems(); DFHack::Units *Creatures = c->getUnits(); DFHack::Translation *Tran = c->getTranslation(); @@ -99,25 +103,17 @@ DFhackCExport command_result df_cleanowned (Core * c, vector <string> & paramete ok &= Creatures->Start(num_creatures); ok &= Tran->Start(); - vector<df::item *> p_items; - ok &= Items->readItemVector(p_items); - if(!ok) - { - c->con.printerr("Can't continue due to offset errors.\n"); - c->Resume(); - return CR_FAILURE; - } - c->con.print("Found total %d items.\n", p_items.size()); + c->con.print("Found total %d items.\n", world->items.all.size()); - for (std::size_t i=0; i < p_items.size(); i++) + for (std::size_t i=0; i < world->items.all.size(); i++) { - df::item * item = p_items[i]; + df::item * item = world->items.all[i]; bool confiscate = false; bool dump = false; if (!item->flags.bits.owned) { - int32_t owner = Items->getItemOwnerID(item); + int32_t owner = Items::getItemOwnerID(item); if (owner >= 0) { c->con.print("Fixing a misflagged item: \t"); @@ -129,8 +125,6 @@ DFhackCExport command_result df_cleanowned (Core * c, vector <string> & paramete } } - std::string name = Items->getItemClass(item); - if (item->flags.bits.rotten) { c->con.print("Confiscating a rotten item: \t"); @@ -189,7 +183,7 @@ DFhackCExport command_result df_cleanowned (Core * c, vector <string> & paramete item->getWear() ); - int32_t owner = Items->getItemOwnerID(item); + int32_t owner = Items::getItemOwnerID(item); int32_t owner_index = Creatures->FindIndexById(owner); std::string info; @@ -206,7 +200,7 @@ DFhackCExport command_result df_cleanowned (Core * c, vector <string> & paramete if (!dry_run) { - if (!Items->removeItemOwner(item, Creatures)) + if (!Items::removeItemOwner(item, Creatures)) c->con.print("(unsuccessfully) "); if (dump) item->flags.bits.dump = 1; |
