diff --git a/library/include/dfhack/modules/Items.h b/library/include/dfhack/modules/Items.h index df0718a4d..2b74bbb9e 100644 --- a/library/include/dfhack/modules/Items.h +++ b/library/include/dfhack/modules/Items.h @@ -73,7 +73,7 @@ union t_itemflags unsigned int unk3 : 1; ///< 0000 0800 unknown, unseen, unusable unsigned int unk4 : 1; ///< 0000 1000 unknown, unseen - unsigned int unk5 : 1; ///< 0000 2000 unknown, unseen + unsigned int murder : 1; ///< 0000 2000 Implies murder - used in fell moods unsigned int foreign : 1; ///< 0000 4000 Item is imported unsigned int trader : 1; ///< 0000 8000 Item ownwed by trader diff --git a/library/modules/Creatures.cpp b/library/modules/Creatures.cpp index c19b6cc93..6964e29c9 100644 --- a/library/modules/Creatures.cpp +++ b/library/modules/Creatures.cpp @@ -53,73 +53,12 @@ struct Creatures::Private { bool Inited; bool Started; - /* - bool Ft_basic; - bool Ft_advanced; - bool Ft_jobs; - bool Ft_job_materials; - bool Ft_soul; - bool Ft_inventory; - bool Ft_owned_items; - struct t_offsets - { - // creature offsets - uint32_t vector; - uint32_t pos_offset; - uint32_t profession_offset; - uint32_t custom_profession_offset; - uint32_t race_offset; - int32_t civ_offset; - uint32_t flags1_offset; - uint32_t flags2_offset; - uint32_t flags3_offset; - uint32_t name_offset; - uint32_t sex_offset; - uint32_t caste_offset; - uint32_t id_offset; - uint32_t labors_offset; - uint32_t happiness_offset; - uint32_t artifact_name_offset; - uint32_t physical_offset; - uint32_t mood_offset; - uint32_t pregnancy_offset; - uint32_t pregnancy_ptr_offset; - uint32_t mood_skill_offset; - uint32_t pickup_equipment_bit; - uint32_t soul_vector_offset; - uint32_t default_soul_offset; - uint32_t current_job_offset; - // soul offsets - uint32_t soul_skills_vector_offset; - // name offsets (needed for reading creature names) - uint32_t name_firstname_offset; - uint32_t name_nickname_offset; - uint32_t name_words_offset; - uint32_t soul_mental_offset; - uint32_t soul_traits_offset; - uint32_t appearance_vector_offset; - uint32_t birth_year_offset; - uint32_t birth_time_offset; - uint32_t inventory_offset; - uint32_t owned_items_offset; - // creature job stuff - int32_t job_type_offset; - int32_t job_id_offset; - int32_t job_materials_vector; - int32_t job_material_itemtype_o; - int32_t job_material_subtype_o; - int32_t job_material_subindex_o; - int32_t job_material_index_o; - int32_t job_material_flags_o; - // creature job material stuff - } creatures; - */ - uint32_t creature_module; + uint32_t dwarf_race_index_addr; uint32_t dwarf_civ_id_addr; bool IdMapReady; std::map IdMap; - //DfVector *p_cre; + Process *owner; Translation * trans; }; @@ -132,7 +71,6 @@ Module* DFHack::createCreatures() Creatures::Creatures() { Core & c = Core::getInstance(); - creatures = 0; d = new Private; d->owner = c.p; VersionInfo * minfo = c.vinfo; @@ -140,16 +78,11 @@ Creatures::Creatures() d->Started = false; d->IdMapReady = false; d->trans = c.getTranslation(); - d->trans->InitReadNames(); // throws on error + d->trans->InitReadNames(); // FIXME: throws on error 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"); - OffsetGroup * OG_jobs = OG_Creatures->getGroup("job"); - OffsetGroup * OG_job_mats = OG_jobs->getGroup("material"); + creatures = 0; try { creatures = (vector *) OG_Creatures->getAddress ("vector"); @@ -172,6 +105,7 @@ bool Creatures::Start( uint32_t &numcreatures ) { d->Started = true; numcreatures = creatures->size(); + d->IdMap.clear(); d->IdMapReady = false; return true; } diff --git a/plugins/devel/itemhacks.cpp b/plugins/devel/itemhacks.cpp index c58572e4b..199117c90 100644 --- a/plugins/devel/itemhacks.cpp +++ b/plugins/devel/itemhacks.cpp @@ -67,7 +67,7 @@ public: t_itemflags &f = itm->base->flags; - return (f.unk1 || f.unk2 || f.unk3 || f.unk4 || f.unk5 || + return (f.unk1 || f.unk2 || f.unk3 || f.unk4 || /*f.unk5 ||*/ f.unk6 || f.unk7 || // f.unk8 || f.unk9 || /* Too common */ f.unk10 || f.unk11); @@ -100,7 +100,7 @@ public: if (f.unk2) flags.push_back("unk2"); if (f.unk3) flags.push_back("unk3"); if (f.unk4) flags.push_back("unk4"); - if (f.unk5) flags.push_back("unk5"); + //if (f.unk5) flags.push_back("unk5"); if (f.unk6) flags.push_back("unk6"); if (f.unk7) flags.push_back("unk7"); if (f.unk8) flags.push_back("unk8"); diff --git a/plugins/devel/kittens.cpp b/plugins/devel/kittens.cpp index c82e55194..8ec0c11e4 100644 --- a/plugins/devel/kittens.cpp +++ b/plugins/devel/kittens.cpp @@ -26,6 +26,7 @@ DFhackCExport command_result bflags (Core * c, vector & parameters); DFhackCExport command_result trackmenu (Core * c, vector & parameters); DFhackCExport command_result mapitems (Core * c, vector & parameters); DFhackCExport command_result test_creature_offsets (Core * c, vector & parameters); +DFhackCExport command_result creat_job (Core * c, vector & parameters); DFhackCExport const char * plugin_name ( void ) { @@ -41,6 +42,7 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector commands.push_back(PluginCommand("trackmenu","Track menu ID changes (toggle).",trackmenu)); commands.push_back(PluginCommand("mapitems","Check item ids under cursor against item ids in map block.",mapitems)); commands.push_back(PluginCommand("test_creature_offsets","Bleh.",test_creature_offsets)); + commands.push_back(PluginCommand("creat_job","Bleh.",creat_job)); return CR_OK; } @@ -300,4 +302,38 @@ command_result test_creature_offsets(Core* c, vector< string >& parameters) uint32_t off_struct = offsetof(df_creature,custom_profession); c->con.print("Struct 0x%x, vinfo 0x%x\n", off_struct, off_vinfo); return CR_OK; +}; + +command_result creat_job (Core * c, vector< string >& parameters) +{ + c->Suspend(); + Creatures * cr = c->getCreatures(); + Gui * g = c-> getGui(); + uint32_t num_cr = 0; + int32_t cx,cy,cz; + g->getCursorCoords(cx,cy,cz); + if(cx == -30000) + { + c->con.printerr("No cursor.\n"); + c->Resume(); + return CR_FAILURE; + } + if(!cr->Start(num_cr) || num_cr == 0) + { + c->con.printerr("No creatures.\n"); + c->Resume(); + return CR_FAILURE; + } + auto iter = cr->creatures->begin(); + while (iter != cr->creatures->end()) + { + df_creature * unit = *iter; + if(cx == unit->x && cy == unit->y && cz == unit->z) + { + c->con.print("%d:%s - address 0x%x - job 0x%x\n", unit->id, unit->name.first_name.c_str(), unit, uint32_t(unit) + offsetof(df_creature,current_job)); + } + iter++; + } + c->Resume(); + return CR_OK; }; \ No newline at end of file