From 1ff7f6e4783192a7cb6e1c41a0429b5e55410432 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 19 Apr 2010 14:36:21 +0200 Subject: [PATCH] Add civilization support : * field in creature structure * offset of the player civilization id --- dfhack/include/modules/Creatures.h | 4 +++- dfhack/modules/Creatures.cpp | 13 ++++++++++++- dfhack/shm/mod-creature2010.h | 3 ++- output/Memory.xml | 5 +++-- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/dfhack/include/modules/Creatures.h b/dfhack/include/modules/Creatures.h index e20264fa3..e6f826f9b 100644 --- a/dfhack/include/modules/Creatures.h +++ b/dfhack/include/modules/Creatures.h @@ -319,6 +319,7 @@ namespace DFHack uint16_t y; uint16_t z; uint32_t race; + int32_t civ; t_creaturflags1 flags1; t_creaturflags2 flags2; @@ -369,9 +370,10 @@ namespace DFHack /// write labors of a creature (for Dwarf Therapist) bool WriteLabors(const uint32_t index, uint8_t labors[NUM_CREATURE_LABORS]); uint32_t GetDwarfRaceIndex ( void ); + int32_t GetDwarfCivId ( void ); private: struct Private; Private *d; }; } -#endif \ No newline at end of file +#endif diff --git a/dfhack/modules/Creatures.cpp b/dfhack/modules/Creatures.cpp index 53b034589..ef50735e7 100644 --- a/dfhack/modules/Creatures.cpp +++ b/dfhack/modules/Creatures.cpp @@ -52,6 +52,7 @@ struct Creatures::Private Creatures2010::creature_offsets creatures; uint32_t creature_module; uint32_t dwarf_race_index_addr; + uint32_t dwarf_civ_id_addr; DfVector *p_cre; APIPrivate *d; Process *owner; @@ -74,6 +75,7 @@ Creatures::Creatures(APIPrivate* _d) creatures.profession_offset = minfo->getOffset ("creature_profession"); creatures.custom_profession_offset = minfo->getOffset ("creature_custom_profession"); creatures.race_offset = minfo->getOffset ("creature_race"); + creatures.civ_offset = minfo->getOffset ("creature_civ"); creatures.flags1_offset = minfo->getOffset ("creature_flags1"); creatures.flags2_offset = minfo->getOffset ("creature_flags2"); 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_words_offset = minfo->getOffset("name_words"); 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 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->read (temp + offs.pos_offset, 3 * sizeof (uint16_t), (uint8_t *) & (furball.x)); // xyz really 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->readDWord (temp + offs.flags1_offset, furball.flags1.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); } +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) { @@ -331,4 +342,4 @@ bool Creatures::getCurrentCursorCreature(uint32_t & creature_index) creature_index = p->readDWord(d->current_cursor_creature_offset); return true; } -*/ \ No newline at end of file +*/ diff --git a/dfhack/shm/mod-creature2010.h b/dfhack/shm/mod-creature2010.h index c17da3d53..656cd6561 100644 --- a/dfhack/shm/mod-creature2010.h +++ b/dfhack/shm/mod-creature2010.h @@ -39,6 +39,7 @@ typedef struct uint32_t profession_offset; uint32_t custom_profession_offset; uint32_t race_offset; + int32_t civ_offset; uint32_t flags1_offset; uint32_t flags2_offset; uint32_t name_offset; @@ -94,4 +95,4 @@ DFPP_module Init(void); } } -#endif \ No newline at end of file +#endif diff --git a/output/Memory.xml b/output/Memory.xml index 1b94d3000..647c0eb36 100644 --- a/output/Memory.xml +++ b/output/Memory.xml @@ -1124,6 +1124,7 @@ map_data_1b60_offset 0x1B9c =========
0x0166ecc4
0x01470fbc
+
0x01470fb0
0x0 0x6c @@ -1134,7 +1135,7 @@ map_data_1b60_offset 0x1B9c 0xFC 0x110 0x114 - 0X120 + 0X120 0X1F4 0X21C 0x238 @@ -1375,7 +1376,7 @@ map_data_1b60_offset 0x1B9c 0xFC 0x110 0x114 - 0X120 + 0X120 0X1F4 0X21C