More of the items overhaul

develop
Petr Mrázek 2011-10-25 13:30:41 +02:00
parent 8648b2f080
commit 866b63f567
4 changed files with 27 additions and 37 deletions

@ -115,12 +115,18 @@ struct t_itemref : public t_virtual
class df_item class df_item
{ {
public: public:
// 4
int16_t x; int16_t x;
int16_t y; int16_t y;
// 8
int16_t z; int16_t z;
// C
t_itemflags flags; t_itemflags flags;
// 10
uint32_t age; uint32_t age;
// 14
uint32_t id; uint32_t id;
// 18
std::vector<void *> unk1; std::vector<void *> unk1;
std::vector<t_itemref *> itemrefs; std::vector<t_itemref *> itemrefs;
public: public:
@ -344,7 +350,7 @@ public:
virtual void fn166(void); virtual void fn166(void);
virtual void fn167(void); virtual void fn167(void);
// 0x2A0 // 0x2A0
virtual void fn168(void); virtual void fn168(void); // value returned (int) = first param to descriprion construction function
virtual void fn169(void); virtual void fn169(void);
virtual void fn170(void); virtual void fn170(void);
virtual void fn171(void); virtual void fn171(void);
@ -356,7 +362,8 @@ public:
// 0x2C0 // 0x2C0
virtual void fn176(void); virtual void fn176(void);
virtual void fn177(void); virtual void fn177(void);
virtual std::string *getItemDescription ( std::string * str, int bleh = 0); //virtual std::string *getItemDescription ( std::string * str, int sizes = 0); // 0 = stacked, 1 = singular, 2 = plural
virtual std::string *getItemDescription ( std::string * str, int sizes = 0); // 0 = stacked, 1 = singular, 2 = plural
virtual void fn179(void); virtual void fn179(void);
// more follows for sure... bleh. // more follows for sure... bleh.
}; };
@ -402,7 +409,7 @@ public:
df_item * findItemByID(int32_t id); df_item * findItemByID(int32_t id);
/// get a string describing an item /// get a string describing an item
std::string getItemDescription(const dfh_item & item, Materials * Materials); //std::string getItemDescription(const dfh_item & item, int type);
/// get a short name for an item /// get a short name for an item
std::string getItemClass(const dfh_item & item); std::string getItemClass(const dfh_item & item);
/// read an item, including the extra attributes /// read an item, including the extra attributes

@ -292,38 +292,11 @@ std::string Items::getItemClass(const dfh_item & item)
return virt->getClassName(); return virt->getClassName();
//return getItemClass(item.matdesc.itemType); //return getItemClass(item.matdesc.itemType);
} }
/*
std::string Items::getItemDescription(const dfh_item & item, Materials * Materials) std::string Items::getItemDescription(const dfh_item & item, int type)
{ {
/*
std::stringstream outss;
switch(item.quality)
{
case 0:
outss << "Ordinary ";
break;
case 1:
outss << "Well crafted ";
break;
case 2:
outss << "Finely crafted ";
break;
case 3:
outss << "Superior quality ";
break;
case 4:
outss << "Exceptionnal ";
break;
case 5:
outss << "Masterful ";
break;
default: outss << "Crazy quality " << item.quality << " "; break;
}
outss << Materials->getDescription(item.matdesc) << " " << getItemClass(item);
return outss.str();
*/
std::string strzzz; std::string strzzz;
item.base->getItemDescription(&strzzz); item.base->getItemDescription(&strzzz,type);
// delete ptrs; // delete ptrs;
return strzzz; return strzzz;
} }*/

@ -165,10 +165,12 @@ DFhackCExport command_result df_cleanowned (Core * c, vector <string> & paramete
if (confiscate) if (confiscate)
{ {
std::string description;
itm.base->getItemDescription(&description, 0);
c->con.print( c->con.print(
"0x%x %s (wear %d)", "0x%x %s (wear %d)",
itm.base, itm.base,
Items->getItemDescription(itm, Materials).c_str(), description.c_str(),
itm.wear_level itm.wear_level
); );

@ -228,15 +228,23 @@ DFhackCExport command_result df_dumpitems (Core * c, vector <string> & parameter
else else
sprintf(location, "%d,%d,%d", itm.base->x, itm.base->y, sprintf(location, "%d,%d,%d", itm.base->x, itm.base->y,
itm.base->z); itm.base->z);
std::string descr;
string name1,name2,name0;
itm.base->getItemDescription(&name0, 0);
itm.base->getItemDescription(&name1, 1);
itm.base->getItemDescription(&name2, 2);
c->con.print( c->con.print(
"%5d: addr:0x%08x %6d %08x (%s) vptr:0x%08x [%d]\n" "%5d: addr:0x%08x %6d %08x (%s) vptr:0x%08x [%d]\n"
" %s\n"
" %s\n"
" %s\n", " %s\n",
i, itm.base, itm.base->id, itm.base->flags.whole, i, itm.base, itm.base->id, itm.base->flags.whole,
location, location,
((t_virtual *)itm.base)->vptr, ((t_virtual *)itm.base)->vptr,
itm.wear_level, itm.wear_level,
Items->getItemDescription(itm, Materials).c_str() name0.c_str(),// stacked
name1.c_str(),// singular
name2.c_str() // plural
); );
chooser->postPrint(&itm); chooser->postPrint(&itm);
/* /*