|
|
|
@ -51,7 +51,7 @@ DFhackCExport command_result df_cleanitems (Core * c, vector <string> & paramete
|
|
|
|
|
c->Suspend();
|
|
|
|
|
DFHack::Items * Items = c->getItems();
|
|
|
|
|
|
|
|
|
|
vector <t_item*> p_items;
|
|
|
|
|
vector <df_item*> p_items;
|
|
|
|
|
if(!Items->readItemVector(p_items))
|
|
|
|
|
{
|
|
|
|
|
c->con.printerr("Can't access the item vector.\n");
|
|
|
|
@ -63,17 +63,14 @@ DFhackCExport command_result df_cleanitems (Core * c, vector <string> & paramete
|
|
|
|
|
int cleaned_items = 0, cleaned_total = 0;
|
|
|
|
|
for (std::size_t i = 0; i < numItems; i++)
|
|
|
|
|
{
|
|
|
|
|
t_item * itm = p_items[i];
|
|
|
|
|
// TODO - get peterix to expand the item base class so it includes this pointer
|
|
|
|
|
uint32_t cont_ptr = *(uint32_t *)((int8_t *)itm + 0x0064);
|
|
|
|
|
if (!cont_ptr)
|
|
|
|
|
df_item * itm = p_items[i];
|
|
|
|
|
if(!itm->contaminants)
|
|
|
|
|
continue;
|
|
|
|
|
std::vector<void *> *contaminants = (std::vector<void *> *)cont_ptr;
|
|
|
|
|
if (contaminants->size())
|
|
|
|
|
if (itm->contaminants->size())
|
|
|
|
|
{
|
|
|
|
|
cleaned_items++;
|
|
|
|
|
cleaned_total += contaminants->size();
|
|
|
|
|
contaminants->clear();
|
|
|
|
|
cleaned_total += itm->contaminants->size();
|
|
|
|
|
itm->contaminants->clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
c->Resume();
|
|
|
|
|