Skip to content

Commit

Permalink
Merge pull request #1163 from myk002/myk_canon
Browse files Browse the repository at this point in the history
adapt to canonicalized structures
  • Loading branch information
myk002 authored Jun 8, 2024
2 parents 8fe33f2 + b9831e2 commit 50bf305
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 43 deletions.
10 changes: 5 additions & 5 deletions colonies.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function findVermin(target_verm)
end

function list_colonies()
for idx, col in pairs(df.global.world.vermin.colonies) do
for idx, col in pairs(df.global.world.event.vermin_colonies) do
local race = df.global.world.raws.creatures.all[col.race].creature_id
print(race..' at '..col.pos.x..', '..col.pos.y..', '..col.pos.z)
end
Expand All @@ -39,7 +39,7 @@ end
function convert_vermin_to(target_verm)
local vermin_id = findVermin(target_verm)
local changed = 0
for _, verm in pairs(df.global.world.vermin.colonies) do
for _, verm in pairs(df.global.world.event.vermin_colonies) do
verm.race = vermin_id
verm.caste = -1 -- check for queen bee?
verm.amount = 18826
Expand All @@ -61,8 +61,8 @@ function place_vermin(target_verm)
verm.amount = 18826
verm.visible = true
verm.pos:assign(pos)
df.global.world.vermin.colonies:insert("#", verm)
df.global.world.vermin.all:insert("#", verm)
df.global.world.event.vermin_colonies:insert("#", verm)
df.global.world.event.vermin:insert("#", verm)
end

local args = {...}
Expand All @@ -75,7 +75,7 @@ elseif args[1] == 'convert' then
elseif args[1] == 'place' then
place_vermin(target_verm)
else
if #df.global.world.vermin.colonies < 1 then
if #df.global.world.event.vermin_colonies < 1 then
dfhack.printerr('There are no colonies on the map.')
end
list_colonies()
Expand Down
4 changes: 2 additions & 2 deletions deep-embark.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function reveal(pos)
local tiletype = block.tiletype[x%16][y%16]
if tiletype ~= df.tiletype.GlowingBarrier then -- to avoid multiple instances
block.tiletype[x%16][y%16] = df.tiletype.GlowingBarrier
local barriers = df.global.world.glowing_barriers
local barriers = df.global.world.event.glowing_barriers
local barrier = df.glowing_barrier:new()
barrier.buildings:insert('#',-1) -- being unbound to a building makes the barrier disappear immediately
barrier.pos:assign(pos)
Expand Down Expand Up @@ -255,7 +255,7 @@ end

function disableSpireDemons()
-- marks underworld spires on the map as having been breached already, preventing HFS events
for _, spire in ipairs(df.global.world.deep_vein_hollows) do
for _, spire in ipairs(df.global.world.event.deep_vein_hollows) do
spire.triggered = true
end
end
Expand Down
2 changes: 1 addition & 1 deletion do-job-now.lua
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ local function getSelectedWorkOrder()
local orders
local idx
if df.viewscreen_jobmanagementst:is_instance(scr) then
orders = df.global.world.manager_orders
orders = df.global.world.manager_orders.all
idx = scr.sel_idx
elseif df.viewscreen_workshop_profilest:is_instance(scr)
and scr.tab == df.viewscreen_workshop_profilest.T_tab.Orders
Expand Down
4 changes: 2 additions & 2 deletions exportlegends.lua
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ local function export_more_legends_xml()
end
if df.abstract_building_templest:is_instance(buildingV) then
file:write("\t\t\t\t<deity_type>"..buildingV.deity_type.."</deity_type>\n")
if buildingV.deity_type == df.temple_deity_type.Deity then
if buildingV.deity_type == df.religious_practice_type.WORSHIP_HFID then
file:write("\t\t\t\t<deity>"..buildingV.deity_data.Deity.."</deity>\n")
elseif buildingV.deity_type == df.temple_deity_type.Religion then
elseif buildingV.deity_type == df.religious_practice_type.RELIGION_ENID then
file:write("\t\t\t\t<religion>"..buildingV.deity_data.Religion.."</religion>\n")
end
end
Expand Down
8 changes: 4 additions & 4 deletions extinguish.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ function extinguishUnit(unit)
end

function extinguishAll()
local fires = df.global.world.fires
local fires = df.global.world.event.fires
for i = #fires - 1, 0, -1 do
extinguishTile(pos2xyz(fires[i].pos))
fires:erase(i)
end
local campfires = df.global.world.campfires
local campfires = df.global.world.event.campfires
for i = #campfires - 1, 0, -1 do
extinguishTile(pos2xyz(campfires[i].pos))
campfires:erase(i)
Expand All @@ -118,14 +118,14 @@ end

function extinguishLocation(x, y, z)
local pos = xyz2pos(x, y, z)
local fires = df.global.world.fires
local fires = df.global.world.event.fires
for i = #fires - 1, 0, -1 do
if same_xyz(pos, fires[i].pos) then
extinguishTile(x, y, z)
fires:erase(i)
end
end
local campfires = df.global.world.campfires
local campfires = df.global.world.event.campfires
for i = #campfires - 1, 0, -1 do
if same_xyz(pos, campfires[i].pos) then
extinguishTile(x, y, z)
Expand Down
2 changes: 1 addition & 1 deletion firestarter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ elseif dfhack.gui.getSelectedUnit(true) then
entry.item.flags.on_fire = true
end
elseif guidm.getCursorPos() then
df.global.world.fires:insert('#', {
df.global.world.event.fires:insert('#', {
new=df.fire,
timer=1000,
pos=guidm.getCursorPos(),
Expand Down
2 changes: 1 addition & 1 deletion fix/engravings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ end

--loop runs through list of all engravings checking each using is_good_engraving and if bad gets deleted
local cleanup = 0
local engravings = df.global.world.engravings
local engravings = df.global.world.event.engravings
for index = #engravings-1,0,-1 do
local engraving = engravings[index]
if not is_good_engraving(engraving) then
Expand Down
8 changes: 4 additions & 4 deletions gui/advfort.lua
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ function advGlobalPos()
local map=df.global.world.map
local wd=df.global.world.world_data
local adv=df.global.world.units.active[0]
--wd.adv_region_x*16+wd.adv_emb_x,wd.adv_region_y*16+wd.adv_emb_y
--return wd.adv_region_x*16+wd.adv_emb_x,wd.adv_region_y*16+wd.adv_emb_y
--return wd.adv_region_x*16+wd.adv_emb_x+adv.pos.x/16,wd.adv_region_y*16+wd.adv_emb_y+adv.pos.y/16
--wd.midmap_data.adv_region_x*16+wd.midmap_data.adv_emb_x,wd.midmap_data.adv_region_y*16+wd.midmap_data.adv_emb_y
--return wd.midmap_data.adv_region_x*16+wd.midmap_data.adv_emb_x,wd.midmap_data.adv_region_y*16+wd.midmap_data.adv_emb_y
--return wd.midmap_data.adv_region_x*16+wd.midmap_data.adv_emb_x+adv.pos.x/16,wd.midmap_data.adv_region_y*16+wd.midmap_data.adv_emb_y+adv.pos.y/16
--print(map.region_x,map.region_y,adv.pos.x,adv.pos.y)
--print(map.region_x+adv.pos.x/48, map.region_y+adv.pos.y/48,wd.adv_region_x*16+wd.adv_emb_x,wd.adv_region_y*16+wd.adv_emb_y)
--print(map.region_x+adv.pos.x/48, map.region_y+adv.pos.y/48,wd.midmap_data.adv_region_x*16+wd.midmap_data.adv_emb_x,wd.midmap_data.adv_region_y*16+wd.midmap_data.adv_emb_y)
return math.floor(map.region_x+adv.pos.x/48), math.floor(map.region_y+adv.pos.y/48)
end
function inSite()
Expand Down
8 changes: 4 additions & 4 deletions gui/extended-status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ function queue_beds(amount)
end

order = df.manager_order:new()
order.id = df.global.world.manager_order_next_id
df.global.world.manager_order_next_id = df.global.world.manager_order_next_id + 1
order.id = df.global.world.manager_orders.manager_order_next_id
df.global.world.manager_orders.manager_order_next_id = df.global.world.manager_orders.manager_order_next_id + 1
order.job_type = df.job_type.ConstructBed
order.material_category.wood = true
order.amount_left = amount
order.amount_total = amount
df.global.world.manager_orders:insert('#', order)
df.global.world.manager_orders.all:insert('#', order)
end

status_overlay = defclass(status_overlay, gui.Screen)
Expand Down Expand Up @@ -172,7 +172,7 @@ function bedroom_list:refresh()
end
end
self.queued_beds = 0
for _, order in pairs(df.global.world.manager_orders) do
for _, order in pairs(df.global.world.manager_orders.all) do
if order.job_type == df.job_type.ConstructBed then
self.queued_beds = self.queued_beds + order.amount_left
end
Expand Down
2 changes: 1 addition & 1 deletion gui/gm-editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function getTargetFromScreens()
if dfhack.gui.matchFocusString('dwarfmode/ViewSheets/ENGRAVING', dfhack.gui.getDFViewscreen(true)) then
local sheet = df.global.game.main_interface.view_sheets
local pos = xyz2pos(sheet.viewing_x, sheet.viewing_y, sheet.viewing_z)
for _, engraving in ipairs(df.global.world.engravings) do
for _, engraving in ipairs(df.global.world.event.engravings) do
if same_xyz(engraving.pos, pos) then
my_trg = engraving
break
Expand Down
2 changes: 1 addition & 1 deletion gui/sitemap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ local function get_location_desc(loc)
if not prof then return 'Guildhall', COLOR_MAGENTA end
return ('%s guildhall'):format(to_title_case(prof)), COLOR_MAGENTA
elseif df.abstract_building_templest:is_instance(loc) then
local is_deity = loc.deity_type == df.temple_deity_type.Deity
local is_deity = loc.deity_type == df.religious_practice_type.WORSHIP_HFID
local id = loc.deity_data[is_deity and 'Deity' or 'Religion']
local entity = is_deity and df.historical_figure.find(id) or df.historical_entity.find(id)
local desc = 'Temple'
Expand Down
2 changes: 1 addition & 1 deletion internal/quickfort/dig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ end
local function ensure_engravings_cache(ctx)
if ctx.engravings_cache then return end
local engravings_cache = {}
for _,engraving in ipairs(df.global.world.engravings) do
for _,engraving in ipairs(df.global.world.event.engravings) do
local pos = engraving.pos
local grid = ensure_key(engravings_cache, pos.z)
local row = ensure_key(grid, pos.y)
Expand Down
6 changes: 3 additions & 3 deletions internal/quickfort/stockflow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ function create_orders(order, amount)
-- Todo: Create in a validated state if the fortress is small enough?
new_order.status.validated = false
new_order.status.active = false
new_order.id = df.global.world.manager_order_next_id
df.global.world.manager_order_next_id = df.global.world.manager_order_next_id + 1
df.global.world.manager_orders:insert('#', new_order)
new_order.id = df.global.world.manager_orders.manager_order_next_id
df.global.world.manager_orders.manager_order_next_id = df.global.world.manager_orders.manager_order_next_id + 1
df.global.world.manager_orders.all:insert('#', new_order)
end
4 changes: 2 additions & 2 deletions open-legends.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function LegendsManager:init()
-- missing, but it shows that jumping back and forth between modes is not
-- safe.
self.region_details_backup = {} --as:df.world_region_details[]
local vec = df.global.world.world_data.region_details
local vec = df.global.world.world_data.midmap_data.region_details
utils.assign(self.region_details_backup, vec)
vec:resize(0)

Expand Down Expand Up @@ -68,7 +68,7 @@ function LegendsManager:onDestroy()
else
df.global.gametype = self.gametype_backup

local vec = df.global.world.world_data.region_details
local vec = df.global.world.world_data.midmap_data.region_details
vec:resize(0)
utils.assign(vec, self.region_details_backup)

Expand Down
12 changes: 6 additions & 6 deletions test/gui/workorder-details.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function test.changeOrderDetails()
send_keys('D_JOBLIST', 'UNITJOB_MANAGER')
expect.true_(df.viewscreen_jobmanagementst:is_instance(dfhack.gui.getCurViewscreen(true)), "We need to be in the jobmanagement/Main screen")

local ordercount = #df.global.world.manager_orders
local ordercount = #df.global.world.manager_orders.all

--- create an order
dfhack.run_command [[workorder "{ \"frequency\" : \"OneTime\", \"job\" : \"CutGems\", \"material\" : \"INORGANIC:SLADE\" }"]]
Expand All @@ -57,7 +57,7 @@ function test.changeOrderDetails()
wait()
send_keys('MANAGER_DETAILS')
expect.true_(df.viewscreen_workquota_detailsst:is_instance(dfhack.gui.getCurViewscreen(true)), "We need to be in the workquota_details screen")
expect.eq(ordercount + 1, #df.global.world.manager_orders, "Test order should have been added")
expect.eq(ordercount + 1, #df.global.world.manager_orders.all, "Test order should have been added")
local job = dfhack.gui.getCurViewscreen(true).order
local item = job.items[0]

Expand Down Expand Up @@ -90,7 +90,7 @@ function test.changeOrderDetails()
wait()
send_keys('LEAVESCREEN', 'LEAVESCREEN', 'MANAGER_REMOVE')
confirmRemove()
expect.eq(ordercount, #df.global.world.manager_orders, "Test order should've been removed")
expect.eq(ordercount, #df.global.world.manager_orders.all, "Test order should've been removed")
-- go back to map screen
wait()
send_keys('LEAVESCREEN', 'LEAVESCREEN')
Expand All @@ -109,11 +109,11 @@ function test.unsetAllItemTraits()
send_keys('D_JOBLIST', 'UNITJOB_MANAGER')
expect.true_(df.viewscreen_jobmanagementst:is_instance(dfhack.gui.getCurViewscreen(true)), "We need to be in the jobmanagement/Main screen")

local ordercount = #df.global.world.manager_orders
local ordercount = #df.global.world.manager_orders.all

--- create an order
dfhack.run_command [[workorder "{ \"frequency\" : \"OneTime\", \"job\" : \"CutGems\", \"material\" : \"INORGANIC:SLADE\" }"]]
expect.eq(ordercount + 1, #df.global.world.manager_orders, "Test order should have been added")
expect.eq(ordercount + 1, #df.global.world.manager_orders.all, "Test order should have been added")
wait()
send_keys('STANDARDSCROLL_UP') -- move cursor to newly created CUT SLADE
wait()
Expand Down Expand Up @@ -152,7 +152,7 @@ function test.unsetAllItemTraits()
wait()
send_keys('LEAVESCREEN', 'LEAVESCREEN', 'MANAGER_REMOVE')
confirmRemove()
expect.eq(ordercount, #df.global.world.manager_orders, "Test order should've been removed")
expect.eq(ordercount, #df.global.world.manager_orders.all, "Test order should've been removed")
-- go back to map screen
wait()
send_keys('LEAVESCREEN', 'LEAVESCREEN')
Expand Down
10 changes: 5 additions & 5 deletions workorder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ end
-- Get the remaining quantity for open matching orders in the queue.
local function cur_order_quantity(order)
local amount, cur_order, cur_idx = 0, nil, nil
for idx, managed in ipairs(world.manager_orders) do
for idx, managed in ipairs(world.manager_orders.all) do
if orders_match(order, managed) then
-- if infinity, don't plan anything
if 0 == managed.amount_total then
Expand Down Expand Up @@ -187,8 +187,8 @@ function create_orders(orders, quiet)
-- we need id mapping to restore saved order_conditions
local id_mapping = {}
for _, it in ipairs(orders) do
id_mapping[it["id"]] = world.manager_order_next_id
world.manager_order_next_id = world.manager_order_next_id + 1
id_mapping[it["id"]] = world.manager_orders.manager_order_next_id
world.manager_orders.manager_order_next_id = world.manager_orders.manager_order_next_id + 1
end

for _, it in ipairs (orders) do
Expand Down Expand Up @@ -412,7 +412,7 @@ function create_orders(orders, quiet)
cur_order.amount_total = cur_order.amount_total + diff
if cur_order.amount_left <= 0 then
if verbose then print('negative amount; removing existing order') end
world.manager_orders:erase(cur_order_idx)
world.manager_orders.all:erase(cur_order_idx)
cur_order:delete()
end
end
Expand All @@ -437,7 +437,7 @@ function create_orders(orders, quiet)
print("Queuing " .. job_type
.. (amount==0 and " infinitely" or " x"..amount))
end
world.manager_orders:insert('#', order)
world.manager_orders.all:insert('#', order)
end
end)
end
Expand Down

0 comments on commit 50bf305

Please sign in to comment.