summaryrefslogtreecommitdiff
path: root/plugins/cleanowned.cpp
diff options
context:
space:
mode:
authorQuietust2012-01-24 11:32:34 -0600
committerQuietust2012-01-24 11:32:34 -0600
commitcc7c7795a161a467892ae60aa2ab67f5ff659e8f (patch)
treefcd4d92585de379e4c2fca7648ab2dfc1761066c /plugins/cleanowned.cpp
parent02d75e2c94eebaa771aef6da9ff9d83a786f904b (diff)
downloaddfhack-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.cpp21
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;