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"}
mgobjs[k]={c=k,super="color"}
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 tt=0
local bat=1
@ -686,6 +694,7 @@ function love.mousemoved()
end
function love.update(dt)
ltest=os.time()
dt=math.min(dt,0.2)*(speeds[slow])
accumdt=math.min(1,accumdt+dt)
local fcc=0
@ -695,22 +704,49 @@ function love.update(dt)
accumdt=accumdt-dt
if fcc>10 then return end
if running and playdbg then
for _=1,100 do
local ix,iy=math.random(1,bw),math.random(1,bh)
local px,py=0,0
while px<1 or py<1 or px>bw or py>bh do
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[px][py],board[ix][iy]
local kills=check(ix,iy,check(px,py))
if kills and board[ix][iy] and board[px][py] then
megascan(ix,iy,board[ix][iy],megascan(px,py,board[px][py],kills))
killall(kills)
else
local gc=0
local tc=0
for x=1,bw do
for y=1,bh do
gc=gc+(board[x][y] and 1 or 0)
tc=tc+1
end end
if gc/tc>0.8 then
local goods={}
for _=1,1000 do
local ix,iy=math.random(1,bw),math.random(1,bh)
local px,py=0,0
while px<1 or py<1 or px>bw or py>bh do
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[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
@ -820,7 +856,11 @@ function love.update(dt)
toplchi=plchint
end
local oam,obm,rm={},{},{}
local tt=os.clock()
local itc=0
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)
check(x,y,rm,oam,obm)
end