-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finished script and added it to control panel
- Loading branch information
Branislav Setlák
committed
Oct 14, 2023
1 parent
b9109af
commit 5952f23
Showing
3 changed files
with
25 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
fix/corrupt-jobs | ||
================== | ||
|
||
.. dfhack-tool:: | ||
:summary: Removes jobs with an id of -1 from units. | ||
:tags: fort bugfix | ||
|
||
This fix ensures that no units have a job with an id of -1 set as their current job. | ||
|
||
Usage | ||
----- | ||
|
||
:: | ||
|
||
fix/corrupt-jobs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,14 @@ | ||
-- Deletes corrupted jobs from global job list | ||
|
||
local utils = require("utils") | ||
-- Deletes corrupted jobs from affected units | ||
|
||
local count = 0 | ||
|
||
functioning_job_list = {} | ||
|
||
for _, job in ipairs(df.global.job_list) do | ||
if job.id != -1 then | ||
functioning_job_list[#functioning_job_list+1] = job | ||
for _, unit in ipairs(df.global.world.units.all) do | ||
if unit.job.current_job and unit.job.current_job.id == -1 then | ||
unit.job.current_job = nil | ||
count = count + 1 | ||
end | ||
end | ||
|
||
for _, v in ipairs(df.global.world.units.all) do | ||
if v.job.current_job then | ||
if utils.linear_index(functioning_job_list, v.job.current_job) == nil then | ||
v.job.current_job = nil | ||
end | ||
end | ||
if count > 0 then | ||
print(('removed %d corrupted job(s) from affected units'):format(count)) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters