diff options
| author | Quietust | 2012-01-24 11:32:34 -0600 |
|---|---|---|
| committer | Quietust | 2012-01-24 11:32:34 -0600 |
| commit | cc7c7795a161a467892ae60aa2ab67f5ff659e8f (patch) | |
| tree | fcd4d92585de379e4c2fca7648ab2dfc1761066c /plugins/cleanowned.cpp | |
| parent | 02d75e2c94eebaa771aef6da9ff9d83a786f904b (diff) | |
| download | dfhack-cc7c7795a161a467892ae60aa2ab67f5ff659e8f.tar.gz dfhack-cc7c7795a161a467892ae60aa2ab67f5ff659e8f.tar.bz2 dfhack-cc7c7795a161a467892ae60aa2ab67f5ff659e8f.tar.xz | |
Kill the Units module, and add another pair of methods to the Items module to simplify some things
Diffstat (limited to 'plugins/cleanowned.cpp')
| -rw-r--r-- | plugins/cleanowned.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/plugins/cleanowned.cpp b/plugins/cleanowned.cpp index 78dbb04e..e20647d9 100644 --- a/plugins/cleanowned.cpp +++ b/plugins/cleanowned.cpp @@ -97,12 +97,9 @@ DFhackCExport command_result df_cleanowned (Core * c, vector <string> & paramete CoreSuspender suspend(c); DFHack::Materials *Materials = c->getMaterials(); - DFHack::Units *Creatures = c->getUnits(); uint32_t num_creatures; - bool ok = true; - ok &= Materials->ReadAllMaterials(); - ok &= Creatures->Start(num_creatures); + bool ok = Materials->ReadAllMaterials(); c->con.print("Found total %d items.\n", world->items.all.size()); @@ -184,24 +181,22 @@ DFhackCExport command_result df_cleanowned (Core * c, vector <string> & paramete item->getWear() ); - int32_t owner = Items::getItemOwnerID(item); - int32_t owner_index = Creatures->FindIndexById(owner); + df::unit *owner = Items::getItemOwner(item); std::string info; - if (owner_index >= 0) + if (owner) { - df::unit * temp = Creatures->GetCreature(owner_index); - info = temp->name.first_name; - if (!temp->name.nickname.empty()) - info += std::string(" '") + temp->name.nickname + "'"; + info = owner->name.first_name; + if (!owner->name.nickname.empty()) + info += std::string(" '") + owner->name.nickname + "'"; info += " "; - info += Translation::TranslateName(&temp->name,false); + info += Translation::TranslateName(&owner->name,false); c->con.print(", owner %s", info.c_str()); } if (!dry_run) { - if (!Items::removeItemOwner(item, Creatures)) + if (!Items::removeItemOwner(item)) c->con.print("(unsuccessfully) "); if (dump) item->flags.bits.dump = 1; |
