Item quantity support for 31.25

develop
Petr Mrázek 2011-05-11 23:53:16 +02:00
parent ed1477b53d
commit 4631ec2e0d
3 changed files with 22 additions and 7 deletions

@ -1005,6 +1005,7 @@
<Offset name="item_subindex_accessor" /> <Offset name="item_subindex_accessor" />
<Offset name="item_index_accessor" /> <Offset name="item_index_accessor" />
<Offset name="item_quality_accessor" /> <Offset name="item_quality_accessor" />
<Offset name="item_quantity_accessor" />
<!-- <!--
<Offset name="item_improvement_vector" /> <Offset name="item_improvement_vector" />
<Offset name="item_improvement_subindex" /> <Offset name="item_improvement_subindex" />
@ -2242,6 +2243,7 @@
<Offset name="item_ref_vector" value="0x28" /> <Offset name="item_ref_vector" value="0x28" />
<Offset name="owner_ref_id_field" value="0x4" /> <Offset name="owner_ref_id_field" value="0x4" />
<Offset name="item_wear_accessor" value="0xCC" /> <Offset name="item_wear_accessor" value="0xCC" />
<Offset name="item_quantity_accessor" value="0x214" /> 0x194 TEST
<Offset name="item_quality_accessor" value="0x25C" /> <Offset name="item_quality_accessor" value="0x25C" />
</Group> </Group>
</Offsets> </Offsets>
@ -3034,6 +3036,7 @@
<Offset name="item_subtype_accessor" value="0x4" /> <Offset name="item_subtype_accessor" value="0x4" />
<Offset name="item_subindex_accessor" value="0x8" /> <Offset name="item_subindex_accessor" value="0x8" />
<Offset name="item_index_accessor" value="0xC" /> <Offset name="item_index_accessor" value="0xC" />
<Offset name="item_quantity_accessor" value="0x214" /> 0x194 TEST
<Offset name="item_quality_accessor" value="0x25C" /> <Offset name="item_quality_accessor" value="0x25C" />
<Offset name="item_wear_accessor" value="0xCC" /> <Offset name="item_wear_accessor" value="0xCC" />
<Offset name="item_ref_vector" value="0x24" /> <Offset name="item_ref_vector" value="0x24" />

@ -93,6 +93,7 @@ private:
Accessor * ASubIndex; Accessor * ASubIndex;
Accessor * AIndex; Accessor * AIndex;
Accessor * AQuality; Accessor * AQuality;
Accessor * AQuantity;
Accessor * AWear; Accessor * AWear;
Process * p; Process * p;
bool hasDecoration; bool hasDecoration;
@ -365,6 +366,7 @@ ItemDesc::ItemDesc(uint32_t VTable, Process *p)
AIndex = buildAccessor(Items, p, "item_index_accessor", VTable); AIndex = buildAccessor(Items, p, "item_index_accessor", VTable);
AQuality = buildAccessor(Items, p, "item_quality_accessor", VTable); AQuality = buildAccessor(Items, p, "item_quality_accessor", VTable);
AWear = buildAccessor(Items, p, "item_wear_accessor", VTable); AWear = buildAccessor(Items, p, "item_wear_accessor", VTable);
AQuantity = buildAccessor(Items, p, "item_quantity_accessor", VTable);
idFieldOffset = Items->getOffset("id"); idFieldOffset = Items->getOffset("id");
@ -391,6 +393,7 @@ string ItemDesc::dumpAccessors()
outss << "ASubIndex :" << ASubIndex->dump() << endl; outss << "ASubIndex :" << ASubIndex->dump() << endl;
outss << "AIndex :" << AIndex->dump() << endl; outss << "AIndex :" << AIndex->dump() << endl;
outss << "AQuality :" << AQuality->dump() << endl; outss << "AQuality :" << AQuality->dump() << endl;
outss << "AQuantity :" << AQuantity->dump() << endl;
outss << "AWear :" << AWear->dump() << endl; outss << "AWear :" << AWear->dump() << endl;
return outss.str(); return outss.str();
} }
@ -405,7 +408,7 @@ bool ItemDesc::readItem(uint32_t itemptr, DFHack::dfh_item &item)
item.matdesc.subIndex = ASubIndex->getValue(itemptr); item.matdesc.subIndex = ASubIndex->getValue(itemptr);
item.matdesc.index = AIndex->getValue(itemptr); item.matdesc.index = AIndex->getValue(itemptr);
item.quality = AQuality->getValue(itemptr); item.quality = AQuality->getValue(itemptr);
item.quantity = 1; /* TODO */ item.quantity = AQuantity->getValue(itemptr);
item.origin = itemptr; item.origin = itemptr;
// FIXME: use templates. seriously. // FIXME: use templates. seriously.
// Note: this accessor returns a 32-bit value with the higher // Note: this accessor returns a 32-bit value with the higher

@ -57,31 +57,40 @@ int main ()
Items->readItem(p_items[i],itm); Items->readItem(p_items[i],itm);
if(x != -30000) if(x != -30000)
{ {
if(itm.base.x == x && itm.base.y == y && itm.base.z == z) if(itm.base.x == x
&& itm.base.y == y
&& itm.base.z == z
&& itm.base.flags.on_ground
&& !itm.base.flags.in_chest
&& !itm.base.flags.in_inventory
&& !itm.base.flags.in_building
)
{ {
printf( printf(
"%5d: %08x %6d %08x (%d,%d,%d) #%08x [%d] %s - %s\n", "%5d: %08x %6d %08x (%d,%d,%d) #%08x [%d] %s - %s. Stack: %d\n",
i, itm.origin, itm.id, itm.base.flags.whole, i, itm.origin, itm.id, itm.base.flags.whole,
itm.base.x, itm.base.y, itm.base.z, itm.base.x, itm.base.y, itm.base.z,
itm.base.vtable, itm.base.vtable,
itm.wear_level, itm.wear_level,
Items->getItemClass(itm.matdesc.itemType).c_str(), Items->getItemClass(itm.matdesc.itemType).c_str(),
Items->getItemDescription(itm, Materials).c_str() Items->getItemDescription(itm, Materials).c_str(),
itm.quantity
); );
hexdump(DF,p_items[i],0x100); hexdump(DF,p_items[i],0x300);
cout << Items->dumpAccessors(itm) << endl; cout << Items->dumpAccessors(itm) << endl;
} }
} }
else else
{ {
printf( printf(
"%5d: %08x %6d %08x (%d,%d,%d) #%08x [%d] %s - %s\n", "%5d: %08x %6d %08x (%d,%d,%d) #%08x [%d] %s - %s. Stack: %d\n",
i, itm.origin, itm.id, itm.base.flags.whole, i, itm.origin, itm.id, itm.base.flags.whole,
itm.base.x, itm.base.y, itm.base.z, itm.base.x, itm.base.y, itm.base.z,
itm.base.vtable, itm.base.vtable,
itm.wear_level, itm.wear_level,
Items->getItemClass(itm.matdesc.itemType).c_str(), Items->getItemClass(itm.matdesc.itemType).c_str(),
Items->getItemDescription(itm, Materials).c_str() Items->getItemDescription(itm, Materials).c_str(),
itm.quantity
); );
} }
} }