Add civilization support :

* field in creature structure
* offset of the player civilization id
develop
simon 2010-04-19 14:36:21 +02:00
parent 9705e05d8c
commit 1ff7f6e478
4 changed files with 20 additions and 5 deletions

@ -319,6 +319,7 @@ namespace DFHack
uint16_t y; uint16_t y;
uint16_t z; uint16_t z;
uint32_t race; uint32_t race;
int32_t civ;
t_creaturflags1 flags1; t_creaturflags1 flags1;
t_creaturflags2 flags2; t_creaturflags2 flags2;
@ -369,9 +370,10 @@ namespace DFHack
/// write labors of a creature (for Dwarf Therapist) /// write labors of a creature (for Dwarf Therapist)
bool WriteLabors(const uint32_t index, uint8_t labors[NUM_CREATURE_LABORS]); bool WriteLabors(const uint32_t index, uint8_t labors[NUM_CREATURE_LABORS]);
uint32_t GetDwarfRaceIndex ( void ); uint32_t GetDwarfRaceIndex ( void );
int32_t GetDwarfCivId ( void );
private: private:
struct Private; struct Private;
Private *d; Private *d;
}; };
} }
#endif #endif

@ -52,6 +52,7 @@ struct Creatures::Private
Creatures2010::creature_offsets creatures; Creatures2010::creature_offsets creatures;
uint32_t creature_module; uint32_t creature_module;
uint32_t dwarf_race_index_addr; uint32_t dwarf_race_index_addr;
uint32_t dwarf_civ_id_addr;
DfVector <uint32_t> *p_cre; DfVector <uint32_t> *p_cre;
APIPrivate *d; APIPrivate *d;
Process *owner; Process *owner;
@ -74,6 +75,7 @@ Creatures::Creatures(APIPrivate* _d)
creatures.profession_offset = minfo->getOffset ("creature_profession"); creatures.profession_offset = minfo->getOffset ("creature_profession");
creatures.custom_profession_offset = minfo->getOffset ("creature_custom_profession"); creatures.custom_profession_offset = minfo->getOffset ("creature_custom_profession");
creatures.race_offset = minfo->getOffset ("creature_race"); creatures.race_offset = minfo->getOffset ("creature_race");
creatures.civ_offset = minfo->getOffset ("creature_civ");
creatures.flags1_offset = minfo->getOffset ("creature_flags1"); creatures.flags1_offset = minfo->getOffset ("creature_flags1");
creatures.flags2_offset = minfo->getOffset ("creature_flags2"); creatures.flags2_offset = minfo->getOffset ("creature_flags2");
creatures.name_offset = minfo->getOffset ("creature_name"); creatures.name_offset = minfo->getOffset ("creature_name");
@ -97,6 +99,7 @@ Creatures::Creatures(APIPrivate* _d)
creatures.name_nickname_offset = minfo->getOffset("name_nickname"); creatures.name_nickname_offset = minfo->getOffset("name_nickname");
creatures.name_words_offset = minfo->getOffset("name_words"); creatures.name_words_offset = minfo->getOffset("name_words");
d->dwarf_race_index_addr = minfo->getAddress("dwarf_race_index"); d->dwarf_race_index_addr = minfo->getAddress("dwarf_race_index");
d->dwarf_civ_id_addr = minfo->getAddress("dwarf_civ_id");
// upload offsets to the SHM // upload offsets to the SHM
if(p->getModuleIndex("Creatures2010",1,d->creature_module)) if(p->getModuleIndex("Creatures2010",1,d->creature_module))
{ {
@ -170,6 +173,7 @@ bool Creatures::ReadCreature (const int32_t index, t_creature & furball)
p->readDWord (temp + offs.id_offset, furball.id); p->readDWord (temp + offs.id_offset, furball.id);
p->read (temp + offs.pos_offset, 3 * sizeof (uint16_t), (uint8_t *) & (furball.x)); // xyz really p->read (temp + offs.pos_offset, 3 * sizeof (uint16_t), (uint8_t *) & (furball.x)); // xyz really
p->readDWord (temp + offs.race_offset, furball.race); p->readDWord (temp + offs.race_offset, furball.race);
furball.civ = p->readDWord (temp + offs.civ_offset);
p->readByte (temp + offs.sex_offset, furball.sex); p->readByte (temp + offs.sex_offset, furball.sex);
p->readDWord (temp + offs.flags1_offset, furball.flags1.whole); p->readDWord (temp + offs.flags1_offset, furball.flags1.whole);
p->readDWord (temp + offs.flags2_offset, furball.flags2.whole); p->readDWord (temp + offs.flags2_offset, furball.flags2.whole);
@ -323,6 +327,13 @@ uint32_t Creatures::GetDwarfRaceIndex()
return p->readDWord(d->dwarf_race_index_addr); return p->readDWord(d->dwarf_race_index_addr);
} }
int32_t Creatures::GetDwarfCivId()
{
if(!d->Inited) return -1;
Process * p = d->owner;
printf("civid=%p\n", d->dwarf_civ_id_addr);
return p->readDWord(d->dwarf_civ_id_addr);
}
/* /*
bool Creatures::getCurrentCursorCreature(uint32_t & creature_index) bool Creatures::getCurrentCursorCreature(uint32_t & creature_index)
{ {
@ -331,4 +342,4 @@ bool Creatures::getCurrentCursorCreature(uint32_t & creature_index)
creature_index = p->readDWord(d->current_cursor_creature_offset); creature_index = p->readDWord(d->current_cursor_creature_offset);
return true; return true;
} }
*/ */

@ -39,6 +39,7 @@ typedef struct
uint32_t profession_offset; uint32_t profession_offset;
uint32_t custom_profession_offset; uint32_t custom_profession_offset;
uint32_t race_offset; uint32_t race_offset;
int32_t civ_offset;
uint32_t flags1_offset; uint32_t flags1_offset;
uint32_t flags2_offset; uint32_t flags2_offset;
uint32_t name_offset; uint32_t name_offset;
@ -94,4 +95,4 @@ DFPP_module Init(void);
} }
} }
#endif #endif

@ -1124,6 +1124,7 @@ map_data_1b60_offset 0x1B9c
========= =========
<Address name="creature_vector">0x0166ecc4</Address> <Address name="creature_vector">0x0166ecc4</Address>
<Address name="dwarf_race_index">0x01470fbc</Address> <Address name="dwarf_race_index">0x01470fbc</Address>
<Address name="dwarf_civ_id">0x01470fb0</Address>
<Offset name="creature_name">0x0</Offset> <Offset name="creature_name">0x0</Offset>
<Offset name="creature_custom_profession">0x6c</Offset> <Offset name="creature_custom_profession">0x6c</Offset>
@ -1134,7 +1135,7 @@ map_data_1b60_offset 0x1B9c
<Offset name="creature_flags2">0xFC</Offset> <Offset name="creature_flags2">0xFC</Offset>
<Offset name="creature_sex">0x110</Offset> <Offset name="creature_sex">0x110</Offset>
<Offset name="creature_id">0x114</Offset> <Offset name="creature_id">0x114</Offset>
<Offset name="creature_side">0X120</Offset> <!-- what? --> <Offset name="creature_civ">0X120</Offset>
<Offset name="creature_soulskill_vector">0X1F4</Offset> <Offset name="creature_soulskill_vector">0X1F4</Offset>
<Offset name="creature_pickup_equipment_bit">0X21C</Offset> <Offset name="creature_pickup_equipment_bit">0X21C</Offset>
<Offset name="creature_mood">0x238</Offset> <Offset name="creature_mood">0x238</Offset>
@ -1375,7 +1376,7 @@ map_data_1b60_offset 0x1B9c
<Offset name="creature_flags2">0xFC</Offset> <Offset name="creature_flags2">0xFC</Offset>
<Offset name="creature_sex">0x110</Offset> <Offset name="creature_sex">0x110</Offset>
<Offset name="creature_id">0x114</Offset> <Offset name="creature_id">0x114</Offset>
<Offset name="creature_side">0X120</Offset> <Offset name="creature_civ">0X120</Offset>
<Offset name="creature_soulskill_vector">0X1F4</Offset> <Offset name="creature_soulskill_vector">0X1F4</Offset>
<Offset name="creature_pickup_equipment_bit">0X21C</Offset> <Offset name="creature_pickup_equipment_bit">0X21C</Offset>
<!--<Offset name="creature_mood">0x238</Offset>--> <!--<Offset name="creature_mood">0x238</Offset>-->