bug fix, sex writing (seems to work ok), trait writing(untested)

develop
Simon Jackson 2010-06-16 20:47:05 +01:00
parent 8e30073d9d
commit 9a15f00c8d
4 changed files with 39 additions and 2 deletions

@ -698,6 +698,11 @@ string memory_info::getTraitName(const uint32_t traitIdx) const
throw Error::MissingMemoryDefinition("traitname", traitIdx); throw Error::MissingMemoryDefinition("traitname", traitIdx);
} }
std::vector< std::vector<std::string>> const& memory_info::getAllTraits()
{
return d->traits;
}
string memory_info::getLabor (const uint32_t laborIdx) string memory_info::getLabor (const uint32_t laborIdx)
{ {
if(d->labors.count(laborIdx)) if(d->labors.count(laborIdx))

@ -73,6 +73,7 @@ namespace DFHack
std::string getTrait (const uint32_t, const uint32_t) const; std::string getTrait (const uint32_t, const uint32_t) const;
std::string getTraitName(const uint32_t) const; std::string getTraitName(const uint32_t) const;
std::string getLabor (const uint32_t); std::string getLabor (const uint32_t);
std::vector< std::vector<std::string>> const& getAllTraits();
DFHack::t_level getLevelInfo(const uint32_t level) const; DFHack::t_level getLevelInfo(const uint32_t level) const;

@ -257,8 +257,8 @@ namespace DFHack
struct t_skill struct t_skill
{ {
uint32_t id; uint32_t id;
uint32_t experience;
uint32_t rating; uint32_t rating;
uint32_t experience;
}; };
struct t_job struct t_job
{ {
@ -385,6 +385,8 @@ namespace DFHack
bool WriteFlags(const uint32_t index, const uint32_t flags1, const uint32_t flags2); bool WriteFlags(const uint32_t index, const uint32_t flags1, const uint32_t flags2);
bool WriteSkills(const uint32_t index, const t_soul &soul); bool WriteSkills(const uint32_t index, const t_soul &soul);
bool WriteAttributes(const uint32_t index, const t_creature &creature); bool WriteAttributes(const uint32_t index, const t_creature &creature);
bool WriteSex(const uint32_t index, const uint8_t sex);
bool WriteTraits(const uint32_t index, const t_soul &soul);
private: private:
struct Private; struct Private;

@ -445,6 +445,35 @@ bool Creatures::WriteAttributes(const uint32_t index, const t_creature &creature
return true; return true;
} }
bool Creatures::WriteSex(const uint32_t index, const uint8_t sex)
{
if(!d->Started)
return false;
uint32_t temp = d->p_cre->at (index);
Process * p = d->owner;
p->writeByte (temp + d->creatures.sex_offset, sex);
}
bool Creatures::WriteTraits(const uint32_t index, const t_soul &soul)
{
if(!d->Started)
return false;
uint32_t temp = d->p_cre->at (index);
Process * p = d->owner;
uint32_t souloff = p->readDWord(temp + d->creatures.default_soul_offset);
if(!souloff)
return false;
p->write(souloff + d->creatures.soul_traits_offset,
sizeof (uint16_t) * NUM_CREATURE_TRAITS,
(uint8_t *) &soul.traits);
return true;
}
uint32_t Creatures::GetDwarfRaceIndex() uint32_t Creatures::GetDwarfRaceIndex()
{ {
if(!d->Inited) return 0; if(!d->Inited) return 0;