Support reading the item ID field, which is used for cross-referencing.

develop
Alexander Gavrilov 2011-05-09 14:04:39 +04:00
parent e993bbcb67
commit 14f291d539
4 changed files with 13 additions and 4 deletions

@ -997,6 +997,7 @@
<Group name="Items">
<!-- most of those seem completely unused! -->
<Address name="items_vector" />
<Offset name="id" description="Item ID offset"/>
List of offsets in the VTable :
<Offset name="item_type_accessor" />
<Offset name="item_subtype_accessor" />
@ -2236,6 +2237,7 @@
<Offsets>
<Group name="Items" valid="true">
<Address name="items_vector" value="0x16c4540"/>
<Offset name="id" value="0x14"/>
<Offset name="item_ref_vector" value="0x28" />
<Offset name="owner_ref_id_field" value="0x4" />
<Offset name="item_wear_accessor" value="0xCC" />
@ -3025,6 +3027,7 @@
</Group>
<Group name="Items">
<Address name="items_vector" value="0x940b1fc" />
<Offset name="id" value="0x14"/>
<Offset name="item_type_accessor" value="0x0" />
<Offset name="item_subtype_accessor" value="0x4" />
<Offset name="item_subindex_accessor" value="0x8" />

@ -78,6 +78,7 @@ struct t_item
struct dfh_item
{
int32_t id;
t_item base;
t_material matdesc;
int32_t quantity;

@ -96,6 +96,7 @@ private:
Accessor * AWear;
Process * p;
bool hasDecoration;
int idFieldOffset;
public:
ItemDesc(uint32_t VTable, Process * p);
bool readItem(uint32_t itemptr, dfh_item & item);
@ -365,6 +366,8 @@ ItemDesc::ItemDesc(uint32_t VTable, Process *p)
AQuality = buildAccessor(Items, p, "item_quality_accessor", VTable);
AWear = buildAccessor(Items, p, "item_wear_accessor", VTable);
idFieldOffset = Items->getOffset("id");
this->vtable = VTable;
this->p = p;
this->className = p->readClassName(VTable).substr(5);
@ -395,6 +398,7 @@ string ItemDesc::dumpAccessors()
bool ItemDesc::readItem(uint32_t itemptr, DFHack::dfh_item &item)
{
item.id = p->readDWord(itemptr+idFieldOffset);
p->read(itemptr, sizeof(t_item), (uint8_t*)&item.base);
item.matdesc.itemType = AMainType->getValue(itemptr);
item.matdesc.subType = ASubType->getValue(itemptr);
@ -419,6 +423,7 @@ class Items::Private
std::map<uint32_t, ItemDesc *> descVTable;
uint32_t refVectorOffset;
uint32_t refIDOffset;
uint32_t idFieldOffset;
ClassNameCheck isOwnerRefClass;
};

@ -60,8 +60,8 @@ int main ()
if(itm.base.x == x && itm.base.y == y && itm.base.z == z)
{
printf(
"%5d: %08x %08x (%d,%d,%d) #%08x [%d] %s - %s\n",
i, itm.origin, itm.base.flags.whole,
"%5d: %08x %6d %08x (%d,%d,%d) #%08x [%d] %s - %s\n",
i, itm.origin, itm.id, itm.base.flags.whole,
itm.base.x, itm.base.y, itm.base.z,
itm.base.vtable,
itm.wear_level,
@ -75,8 +75,8 @@ int main ()
else
{
printf(
"%5d: %08x %08x (%d,%d,%d) #%08x [%d] %s - %s\n",
i, itm.origin, itm.base.flags.whole,
"%5d: %08x %6d %08x (%d,%d,%d) #%08x [%d] %s - %s\n",
i, itm.origin, itm.id, itm.base.flags.whole,
itm.base.x, itm.base.y, itm.base.z,
itm.base.vtable,
itm.wear_level,