|
|
@ -124,6 +124,8 @@ Creatures::Creatures(DFContextShared* _d)
|
|
|
|
creatures.labors_offset = OG_creature_ex->getOffset ("labors");
|
|
|
|
creatures.labors_offset = OG_creature_ex->getOffset ("labors");
|
|
|
|
creatures.happiness_offset = OG_creature_ex->getOffset ("happiness");
|
|
|
|
creatures.happiness_offset = OG_creature_ex->getOffset ("happiness");
|
|
|
|
d->Ft_advanced = true;
|
|
|
|
d->Ft_advanced = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch(Error::All&){};
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
creatures.soul_vector_offset = OG_creature_ex->getOffset("soul_vector");
|
|
|
|
creatures.soul_vector_offset = OG_creature_ex->getOffset("soul_vector");
|
|
|
@ -136,8 +138,6 @@ Creatures::Creatures(DFContextShared* _d)
|
|
|
|
catch(Error::All&){};
|
|
|
|
catch(Error::All&){};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Error::All&){};
|
|
|
|
catch(Error::All&){};
|
|
|
|
}
|
|
|
|
|
|
|
|
catch(Error::All&){};
|
|
|
|
|
|
|
|
d->Inited = true;
|
|
|
|
d->Inited = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -169,6 +169,7 @@ bool Creatures::Finish()
|
|
|
|
bool Creatures::ReadCreature (const int32_t index, t_creature & furball)
|
|
|
|
bool Creatures::ReadCreature (const int32_t index, t_creature & furball)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(!d->Started) return false;
|
|
|
|
if(!d->Started) return false;
|
|
|
|
|
|
|
|
memset(&furball, 0, sizeof(t_creature));
|
|
|
|
// SHM fast path
|
|
|
|
// SHM fast path
|
|
|
|
Process * p = d->owner;
|
|
|
|
Process * p = d->owner;
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -190,12 +191,12 @@ bool Creatures::ReadCreature (const int32_t index, t_creature & furball)
|
|
|
|
Creatures2010::creature_offsets &offs = d->creatures;
|
|
|
|
Creatures2010::creature_offsets &offs = d->creatures;
|
|
|
|
|
|
|
|
|
|
|
|
//read creature from memory
|
|
|
|
//read creature from memory
|
|
|
|
|
|
|
|
if(d->Ft_basic)
|
|
|
|
|
|
|
|
{
|
|
|
|
// name
|
|
|
|
// name
|
|
|
|
d->d->readName(furball.name,temp + offs.name_offset);
|
|
|
|
d->d->readName(furball.name,temp + offs.name_offset);
|
|
|
|
|
|
|
|
|
|
|
|
// basic stuff
|
|
|
|
// basic stuff
|
|
|
|
p->readDWord (temp + offs.happiness_offset, furball.happiness);
|
|
|
|
|
|
|
|
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);
|
|
|
@ -204,6 +205,15 @@ bool Creatures::ReadCreature (const int32_t index, t_creature & furball)
|
|
|
|
p->readWord (temp + offs.caste_offset, furball.caste);
|
|
|
|
p->readWord (temp + offs.caste_offset, furball.caste);
|
|
|
|
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);
|
|
|
|
|
|
|
|
// custom profession
|
|
|
|
|
|
|
|
p->readSTLString(temp + offs.custom_profession_offset, furball.custom_profession, sizeof(furball.custom_profession));
|
|
|
|
|
|
|
|
// profession
|
|
|
|
|
|
|
|
furball.profession = p->readByte (temp + offs.profession_offset);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(d->Ft_advanced)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// happiness
|
|
|
|
|
|
|
|
p->readDWord (temp + offs.happiness_offset, furball.happiness);
|
|
|
|
|
|
|
|
|
|
|
|
// physical attributes
|
|
|
|
// physical attributes
|
|
|
|
p->read(temp + offs.physical_offset,
|
|
|
|
p->read(temp + offs.physical_offset,
|
|
|
@ -215,50 +225,36 @@ bool Creatures::ReadCreature (const int32_t index, t_creature & furball)
|
|
|
|
furball.mood_skill = p->readWord (temp + offs.mood_skill_offset);
|
|
|
|
furball.mood_skill = p->readWord (temp + offs.mood_skill_offset);
|
|
|
|
d->d->readName(furball.artifact_name, temp + offs.artifact_name_offset);
|
|
|
|
d->d->readName(furball.artifact_name, temp + offs.artifact_name_offset);
|
|
|
|
|
|
|
|
|
|
|
|
// custom profession
|
|
|
|
|
|
|
|
p->readSTLString(temp + offs.custom_profession_offset, furball.custom_profession, sizeof(furball.custom_profession));
|
|
|
|
|
|
|
|
//fill_char_buf (furball.custom_profession, p->readSTLString (temp + offs.custom_profession_offset));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// labors
|
|
|
|
// labors
|
|
|
|
p->read (temp + offs.labors_offset, NUM_CREATURE_LABORS, furball.labors);
|
|
|
|
p->read (temp + offs.labors_offset, NUM_CREATURE_LABORS, furball.labors);
|
|
|
|
|
|
|
|
|
|
|
|
// profession
|
|
|
|
|
|
|
|
furball.profession = p->readByte (temp + offs.profession_offset);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
furball.current_job.occupationPtr = p->readDWord (temp + offs.current_job_offset);
|
|
|
|
|
|
|
|
if(furball.current_job.occupationPtr)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
furball.current_job.active = true;
|
|
|
|
|
|
|
|
furball.current_job.jobType = p->readByte (furball.current_job.occupationPtr + d->OG_jobs->getOffset("type") );
|
|
|
|
|
|
|
|
furball.current_job.jobId = p->readDWord (furball.current_job.occupationPtr + d->OG_jobs->getOffset("id") );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
furball.current_job.active = false;;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
furball.birth_year = p->readDWord (temp + offs.birth_year_offset );
|
|
|
|
furball.birth_year = p->readDWord (temp + offs.birth_year_offset );
|
|
|
|
furball.birth_time = p->readDWord (temp + offs.birth_time_offset );
|
|
|
|
furball.birth_time = p->readDWord (temp + offs.birth_time_offset );
|
|
|
|
|
|
|
|
|
|
|
|
// current job HACK: the job object isn't cleanly represented here
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
uint32_t jobIdAddr = p->readDWord (temp + offs.creature_current_job_offset);
|
|
|
|
* p->readDWord(temp + offs.creature_pregnancy_offset, furball.pregnancy_timer);
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
if (jobIdAddr)
|
|
|
|
// appearance
|
|
|
|
{
|
|
|
|
DfVector <uint32_t> app(p, temp + offs.appearance_vector_offset);
|
|
|
|
furball.current_job.active = true;
|
|
|
|
furball.nbcolors = app.size();
|
|
|
|
furball.current_job.jobId = p->readByte (jobIdAddr + offs.creature_current_job_id_offset);
|
|
|
|
if(furball.nbcolors>MAX_COLORS)
|
|
|
|
}
|
|
|
|
furball.nbcolors = MAX_COLORS;
|
|
|
|
else
|
|
|
|
for(uint32_t i = 0; i < furball.nbcolors; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
furball.current_job.active = false;
|
|
|
|
furball.color[i] = app[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//likes
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
p->readDWord(temp + offs.creature_pregnancy_offset, furball.pregnancy_timer);
|
|
|
|
DfVector <uint32_t> likes(d->p, temp + offs.creature_likes_offset);
|
|
|
|
*/
|
|
|
|
furball.numLikes = likes.getSize();
|
|
|
|
|
|
|
|
for(uint32_t i = 0;i<furball.numLikes;i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
uint32_t temp2 = *(uint32_t *) likes[i];
|
|
|
|
|
|
|
|
p->read(temp2,sizeof(t_like),(uint8_t *) &furball.likes[i]);
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(d->Ft_soul)
|
|
|
|
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
// enum soul pointer vector
|
|
|
|
// enum soul pointer vector
|
|
|
|
DfVector <uint32_t> souls(p,temp + offs.creature_soul_vector_offset);
|
|
|
|
DfVector <uint32_t> souls(p,temp + offs.creature_soul_vector_offset);
|
|
|
@ -294,25 +290,21 @@ bool Creatures::ReadCreature (const int32_t index, t_creature & furball)
|
|
|
|
sizeof (uint16_t) * NUM_CREATURE_TRAITS,
|
|
|
|
sizeof (uint16_t) * NUM_CREATURE_TRAITS,
|
|
|
|
(uint8_t *) &furball.defaultSoul.traits);
|
|
|
|
(uint8_t *) &furball.defaultSoul.traits);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
DfVector <uint32_t> app(p, temp + offs.appearance_vector_offset);
|
|
|
|
if(d->Ft_jobs)
|
|
|
|
furball.nbcolors = app.size();
|
|
|
|
|
|
|
|
if(furball.nbcolors>MAX_COLORS)
|
|
|
|
|
|
|
|
furball.nbcolors = MAX_COLORS;
|
|
|
|
|
|
|
|
for(uint32_t i = 0; i < furball.nbcolors; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
furball.color[i] = app[i];
|
|
|
|
furball.current_job.occupationPtr = p->readDWord (temp + offs.current_job_offset);
|
|
|
|
|
|
|
|
if(furball.current_job.occupationPtr)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
furball.current_job.active = true;
|
|
|
|
|
|
|
|
furball.current_job.jobType = p->readByte (furball.current_job.occupationPtr + d->OG_jobs->getOffset("type") );
|
|
|
|
|
|
|
|
furball.current_job.jobId = p->readDWord (furball.current_job.occupationPtr + d->OG_jobs->getOffset("id") );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//likes
|
|
|
|
else
|
|
|
|
/*
|
|
|
|
|
|
|
|
DfVector <uint32_t> likes(d->p, temp + offs.creature_likes_offset);
|
|
|
|
|
|
|
|
furball.numLikes = likes.getSize();
|
|
|
|
|
|
|
|
for(uint32_t i = 0;i<furball.numLikes;i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint32_t temp2 = *(uint32_t *) likes[i];
|
|
|
|
furball.current_job.active = false;;
|
|
|
|
p->read(temp2,sizeof(t_like),(uint8_t *) &furball.likes[i]);
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|