-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5181 from myk002/myk_quickfix
add automatic fixing of DF beta-specific caravan crash bug
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 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
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,30 @@ | ||
-- short-term urgent bugfixes | ||
|
||
local _ENV = mkmodule("quickfix") | ||
|
||
local function get_dwarf_race() | ||
for k,v in ipairs(df.global.world.raws.creatures.all) do | ||
-- dwarves are always the first entity race | ||
if v.flags.OCCURS_AS_ENTITY_RACE then return k end | ||
end | ||
end | ||
|
||
-- entities can send caravans, and if the race is -1, then DF crashes | ||
-- called from onLoad.default.init | ||
function set_entity_race_references() | ||
local race = get_dwarf_race() | ||
if not race then | ||
return | ||
end | ||
|
||
local count = 0 | ||
for _,v in ipairs(df.global.world.entities.all) do | ||
if v.race == -1 then | ||
count = count + 1 | ||
v.race = race | ||
end | ||
end | ||
print(('quickfix: fixed %d unset entity race reference(s)'):format(count)) | ||
end | ||
|
||
return _ENV |