Currently the bot script uses timer recursion for some of the logic. A function may execute some logic and then set a timer for itself.
Although this is perfectly valid, due to the way our script engine is implemented, this timer recursion grows the function stack indefinitely. Eventually it goes above the limit and the engine kills the map.
To prevent this, I added an Updater type that can be set for each of the functions. It should then be called inside bot's Update function with EachSec or EachFrame. Since Update is called every frame, and the updater checks the last time it was executed, the logic will still work the same way as with the timers.
This makes the script way more stable, however, it seems there are still a few similar issues left. I marked two more places that could cause this with FIXME comment. I was not sure if I can rewrite that without breaking the logic.
Also, turned out the OpenNox itself suffers from a similar issue. It will be fixed in the next release too.
Currently the bot script uses timer recursion for some of the logic. A function may execute some logic and then set a timer for itself.
Although this is perfectly valid, due to the way our script engine is implemented, this timer recursion grows the function stack indefinitely. Eventually it goes above the limit and the engine kills the map.
To prevent this, I added an
Updater
type that can be set for each of the functions. It should then be called inside bot'sUpdate
function withEachSec
orEachFrame
. SinceUpdate
is called every frame, and the updater checks the last time it was executed, the logic will still work the same way as with the timers.This makes the script way more stable, however, it seems there are still a few similar issues left. I marked two more places that could cause this with
FIXME
comment. I was not sure if I can rewrite that without breaking the logic.Also, turned out the OpenNox itself suffers from a similar issue. It will be fixed in the next release too.