Add item contaminants vector to df_item, fixed up cleanitems plugin to use it.

develop
Petr Mrázek 2011-10-27 01:08:59 +02:00
parent f2205364b8
commit 335ad28fe5
3 changed files with 61 additions and 43 deletions

@ -105,6 +105,11 @@ struct t_itemref : public t_virtual
int32_t value; int32_t value;
}; };
struct df_contaminant
{
// fixme: figure it out
};
/** /**
* A partial mirror of a DF base type for items * A partial mirror of a DF base type for items
* \ingroup grp_items * \ingroup grp_items
@ -125,7 +130,22 @@ public:
uint32_t id; uint32_t id;
// 18 // 18
std::vector<void *> unk1; std::vector<void *> unk1;
// 24 L, 28 W
std::vector<t_itemref *> itemrefs; std::vector<t_itemref *> itemrefs;
// 30 L, 38 W - these were mostly unset (0xCC with malloc patch)
int16_t mystery_meat[12];
// 48 L, 50 W
int32_t mystery1;
// 4C L, 54 W
int32_t mystery2;
// 50 L, 58 W
int32_t mystery3;
// 54 L, 5C W
int32_t mystery4;
// 58 L, 60 W
int32_t mystery5;
// 5C L, 64 W - pointer to vector of contaminants
std::vector <df_contaminant *> * contaminants;
public: public:
// 0x0 // 0x0
virtual int32_t getType(); virtual int32_t getType();

@ -33,6 +33,7 @@ DFHACK_PLUGIN(plants plants.cpp)
DFHACK_PLUGIN(fastdwarf fastdwarf.cpp) DFHACK_PLUGIN(fastdwarf fastdwarf.cpp)
DFHACK_PLUGIN(prospector prospector.cpp) DFHACK_PLUGIN(prospector prospector.cpp)
DFHACK_PLUGIN(cleanmap cleanmap.cpp) DFHACK_PLUGIN(cleanmap cleanmap.cpp)
DFHACK_PLUGIN(cleanitems cleanitems.cpp)
DFHACK_PLUGIN(weather weather.cpp) DFHACK_PLUGIN(weather weather.cpp)
DFHACK_PLUGIN(vdig vdig.cpp) DFHACK_PLUGIN(vdig vdig.cpp)
DFHACK_PLUGIN(colonies colonies.cpp) DFHACK_PLUGIN(colonies colonies.cpp)

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