Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
purerosefallen committed Feb 12, 2025
1 parent 9c2c013 commit 28bf3a5
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions procedure.lua
Original file line number Diff line number Diff line change
Expand Up @@ -980,9 +980,12 @@ function Auxiliary.FUltimateGetCondsResultCode(c,conds,fc,sub,mg,sg)
if c:IsLocation(LOCATION_MZONE) or Auxiliary.FGoalCheckAdditional then return -1 end

local code=0
if sub and c:CheckFusionSubstitute(fc) then
code=code|0x1
end
for i,o in ipairs(conds) do
if o.max>0 and o.f(c,fc,sub,mg,sg) then
code=code|(1<<(i-1))
code=code|(1<<i)
end
end
return code
Expand Down Expand Up @@ -1162,34 +1165,37 @@ function Auxiliary.FOperationUltimate(insf,sub,...)
current_routes = Auxiliary.FUltimateGetNextRoutes(gc,mg,sg,tp,c,chkfnf,current_routes)
end
local select_history_cards={}
local select_history_routes={current_routes}
local select_history_routes={}
while sg:GetCount()<total_maxc do
local crcodes_by_routes={}
local crcode_cache={}
local function select_filter(sc)
for _,route in ipairs(current_routes) do
if not crcodes_by_routes[route] then
crcodes_by_routes[route]={}
if not crcode_cache[route] then
crcode_cache[route]={}
end
local crcode=Auxiliary.FUltimateGetCondsResultCode(sc,route.conds,c,route.sub,mg,sg)
local cached=crcodes_by_routes[route][crcode]
local cached=crcode_cache[route][crcode]
if cached then
if cached==1 then return true end
else
local res=Auxiliary.FUltimateCheck(sc,mg,sg,tp,c,route.sub,chkfnf,route.conds)
if res then
if crcode~=-1 then
crcodes_by_routes[route][crcode]=1
crcode_cache[route][crcode]=1
end
return true
elseif crcode~=-1 then
crcodes_by_routes[route][crcode]=0
crcode_cache[route][crcode]=0
end
end
end
return false
end
local cg=mg:Filter(select_filter,sg)
if cg:GetCount()==0 then break end
if cg:GetCount()==0 then
Debug.Message("Not selectable")
break
end

local finish=false
for _,route in ipairs(current_routes) do
Expand Down Expand Up @@ -1225,7 +1231,7 @@ function Auxiliary.FOperationUltimate(insf,sub,...)
local rc=table.remove(select_history_cards,remove_index)
if not rc then break end
sg:RemoveCard(rc)
table.remove(select_history_routes,remove_index+1)
table.remove(select_history_routes,remove_index)
end
else
table.insert(select_history_cards, tc)
Expand Down

0 comments on commit 28bf3a5

Please sign in to comment.