only set labor validity for the player civ

develop
myk002 2021-02-17 09:16:49 -08:00
parent 55743fc43f
commit 9e17bc938c
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
2 changed files with 8 additions and 16 deletions

@ -1276,9 +1276,10 @@ Units module
* ``dfhack.units.setLaborValidity(unit_labor, isValid)``
Sets the given labor to the given (boolean) validity for all playable units in
the game (that is, for all civilizations whose members can be residents of
your fort).
Sets the given labor to the given (boolean) validity for all units that are
part of your fortress civilization. Valid labors are allowed to be toggled
in the in-game labor management screens (including DFHack's labor manipulator
screen).
* ``dfhack.units.getNominalSkill(unit, skill[, use_rust])``

@ -899,19 +899,10 @@ bool Units::setLaborValidity(df::unit_labor labor, bool isValid)
return false;
if (labor == df::unit_labor::NONE)
return false;
for (size_t i = 0; i < world->raws.entities.size(); ++i)
{
if (!world->raws.entities[i] ||
world->raws.entities[i]->flags.is_set(df::entity_raw_flags::LAYER_LINKED) || // Animal people
world->raws.entities[i]->flags.is_set(df::entity_raw_flags::GENERATED) || // Vault guardians
!world->raws.entities[i]->flags.is_set(df::entity_raw_flags::CIV_CONTROLLABLE) || // non-controllable civs
world->raws.entities[i]->translation == "") // Kobolds
{
continue;
}
world->raws.entities[i]->jobs.permitted_labor[labor] = isValid;
}
df::historical_entity *entity = df::historical_entity::find(ui->civ_id);
if (!entity || !entity->entity_raw)
return false;
entity->entity_raw->jobs.permitted_labor[labor] = isValid;
return true;
}