Creature rework

develop
Petr Mrázek 2010-09-03 02:15:09 +02:00
parent ece423a611
commit dc6aa19083
3 changed files with 63 additions and 67 deletions

@ -1032,7 +1032,7 @@
<Group name="World">
<Address name="current_tick" description="Current time of the year" />
<Address name="current_year" description="Current year" />
<Address name="current_weather" description="Single byte, 0=clear, 1=raining, 2=snowing" />
<Address name="current_weather" description="Single byte, 0=clear, 1=raining, 2=snowing" />
</Group>
</Offsets>
</Base>

@ -50,6 +50,10 @@ struct Creatures::Private
{
bool Inited;
bool Started;
bool Ft_basic;
bool Ft_advanced;
bool Ft_jobs;
bool Ft_soul;
Creatures2010::creature_offsets creatures;
uint32_t creature_module;
uint32_t dwarf_race_index_addr;
@ -69,82 +73,72 @@ Creatures::Creatures(DFContextShared* _d)
d->Inited = false;
d->Started = false;
d->d->InitReadNames(); // throws on error
VersionInfo * minfo = d->d->offset_descriptor;
OffsetGroup *OG_Creatures = minfo->getGroup("Creatures");
OffsetGroup *OG_creature = OG_Creatures->getGroup("creature");
OffsetGroup *OG_creature_ex = OG_creature->getGroup("advanced");
OffsetGroup *OG_soul = OG_Creatures->getGroup("soul");
OffsetGroup * OG_name = minfo->getGroup("name");
d->OG_jobs = OG_Creatures->getGroup("job");
d->OG_job_mats = d->OG_jobs->getGroup("material");
d->Ft_basic = d->Ft_advanced = d->Ft_jobs = d->Ft_soul = false;
Creatures2010::creature_offsets &creatures = d->creatures;
try
{
VersionInfo * minfo = d->d->offset_descriptor;
Creatures2010::creature_offsets &creatures = d->creatures;
OffsetGroup *OG_Creatures = minfo->getGroup("Creatures");
// Creatures
creatures.vector = OG_Creatures->getAddress ("vector");
d->dwarf_race_index_addr = OG_Creatures->getAddress("current_race");
d->dwarf_civ_id_addr = OG_Creatures->getAddress("current_civ");
// Creatures/creature
creatures.name_offset = OG_creature->getOffset ("name");
creatures.custom_profession_offset = OG_creature->getOffset ("custom_profession");
creatures.profession_offset = OG_creature->getOffset ("profession");
creatures.race_offset = OG_creature->getOffset ("race");
creatures.pos_offset = OG_creature->getOffset ("position");
creatures.flags1_offset = OG_creature->getOffset ("flags1");
creatures.flags2_offset = OG_creature->getOffset ("flags2");
creatures.sex_offset = OG_creature->getOffset ("sex");
creatures.caste_offset = OG_creature->getOffset ("caste");
creatures.id_offset = OG_creature->getOffset ("id");
creatures.civ_offset = OG_creature->getOffset ("civ");
// name struct
creatures.name_firstname_offset = OG_name->getOffset("first");
creatures.name_nickname_offset = OG_name->getOffset("nick");
creatures.name_words_offset = OG_name->getOffset("second_words");
d->Ft_basic = true;
try
{
creatures.vector = OG_Creatures->getAddress ("vector");
d->dwarf_race_index_addr = OG_Creatures->getAddress("current_race");
d->dwarf_civ_id_addr = OG_Creatures->getAddress("current_civ");
OffsetGroup *OG_creature = OG_Creatures->getGroup("creature");
{
creatures.name_offset = OG_creature->getOffset ("name");
creatures.custom_profession_offset = OG_creature->getOffset ("custom_profession");
creatures.profession_offset = OG_creature->getOffset ("profession");
creatures.race_offset = OG_creature->getOffset ("race");
creatures.pos_offset = OG_creature->getOffset ("position");
creatures.flags1_offset = OG_creature->getOffset ("flags1");
creatures.flags2_offset = OG_creature->getOffset ("flags2");
creatures.sex_offset = OG_creature->getOffset ("sex");
creatures.caste_offset = OG_creature->getOffset ("caste");
creatures.id_offset = OG_creature->getOffset ("id");
creatures.civ_offset = OG_creature->getOffset ("civ");
OffsetGroup *OG_creature_ex = OG_creature->getGroup("advanced");
{
creatures.inventory_offset = OG_creature_ex->getOffset("inventory_vector");
creatures.pickup_equipment_bit = OG_creature_ex->getOffset("pickup_equipment_bit");
creatures.mood_offset = OG_creature_ex->getOffset("mood");
// pregnancy
// pregnancy_ptr
creatures.birth_year_offset = OG_creature_ex->getOffset("birth_year");
creatures.birth_time_offset = OG_creature_ex->getOffset("birth_time");
creatures.current_job_offset = OG_creature_ex->getOffset("current_job");
creatures.mood_skill_offset = OG_creature_ex->getOffset("current_job_skill");
creatures.physical_offset = OG_creature_ex->getOffset("physical");
creatures.appearance_vector_offset = OG_creature_ex->getOffset("appearance_vector");
creatures.artifact_name_offset = OG_creature_ex->getOffset("artifact_name");
creatures.soul_vector_offset = OG_creature_ex->getOffset("soul_vector");
creatures.default_soul_offset = OG_creature_ex->getOffset("current_soul");
creatures.labors_offset = OG_creature_ex->getOffset ("labors");
creatures.happiness_offset = OG_creature_ex->getOffset ("happiness");
}
}
OffsetGroup *OG_soul = OG_Creatures->getGroup("soul");
creatures.inventory_offset = OG_creature_ex->getOffset("inventory_vector");
creatures.pickup_equipment_bit = OG_creature_ex->getOffset("pickup_equipment_bit");
creatures.mood_offset = OG_creature_ex->getOffset("mood");
// pregnancy
// pregnancy_ptr
creatures.birth_year_offset = OG_creature_ex->getOffset("birth_year");
creatures.birth_time_offset = OG_creature_ex->getOffset("birth_time");
creatures.current_job_offset = OG_creature_ex->getOffset("current_job");
creatures.mood_skill_offset = OG_creature_ex->getOffset("current_job_skill");
creatures.physical_offset = OG_creature_ex->getOffset("physical");
creatures.appearance_vector_offset = OG_creature_ex->getOffset("appearance_vector");
creatures.artifact_name_offset = OG_creature_ex->getOffset("artifact_name");
creatures.labors_offset = OG_creature_ex->getOffset ("labors");
creatures.happiness_offset = OG_creature_ex->getOffset ("happiness");
d->Ft_advanced = true;
try
{
creatures.soul_vector_offset = OG_creature_ex->getOffset("soul_vector");
creatures.default_soul_offset = OG_creature_ex->getOffset("current_soul");
creatures.soul_mental_offset = OG_soul->getOffset("mental");
creatures.soul_skills_vector_offset = OG_soul->getOffset("skills_vector");
creatures.soul_traits_offset = OG_soul->getOffset("traits");
d->Ft_soul = true;
}
catch(Error::All&){};
}
// name offsets for the creature module
OffsetGroup * OG_name = minfo->getGroup("name");
{
creatures.name_firstname_offset = OG_name->getOffset("first");
creatures.name_nickname_offset = OG_name->getOffset("nick");
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
if(p->getModuleIndex("Creatures2010",1,d->creature_module))
{
// supply the module with offsets so it can work with them
memcpy(SHMDATA(Creatures2010::creature_offsets),&creatures,sizeof(Creatures2010::creature_offsets));
const uint32_t cmd = Creatures2010::CREATURE_INIT + (d->creature_module << 16);
p->SetAndWait(cmd);
}
*/
d->Inited = true;
}
catch (Error::MissingMemoryDefinition&)
{
d->Inited = false;
throw;
catch(Error::All&){};
}
catch(Error::All&){};
d->Inited = true;
}
Creatures::~Creatures()

@ -26,11 +26,13 @@ void printWeather(DFHack::WeatherType current)
break;
case RAINING:
cout << "It is raining." << endl;
cout << "Options:" << endl;
cout << "'c' to clear the sky." << endl;
cout << "'s' to make it snow." << endl;
break;
case SNOWING:
cout << "It is snowing." << endl;
cout << "Options:" << endl;
cout << "'c' to clear the sky." << endl;
cout << "'r' to make it rain." << endl;
break;