Happiness writing function added and tested. Seems ok so far

develop
Simon Jackson 2010-06-15 07:59:18 +08:00 committed by Petr Mrázek
parent b732e63673
commit b95efc22fe
3 changed files with 397 additions and 381 deletions

@ -203,7 +203,7 @@ struct t_settlement
struct t_attrib struct t_attrib
{ {
uint32_t level; uint32_t level;
uint32_t field_4; uint32_t field_4; // offset from beginning, purpose unknown
uint32_t field_8; uint32_t field_8;
uint32_t field_C; uint32_t field_C;
uint32_t leveldiff; uint32_t leveldiff;

@ -363,17 +363,24 @@ namespace DFHack
bool Start( uint32_t & numCreatures); bool Start( uint32_t & numCreatures);
bool Finish(); bool Finish();
/* Read Functions */
// Read creatures in a box, starting with index. Returns -1 if no more creatures // Read creatures in a box, starting with index. Returns -1 if no more creatures
// found. Call repeatedly do get all creatures in a specified box (uses tile coords) // found. Call repeatedly do get all creatures in a specified box (uses tile coords)
int32_t ReadCreatureInBox(const int32_t index, t_creature & furball, int32_t ReadCreatureInBox(const int32_t index, t_creature & furball,
const uint16_t x1, const uint16_t y1,const uint16_t z1, const uint16_t x1, const uint16_t y1,const uint16_t z1,
const uint16_t x2, const uint16_t y2,const uint16_t z2); const uint16_t x2, const uint16_t y2,const uint16_t z2);
bool ReadCreature(const int32_t index, t_creature & furball); bool ReadCreature(const int32_t index, t_creature & furball);
/// write labors of a creature (for Dwarf Therapist) bool ReadJob(const t_creature * furball, std::vector<t_material> & mat);
bool WriteLabors(const uint32_t index, uint8_t labors[NUM_CREATURE_LABORS]);
/* Getters */
uint32_t GetDwarfRaceIndex ( void ); uint32_t GetDwarfRaceIndex ( void );
int32_t GetDwarfCivId ( void ); int32_t GetDwarfCivId ( void );
bool ReadJob(const t_creature * furball, std::vector<t_material> & mat);
/* Write Functions */
// write labors of a creature (for Dwarf Therapist)
bool WriteLabors(const uint32_t index, uint8_t labors[NUM_CREATURE_LABORS]);
bool WriteHappiness(const uint32_t index, const uint32_t happinessValue);
private: private:
struct Private; struct Private;
Private *d; Private *d;

@ -346,8 +346,6 @@ int32_t Creatures::ReadCreatureInBox (int32_t index, t_creature & furball,
} }
} }
bool Creatures::WriteLabors(const uint32_t index, uint8_t labors[NUM_CREATURE_LABORS]) bool Creatures::WriteLabors(const uint32_t index, uint8_t labors[NUM_CREATURE_LABORS])
{ {
if(!d->Started) return false; if(!d->Started) return false;
@ -362,6 +360,17 @@ bool Creatures::WriteLabors(const uint32_t index, uint8_t labors[NUM_CREATURE_LA
return true; return true;
} }
bool Creatures::WriteHappiness(const uint32_t index, const uint32_t happinessValue)
{
if(!d->Started)
return false;
uint32_t temp = d->p_cre->at (index);
Process * p = d->owner;
p->writeDWord (temp + d->creatures.happiness_offset, happinessValue);
return true;
}
uint32_t Creatures::GetDwarfRaceIndex() uint32_t Creatures::GetDwarfRaceIndex()
{ {
if(!d->Inited) return 0; if(!d->Inited) return 0;