Fix for Creature module

develop
Petr Mrázek 2010-08-31 17:21:47 +02:00
parent 66c3d30bd8
commit 86aa19daa4
2 changed files with 38 additions and 32 deletions

@ -939,11 +939,11 @@
<Offset name="type" description="seems to be just like the old occupations" /> <Offset name="type" description="seems to be just like the old occupations" />
<Offset name="materials_vector" /> <Offset name="materials_vector" />
<Group name="material"> <Group name="material">
<Offset name="material_maintype" description="like mood materials, 0=bars, 4=stone, 5=wood, 57=cloth, 54=leather ..." /> <Offset name="maintype" description="like mood materials, 0=bars, 4=stone, 5=wood, 57=cloth, 54=leather ..." />
<Offset name="material_sectype1" description="subsubtype ?" /> <Offset name="sectype1" description="subsubtype ?" />
<Offset name="material_sectype2" description="subtype ?" /> <Offset name="sectype2" description="subtype ?" />
<Offset name="material_sectype3" description="index of material (for example, 2 is for silver)" /> <Offset name="sectype3" description="index of material (for example, 2 is for silver)" />
<Offset name="material_flags" description="set only for shell / bone mood requirements ?" /> <Offset name="flags" description="set only for shell / bone mood requirements ?" />
</Group> </Group>
</Group> </Group>
</Group> </Group>
@ -1214,11 +1214,11 @@
<Offset name="type" value="0x8" /> seems to be just like the old occupations <Offset name="type" value="0x8" /> seems to be just like the old occupations
<Offset name="materials_vector" value="0xa4" /> <Offset name="materials_vector" value="0xa4" />
<Group name="material"> <Group name="material">
<Offset name="material_maintype" value="0x0" /> like mood materials, 0=bars, 4=stone, 5=wood, 57=cloth, 54=leather ... <Offset name="maintype" value="0x0" /> like mood materials, 0=bars, 4=stone, 5=wood, 57=cloth, 54=leather ...
<Offset name="material_sectype1" value="0x2" /> subsubtype ? <Offset name="sectype1" value="0x2" /> subsubtype ?
<Offset name="material_sectype2" value="0x4" /> subtype ? <Offset name="sectype2" value="0x4" /> subtype ?
<Offset name="material_sectype3" value="0x8" /> index of material (for example, 2 is for silver) <Offset name="sectype3" value="0x8" /> index of material (for example, 2 is for silver)
<Offset name="material_flags" value="0x18" /> set only for shell / bone mood requirements ? <Offset name="flags" value="0x18" /> set only for shell / bone mood requirements ?
</Group> </Group>
</Group> </Group>
</Group> </Group>
@ -1746,11 +1746,11 @@
<Offset name="type" value="0x8" /> seems to be just like the old occupations <Offset name="type" value="0x8" /> seems to be just like the old occupations
<Offset name="materials_vector" value="0xa4" /> <Offset name="materials_vector" value="0xa4" />
<Group name="material"> <Group name="material">
<Offset name="material_maintype" value="0x0" /> like mood materials, 0=bars, 4=stone, 5=wood, 57=cloth, 54=leather ... <Offset name="maintype" value="0x0" /> like mood materials, 0=bars, 4=stone, 5=wood, 57=cloth, 54=leather ...
<Offset name="material_sectype1" value="0x2" /> subsubtype ? <Offset name="sectype1" value="0x2" /> subsubtype ?
<Offset name="material_sectype2" value="0x4" /> subtype ? <Offset name="sectype2" value="0x4" /> subtype ?
<Offset name="material_sectype3" value="0x8" /> index of material (for example, 2 is for silver) <Offset name="sectype3" value="0x8" /> index of material (for example, 2 is for silver)
<Offset name="material_flags" value="0x18" /> set only for shell / bone mood requirements ? <Offset name="flags" value="0x18" /> set only for shell / bone mood requirements ?
</Group> </Group>
</Group> </Group>
--> -->
@ -1865,6 +1865,10 @@
<Version name="v0.31.12 linux" os="linux" base="v0.31.11 linux" rebase="-0x1000"> <Version name="v0.31.12 linux" os="linux" base="v0.31.11 linux" rebase="-0x1000">
<MD5 value="e79cead03187ecb692961b316b7cdcd4" /> <MD5 value="e79cead03187ecb692961b316b7cdcd4" />
<Offsets> <Offsets>
<Group name="Constructions">
<Address name="vector" value="0x92f30a4"/>
<Offset name="sizeof" value="0x14"/>
</Group>
<Group name="Position"> <Group name="Position">
<Address name="screen_tiles_pointer" value="0x09487970" /> <Address name="screen_tiles_pointer" value="0x09487970" />
</Group> </Group>

@ -54,6 +54,8 @@ struct Creatures::Private
uint32_t creature_module; uint32_t creature_module;
uint32_t dwarf_race_index_addr; uint32_t dwarf_race_index_addr;
uint32_t dwarf_civ_id_addr; uint32_t dwarf_civ_id_addr;
OffsetGroup * OG_jobs;
OffsetGroup * OG_job_mats;
DfVector <uint32_t> *p_cre; DfVector <uint32_t> *p_cre;
DFContextShared *d; DFContextShared *d;
Process *owner; Process *owner;
@ -123,6 +125,8 @@ Creatures::Creatures(DFContextShared* _d)
creatures.name_nickname_offset = OG_name->getOffset("nick"); creatures.name_nickname_offset = OG_name->getOffset("nick");
creatures.name_words_offset = OG_name->getOffset("second_words"); creatures.name_words_offset = OG_name->getOffset("second_words");
} }
d->OG_jobs = OG_Creatures->getGroup("job");
d->OG_job_mats = d->OG_jobs->getGroup("material");
/* /*
// upload offsets to the SHM // upload offsets to the SHM
@ -231,8 +235,8 @@ bool Creatures::ReadCreature (const int32_t index, t_creature & furball)
if(furball.current_job.occupationPtr) if(furball.current_job.occupationPtr)
{ {
furball.current_job.active = true; furball.current_job.active = true;
furball.current_job.jobType = p->readByte (furball.current_job.occupationPtr + minfo->getOffset("job_type") ); 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 + minfo->getOffset("job_id") ); furball.current_job.jobId = p->readDWord (furball.current_job.occupationPtr + d->OG_jobs->getOffset("id") );
} }
else else
{ {
@ -538,17 +542,15 @@ bool Creatures::WriteJob(const t_creature * furball, std::vector<t_material> con
if(!d->Inited) return false; if(!d->Inited) return false;
if(!furball->current_job.active) return false; if(!furball->current_job.active) return false;
Process * p = d->owner; Process * p = d->owner;
VersionInfo * minfo = d->d->offset_descriptor; DfVector <uint32_t> cmats(p, furball->current_job.occupationPtr + d->OG_jobs->getOffset("materials_vector"));
DfVector <uint32_t> cmats(p, furball->current_job.occupationPtr + minfo->getOffset("job_materials_vector"));
for(i=0;i<cmats.size();i++) for(i=0;i<cmats.size();i++)
{ {
p->writeWord(cmats[i] + minfo->getOffset("job_material_maintype"), mat[i].itemType); p->writeWord(cmats[i] + d->OG_job_mats->getOffset("maintype"), mat[i].itemType);
p->writeWord(cmats[i] + minfo->getOffset("job_material_sectype1"), mat[i].subType); p->writeWord(cmats[i] + d->OG_job_mats->getOffset("sectype1"), mat[i].subType);
p->writeWord(cmats[i] + minfo->getOffset("job_material_sectype2"), mat[i].subIndex); p->writeWord(cmats[i] + d->OG_job_mats->getOffset("sectype2"), mat[i].subIndex);
p->writeDWord(cmats[i] + minfo->getOffset("job_material_sectype3"), mat[i].index); p->writeDWord(cmats[i] + d->OG_job_mats->getOffset("sectype3"), mat[i].index);
p->writeDWord(cmats[i] + minfo->getOffset("job_material_flags"), mat[i].flags); p->writeDWord(cmats[i] + d->OG_job_mats->getOffset("flags"), mat[i].flags);
} }
return true; return true;
} }
@ -610,15 +612,15 @@ bool Creatures::ReadJob(const t_creature * furball, vector<t_material> & mat)
Process * p = d->owner; Process * p = d->owner;
VersionInfo * minfo = d->d->offset_descriptor; VersionInfo * minfo = d->d->offset_descriptor;
DfVector <uint32_t> cmats(p, furball->current_job.occupationPtr + minfo->getOffset("job_materials_vector")); DfVector <uint32_t> cmats(p, furball->current_job.occupationPtr + d->OG_jobs->getOffset("materials_vector"));
mat.resize(cmats.size()); mat.resize(cmats.size());
for(i=0;i<cmats.size();i++) for(i=0;i<cmats.size();i++)
{ {
mat[i].itemType = p->readWord(cmats[i] + minfo->getOffset("job_material_maintype")); mat[i].itemType = p->readWord(cmats[i] + d->OG_job_mats->getOffset("maintype"));
mat[i].subType = p->readWord(cmats[i] + minfo->getOffset("job_material_sectype1")); mat[i].subType = p->readWord(cmats[i] + d->OG_job_mats->getOffset("sectype1"));
mat[i].subIndex = p->readWord(cmats[i] + minfo->getOffset("job_material_sectype2")); mat[i].subIndex = p->readWord(cmats[i] + d->OG_job_mats->getOffset("sectype2"));
mat[i].index = p->readDWord(cmats[i] + minfo->getOffset("job_material_sectype3")); mat[i].index = p->readDWord(cmats[i] + d->OG_job_mats->getOffset("sectype3"));
mat[i].flags = p->readDWord(cmats[i] + minfo->getOffset("job_material_flags")); mat[i].flags = p->readDWord(cmats[i] + d->OG_job_mats->getOffset("flags"));
} }
return true; return true;
} }