Merge remote-tracking branches 'sv-esk/autolabor_new_jobs' and 'sv-esk/manipulator' into develop

develop
lethosor 2016-02-24 16:36:57 -05:00
commit 78a7d7a43b
6 changed files with 74 additions and 8 deletions

@ -1535,6 +1535,7 @@ static const LuaWrapper::FunctionReg dfhack_units_module[] = {
WRAPM(Units, isHunter), WRAPM(Units, isHunter),
WRAPM(Units, isAvailableForAdoption), WRAPM(Units, isAvailableForAdoption),
WRAPM(Units, isOwnCiv), WRAPM(Units, isOwnCiv),
WRAPM(Units, isOwnGroup),
WRAPM(Units, isOwnRace), WRAPM(Units, isOwnRace),
WRAPM(Units, getRaceName), WRAPM(Units, getRaceName),
WRAPM(Units, getRaceNamePlural), WRAPM(Units, getRaceNamePlural),

@ -240,6 +240,7 @@ DFHACK_EXPORT bool isWar(df::unit* unit);
DFHACK_EXPORT bool isHunter(df::unit* unit); DFHACK_EXPORT bool isHunter(df::unit* unit);
DFHACK_EXPORT bool isAvailableForAdoption(df::unit* unit); DFHACK_EXPORT bool isAvailableForAdoption(df::unit* unit);
DFHACK_EXPORT bool isOwnCiv(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 bool isOwnRace(df::unit* unit);
DFHACK_EXPORT std::string getRaceNameById(int32_t race_id); DFHACK_EXPORT std::string getRaceNameById(int32_t race_id);

@ -888,6 +888,22 @@ bool Units::isOwnCiv(df::unit* unit)
return unit->civ_id == ui->civ_id; 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 // check if creature belongs to the player's race
// (in combination with check for civ helps to filter out own dwarves) // (in combination with check for civ helps to filter out own dwarves)
bool Units::isOwnRace(df::unit* unit) bool Units::isOwnRace(df::unit* unit)

@ -365,7 +365,15 @@ static const dwarf_state dwarf_states[] = {
BUSY /* PushTrackVehicle */, BUSY /* PushTrackVehicle */,
BUSY /* PlaceTrackVehicle */, BUSY /* PlaceTrackVehicle */,
BUSY /* StoreItemInVehicle */, 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 struct labor_info

@ -360,7 +360,16 @@ static const dwarf_state dwarf_states[] = {
BUSY /* CarveTrack */, BUSY /* CarveTrack */,
BUSY /* PushTrackVehicle */, BUSY /* PushTrackVehicle */,
BUSY /* PlaceTrackVehicle */, 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 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::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::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::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) df::unit_labor find_job_labor(df::job* j)

@ -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::POETRY, "Po"},
{19, 6, profession::NONE, unit_labor::NONE, job_skill::READING, "Rd"}, {19, 6, profession::NONE, unit_labor::NONE, job_skill::READING, "Rd"},
{19, 6, profession::NONE, unit_labor::NONE, job_skill::SPEAKING, "Sp"}, {19, 6, profession::NONE, unit_labor::NONE, job_skill::SPEAKING, "Sp"},
{19, 6, profession::NONE, unit_labor::NONE, job_skill::DANCE, "Dn"},
{20, 5, profession::NONE, unit_labor::NONE, job_skill::MILITARY_TACTICS, "MT"}, {19, 6, profession::NONE, unit_labor::NONE, job_skill::MAKE_MUSIC, "MM"},
{20, 5, profession::NONE, unit_labor::NONE, job_skill::TRACKING, "Tr"}, {19, 6, profession::NONE, unit_labor::NONE, job_skill::SING_MUSIC, "SM"},
{20, 5, profession::NONE, unit_labor::NONE, job_skill::MAGIC_NATURE, "Dr"}, {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 struct UnitInfo
@ -1127,15 +1143,21 @@ viewscreen_unitlaborsst::viewscreen_unitlaborsst(vector<df::unit*> &src, int cur
cur->selected = false; cur->selected = false;
cur->active_index = active_idx[unit]; cur->active_index = active_idx[unit];
if (!Units::isOwnRace(unit)) if (!Units::isOwnCiv(unit))
cur->allowEdit = false; cur->allowEdit = false;
if (!Units::isOwnCiv(unit)) if (!Units::isOwnGroup(unit))
cur->allowEdit = false; cur->allowEdit = false;
if (unit->flags1.bits.dead) if (unit->flags1.bits.dead)
cur->allowEdit = false; cur->allowEdit = false;
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)) if (!ENUM_ATTR(profession, can_assign_labor, unit->profession))
cur->allowEdit = false; cur->allowEdit = false;