From ff4b2f8522fe592ea9cf82810aea6f100f3f19b5 Mon Sep 17 00:00:00 2001 From: sv-esk Date: Wed, 10 Feb 2016 15:55:21 +0200 Subject: [PATCH 1/6] add new skill columns --- plugins/manipulator.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index e2a4e54a0..7134d8b63 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -256,10 +256,26 @@ const SkillColumn columns[] = { {19, 6, profession::NONE, unit_labor::NONE, job_skill::POETRY, "Po"}, {19, 6, profession::NONE, unit_labor::NONE, job_skill::READING, "Rd"}, {19, 6, profession::NONE, unit_labor::NONE, job_skill::SPEAKING, "Sp"}, - - {20, 5, profession::NONE, unit_labor::NONE, job_skill::MILITARY_TACTICS, "MT"}, - {20, 5, profession::NONE, unit_labor::NONE, job_skill::TRACKING, "Tr"}, - {20, 5, profession::NONE, unit_labor::NONE, job_skill::MAGIC_NATURE, "Dr"}, + {19, 6, profession::NONE, unit_labor::NONE, job_skill::DANCE, "Dn"}, + {19, 6, profession::NONE, unit_labor::NONE, job_skill::MAKE_MUSIC, "MM"}, + {19, 6, profession::NONE, unit_labor::NONE, job_skill::SING_MUSIC, "SM"}, + {19, 6, profession::NONE, unit_labor::NONE, job_skill::PLAY_KEYBOARD_INSTRUMENT, "PK"}, + {19, 6, profession::NONE, unit_labor::NONE, job_skill::PLAY_STRINGED_INSTRUMENT, "PS"}, + {19, 6, profession::NONE, unit_labor::NONE, job_skill::PLAY_WIND_INSTRUMENT, "PW"}, + {19, 6, profession::NONE, unit_labor::NONE, job_skill::PLAY_PERCUSSION_INSTRUMENT, "PP"}, + + {20, 4, profession::NONE, unit_labor::NONE, job_skill::CRITICAL_THINKING, "CT"}, + {20, 4, profession::NONE, unit_labor::NONE, job_skill::LOGIC, "Lo"}, + {20, 4, profession::NONE, unit_labor::NONE, job_skill::MATHEMATICS, "Ma"}, + {20, 4, profession::NONE, unit_labor::NONE, job_skill::ASTRONOMY, "As"}, + {20, 4, profession::NONE, unit_labor::NONE, job_skill::CHEMISTRY, "Ch"}, + {20, 4, profession::NONE, unit_labor::NONE, job_skill::GEOGRAPHY, "Ge"}, + {20, 4, profession::NONE, unit_labor::NONE, job_skill::OPTICS_ENGINEER, "OE"}, + {20, 4, profession::NONE, unit_labor::NONE, job_skill::FLUID_ENGINEER, "FE"}, + + {21, 5, profession::NONE, unit_labor::NONE, job_skill::MILITARY_TACTICS, "MT"}, + {21, 5, profession::NONE, unit_labor::NONE, job_skill::TRACKING, "Tr"}, + {21, 5, profession::NONE, unit_labor::NONE, job_skill::MAGIC_NATURE, "Dr"}, }; struct UnitInfo From 3cab865d58bc2068ef7c08557defdd719f7ae1c4 Mon Sep 17 00:00:00 2001 From: sv-esk Date: Thu, 11 Feb 2016 02:50:45 +0200 Subject: [PATCH 2/6] fix manipulator racism (allow editing non-dwarves) --- plugins/manipulator.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index 7134d8b63..d3fdeeaf5 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -1143,9 +1143,6 @@ viewscreen_unitlaborsst::viewscreen_unitlaborsst(vector &src, int cur cur->selected = false; cur->active_index = active_idx[unit]; - if (!Units::isOwnRace(unit)) - cur->allowEdit = false; - if (!Units::isOwnCiv(unit)) cur->allowEdit = false; From ac070e49a45b55c638227e8c6e9b4ff3396c2712 Mon Sep 17 00:00:00 2001 From: sv-esk Date: Thu, 11 Feb 2016 02:54:17 +0200 Subject: [PATCH 3/6] forbid manipulator editing visitors --- plugins/manipulator.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index d3fdeeaf5..067ed1497 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -1149,6 +1149,9 @@ viewscreen_unitlaborsst::viewscreen_unitlaborsst(vector &src, int cur if (unit->flags1.bits.dead) cur->allowEdit = false; + if (unit->flags2.bits.visitor) + cur->allowEdit = false; + if (!ENUM_ATTR(profession, can_assign_labor, unit->profession)) cur->allowEdit = false; From 83c70ccb0f985fac5c7683cd3e01b37e65319258 Mon Sep 17 00:00:00 2001 From: sv-esk Date: Thu, 11 Feb 2016 06:14:04 +0200 Subject: [PATCH 4/6] forbid manipulator editing non-citizens --- library/LuaApi.cpp | 1 + library/include/modules/Units.h | 1 + library/modules/Units.cpp | 16 ++++++++++++++++ plugins/manipulator.cpp | 3 +++ 4 files changed, 21 insertions(+) diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index abf4d4c7f..3e2661984 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -1535,6 +1535,7 @@ static const LuaWrapper::FunctionReg dfhack_units_module[] = { WRAPM(Units, isHunter), WRAPM(Units, isAvailableForAdoption), WRAPM(Units, isOwnCiv), + WRAPM(Units, isOwnGroup), WRAPM(Units, isOwnRace), WRAPM(Units, getRaceName), WRAPM(Units, getRaceNamePlural), diff --git a/library/include/modules/Units.h b/library/include/modules/Units.h index e5210013b..0c7be6f80 100644 --- a/library/include/modules/Units.h +++ b/library/include/modules/Units.h @@ -240,6 +240,7 @@ DFHACK_EXPORT bool isWar(df::unit* unit); DFHACK_EXPORT bool isHunter(df::unit* unit); DFHACK_EXPORT bool isAvailableForAdoption(df::unit* unit); DFHACK_EXPORT bool isOwnCiv(df::unit* unit); +DFHACK_EXPORT bool isOwnGroup(df::unit* unit); DFHACK_EXPORT bool isOwnRace(df::unit* unit); DFHACK_EXPORT std::string getRaceNameById(int32_t race_id); diff --git a/library/modules/Units.cpp b/library/modules/Units.cpp index 08c2191ec..341a90b22 100644 --- a/library/modules/Units.cpp +++ b/library/modules/Units.cpp @@ -888,6 +888,22 @@ bool Units::isOwnCiv(df::unit* unit) return unit->civ_id == ui->civ_id; } +// check if creature belongs to the player's group +bool Units::isOwnGroup(df::unit* unit) +{ + CHECK_NULL_POINTER(unit); + auto histfig = df::historical_figure::find(unit->hist_figure_id); + if (!histfig) + return false; + for (size_t i = 0; i < histfig->entity_links.size(); i++) + { + auto link = histfig->entity_links[i]; + if (link->entity_id == ui->group_id && (*link).getType() == df::histfig_entity_link_type::MEMBER) + return true; + } + return false; +} + // check if creature belongs to the player's race // (in combination with check for civ helps to filter out own dwarves) bool Units::isOwnRace(df::unit* unit) diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index 067ed1497..ae21080eb 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -1146,6 +1146,9 @@ viewscreen_unitlaborsst::viewscreen_unitlaborsst(vector &src, int cur if (!Units::isOwnCiv(unit)) cur->allowEdit = false; + if (!Units::isOwnGroup(unit)) + cur->allowEdit = false; + if (unit->flags1.bits.dead) cur->allowEdit = false; From d2450c34ff3b163c596d83fec1206f249459a56b Mon Sep 17 00:00:00 2001 From: sv-esk Date: Fri, 12 Feb 2016 13:47:58 +0200 Subject: [PATCH 5/6] forbid manipulator editing ghosts they are not flags1.dead --- plugins/manipulator.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index ae21080eb..7c86b6f7d 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -1155,6 +1155,9 @@ viewscreen_unitlaborsst::viewscreen_unitlaborsst(vector &src, int cur if (unit->flags2.bits.visitor) cur->allowEdit = false; + if (unit->flags3.bits.ghostly) + cur->allowEdit = false; + if (!ENUM_ATTR(profession, can_assign_labor, unit->profession)) cur->allowEdit = false; From 20572fb6670f8e7ebe9410af2a4462638d80de8c Mon Sep 17 00:00:00 2001 From: sv-esk Date: Mon, 22 Feb 2016 19:40:52 +0200 Subject: [PATCH 6/6] add new jobs to autolabor --- plugins/autolabor.cpp | 10 +++++++++- plugins/devel/autolabor2.cpp | 20 +++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/plugins/autolabor.cpp b/plugins/autolabor.cpp index 070744de0..b8c89215e 100644 --- a/plugins/autolabor.cpp +++ b/plugins/autolabor.cpp @@ -365,7 +365,15 @@ static const dwarf_state dwarf_states[] = { BUSY /* PushTrackVehicle */, BUSY /* PlaceTrackVehicle */, BUSY /* StoreItemInVehicle */, - BUSY /* GeldAnimal */ + BUSY /* GeldAnimal */, + BUSY /* MakeFigurine */, + BUSY /* MakeAmulet */, + BUSY /* MakeScepter */, + BUSY /* MakeCrown */, + BUSY /* MakeRing */, + BUSY /* MakeEarring */, + BUSY /* MakeBracelet */, + BUSY /* MakeGem */ }; struct labor_info diff --git a/plugins/devel/autolabor2.cpp b/plugins/devel/autolabor2.cpp index 62bcc98d0..4897832d4 100644 --- a/plugins/devel/autolabor2.cpp +++ b/plugins/devel/autolabor2.cpp @@ -360,7 +360,16 @@ static const dwarf_state dwarf_states[] = { BUSY /* CarveTrack */, BUSY /* PushTrackVehicle */, BUSY /* PlaceTrackVehicle */, - BUSY /* StoreItemInVehicle */ + BUSY /* StoreItemInVehicle */, + BUSY /* GeldAnimal */, + BUSY /* MakeFigurine */, + BUSY /* MakeAmulet */, + BUSY /* MakeScepter */, + BUSY /* MakeCrown */, + BUSY /* MakeRing */, + BUSY /* MakeEarring */, + BUSY /* MakeBracelet */, + BUSY /* MakeGem */ }; struct labor_info @@ -1328,6 +1337,15 @@ public: job_to_labor_table[df::job_type::PushTrackVehicle] = jlf_const(df::unit_labor::PUSH_HAUL_VEHICLE); job_to_labor_table[df::job_type::PlaceTrackVehicle] = jlf_const(df::unit_labor::PUSH_HAUL_VEHICLE); job_to_labor_table[df::job_type::StoreItemInVehicle] = jlf_const(df::unit_labor::PUSH_HAUL_VEHICLE); + job_to_labor_table[df::job_type::GeldAnimal] = jlf_const(df::unit_labor::GELD); + job_to_labor_table[df::job_type::MakeFigurine] = jlf_make_object; + job_to_labor_table[df::job_type::MakeAmulet] = jlf_make_object; + job_to_labor_table[df::job_type::MakeScepter] = jlf_make_object; + job_to_labor_table[df::job_type::MakeCrown] = jlf_make_object; + job_to_labor_table[df::job_type::MakeRing] = jlf_make_object; + job_to_labor_table[df::job_type::MakeEarring] = jlf_make_object; + job_to_labor_table[df::job_type::MakeBracelet] = jlf_make_object; + job_to_labor_table[df::job_type::MakeGem] = jlf_make_object; }; df::unit_labor find_job_labor(df::job* j)