Merge pull request #3813 from ab9rf/autolabor-3812

autolabor: fix #3812
develop
Myk 2023-09-24 17:56:48 -07:00 committed by GitHub
commit bc01d4bf45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 7 deletions

@ -56,6 +56,7 @@ Template for new versions:
## New Features ## New Features
## Fixes ## Fixes
- `autolabor`: now unconditionally re-enables vanilla work details when the fort or the plugin is unloaded
## Misc Improvements ## Misc Improvements
- `dig`: `digtype` command now has options to choose between designating only visible tiles or hidden tiles, as well as "auto" dig mode. Z-level options adjusted to allow choosing z-levels above, below, or the same as the cursor. - `dig`: `digtype` command now has options to choose between designating only visible tiles or hidden tiles, as well as "auto" dig mode. Z-level options adjusted to allow choosing z-levels above, below, or the same as the cursor.

@ -305,6 +305,7 @@ static void cleanup_state()
{ {
enable_autolabor = false; enable_autolabor = false;
labor_infos.clear(); labor_infos.clear();
game->external_flag &= ~1; // reinstate DF's work detail system
} }
static void reset_labor(df::unit_labor labor) static void reset_labor(df::unit_labor labor)
@ -326,6 +327,8 @@ static void init_state()
if (!enable_autolabor) if (!enable_autolabor)
return; return;
game->external_flag |= 1; // bypass DF's work detail system
auto cfg_haulpct = World::GetPersistentData("autolabor/haulpct"); auto cfg_haulpct = World::GetPersistentData("autolabor/haulpct");
if (cfg_haulpct.isValid()) if (cfg_haulpct.isValid())
{ {
@ -413,8 +416,17 @@ static void enable_plugin(color_ostream &out)
cleanup_state(); cleanup_state();
init_state(); init_state();
}
static void disable_plugin(color_ostream& out)
{
if (config.isValid())
setOptionEnabled(CF_ENABLED, false);
enable_autolabor = false;
out << "Disabling autolabor." << std::endl;
game->external_flag |= 1; // shut down DF's work detail system cleanup_state();
} }
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
@ -1081,12 +1093,7 @@ DFhackCExport command_result plugin_enable ( color_ostream &out, bool enable )
} }
else if(!enable && enable_autolabor) else if(!enable && enable_autolabor)
{ {
enable_autolabor = false; disable_plugin(out);
setOptionEnabled(CF_ENABLED, false);
game->external_flag &= ~1; // reenable DF's work detail system
out << "Autolabor is disabled." << std::endl;
} }
return CR_OK; return CR_OK;