|
From: <gi...@cr...> - 2026-01-30 04:35:09
|
at 03f7a86f9360fedb60591b8267e28cedf8b6b3b5 (commit)
-----------------------------------------------------------------------
commit 03f7a86f9360fedb60591b8267e28cedf8b6b3b5
Author: gammafunk <gam...@gm...>
Date: Thu Jan 29 22:04:06 2026 -0600
Don't pollute the lua C stack (DracoOmega)
For some reason, I never checked whether the error handler added in
2b9214b6 was being removed by lua_pcall(). I assumed it just removed it
like how it removes the called function and its arguments. It turns out
we were polluting the lua C stack with an unremoved copy of this handler
C function with almost *every* call to lua from C! This grew the stack
so much that various weird issues could happen. In the case of the Disco
Pan vault, where lua is getting called a lot in every turn, the game
would start to lag more than it did in the past on that level. This was
probably the source of the mysterious objstat behaviour as well, but
I'll have to investigate that further.
This commit removes the handler from position 1 of the stack after each
pcall. Debugging has shown that we're now entering functions like
lua_element_colour_calc::get() each time with a C stack size of 0
instead one that can easily grow into the thousands. Movement through
Disco Pan is significantly faster, although still laggy due to the
amount of lua calls happening.
-----------------------------------------------------------------------
--
Dungeon Crawl Stone Soup
|