Merge remote-tracking branch 'myk002/myk_manipulator' into develop

Conflicts:
	docs/changelog.txt
develop
lethosor 2021-02-25 00:39:01 -05:00
commit cb9ed4ff0c
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
6 changed files with 44 additions and 4 deletions

@ -1270,6 +1270,17 @@ Units module
Returns the age of the unit in years as a floating-point value.
If ``true_age`` is true, ignores false identities.
* ``dfhack.units.isValidLabor(unit, unit_labor)``
Returns whether the indicated labor is settable for the given unit.
* ``dfhack.units.setLaborValidity(unit_labor, isValid)``
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])``
Retrieves the nominal skill level for the given unit. If ``use_rust``

@ -34,6 +34,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
# Future
## Misc Improvements
- `autohauler`: allow the ``Alchemist`` labor to be enabled in `manipulator` and other labor screens so it can be used for its intended purpose of flagging that no hauling labors should be assigned to a dwarf. Before, the only way to set the flag was to use an external program like Dwarf Therapist.
- `embark-assistant`: slightly improved performance of surveying
- `quickfort`: Dreamfort blueprint set improvements: `significant <http://www.bay12forums.com/smf/index.php?topic=176889.msg8239017#msg8239017>`_ refinements across the entire blueprint set. Dreamfort is now much faster, much more efficient, and much easier to use. The `checklist <https://docs.google.com/spreadsheets/d/13PVZ2h3Mm3x_G1OXQvwKd7oIR2lK4A1Ahf6Om1kFigw/edit#gid=1459509569>`__ now includes a mini-walkthrough for quick reference. The spreadsheet now also includes `embark profile suggestions <https://docs.google.com/spreadsheets/d/13PVZ2h3Mm3x_G1OXQvwKd7oIR2lK4A1Ahf6Om1kFigw/edit#gid=149144025>`__
- `quickfort`: added aliases for configuring masterwork and artifact core quality for all stockpile categories that have them; made it possible to take from multiple stockpiles in the ``quantumstop`` alias

@ -1600,6 +1600,7 @@ static const LuaWrapper::FunctionReg dfhack_units_module[] = {
WRAPM(Units, getEffectiveSkill),
WRAPM(Units, getExperience),
WRAPM(Units, isValidLabor),
WRAPM(Units, setLaborValidity),
WRAPM(Units, computeMovementSpeed),
WRAPM(Units, computeSlowdownFactor),
WRAPM(Units, getProfessionName),

@ -163,6 +163,7 @@ DFHACK_EXPORT int getEffectiveSkill(df::unit *unit, df::job_skill skill_id);
DFHACK_EXPORT int getExperience(df::unit *unit, df::job_skill skill_id, bool total = false);
DFHACK_EXPORT bool isValidLabor(df::unit *unit, df::unit_labor labor);
DFHACK_EXPORT bool setLaborValidity(df::unit_labor labor, bool isValid);
DFHACK_EXPORT int computeMovementSpeed(df::unit *unit);
DFHACK_EXPORT float computeSlowdownFactor(df::unit *unit);

@ -893,6 +893,19 @@ bool Units::isValidLabor(df::unit *unit, df::unit_labor labor)
return true;
}
bool Units::setLaborValidity(df::unit_labor labor, bool isValid)
{
if (!is_valid_enum_item(labor))
return false;
if (labor == df::unit_labor::NONE)
return false;
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;
}
inline void adjust_speed_rating(int &rating, bool is_adventure, int value, int dwarf100, int dwarf200, int adv50, int adv75, int adv100, int adv200)
{
if (is_adventure)

@ -565,10 +565,20 @@ static void cleanup_state()
labor_infos.clear();
}
static void enable_alchemist(color_ostream &out)
{
if (!Units::setLaborValidity(unit_labor::ALCHEMIST, true))
{
// informational only; this is a non-fatal error
out.printerr("manipulator: Could not flag Alchemist as a valid skill; Alchemist will not"
" be settable from DF or DFHack labor management screens.\n");
}
}
/**
* Initialize the plugin labor lists
*/
static void init_state()
static void init_state(color_ostream &out)
{
// This obtains the persistent data from the world save file
config = World::GetPersistentData("autohauler/config");
@ -656,6 +666,9 @@ static void init_state()
reset_labor((df::unit_labor) i);
}
// Allow Alchemist to be set in the labor-related UI screens so the player
// can actually use it as a flag without having to run Dwarf Therapist
enable_alchemist(out);
}
/**
@ -681,7 +694,7 @@ static void enable_plugin(color_ostream &out)
cleanup_state();
// Initialize the plugin
init_state();
init_state(out);
}
/**
@ -740,7 +753,7 @@ DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <Plug
));
// Initialize plugin labor lists
init_state();
init_state(out);
return CR_OK;
}
@ -763,7 +776,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan
switch (event) {
case SC_MAP_LOADED:
cleanup_state();
init_state();
init_state(out);
break;
case SC_MAP_UNLOADED:
cleanup_state();