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

@ -899,19 +899,10 @@ bool Units::setLaborValidity(df::unit_labor labor, bool isValid)
return false; return false;
if (labor == df::unit_labor::NONE) if (labor == df::unit_labor::NONE)
return false; return false;
for (size_t i = 0; i < world->raws.entities.size(); ++i) df::historical_entity *entity = df::historical_entity::find(ui->civ_id);
{ if (!entity || !entity->entity_raw)
if (!world->raws.entities[i] || return false;
world->raws.entities[i]->flags.is_set(df::entity_raw_flags::LAYER_LINKED) || // Animal people entity->entity_raw->jobs.permitted_labor[labor] = isValid;
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;
}
return true; return true;
} }