Creature tile description support

Reading of the tile character and colors in the race structure, plus
offsets in Memory.xml.
Upgrade of creaturedump
develop
simon 2010-04-19 11:23:11 +02:00
parent 6d06cfcee1
commit 9705e05d8c
4 changed files with 26 additions and 5 deletions

@ -41,6 +41,13 @@ namespace DFHack
{ {
char rawname[128]; char rawname[128];
vector <t_creaturecaste> castes; vector <t_creaturecaste> castes;
uint8_t tile_character;
struct
{
uint16_t fore;
uint16_t back;
uint16_t bright;
} tilecolor;
}; };
class DFHACK_EXPORT Materials class DFHACK_EXPORT Materials

@ -232,6 +232,8 @@ bool Materials::ReadCreatureTypesEx (vector<t_creaturetype> & creatures)
uint32_t sizeof_string = mem->getHexValue ("sizeof_string"); uint32_t sizeof_string = mem->getHexValue ("sizeof_string");
uint32_t size = p_races.size(); uint32_t size = p_races.size();
uint32_t sizecas = 0; uint32_t sizecas = 0;
uint32_t tile_offset = mem->getOffset ("creature_tile");
uint32_t tile_color_offset = mem->getOffset ("creature_tile_color");
creatures.clear(); creatures.clear();
creatures.reserve (size); creatures.reserve (size);
for (uint32_t i = 0; i < size;i++) for (uint32_t i = 0; i < size;i++)
@ -250,6 +252,10 @@ bool Materials::ReadCreatureTypesEx (vector<t_creaturetype> & creatures)
p->readSTLString (caste_start + 3 * sizeof_string, caste.adjective, sizeof(caste.adjective)); p->readSTLString (caste_start + 3 * sizeof_string, caste.adjective, sizeof(caste.adjective));
mat.castes.push_back(caste); mat.castes.push_back(caste);
} }
mat.tile_character = p->readByte( p_races[i] + tile_offset );
mat.tilecolor.fore = p->readWord( p_races[i] + tile_color_offset );
mat.tilecolor.back = p->readWord( p_races[i] + tile_color_offset + 2 );
mat.tilecolor.bright = p->readWord( p_races[i] + tile_color_offset + 4 );
creatures.push_back(mat); creatures.push_back(mat);
} }
return true; return true;

@ -33,7 +33,7 @@ enum likeType
FOOD = 3 FOOD = 3
}; };
vector<DFHack::t_matgloss> creaturestypes; vector<DFHack::t_creaturetype> creaturestypes;
matGlosses mat; matGlosses mat;
vector< vector <DFHack::t_itemType> > itemTypes; vector< vector <DFHack::t_itemType> > itemTypes;
DFHack::memory_info *mem; DFHack::memory_info *mem;
@ -147,7 +147,13 @@ likeType printLike40d(DFHack::t_like like, const matGlosses & mat,const vector<
void printCreature(DFHack::API & DF, const DFHack::t_creature & creature) void printCreature(DFHack::API & DF, const DFHack::t_creature & creature)
{ {
cout << "address: " << hex << creature.origin << dec << " creature type: " << creaturestypes[creature.race].id << ", position: " << creature.x << "x " << creature.y << "y "<< creature.z << "z" << endl; cout << "address: " << hex << creature.origin << dec << " creature type: " << creaturestypes[creature.race].rawname
<< "[" << creaturestypes[creature.race].tile_character
<< "," << creaturestypes[creature.race].tilecolor.fore
<< "," << creaturestypes[creature.race].tilecolor.back
<< "," << creaturestypes[creature.race].tilecolor.bright
<< "]"
<< ", position: " << creature.x << "x " << creature.y << "y "<< creature.z << "z" << endl;
bool addendl = false; bool addendl = false;
if(creature.name.first_name[0]) if(creature.name.first_name[0])
{ {
@ -394,7 +400,7 @@ int main (int numargs, char ** args)
mem = DF.getMemoryInfo(); mem = DF.getMemoryInfo();
// get stone matgloss mapping // get stone matgloss mapping
if(!Materials->ReadCreatureTypes(creaturestypes)) if(!Materials->ReadCreatureTypesEx(creaturestypes))
{ {
cerr << "Can't get the creature types." << endl; cerr << "Can't get the creature types." << endl;
return 1; return 1;
@ -411,7 +417,7 @@ int main (int numargs, char ** args)
{ {
DFHack::t_creature temp; DFHack::t_creature temp;
Creatures->ReadCreature(i,temp); Creatures->ReadCreature(i,temp);
if(check.empty() || string(creaturestypes[temp.race].id) == check) if(check.empty() || string(creaturestypes[temp.race].rawname) == check)
{ {
cout << "index " << i << " "; cout << "index " << i << " ";

@ -1200,6 +1200,8 @@ map_data_1b60_offset 0x1B9c
WORLD + 0x54CD0 WORLD + 0x54CD0
<Address name="creature_type_vector">0x016AFE58</Address> <Address name="creature_type_vector">0x016AFE58</Address>
<Offset name="creature_type_caste_vector">0x138</Offset> <Offset name="creature_type_caste_vector">0x138</Offset>
<Offset name="creature_tile">0xE0</Offset>
<Offset name="creature_tile_color">0xF6</Offset>
<!-- <!--
NOT used yet NOT used yet