Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion add-thought.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function addEmotionToUnit(unit,thought,emotion,severity,strength,subthought)
local properThought = tonumber(thought) or df.unit_thought_type[thought]
local properSubthought = tonumber(subthought)
if not properThought or not df.unit_thought_type[properThought] then
for _,syn in ipairs(df.global.world.raws.syndromes.all) do
for _,syn in ipairs(df.global.world.raws.mat_table.syndromes.all) do
if syn.syn_name == thought then
properThought = df.unit_thought_type.Syndrome
properSubthought = syn.id
Expand Down
18 changes: 9 additions & 9 deletions assign-preferences.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ local preference_functions = {
mattype = mat_info.type,
matindex = mat_info.index,
mat_state = 0,
active = true,
flags = {visible = true},
prefstring_seed = rng:random()
}
else
Expand Down Expand Up @@ -122,7 +122,7 @@ local preference_functions = {
mattype = -1,
matindex = -1,
mat_state = 0,
active = true,
flags = {visible = true},
prefstring_seed = rng:random()
}
else
Expand Down Expand Up @@ -199,7 +199,7 @@ local preference_functions = {
mattype = mat_info.type,
matindex = mat_info.index,
mat_state = 1,
active = true,
flags = {visible = true},
prefstring_seed = rng:random()
}
end
Expand Down Expand Up @@ -234,7 +234,7 @@ local preference_functions = {
mattype = -1,
matindex = -1,
mat_state = 0,
active = true,
flags = {visible = true},
prefstring_seed = rng:random()
}
else
Expand Down Expand Up @@ -275,7 +275,7 @@ local preference_functions = {
mattype = -1,
matindex = -1,
mat_state = 0,
active = true,
flags = {visible = true},
prefstring_seed = rng:random()
}
end
Expand Down Expand Up @@ -310,7 +310,7 @@ local preference_functions = {
mattype = -1,
matindex = -1,
mat_state = 0,
active = true,
flags = {visible = true},
prefstring_seed = rng:random()
}
else
Expand Down Expand Up @@ -343,7 +343,7 @@ local preference_functions = {
mattype = -1,
matindex = -1,
mat_state = 0,
active = true,
flags = {visible = true},
prefstring_seed = rng:random()
}
else
Expand Down Expand Up @@ -377,7 +377,7 @@ local preference_functions = {
mattype = -1,
matindex = -1,
mat_state = 0,
active = true,
flags = {visible = true},
prefstring_seed = rng:random()
}
else
Expand Down Expand Up @@ -410,7 +410,7 @@ local preference_functions = {
mattype = -1,
matindex = -1,
mat_state = 0,
active = true,
flags = {visible = true},
prefstring_seed = rng:random()
}
else
Expand Down
20 changes: 10 additions & 10 deletions devel/export-dt-ini.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ address('musical_forms_vector',globals,'world','musical_forms','all')
address('dance_forms_vector',globals,'world','dance_forms','all')
address('occupations_vector',globals,'world','occupations','all')
address('world_data',globals,'world','world_data')
address('material_templates_vector',globals,'world','raws','material_templates')
address('material_templates_vector',globals,'world','raws','material_templates','all')
address('inorganics_vector',globals,'world','raws','inorganics')
address('plants_vector',globals,'world','raws','plants','all')
address('races_vector',globals,'world','raws','creatures','all')
Expand Down Expand Up @@ -255,14 +255,14 @@ address('pants_armor_properties',df.itemdef_pantsst,'props')
address('other_armor_properties',df.itemdef_helmst,'props')

header('material_offsets')
address('solid_name',df.material_common,'state_name','Solid')
address('liquid_name',df.material_common,'state_name','Liquid')
address('gas_name',df.material_common,'state_name','Gas')
address('powder_name',df.material_common,'state_name','Powder')
address('paste_name',df.material_common,'state_name','Paste')
address('pressed_name',df.material_common,'state_name','Pressed')
address('flags',df.material_common,'flags')
address('reaction_class',df.material_common,'reaction_class')
address('solid_name',df.material,'state_name','Solid')
address('liquid_name',df.material,'state_name','Liquid')
address('gas_name',df.material,'state_name','Gas')
address('powder_name',df.material,'state_name','Powder')
address('paste_name',df.material,'state_name','Paste')
address('pressed_name',df.material,'state_name','Pressed')
address('flags',df.material,'flags')
address('reaction_class',df.material,'reaction_class')
address('prefix',df.material,'prefix')
address('inorganic_materials_vector',df.inorganic_raw,'material')
address('inorganic_flags',df.inorganic_raw,'flags')
Expand Down Expand Up @@ -320,7 +320,7 @@ address('size_info',df.unit,'body','size_info','size_cur')
address('size_base',df.unit,'body','size_info','size_base')
address('curse',df.unit,'curse','name')
address('curse_add_flags1',df.unit,'curse','add_tags1')
address('turn_count',df.unit,'curse','time_on_site')
address('turn_count',df.unit,'curse','interaction','time_on_site')
address('souls',df.unit,'status','souls')
address('states',df.unit,'status','misc_traits')
address('labors',df.unit,'status','labors')
Expand Down
2 changes: 1 addition & 1 deletion devel/export-map.lua
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ local function setup_keys(options)
KEYS.MATERIAL.STONE = {}
KEYS.MATERIAL.GEM = {}

for id, rock in ipairs(df.global.world.raws.inorganics) do
for id, rock in ipairs(df.global.world.raws.inorganics.all) do
local material = rock.material
local name = material.state_adj.Solid
KEYS.MATERIAL.SOLID[id] = name
Expand Down
68 changes: 48 additions & 20 deletions devel/tree-info.lua
Original file line number Diff line number Diff line change
@@ -1,29 +1,57 @@
--Print a tree_info visualization of the tree at the cursor.
--@module = true

local branch_dir =
{
[0] = ' ',
[1] = string.char(26), --W
[2] = string.char(25), --N
[3] = string.char(217), --WN
[4] = string.char(27), --E
[5] = string.char(196), --WE
[6] = string.char(192), --NE
[7] = string.char(193), --WNE
[8] = string.char(24), --S
[9] = string.char(191), --WS
[10] = string.char(179), --NS
[11] = string.char(180), --WNS
[12] = string.char(218), --ES
[13] = string.char(194), --WES
[14] = string.char(195), --NES
[15] = string.char(197), --WNES
-- [w][n][e][s]
local branch_chars = {
[true]={
[true]={
[true]={
[true]=string.char(197), --WNES
[false]=string.char(193), --WNE
},
[false]={
[true]=string.char(180), --WNS
[false]=string.char(217), --WN
},
},
[false]={
[true]={
[true]=string.char(194), --WES
[false]=string.char(196), --WE
},
[false]={
[true]=string.char(191), --WS
[false]=string.char(26), --W
},
},
},
[false]={
[true]={
[true]={
[true]=string.char(195), --NES
[false]=string.char(192), --NE
},
[false]={
[true]=string.char(179), --NS
[false]=string.char(25), --N
},
},
[false]={
[true]={
[true]=string.char(218), --ES
[false]=string.char(27), --E
},
[false]={
[true]=string.char(24), --S
[false]=' ',
},
},
},
}

local function print_color(s, color)
dfhack.color(color)
dfhack.print(s)
dfhack.print(dfhack.df2console(s))
dfhack.color(COLOR_RESET)
end

Expand Down Expand Up @@ -68,7 +96,7 @@ function printTreeTile(bits)
end

chars = chars-2
print_color(' '..(branch_dir[bits.branches_dir] or '?'), COLOR_GREY)
print_color(' '..(branch_chars[bits.branch_w][bits.branch_n][bits.branch_e][bits.branch_s] or '?'), COLOR_GREY)

local dir = bits.parent_dir
if dir > 0 then
Expand Down
2 changes: 1 addition & 1 deletion docs/fix/population-cap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fix/population-cap
:summary: Ensure the population cap is respected.
:tags: fort bugfix

Run this if you continue to get migrant wave even after you have exceeded your
Run this if you continue to get migrant waves even after you have exceeded your
set population cap.

The reason this tool is needed is that the game only updates the records of your
Expand Down
2 changes: 1 addition & 1 deletion dwarf-op.lua
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ local seasons = {
'winter',
}
function GetWave(dwf)
arrival_time = current_tick - dwf.curse.time_on_site;
arrival_time = current_tick - dwf.curse.interaction.time_on_site;
--print(string.format("Current year %s, arrival_time = %s, ticks_per_year = %s", df.global.cur_year, arrival_time, ticks_per_year))
arrival_year = df.global.cur_year + (arrival_time // ticks_per_year);
arrival_season = 1 + (arrival_time % ticks_per_year) // ticks_per_season;
Expand Down
10 changes: 5 additions & 5 deletions exportlegends.lua
Original file line number Diff line number Diff line change
Expand Up @@ -784,16 +784,16 @@ local function export_more_legends_xml()
file:write("\t\t<caste>"..(world.raws.creatures.all[event.race].caste[v].caste_id):lower().."</caste>\n")
end
elseif k == "interaction" and df.history_event_hf_does_interactionst:is_instance(event) then
if #world.raws.interactions[v].sources > 0 then
local str_1 = world.raws.interactions[v].sources[0].hist_string_1
if #world.raws.interactions.all[v].sources > 0 then
local str_1 = world.raws.interactions.all[v].sources[0].hist_string_1
if string.sub (str_1, 1, 1) == " " and string.sub (str_1, string.len (str_1), string.len (str_1)) == " " then
str_1 = string.sub (str_1, 2, string.len (str_1) - 1)
end
file:write("\t\t<interaction_action>"..str_1..world.raws.interactions[v].sources[0].hist_string_2.."</interaction_action>\n")
file:write("\t\t<interaction_action>"..str_1..world.raws.interactions.all[v].sources[0].hist_string_2.."</interaction_action>\n")
end
elseif k == "interaction" and df.history_event_hf_learns_secretst:is_instance(event) then
if #world.raws.interactions[v].sources > 0 then
file:write("\t\t<secret_text>"..world.raws.interactions[v].sources[0].name.."</secret_text>\n")
if #world.raws.interactions.all[v].sources > 0 then
file:write("\t\t<secret_text>"..world.raws.interactions.all[v].sources[0].name.."</secret_text>\n")
end
elseif df.history_event_hist_figure_diedst:is_instance(event) and k == "weapon" then
for detailK,detailV in pairs(v) do
Expand Down
33 changes: 18 additions & 15 deletions fix/population-cap.lua
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
local ui = df.global.plotinfo
local ui_stats = ui.tasks
local civ = df.historical_entity.find(ui.civ_id)
local plotinfo = df.global.plotinfo
local tasks = plotinfo.tasks
local knowledge = tasks.knowledge

if not civ then
local civ = df.historical_entity.find(plotinfo.civ_id)

if not dfhack.isMapLoaded() or not dfhack.world.isFortressMode() or not civ then
qerror('No active fortress.')
end

local civ_stats = civ.activity_stats

if not civ_stats then
civ.activity_stats = {
new = true,
created_weapons = { resize = #ui_stats.created_weapons },
discovered_creature_foods = { resize = #ui_stats.discovered_creature_foods },
discovered_creatures = { resize = #ui_stats.discovered_creatures },
discovered_plant_foods = { resize = #ui_stats.discovered_plant_foods },
discovered_plants = { resize = #ui_stats.discovered_plants },
}
civ_stats = civ.activity_stats
local function upsize(civ_vec, tasks_vec)
local tasks_vec_size = #tasks_vec
if #civ_vec < tasks_vec_size then
civ_vec:resize(tasks_vec_size)
end
end

upsize(civ_stats.created_weapons, tasks.created_weapons)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rewrote the logic here because the original didn't seem to make sense -- civ.activity_stats is not a pointer

upsize(civ_stats.knowledge.discovered_creature_foods, knowledge.discovered_creature_foods)
upsize(civ_stats.knowledge.discovered_creatures, knowledge.discovered_creatures)
upsize(civ_stats.knowledge.discovered_plant_foods, knowledge.discovered_plant_foods)
upsize(civ_stats.knowledge.discovered_plants, knowledge.discovered_plants)

-- Use max to keep at least some of the original caravan communication idea
local new_pop = math.max(civ_stats.population, ui_stats.population)
local new_pop = math.max(civ_stats.population, tasks.population)

if civ_stats.population ~= new_pop then
civ_stats.population = new_pop
Expand Down
2 changes: 1 addition & 1 deletion fix/wildlife.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ end

local function refund_population(entry)
local epop = entry.pop
for _,population in ipairs(df.global.world.populations) do
for _,population in ipairs(df.global.world.populations.all) do
local wpop = population.population
if population.quantity < 10000001 and
wpop.region_x == epop.region_x and
Expand Down
4 changes: 2 additions & 2 deletions gui/autogems.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ CONFIG_KEY = "autogems/config"
blacklist = {}

gems = {}
for id, raw in pairs(df.global.world.raws.inorganics) do
for id, raw in pairs(df.global.world.raws.inorganics.all) do
if raw.material.flags.IS_GEM then
if blacklist[id] == nil then
blacklist[id] = false
Expand Down Expand Up @@ -97,7 +97,7 @@ end

function save()
local save_blacklist = {}
for id in ipairs(df.global.world.raws.inorganics) do
for id in ipairs(df.global.world.raws.inorganics.all) do
if blacklist[id] then
table.insert(save_blacklist, id)
end
Expand Down
2 changes: 1 addition & 1 deletion gui/dfstatus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ config = {

function parse_config()
local metal_map = {}
for id, raw in pairs(df.global.world.raws.inorganics) do
for id, raw in pairs(df.global.world.raws.inorganics.all) do
if raw.material.flags.IS_METAL then
metal_map[raw.id:upper()] = id
metal_map[id] = raw.id:upper()
Expand Down
2 changes: 1 addition & 1 deletion gui/sandbox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ end

function Sandbox:find_zombie_syndrome()
if self.zombie_syndrome then return self.zombie_syndrome end
for _,syn in ipairs(df.global.world.raws.syndromes.all) do
for _,syn in ipairs(df.global.world.raws.mat_table.syndromes.all) do
local has_flags, has_flash = false, false
for _,effect in ipairs(syn.ce) do
if df.creature_interaction_effect_display_namest:is_instance(effect) then
Expand Down
2 changes: 1 addition & 1 deletion gui/tiletypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1739,7 +1739,7 @@ function TiletypeScreen:generateDataLists()

data_lists.stone_list = { { text = "none", value = -1 } }
data_lists.stone_dict = { [-1] = { label= "NONE", value= -1, pen= itemColor("NONE") } }
for i,mat in ipairs(df.global.world.raws.inorganics) do
for i,mat in ipairs(df.global.world.raws.inorganics.all) do
if mat and mat.material
and not mat.flags[df.inorganic_flags.SOIL_ANY]
and not mat.material.flags[df.material_flags.IS_METAL]
Expand Down
6 changes: 3 additions & 3 deletions gui/unit-syndromes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ local function getSyndromeName(syndrome_raw)
end

local function getSyndromeEffects(syndrome_type)
local syndrome_raw = df.global.world.raws.syndromes.all[syndrome_type]
local syndrome_raw = df.global.world.raws.mat_table.syndromes.all[syndrome_type]
local syndrome_effects = {}

for _, effect in ipairs(syndrome_raw.ce) do
Expand Down Expand Up @@ -442,7 +442,7 @@ function UnitSyndromes:showUnits(_, choice)
local choices = {}

if choice.text == "All syndromes" then
for _, syndrome in pairs(df.global.world.raws.syndromes.all) do
for _, syndrome in pairs(df.global.world.raws.mat_table.syndromes.all) do
if #syndrome.ce == 0 then
goto skipsyndrome
end
Expand Down Expand Up @@ -491,7 +491,7 @@ function UnitSyndromes:showUnitSyndromes(index, choice)
end

for _, syndrome in pairs(unit_syndromes) do
local syndrome_raw = df.global.world.raws.syndromes.all[syndrome.type]
local syndrome_raw = df.global.world.raws.mat_table.syndromes.all[syndrome.type]

if #syndrome_raw.ce == 0 then
goto skipsyndrome
Expand Down
Loading