From db1decea0a0bbec2483acf40cbd770334cbe6e1a Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 12 May 2010 14:41:43 +0200 Subject: [PATCH] Creature birth date and time is now read --- dfhack/include/modules/Creatures.h | 3 +++ dfhack/modules/Creatures.cpp | 6 ++++++ dfhack/shm/mod-creature2010.h | 2 ++ examples/creaturedump.cpp | 1 + output/Memory.xml | 7 ++++++- 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/dfhack/include/modules/Creatures.h b/dfhack/include/modules/Creatures.h index 92d7809aa..bfa661084 100644 --- a/dfhack/include/modules/Creatures.h +++ b/dfhack/include/modules/Creatures.h @@ -348,6 +348,9 @@ namespace DFHack t_soul defaultSoul; uint32_t nbcolors; uint32_t color[MAX_COLORS]; + + uint32_t birth_year; + uint32_t birth_time; }; class APIPrivate; diff --git a/dfhack/modules/Creatures.cpp b/dfhack/modules/Creatures.cpp index 004233d66..c083f5d8d 100644 --- a/dfhack/modules/Creatures.cpp +++ b/dfhack/modules/Creatures.cpp @@ -100,6 +100,10 @@ Creatures::Creatures(APIPrivate* _d) // appearance creatures.appearance_vector_offset = minfo->getOffset("creature_appearance_vector"); + + //birth + creatures.birth_year_offset = minfo->getOffset("creature_birth_year"); + creatures.birth_time_offset = minfo->getOffset("creature_birth_time"); // name offsets for the creature module creatures.name_firstname_offset = minfo->getOffset("name_firstname"); @@ -217,6 +221,8 @@ bool Creatures::ReadCreature (const int32_t index, t_creature & furball) furball.current_job.active = false;; } + furball.birth_year = p->readDWord (temp + offs.birth_year_offset ); + furball.birth_time = p->readDWord (temp + offs.birth_time_offset ); // current job HACK: the job object isn't cleanly represented here /* diff --git a/dfhack/shm/mod-creature2010.h b/dfhack/shm/mod-creature2010.h index 93006d827..f52122127 100644 --- a/dfhack/shm/mod-creature2010.h +++ b/dfhack/shm/mod-creature2010.h @@ -65,6 +65,8 @@ typedef struct uint32_t soul_mental_offset; uint32_t soul_traits_offset; uint32_t appearance_vector_offset; + uint32_t birth_year_offset; + uint32_t birth_time_offset; } creature_offsets; typedef struct diff --git a/examples/creaturedump.cpp b/examples/creaturedump.cpp index 50e716137..89a1b10ef 100644 --- a/examples/creaturedump.cpp +++ b/examples/creaturedump.cpp @@ -204,6 +204,7 @@ void printCreature(DFHack::API & DF, const DFHack::t_creature & creature) } */ cout << endl; + cout << "Born on the year " << creature.birth_year << ", month " << (creature.birth_time/1200/28) << ", day " << ((creature.birth_time/1200) % 28 + 1) << endl; cout << "Appearance : "; for(unsigned int i = 0; i0x1C 0x38 - + Time + ==== +
0x0e47e08
+
0x0e79f00
Creatures ========= @@ -1156,6 +1159,8 @@ map_data_1b60_offset 0x1B9c 0x28C 0x290 + 0x298 + 0x29C 0x464