push debug shits to production

This commit is contained in:
Kimapr 2023-03-29 22:04:45 +05:00
parent dbe5287272
commit d808910705

View file

@ -62,6 +62,14 @@ for k,v in ipairs(colors) do
lgobjs[k]={c=k,super="lines"} lgobjs[k]={c=k,super="lines"}
mgobjs[k]={c=k,super="color"} mgobjs[k]={c=k,super="color"}
end end
local ltest=os.time()
debug.sethook(function()
local lt=os.time()
if lt-ltest>4 then
print("!! we are in a freezer !!",debug.traceback())
ltest=lt
end
end,"",1000)
local cc=3 local cc=3
local tt=0 local tt=0
local bat=1 local bat=1
@ -686,6 +694,7 @@ function love.mousemoved()
end end
function love.update(dt) function love.update(dt)
ltest=os.time()
dt=math.min(dt,0.2)*(speeds[slow]) dt=math.min(dt,0.2)*(speeds[slow])
accumdt=math.min(1,accumdt+dt) accumdt=math.min(1,accumdt+dt)
local fcc=0 local fcc=0
@ -695,22 +704,49 @@ function love.update(dt)
accumdt=accumdt-dt accumdt=accumdt-dt
if fcc>10 then return end if fcc>10 then return end
if running and playdbg then if running and playdbg then
for _=1,100 do local gc=0
local ix,iy=math.random(1,bw),math.random(1,bh) local tc=0
local px,py=0,0 for x=1,bw do
while px<1 or py<1 or px>bw or py>bh do for y=1,bh do
local ox,oy=unpack(({{1,0},{-1,0},{0,1},{0,-1}})[math.random(1,4)]) gc=gc+(board[x][y] and 1 or 0)
px,py=ix+ox,iy+oy tc=tc+1
end end end
board[ix][iy],board[px][py]= if gc/tc>0.8 then
board[px][py],board[ix][iy] local goods={}
local kills=check(ix,iy,check(px,py)) for _=1,1000 do
if kills and board[ix][iy] and board[px][py] then local ix,iy=math.random(1,bw),math.random(1,bh)
megascan(ix,iy,board[ix][iy],megascan(px,py,board[px][py],kills)) local px,py=0,0
killall(kills) while px<1 or py<1 or px>bw or py>bh do
else local ox,oy=unpack(({{1,0},{-1,0},{0,1},{0,-1}})[math.random(1,4)])
px,py=ix+ox,iy+oy
end
board[ix][iy],board[px][py]= board[ix][iy],board[px][py]=
board[px][py],board[ix][iy] board[px][py],board[ix][iy]
local kills=check(ix,iy,check(px,py))
local kc=0
for k,v in pairs(kills or {}) do
if v[3] and v[3].super=="color" then
kc=kc+50
elseif v[3] then
kc=kc+20
end
kc=kc+1
end
if kills and board[ix][iy] and board[px][py] then
goods[#goods+1]={ix,iy,px,py,kills,kc}
end
board[ix][iy],board[px][py]=
board[px][py],board[ix][iy]
end
table.sort(goods,function(a,b)
return a[6]>b[6]
end)
if #goods>0 then
local ix,iy,px,py,kills=unpack(goods[1])
board[ix][iy],board[px][py]=
board[px][py],board[ix][iy]
megascan(ix,iy,board[ix][iy],megascan(px,py,board[px][py],kills))
killall(kills)
end end
end end
end end
@ -820,7 +856,11 @@ function love.update(dt)
toplchi=plchint toplchi=plchint
end end
local oam,obm,rm={},{},{} local oam,obm,rm={},{},{}
local tt=os.clock()
local itc=0
for k,v in pairs(tk) do for k,v in pairs(tk) do
itc=itc+1
if os.clock()-tt>2 then error("too long "..itc.."; #"..#tk) end
local x,y=unpack(v) local x,y=unpack(v)
check(x,y,rm,oam,obm) check(x,y,rm,oam,obm)
end end