remove obsolete fix_job_postings command

develop
myk002 2022-12-06 16:22:39 -08:00
parent e1330a602e
commit 6fc62946e4
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
3 changed files with 1 additions and 65 deletions

@ -50,6 +50,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Internals ## Internals
## Removed ## Removed
- ``fix-job-postings`` from the `workflow` plugin is now obsolete since affected savegames can no longer be loaded
# 0.47.05-r8 # 0.47.05-r8

@ -5,9 +5,6 @@ workflow
:summary: Manage automated item production rules. :summary: Manage automated item production rules.
:tags: fort auto jobs :tags: fort auto jobs
.. dfhack-command:: fix-job-postings
:summary: Fixes crashes caused by old versions of workflow.
Manage repeat jobs according to stock levels. `gui/workflow` provides a simple Manage repeat jobs according to stock levels. `gui/workflow` provides a simple
front-end integrated in the game UI. front-end integrated in the game UI.
@ -59,12 +56,6 @@ Usage
List active constraints as workflow commands that re-create them; this list List active constraints as workflow commands that re-create them; this list
can be copied to a file, and then reloaded using the `script` built-in can be copied to a file, and then reloaded using the `script` built-in
command. command.
``fix-job-postings [dry-run]``
Fixes crashes caused by the version of workflow released with DFHack
0.40.24-r4. It will be run automatically if needed. If your save has never
been run with this version, you will never need this command. Specify the
``dry-run`` keyword to see what this command would do without making any
changes to game state.
Examples Examples
-------- --------

@ -58,13 +58,10 @@ REQUIRE_GLOBAL(job_next_id);
/* Plugin registration */ /* Plugin registration */
static command_result workflow_cmd(color_ostream &out, vector <string> & parameters); static command_result workflow_cmd(color_ostream &out, vector <string> & parameters);
static command_result fix_job_postings_cmd(color_ostream &out, vector<string> &parameters);
static void init_state(color_ostream &out); static void init_state(color_ostream &out);
static void cleanup_state(color_ostream &out); static void cleanup_state(color_ostream &out);
static int fix_job_postings(color_ostream *out = NULL, bool dry_run = false);
DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
{ {
if (!world || !ui) if (!world || !ui)
@ -76,10 +73,6 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
"workflow", "workflow",
"Manage repeat jobs according to stock levels.", "Manage repeat jobs according to stock levels.",
workflow_cmd)); workflow_cmd));
commands.push_back(PluginCommand(
"fix-job-postings",
"Fix broken job postings caused by very old versions of workflow.",
fix_job_postings_cmd));
} }
init_state(out); init_state(out);
@ -111,14 +104,6 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan
return CR_OK; return CR_OK;
} }
command_result fix_job_postings_cmd(color_ostream &out, vector<string> &parameters)
{
bool dry = parameters.size();
int fixed = fix_job_postings(&out, dry);
out << fixed << " job issue(s) " << (dry ? "detected but not fixed" : "fixed") << endl;
return CR_OK;
}
/****************************** /******************************
* JOB STATE TRACKING STRUCTS * * JOB STATE TRACKING STRUCTS *
******************************/ ******************************/
@ -354,34 +339,6 @@ public:
} }
}; };
static int fix_job_postings (color_ostream *out, bool dry_run)
{
int count = 0;
df::job_list_link *link = &world->jobs.list;
while (link)
{
df::job *job = link->item;
if (job)
{
for (size_t i = 0; i < world->jobs.postings.size(); ++i)
{
df::job_handler::T_postings *posting = world->jobs.postings[i];
if (posting->job == job && i != size_t(job->posting_index) && !posting->flags.bits.dead)
{
++count;
if (out)
*out << "Found extra job posting: Job " << job->id << ": "
<< Job::getName(job) << endl;
if (!dry_run)
posting->flags.bits.dead = true;
}
}
}
link = link->next;
}
return count;
}
/****************************** /******************************
* GLOBAL VARIABLES * * GLOBAL VARIABLES *
******************************/ ******************************/
@ -478,11 +435,6 @@ static ItemConstraint *get_constraint(color_ostream &out, const std::string &str
static void start_protect(color_ostream &out) static void start_protect(color_ostream &out)
{ {
out << "workflow: checking for existing job issues" << endl;
int count = fix_job_postings(&out);
if (count)
out << "workflow: fixed " << count << " job issues" << endl;
check_lost_jobs(out, 0); check_lost_jobs(out, 0);
if (!known_jobs.empty()) if (!known_jobs.empty())
@ -1569,13 +1521,6 @@ static int getCountHistory(lua_State *L)
return 1; return 1;
} }
static int fixJobPostings(lua_State *L)
{
bool dry = lua_toboolean(L, 1);
lua_pushinteger(L, fix_job_postings(NULL, dry));
return 1;
}
DFHACK_PLUGIN_LUA_FUNCTIONS { DFHACK_PLUGIN_LUA_FUNCTIONS {
DFHACK_LUA_FUNCTION(deleteConstraint), DFHACK_LUA_FUNCTION(deleteConstraint),
DFHACK_LUA_END DFHACK_LUA_END
@ -1586,7 +1531,6 @@ DFHACK_PLUGIN_LUA_COMMANDS {
DFHACK_LUA_COMMAND(findConstraint), DFHACK_LUA_COMMAND(findConstraint),
DFHACK_LUA_COMMAND(setConstraint), DFHACK_LUA_COMMAND(setConstraint),
DFHACK_LUA_COMMAND(getCountHistory), DFHACK_LUA_COMMAND(getCountHistory),
DFHACK_LUA_COMMAND(fixJobPostings),
DFHACK_LUA_END DFHACK_LUA_END
}; };