develop
Petr Mrázek 2010-11-01 10:47:15 +01:00
commit cb6cf89b0c
4 changed files with 81 additions and 6 deletions

@ -1751,6 +1751,9 @@
<PETimeStamp value="0x4CA9D544" /> <PETimeStamp value="0x4CA9D544" />
<MD5 value="702b3ebaae468f73eb1411af54863013" /> <MD5 value="702b3ebaae468f73eb1411af54863013" />
<Offsets> <Offsets>
<Group name="Materials">
<Address name="other" value="0x16A21FC"/> 0x16445F0 + 0x5DC0C see code at 0x9CFB01
</Group>
<Group name="Creatures"> <Group name="Creatures">
<Address name="current_civ" value="0x1484868 0x14848b8" /> <Address name="current_civ" value="0x1484868 0x14848b8" />
<Address name="current_race" value="0x1484874 0x14848c4" /> <Address name="current_race" value="0x1484874 0x14848c4" />
@ -1771,6 +1774,15 @@
<Address name="current_year" value="0xe8b410" /> <Address name="current_year" value="0xe8b410" />
<Address name="current_weather" value="0x1480948" /> <Address name="current_weather" value="0x1480948" />
</Group> </Group>
<Group name="Items">
<Address name="items_vector" value="0x16580d8" />
<Offset name="item_type_accessor" value="0x0" />
<Offset name="item_subtype_accessor" value="0x4" />
<Offset name="item_subindex_accessor" value="0x8" />
<Offset name="item_index_accessor" value="0xC" />
<Offset name="item_quality_accessor" value="0x238" />
<Offset name="item_improvement_vector" value="0x90" />
</Group>
</Offsets> </Offsets>
</Version> </Version>
.-"""-. .-"""-.

@ -116,6 +116,21 @@ Accessor::Accessor(uint32_t function, Process *p)
this->offset1 = (funcText>>24) & 0xffff; this->offset1 = (funcText>>24) & 0xffff;
return; return;
} }
if( (funcText&0x000000FF00FFFFFFLL) == 0x000000C300418B66LL )
{
/* mov ax, [ecx+xx]; ret; (shorter instruction)*/
this->type = ACCESSOR_INDIRECT;
this->offset1 = (funcText>>24) & 0xff;
return;
}
if( (funcText&0x00000000FF00FFFFLL) == 0x00000000C300418BLL )
{
/* mov eax, [ecx+xx]; ret; */
this->type = ACCESSOR_INDIRECT;
this->offset1 = (funcText>>16) & 0xff;
this->dataWidth = 4;
return;
}
if( (funcText&0xFFFFFFFF0000FFFFLL) == 0x8B6600000000818BLL ) if( (funcText&0xFFFFFFFF0000FFFFLL) == 0x8B6600000000818BLL )
{ {
uint64_t funcText2 = p->readQuad(function+8); uint64_t funcText2 = p->readQuad(function+8);
@ -134,6 +149,13 @@ Accessor::Accessor(uint32_t function, Process *p)
this->offset1 = (funcText>>24) & 0xffff; this->offset1 = (funcText>>24) & 0xffff;
return; return;
} }
if( (funcText&0x000000FF00FFFFFFLL) == 0x000000C30041BF0FLL )
{
/* movsx eax, word ptr [ecx+xx]; ret (shorter opcode)*/
this->type = ACCESSOR_INDIRECT;
this->offset1 = (funcText>>24) & 0xff;
return;
}
if( (funcText&0xFFFFFFFF0000FFFFLL) == 0xCCC300000000818BLL ) if( (funcText&0xFFFFFFFF0000FFFFLL) == 0xCCC300000000818BLL )
{ {
/* mov eax, [ecx+xx]; ret; */ /* mov eax, [ecx+xx]; ret; */
@ -250,6 +272,7 @@ Items::~Items()
while (it != d->descVTable.end()) while (it != d->descVTable.end())
{ {
delete (*it).second; delete (*it).second;
++it;
} }
d->descType.clear(); d->descType.clear();
d->descVTable.clear(); d->descVTable.clear();

@ -459,7 +459,7 @@ void Materials::ReadAllMaterials(void)
this->ReadCreatureTypes(); this->ReadCreatureTypes();
this->ReadCreatureTypesEx(); this->ReadCreatureTypesEx();
this->ReadDescriptorColors(); this->ReadDescriptorColors();
//this->ReadOthers(); this->ReadOthers();
} }
std::string Materials::getDescription(t_material & mat) std::string Materials::getDescription(t_material & mat)
@ -478,6 +478,12 @@ std::string Materials::getDescription(t_material & mat)
{ {
if (mat.subIndex>=this->other.size()) if (mat.subIndex>=this->other.size())
{ {
if (mat.itemType == 0) {
if(mat.subIndex<0)
return "any inorganic";
else
return this->inorganic[mat.subIndex].id;
}
if(mat.subIndex<0) if(mat.subIndex<0)
return "any"; return "any";
if(mat.subIndex>=this->raceEx.size()) if(mat.subIndex>=this->raceEx.size())

@ -41,7 +41,8 @@ int main ()
Materials = DF->getMaterials(); Materials = DF->getMaterials();
Materials->ReadAllMaterials(); Materials->ReadAllMaterials();
p = DF->getProcess(); p = DF->getProcess();
DFHack::DfVector <uint32_t> p_items (p, p->getDescriptor()->getAddress ("items_vector")); DFHack::OffsetGroup* itemGroup = mem->getGroup("Items");
DFHack::DfVector <uint32_t> p_items (p, itemGroup->getAddress("items_vector"));
uint32_t size = p_items.size(); uint32_t size = p_items.size();
Items = DF->getItems(); Items = DF->getItems();
@ -49,6 +50,7 @@ int main ()
printf("type\tvtable\tname\tquality\tdecorate\n"); printf("type\tvtable\tname\tquality\tdecorate\n");
for (i=0;i<size;i++) for (i=0;i<size;i++)
{ {
uint32_t curItem = p_items[i];
uint32_t vtable = p->readDWord(p_items[i]); uint32_t vtable = p->readDWord(p_items[i]);
uint32_t func0 = p->readDWord(vtable); uint32_t func0 = p->readDWord(vtable);
uint64_t funct0 = p->readQuad(func0); uint64_t funct0 = p->readQuad(func0);
@ -84,6 +86,8 @@ int main ()
if (funct1 == 0xC300000092818B66LL) if (funct1 == 0xC300000092818B66LL)
quality = p->readWord(p_items[i]+0x92); quality = p->readWord(p_items[i]+0x92);
if (funct1 == 0xC300000082818B66LL)
quality = p->readWord(p_items[i]+0x82);
else if (funct1 == 0xCCCCCCCCCCC3C033LL) else if (funct1 == 0xCCCCCCCCCCC3C033LL)
quality = 0; quality = 0;
else else
@ -115,6 +119,11 @@ int main ()
uint32_t off1 = (funcBt>>24) & 0xffff; uint32_t off1 = (funcBt>>24) & 0xffff;
typeB = p->readWord(p_items[i] + off1); typeB = p->readWord(p_items[i] + off1);
} }
else if ( (funcBt&0x000000FF00FFFFFFLL) == 0x000000C300418B66LL )
{
uint32_t off1 = (funcBt>>24) & 0xff;
typeB = p->readWord(p_items[i] + off1);
}
else else
printf("bad typeB func @%p\n", (void*) funcB); printf("bad typeB func @%p\n", (void*) funcB);
} }
@ -126,6 +135,16 @@ int main ()
uint32_t off1 = (funcCt>>24)&0xffff; uint32_t off1 = (funcCt>>24)&0xffff;
typeC = p->readWord(p_items[i] + off1); typeC = p->readWord(p_items[i] + off1);
} }
else if ( (funcCt&0x000000FF00FFFFFFLL) == 0x000000C300418B66LL )
{
uint32_t off1 = (funcCt>>24) & 0xff;
typeC = p->readWord(p_items[i] + off1);
}
else if ( (funcCt&0x00000000FF00FFFFLL) == 0x00000000C300418BLL )
{
uint32_t off1 = (funcCt>>16) & 0xff;
typeC = p->readWord(p_items[i] + off1);
}
else else
printf("bad typeC func @%p\n", (void*) funcC); printf("bad typeC func @%p\n", (void*) funcC);
@ -134,12 +153,27 @@ int main ()
else if ( (funcDt&0xFFFFFFFF0000FFFFLL) == 0xCCC300000000818BLL ) else if ( (funcDt&0xFFFFFFFF0000FFFFLL) == 0xCCC300000000818BLL )
{ {
uint32_t off1 = (funcDt>>16) & 0xffff; uint32_t off1 = (funcDt>>16) & 0xffff;
typeD = p->readDWord(p_items[i] + off1); typeD = p->readWord(p_items[i] + off1);
} }
else if ( (funcDt&0xFFFFFF0000FFFFFFLL) == 0xC30000000081BF0FLL ) else if ( (funcDt&0xFFFFFF0000FFFFFFLL) == 0xC30000000081BF0FLL )
{ {
uint32_t off1 = (funcDt>>24) & 0xffff; uint32_t off1 = (funcDt>>24) & 0xffff;
typeD = (int16_t) p->readWord(p_items[i] + off1); typeD = p->readWord(p_items[i] + off1);
}
else if ( (funcDt&0x000000FF00FFFFFFLL) == 0x000000C30041BF0FLL )
{
uint32_t off1 = (funcDt>>24) & 0xff;
typeD = p->readWord(p_items[i] + off1);
}
else if ( (funcDt&0x000000FF00FFFFFFLL) == 0x000000C300418B66LL )
{
uint32_t off1 = (funcDt>>24) & 0xff;
typeD = p->readWord(p_items[i] + off1);
}
else if ( (funcDt&0x00000000FF00FFFFLL) == 0x00000000C300418BLL )
{
uint32_t off1 = (funcDt>>16) & 0xff;
typeD = p->readDWord(p_items[i] + off1);
} }
else else
printf("bad typeD func @%p\n", (void*) funcD); printf("bad typeD func @%p\n", (void*) funcD);
@ -155,8 +189,8 @@ int main ()
{ {
bool sep = false; bool sep = false;
printf("\tdeco=["); printf("\tdeco=[");
uint32_t decStart = p->readDWord(p_items[i] + 0xAC); uint32_t decStart = p->readDWord(p_items[i] + 0x90); // 0xAC pre .13
uint32_t decEnd = p->readDWord(p_items[i] + 0xB0); uint32_t decEnd = p->readDWord(p_items[i] + 0x94); // 0xB0 pre .13
if (decStart != decEnd) if (decStart != decEnd)
{ {
for (j=decStart;j<decEnd;j+=4) for (j=decStart;j<decEnd;j+=4)