This **MAY** resolve the message in issue 312, but this fix ultimately breaks things and will need to eventually be rolled back.
Cette révision appartient à :
Parent
bdb8cdc68c
révision
617f265558
|
@ -131,6 +131,9 @@ local prepared = false
|
|||
local linktime = 0
|
||||
|
||||
function QH_Graph_Pathmultifind(st, nda, reverse, make_path)
|
||||
QuestHelper: Assert(st.x and st.y and st.p)
|
||||
if st.p == 26 then return nil end -- DENIED!!!!
|
||||
|
||||
--QuestHelper:TextOut("Starting PMF")
|
||||
QuestHelper: Assert(not active)
|
||||
QuestHelper: Assert(prepared)
|
||||
|
@ -144,8 +147,6 @@ function QH_Graph_Pathmultifind(st, nda, reverse, make_path)
|
|||
|
||||
--local stats = QuestHelper:CreateTable("graphcore --stats")
|
||||
|
||||
QuestHelper: Assert(st.x and st.y and st.p)
|
||||
|
||||
--stats.dests_complex = 0
|
||||
--stats.dests_total = 0
|
||||
|
||||
|
|
|
@ -101,12 +101,16 @@ local function GetCachedPath(loc1, loc2)
|
|||
-- Not in either, time to create
|
||||
misses = misses + 1
|
||||
local nrt = QH_Graph_Pathfind(loc1.loc, loc2.loc, false, true)
|
||||
QuestHelper: Assert(nrt)
|
||||
if not pathcache_active[loc1] then pathcache_active[loc1] = new_pathcache_table() end
|
||||
if not pathcache_inactive[loc1] then pathcache_inactive[loc1] = new_pathcache_table() end
|
||||
pathcache_active[loc1][loc2] = nrt
|
||||
pathcache_inactive[loc1][loc2] = nrt
|
||||
return nrt
|
||||
if nrt then
|
||||
QuestHelper: Assert(nrt)
|
||||
if not pathcache_active[loc1] then pathcache_active[loc1] = new_pathcache_table() end
|
||||
if not pathcache_inactive[loc1] then pathcache_inactive[loc1] = new_pathcache_table() end
|
||||
pathcache_active[loc1][loc2] = nrt
|
||||
pathcache_inactive[loc1][loc2] = nrt
|
||||
return nrt
|
||||
else
|
||||
return nil
|
||||
end
|
||||
else
|
||||
hits = hits + 1
|
||||
if not pathcache_active[loc1] then pathcache_active[loc1] = new_pathcache_table() end
|
||||
|
@ -134,51 +138,53 @@ local function ReplotPath(progress)
|
|||
|
||||
if last_path[k + 1] then
|
||||
local nrt = GetCachedPath(last_path[k], last_path[k + 1])
|
||||
distance = distance + nrt.d
|
||||
QuestHelper: Assert(nrt)
|
||||
if nrt then
|
||||
distance = distance + nrt.d
|
||||
QuestHelper: Assert(nrt)
|
||||
|
||||
-- The "condense" is kind of weird - we're actually condensing descriptions, but we condense to the *last* item. Urgh.
|
||||
local condense_start = nil
|
||||
local condense_class = nil
|
||||
local condense_to = nil
|
||||
-- The "condense" is kind of weird - we're actually condensing descriptions, but we condense to the *last* item. Urgh.
|
||||
local condense_start = nil
|
||||
local condense_class = nil
|
||||
local condense_to = nil
|
||||
|
||||
-- ugh this is just easier
|
||||
local function condense_doit()
|
||||
--print("start condense doit, was", real_path[condense_start].map_desc[1])
|
||||
for i = condense_start, #real_path do
|
||||
real_path[i].map_desc = condense_to
|
||||
-- ugh this is just easier
|
||||
local function condense_doit()
|
||||
--print("start condense doit, was", real_path[condense_start].map_desc[1])
|
||||
for i = condense_start, #real_path do
|
||||
real_path[i].map_desc = condense_to
|
||||
end
|
||||
--print("end condense doit, now", real_path[condense_start].map_desc[1])
|
||||
condense_start, condense_class, condense_to = nil, nil, nil
|
||||
end
|
||||
--print("end condense doit, now", real_path[condense_start].map_desc[1])
|
||||
condense_start, condense_class, condense_to = nil, nil, nil
|
||||
|
||||
if #nrt > 0 then for _, wp in ipairs(nrt) do
|
||||
QuestHelper: Assert(wp.c)
|
||||
|
||||
--print(wp.condense_class)
|
||||
if condense_class and condense_class ~= wp.condense_class then condense_doit() end
|
||||
|
||||
local pathnode = QuestHelper:CreateTable("pathnode")
|
||||
pathnode.loc = QuestHelper:CreateTable("pathnode.loc")
|
||||
pathnode.loc.x = wp.x
|
||||
pathnode.loc.y = wp.y
|
||||
pathnode.loc.c = wp.c
|
||||
pathnode.ignore = true
|
||||
pathnode.map_desc = wp.map_desc
|
||||
pathnode.map_desc_chain = last_path[k + 1]
|
||||
pathnode.local_allocated = true
|
||||
pathnode.cluster = last_path[k + 1].cluster
|
||||
table.insert(real_path, pathnode) -- Technically, we'll end up with the distance to the next objective. I'm okay with this.
|
||||
|
||||
if not condense_class and wp.condense_class then
|
||||
condense_start, condense_class = #real_path, wp.condense_class
|
||||
end
|
||||
if condense_class then
|
||||
condense_to = wp.map_desc
|
||||
end
|
||||
end end
|
||||
|
||||
if condense_class then condense_doit() end -- in case we have stuff left over
|
||||
end
|
||||
|
||||
if #nrt > 0 then for _, wp in ipairs(nrt) do
|
||||
QuestHelper: Assert(wp.c)
|
||||
|
||||
--print(wp.condense_class)
|
||||
if condense_class and condense_class ~= wp.condense_class then condense_doit() end
|
||||
|
||||
local pathnode = QuestHelper:CreateTable("pathnode")
|
||||
pathnode.loc = QuestHelper:CreateTable("pathnode.loc")
|
||||
pathnode.loc.x = wp.x
|
||||
pathnode.loc.y = wp.y
|
||||
pathnode.loc.c = wp.c
|
||||
pathnode.ignore = true
|
||||
pathnode.map_desc = wp.map_desc
|
||||
pathnode.map_desc_chain = last_path[k + 1]
|
||||
pathnode.local_allocated = true
|
||||
pathnode.cluster = last_path[k + 1].cluster
|
||||
table.insert(real_path, pathnode) -- Technically, we'll end up with the distance to the next objective. I'm okay with this.
|
||||
|
||||
if not condense_class and wp.condense_class then
|
||||
condense_start, condense_class = #real_path, wp.condense_class
|
||||
end
|
||||
if condense_class then
|
||||
condense_to = wp.map_desc
|
||||
end
|
||||
end end
|
||||
|
||||
if condense_class then condense_doit() end -- in case we have stuff left over
|
||||
end
|
||||
|
||||
if progress then progress:SetPercentage(k / #last_path) end
|
||||
|
@ -371,62 +377,66 @@ Route_Core_Init(
|
|||
|
||||
rvv = QuestHelper:CreateTable("route controller path shunt returnvalue")
|
||||
local rv = QH_Graph_Pathmultifind(loc1.loc, lt, reverse, true)
|
||||
QuestHelper: Assert(#lt == #rv, string.format("lt has %d items, rt has %d items. Both should be the same.", #lt, #rv))
|
||||
if rv ~= nil then
|
||||
QuestHelper: Assert(#lt == #rv, string.format("lt has %d items, rt has %d items. Both should be the same.", #lt, #rv))
|
||||
|
||||
-- We want to store the math.max(sqrt(#rv), 10) shortest paths
|
||||
local tostore = complete_pass and math.max(sqrt(#rv), 10) or #rv
|
||||
--print("would store", #rv, "am store", tostore)
|
||||
local linkity = QuestHelper:CreateTable("shortest path summary")
|
||||
for k, v in ipairs(rv) do
|
||||
local tk = QuestHelper:CreateTable("shortest path summary item")
|
||||
tk.k = k
|
||||
tk.v = v
|
||||
table.insert(linkity, tk)
|
||||
-- We want to store the math.max(sqrt(#rv), 10) shortest paths
|
||||
local tostore = complete_pass and math.max(sqrt(#rv), 10) or #rv
|
||||
--print("would store", #rv, "am store", tostore)
|
||||
local linkity = QuestHelper:CreateTable("shortest path summary")
|
||||
for k, v in ipairs(rv) do
|
||||
local tk = QuestHelper:CreateTable("shortest path summary item")
|
||||
tk.k = k
|
||||
tk.v = v
|
||||
table.insert(linkity, tk)
|
||||
|
||||
rvv[k] = rv[k].d
|
||||
end
|
||||
rvv[k] = rv[k].d
|
||||
end
|
||||
|
||||
table.sort(linkity, function(a, b) return a.v.d < b.v.d end)
|
||||
while #linkity > tostore do
|
||||
local rip = table.remove(linkity)
|
||||
QuestHelper:ReleaseTable(rip.v)
|
||||
QuestHelper:ReleaseTable(rip)
|
||||
end
|
||||
|
||||
for _, it in pairs(linkity) do
|
||||
local k, v = it.k, it.v
|
||||
|
||||
if not rv[k] then
|
||||
QuestHelper:TextOut(QuestHelper:StringizeTable(loc1.loc))
|
||||
QuestHelper:TextOut(QuestHelper:StringizeTable(lt[k]))
|
||||
table.sort(linkity, function(a, b) return a.v.d < b.v.d end)
|
||||
while #linkity > tostore do
|
||||
local rip = table.remove(linkity)
|
||||
QuestHelper:ReleaseTable(rip.v)
|
||||
QuestHelper:ReleaseTable(rip)
|
||||
end
|
||||
QuestHelper: Assert(rv[k], string.format("%d to %d", loc1.loc.p, loctable[k].loc.p))
|
||||
QuestHelper: Assert(rv[k].d)
|
||||
|
||||
for _, it in pairs(linkity) do
|
||||
local k, v = it.k, it.v
|
||||
|
||||
-- We're only setting the inactive to give the garbage collector potentially a little more to clean up (i.e. the old path.)
|
||||
if not reverse then
|
||||
QuestHelper: Assert(pathcache_active[loc1])
|
||||
QuestHelper: Assert(pathcache_inactive[loc1])
|
||||
pathcache_active[loc1][loctable[k]] = rv[k]
|
||||
pathcache_inactive[loc1][loctable[k]] = rv[k]
|
||||
else
|
||||
QuestHelper: Assert(loctable[k])
|
||||
QuestHelper: Assert(pathcache_active[loctable[k]])
|
||||
QuestHelper: Assert(pathcache_inactive[loctable[k]])
|
||||
pathcache_active[loctable[k]][loc1] = rv[k]
|
||||
pathcache_inactive[loctable[k]][loc1] = rv[k]
|
||||
if not rv[k] then
|
||||
QuestHelper:TextOut(QuestHelper:StringizeTable(loc1.loc))
|
||||
QuestHelper:TextOut(QuestHelper:StringizeTable(lt[k]))
|
||||
end
|
||||
QuestHelper: Assert(rv[k], string.format("%d to %d", loc1.loc.p, loctable[k].loc.p))
|
||||
QuestHelper: Assert(rv[k].d)
|
||||
|
||||
-- We're only setting the inactive to give the garbage collector potentially a little more to clean up (i.e. the old path.)
|
||||
if not reverse then
|
||||
QuestHelper: Assert(pathcache_active[loc1])
|
||||
QuestHelper: Assert(pathcache_inactive[loc1])
|
||||
pathcache_active[loc1][loctable[k]] = rv[k]
|
||||
pathcache_inactive[loc1][loctable[k]] = rv[k]
|
||||
else
|
||||
QuestHelper: Assert(loctable[k])
|
||||
QuestHelper: Assert(pathcache_active[loctable[k]])
|
||||
QuestHelper: Assert(pathcache_inactive[loctable[k]])
|
||||
pathcache_active[loctable[k]][loc1] = rv[k]
|
||||
pathcache_inactive[loctable[k]][loc1] = rv[k]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for _, v in ipairs(linkity) do
|
||||
-- we do not release v.v, since that's now stored in our path cache
|
||||
QuestHelper:ReleaseTable(v)
|
||||
end
|
||||
QuestHelper:ReleaseTable(linkity)
|
||||
QuestHelper:ReleaseTable(lt)
|
||||
QuestHelper:ReleaseTable(rv) -- this had better be releasable
|
||||
for _, v in ipairs(linkity) do
|
||||
-- we do not release v.v, since that's now stored in our path cache
|
||||
QuestHelper:ReleaseTable(v)
|
||||
end
|
||||
QuestHelper:ReleaseTable(linkity)
|
||||
QuestHelper:ReleaseTable(lt)
|
||||
QuestHelper:ReleaseTable(rv) -- this had better be releasable
|
||||
|
||||
return rvv
|
||||
return rvv
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
|
|
|
@ -773,17 +773,19 @@ function QH_Route_Core_Process()
|
|||
-- Refresh a subset of things.
|
||||
local forward = DistBatch(NodeList[idx], tlnod)
|
||||
local backward = DistBatch(NodeList[idx], tlnod, true)
|
||||
if forward and backward then
|
||||
|
||||
for k, v in ipairs(ActiveNodes) do
|
||||
Distance[idx][v] = forward[k]
|
||||
Distance[v][idx] = backward[k]
|
||||
for k, v in ipairs(ActiveNodes) do
|
||||
Distance[idx][v] = forward[k]
|
||||
Distance[v][idx] = backward[k]
|
||||
end
|
||||
|
||||
QuestHelper:ReleaseTable(forward)
|
||||
QuestHelper:ReleaseTable(backward)
|
||||
|
||||
ctd = ctd + 1
|
||||
resynch_progress:SetPercentage(ctd / ct)
|
||||
end
|
||||
|
||||
QuestHelper:ReleaseTable(forward)
|
||||
QuestHelper:ReleaseTable(backward)
|
||||
|
||||
ctd = ctd + 1
|
||||
resynch_progress:SetPercentage(ctd / ct)
|
||||
end
|
||||
QuestHelper:ReleaseTable(tlnod)
|
||||
end
|
||||
|
@ -1124,22 +1126,24 @@ end
|
|||
|
||||
local forward = DistBatch(NodeList[1], tlnod)
|
||||
|
||||
local ct = 1
|
||||
for _, v in ipairs(ActiveNodes) do
|
||||
if v ~= 1 then
|
||||
QuestHelper: Assert(forward[ct])
|
||||
Distance[1][v] = forward[ct]
|
||||
ct = ct + 1
|
||||
if forward then
|
||||
local ct = 1
|
||||
for _, v in ipairs(ActiveNodes) do
|
||||
if v ~= 1 then
|
||||
QuestHelper: Assert(forward[ct])
|
||||
Distance[1][v] = forward[ct]
|
||||
ct = ct + 1
|
||||
|
||||
Distance[v][1] = 65500 -- this should never be used anyway
|
||||
Distance[v][1] = 65500 -- this should never be used anyway
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if last_best and #last_best > 1 then
|
||||
last_best.distance = last_best.distance + Distance[last_best[1]][last_best[2]]
|
||||
end
|
||||
if last_best and #last_best > 1 then
|
||||
last_best.distance = last_best.distance + Distance[last_best[1]][last_best[2]]
|
||||
end
|
||||
|
||||
QuestHelper:ReleaseTable(forward)
|
||||
QuestHelper:ReleaseTable(forward)
|
||||
end
|
||||
QuestHelper:ReleaseTable(tlnod)
|
||||
|
||||
Storage_Distance_StoreFromIDToAll(1)
|
||||
|
@ -1462,8 +1466,10 @@ function QH_Route_Core_DistanceClear(progress)
|
|||
for ani, idx in ipairs(ActiveNodes) do
|
||||
local forward = DistBatch(NodeList[idx], tlnod, false, true)
|
||||
|
||||
for k, v in ipairs(ActiveNodes) do
|
||||
Distance[idx][v] = forward[k]
|
||||
if forward then
|
||||
for k, v in ipairs(ActiveNodes) do
|
||||
Distance[idx][v] = forward[k]
|
||||
end
|
||||
end
|
||||
|
||||
if QuestHelper.loading_preroll and #ActiveNodes > 1 then QuestHelper.loading_preroll:SetPercentage(ani / #ActiveNodes) end
|
||||
|
|
Référencer dans un nouveau ticket